47 lines
909 B
Go
47 lines
909 B
Go
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 {
|
|
obsPassword = os.Getenv(ObsUserEnv)
|
|
obsUser = 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
|
|
}
|
|
|