Skip to content

Commit

Permalink
Tidying up a bit, don't need struct flag parse annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
foot committed Jun 6, 2019
1 parent e48cf2e commit 234e4c7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ build/static: service/static/* service/static/agent.yaml
integration-tests: all
./integration-tests/setup/reset-local-minikube.sh
./integration-tests/setup/setup-local-minikube.sh
./integration-tests/tests/flux-config.sh
./integration-tests/tests/install-update-flow.sh

clean:
rm -rf build cache vendor
Expand Down
32 changes: 18 additions & 14 deletions agent/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,36 @@ import (
// FluxConfig stores existing flux arguments which will be used when updating WC agents
type FluxConfig struct {
// git parameters
GitLabel *string `long:"git-label"`
GitURL *string `long:"git-url"`
GitLabel *string
GitURL *string
// This arg is multi-valued, or can be passed as comma-separated
// values. This accounts for either form.
GitPath []string `long:"git-path"`
GitBranch *string `long:"git-branch"`
GitTimeout *time.Duration `long:"git-timeout"`
GitPollInterval *time.Duration `long:"git-poll-interval"`
GitSetAuthor *bool `long:"git-set-author"`
GitCISkip *bool `long:"git-ci-skip"`
GitPath []string
GitBranch *string
GitTimeout *time.Duration
GitPollInterval *time.Duration
GitSetAuthor *bool
GitCISkip *bool

// sync behaviour
GarbageCollection *bool `long:"sync-garbage-collection"`
GarbageCollection *bool

// For specifying ECR region from outside AWS (fluxd detects it when inside AWS)
RegistryECRRegion []string `long:"registry-ecr-region"`
RegistryECRRegion []string
// For requiring a particular registry to be accessible, else crash
RegistryRequire []string `long:"registry-require"`
RegistryRequire []string
// Can be used to switch image registry scanning off for some or
// all images (with glob patterns)
RegistryExcludeImage []string `long:"registry-exclude-image"`
RegistryExcludeImage []string

// This is now hard-wired to empty in launch-generator, to tell flux
// _not_ to use service discovery. But: maybe someone needs to use
// service discovery.
MemcachedService *string `long:"memcached-service"`
MemcachedService *string

// Just in case we more explicitly support restricting Weave
// Cloud, or just Flux to particular namespaces
AllowNamespace []string `long:"k8s-allow-namepace"`
AllowNamespace []string
}

// AsQueryParams returns the configuration as a fragment of query
Expand Down Expand Up @@ -120,18 +120,22 @@ func ParseFluxArgs(argString string) (*FluxConfig, error) {
fs := pflag.NewFlagSet("default", pflag.ContinueOnError)
fs.ParseErrorsWhitelist.UnknownFlags = true

// strings
cfg.GitLabel = fs.String("git-label", "", "")
cfg.GitURL = fs.String("git-url", "", "")
cfg.GitBranch = fs.String("git-branch", "", "")
cfg.MemcachedService = fs.String("memcached-service", "", "")

// durations
cfg.GitTimeout = fs.Duration("git-timeout", time.Second, "")
cfg.GitPollInterval = fs.Duration("git-poll-interval", time.Minute, "")

// bools
cfg.GitSetAuthor = fs.Bool("git-set-author", false, "")
cfg.GitCISkip = fs.Bool("git-ci-skip", false, "")
cfg.GarbageCollection = fs.Bool("sync-garbage-collection", false, "")

// string slices
fs.StringSliceVar(&cfg.GitPath, "git-path", nil, "")
fs.StringSliceVar(&cfg.RegistryECRRegion, "registry-ecr-region", nil, "")
fs.StringSliceVar(&cfg.RegistryRequire, "registry-require", nil, "")
Expand Down

0 comments on commit 234e4c7

Please sign in to comment.