diff --git a/obs-staging-bot/main.go b/obs-staging-bot/main.go index 3000d3b..950323c 100644 --- a/obs-staging-bot/main.go +++ b/obs-staging-bot/main.go @@ -1,52 +1,28 @@ package main import ( - "errors" - "fmt" - "log" - "net/http" - "os" - "path/filepath" - "src.opensuse.org/autogits/common" ) const ( GitAuthor = "GiteaBot - Obs Staging" + ObsBuildBot = "/obsbuild" ) var GiteaToken string -func parseObsSecretToken() (string, error) { - ObsToken := os.Getenv(ObsTokenEnv) - if len(ObsToken) < 10 { - return "", fmt.Errorf("Missing %s", ObsTokenEnv) - } - - err := os.Setenv(ObsTokenEnv, "") - if err != nil { - return "", fmt.Errorf("Cannot reset %s: %v", GiteaTokenEnv, err) - } - - return ObsToken, nil -} - -func parseGiteaSecretToken() (string, error) { - GiteaToken := os.Getenv(GiteaTokenEnv) - if len(GiteaToken) < 10 { - return errors.New(GiteaTokenEnv + " not provided") - } - - err := os.Setenv(GiteaTokenEnv, "") - if err != nil { - return fmt.Errorf("%s: %v", "Cannot reset "+GiteaTokenEnv, err) - } - - return nil -} func main() { - parseGiteaSecretToken() - parseObsSecretToken() -// createListenServer() + var defs common.ListenDefinitions + + defs.Url = ObsBuildBot + defs.GitAuthor = GitAuthor + + defs.Handlers = make(map[string]common.RequestProcessor) + defs.Handlers[common.RequestType_PR] = processPullRequest + defs.Handlers[common.RequestType_PR_sync] = processPullRequest + + common.RequireGiteaSecretToken() + common.RequireObsSecretToken() + common.StartServerWithAddress(defs, ListenAddr) }