package common import ( "errors" "fmt" "os" ) var giteaToken string var obsUser, obsPassword string func RequireGiteaSecretToken() 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 RequireObsSecretToken() error { obsUser = os.Getenv(ObsUserEnv) obsPassword = os.Getenv(ObsPasswordEnv) if len(obsPassword) < 10 || len(obsUser) < 2 { return fmt.Errorf("Missing OBS authentication: %s %s", ObsUserEnv, ObsPasswordEnv) } err := os.Setenv(ObsUserEnv, "") if err != nil { return fmt.Errorf("Cannot reset %s: %v", ObsUserEnv, err) } err = os.Setenv(ObsPasswordEnv, "") if err != nil { return fmt.Errorf("Cannot reset %s: %v", ObsPasswordEnv, err) } return nil }