42 lines
866 B
Go
42 lines
866 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\"")
|
||
|
}
|
||
|
|
||
|
return *config
|
||
|
}
|