package containers import "fmt" // Option allows controlling behavior for working with container_push targets. type Option func(*options) // Insecure adds a flag to rules_docker container_push targets to allow HTTP // repositories. func Insecure(opts *options) { opts.insecure = true } // ToRepository overrides the destination repository set on the container_push // rule(s). func ToRepository(r string) Option { return func(opts *options) { opts.registry = r } } func makeOptions(o ...Option) *options { options := &options{} for _, option := range o { option(options) } return options } type options struct { insecure bool registry string } // args generates CLI arguments to pass to Bazel func (o options) args() []string { var args []string if o.registry != "" { args = append(args, fmt.Sprintf("%s=%s", workloadsRepoFlag, o.registry), fmt.Sprintf("%s=%s", thirdPartyRepoFlag, o.registry), ) } if o.insecure { args = append(args, "--", fmt.Sprintf("--%s=true", insecureFlag)) } return args }