2024-10-04 23:43:59 +00:00
|
|
|
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\"")
|
|
|
|
}
|
2024-10-05 09:39:40 +00:00
|
|
|
config.Action = "--" + config.Action
|
2024-10-04 23:43:59 +00:00
|
|
|
|
|
|
|
return *config
|
|
|
|
}
|