loadConfiguration will load in the user's configuration. It will either load the alpha configuration (if alphaConfig is given) or the legacy configuration.
(config, yamlConfig string, extraFlags *pflag.FlagSet, args []string)
| 82 | // It will either load the alpha configuration (if alphaConfig is given) |
| 83 | // or the legacy configuration. |
| 84 | func loadConfiguration(config, yamlConfig string, extraFlags *pflag.FlagSet, args []string) (*options.Options, error) { |
| 85 | opts, err := loadLegacyOptions(config, extraFlags, args) |
| 86 | if err != nil { |
| 87 | return nil, fmt.Errorf("failed to load legacy options: %w", err) |
| 88 | } |
| 89 | |
| 90 | if yamlConfig != "" { |
| 91 | logger.Printf("WARNING: You are using alpha configuration. The structure in this configuration file may change without notice. You MUST remove conflicting options from your existing configuration.") |
| 92 | opts, err = loadYamlOptions(yamlConfig, config, extraFlags, args) |
| 93 | if err != nil { |
| 94 | return nil, fmt.Errorf("failed to load yaml options: %w", err) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Ensure defaults after loading configuration |
| 99 | opts.EnsureDefaults() |
| 100 | return opts, nil |
| 101 | } |
| 102 | |
| 103 | // loadLegacyOptions loads the old toml options using the legacy flagset |
| 104 | // and legacy options struct. |
no test coverage detected