Generate the replacements for all environment variables. This allows to use FB_BRANDING_DISABLE_EXTERNAL environment variables, even when the option name is branding.disableExternal.
(cmd *cobra.Command)
| 71 | // use FB_BRANDING_DISABLE_EXTERNAL environment variables, even when the |
| 72 | // option name is branding.disableExternal. |
| 73 | func generateEnvKeyReplacements(cmd *cobra.Command) []string { |
| 74 | replacements := []string{} |
| 75 | |
| 76 | cmd.Flags().VisitAll(func(f *pflag.Flag) { |
| 77 | oldName := strings.ToUpper(f.Name) |
| 78 | newName := strings.ToUpper(lo.SnakeCase(f.Name)) |
| 79 | replacements = append(replacements, oldName, newName) |
| 80 | }) |
| 81 | |
| 82 | return replacements |
| 83 | } |
| 84 | |
| 85 | func initViper(cmd *cobra.Command) (*viper.Viper, error) { |
| 86 | v := viper.New() |
no outgoing calls