MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / loadConfiguration

Function loadConfiguration

main.go:84–101  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

82// It will either load the alpha configuration (if alphaConfig is given)
83// or the legacy configuration.
84func 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.

Callers 2

main_test.goFile · 0.85
mainFunction · 0.85

Calls 4

PrintfFunction · 0.92
loadLegacyOptionsFunction · 0.85
loadYamlOptionsFunction · 0.85
EnsureDefaultsMethod · 0.45

Tested by

no test coverage detected