status: use env as parameters to service
Instead of having to rewrite the service file with parameters, leverage Env file to pass default parameters values.
This commit is contained in:
@@ -208,22 +208,35 @@ func WriteJson(data any, res http.ResponseWriter) {
|
||||
var ObsUrl *string
|
||||
|
||||
func main() {
|
||||
cert := flag.String("cert-file", "", "TLS certificates file")
|
||||
key := flag.String("key-file", "", "Private key for the TLS certificate")
|
||||
listen := flag.String("listen", "[::1]:8080", "Listening string")
|
||||
obsUrlDef := os.Getenv("OBS_STATUS_SERVICE_OBS_URL")
|
||||
if len(obsUrlDef) == 0 {
|
||||
obsUrlDef = "https://build.opensuse.org"
|
||||
}
|
||||
listenDef := os.Getenv("OBS_STATUS_SERVICE_LISTEN")
|
||||
if len(listenDef) == 0 {
|
||||
listenDef = "[::1]:8080"
|
||||
}
|
||||
certDef := os.Getenv("OBS_STATUS_SERVICE_CERT")
|
||||
if len(certDef) == 0 {
|
||||
certDef = "/run/obs-status-service.pem"
|
||||
}
|
||||
keyDef := os.Getenv("OBS_STATUS_SERVICE_KEY")
|
||||
if len(keyDef) == 0 {
|
||||
keyDef = certDef
|
||||
}
|
||||
|
||||
cert := flag.String("cert-file", certDef, "TLS certificates file")
|
||||
key := flag.String("key-file", keyDef, "Private key for the TLS certificate")
|
||||
listen := flag.String("listen", listenDef, "Listening string")
|
||||
disableTls := flag.Bool("no-tls", false, "Disable TLS")
|
||||
ObsUrl = flag.String("obs-url", "https://http.opensuse.org", "OBS API endpoint for package buildlog information")
|
||||
ObsUrl = flag.String("obs-url", obsUrlDef, "OBS API endpoint for package buildlog information")
|
||||
debug := flag.Bool("debug", false, "Enable debug logging")
|
||||
// RabbitMQHost := flag.String("rabbit-mq", "amqps://rabbit.opensuse.org", "RabbitMQ message bus server")
|
||||
// Topic := flag.String("topic", "opensuse.obs", "RabbitMQ topic prefix")
|
||||
flag.Parse()
|
||||
|
||||
if *debug {
|
||||
common.SetLoggingLevel(common.LogLevelDebug)
|
||||
}
|
||||
|
||||
// common.PanicOnError(common.RequireObsSecretToken())
|
||||
|
||||
if redisUrl := os.Getenv("REDIS"); len(redisUrl) > 0 {
|
||||
RedisConnect(redisUrl)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user