...
1 package containers
2
3 import "fmt"
4
5
6 type Option func(*options)
7
8
9
10 func Insecure(opts *options) {
11 opts.insecure = true
12 }
13
14
15
16 func ToRepository(r string) Option {
17 return func(opts *options) {
18 opts.registry = r
19 }
20 }
21
22 func makeOptions(o ...Option) *options {
23 options := &options{}
24 for _, option := range o {
25 option(options)
26 }
27 return options
28 }
29
30 type options struct {
31 insecure bool
32 registry string
33 }
34
35
36 func (o options) args() []string {
37 var args []string
38 if o.registry != "" {
39 args = append(args,
40 fmt.Sprintf("%s=%s", workloadsRepoFlag, o.registry),
41 fmt.Sprintf("%s=%s", thirdPartyRepoFlag, o.registry),
42 )
43 }
44 if o.insecure {
45 args = append(args, "--", fmt.Sprintf("--%s=true", insecureFlag))
46 }
47
48 return args
49 }
50
View as plain text