diff --git a/chart/flux/flux-config.yaml b/chart/flux/flux-config.yaml new file mode 100644 index 0000000000..c7841668f9 --- /dev/null +++ b/chart/flux/flux-config.yaml @@ -0,0 +1,5 @@ +git-url: "git@github.com:weaveworks/flux-get-started" +ssh-keygen-dir: "/var/fluxd/keygen" +git-branch: "master" +listen-metrics: ":3031" +memcached-service: "" diff --git a/cmd/fluxd/main.go b/cmd/fluxd/main.go index ab23346520..63f9cda346 100644 --- a/cmd/fluxd/main.go +++ b/cmd/fluxd/main.go @@ -280,6 +280,18 @@ func main() { // --- From this point, we can just consult the config struct for values --- + // viper.IsSet, which we could otherwise use for determining + // whether a flag has been supplied, is broken: + // https://github.com/spf13/viper/pull/331. So we have to proceed + // by other means. + envOnly := viper.New() + envOnly.SetEnvPrefix("FLUXD") + envOnly.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) + envOnly.AutomaticEnv() + isSet := func(flag string) bool { + return fs.Changed(flag) || viper.InConfig(flag) || envOnly.IsSet(flag) + } + // Explicitly initialize klog to enable stderr logging, // and parse our own flags. klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) @@ -346,7 +358,7 @@ func main() { } var changedGitRelatedFlags []string for _, gitRelatedFlag := range gitRelatedFlags { - if viper.IsSet(gitRelatedFlag) { + if isSet(gitRelatedFlag) { changedGitRelatedFlags = append(changedGitRelatedFlags, gitRelatedFlag) } } @@ -358,18 +370,18 @@ func main() { // Maintain backwards compatibility with the --registry-poll-interval // _flag_, but only if the --automation-interval is not set to a custom // (non default) value anywhere. - if fs.Changed("registry-poll-interval") && !viper.IsSet("automation-interval") { + if fs.Changed("registry-poll-interval") && !isSet("automation-interval") { config.AutomationInterval = config.RegistryPollInterval } // Sort out values for the git tag and notes ref. There are // running deployments that assume the defaults as given, so don't // mess with those unless explicitly told. - if viper.IsSet("git-label") { + if isSet("git-label") { config.GitSyncTag = config.GitLabel config.GitNotesRef = config.GitLabel for _, f := range []string{"git-sync-tag", "git-notes-ref"} { - if viper.IsSet(f) { + if isSet(f) { logger.Log("overridden", f, "value", config.GitLabel) } }