buildx-manager/config/config.go
2024-10-05 11:39:40 +02:00

43 lines
904 B
Go

package config
import "flag"
var config *Config
type Config struct {
File string
Action string
Verbose bool
Parallel bool
Dryrun bool
DockerExecutable string
}
func GetConfig() Config {
if config != nil {
return *config
}
config = &Config{}
flag.StringVar(&config.File, "f", "", "job definition")
flag.StringVar(&config.Action, "a", "", "action")
flag.BoolVar(&config.Verbose, "v", false, "verbose")
flag.BoolVar(&config.Parallel, "p", false, "parallel")
flag.BoolVar(&config.Dryrun, "dry", false, "dryrun")
flag.StringVar(&config.DockerExecutable, "docker", "docker", "docker executable")
flag.Parse()
if config.File == "" {
panic("missing job definition")
}
if config.Action != "load" && config.Action != "push" {
panic("action must be \"load\" or \"push\"")
}
config.Action = "--" + config.Action
return *config
}