diff --git a/main.go b/main.go index b655117c97..4a57573858 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "github.com/ghodss/yaml" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" - "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options/legacy" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/validation" "github.com/spf13/pflag" @@ -85,13 +84,13 @@ func loadConfiguration(config, legacyConfig string, extraFlags *pflag.FlagSet, a // loadLegacyOptions loads the old toml options using the legacy flagset // and legacy options struct. func loadLegacyOptions(legacyConfig string, extraFlags *pflag.FlagSet, args []string) (*options.Options, error) { - legacyFlagSet := legacy.NewLegacyFlagSet() + legacyFlagSet := options.NewLegacyFlagSet() legacyFlagSet.AddFlagSet(extraFlags) if err := legacyFlagSet.Parse(args); err != nil { return nil, fmt.Errorf("failed to parse flags: %v", err) } - legacyOpts := legacy.NewLegacyOptions() + legacyOpts := options.NewLegacyOptions() if err := options.Load(legacyConfig, legacyFlagSet, legacyOpts); err != nil { return nil, fmt.Errorf("failed to load config: %v", err) } diff --git a/main_test.go b/main_test.go index e59fc3bafb..40d9b159dd 100644 --- a/main_test.go +++ b/main_test.go @@ -102,7 +102,7 @@ redirect_url="http://localhost:4180/oauth2/callback" } testExpectedOptions := func() *options.Options { - opts, err := legacy.NewLegacyOptions().ToOptions() + opts, err := NewLegacyOptions().ToOptions() Expect(err).ToNot(HaveOccurred()) opts.Cookie.Secret = "OQINaROshtE9TcZkNAm-5Zs2Pv3xaWytBmc5W7sPX7w=" diff --git a/pkg/apis/options/legacy/legacy_cookie.go b/pkg/apis/options/legacy_cookie.go similarity index 97% rename from pkg/apis/options/legacy/legacy_cookie.go rename to pkg/apis/options/legacy_cookie.go index f530f14ac0..acb0c31eec 100644 --- a/pkg/apis/options/legacy/legacy_cookie.go +++ b/pkg/apis/options/legacy_cookie.go @@ -1,9 +1,8 @@ -package legacy +package options import ( "time" - . "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/spf13/pflag" ) diff --git a/pkg/apis/options/legacy/legacy_logging.go b/pkg/apis/options/legacy_logging.go similarity index 98% rename from pkg/apis/options/legacy/legacy_logging.go rename to pkg/apis/options/legacy_logging.go index 24457a6d3b..525c25a244 100644 --- a/pkg/apis/options/legacy/legacy_logging.go +++ b/pkg/apis/options/legacy_logging.go @@ -1,7 +1,6 @@ -package legacy +package options import ( - . "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger" "github.com/spf13/pflag" ) diff --git a/pkg/apis/options/legacy/legacy_options.go b/pkg/apis/options/legacy_options.go similarity index 99% rename from pkg/apis/options/legacy/legacy_options.go rename to pkg/apis/options/legacy_options.go index a6d9bf6bb6..33cede1761 100644 --- a/pkg/apis/options/legacy/legacy_options.go +++ b/pkg/apis/options/legacy_options.go @@ -1,4 +1,4 @@ -package legacy +package options import ( "fmt" @@ -8,7 +8,6 @@ import ( "strings" "time" - . "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger" "github.com/spf13/pflag" ) @@ -34,6 +33,8 @@ type LegacyOptions struct { LegacyPageTemplates LegacyPageTemplates `cfg:",squash"` + LegacyProxyOptions LegacyProxyOptions `cfg:",squash"` + LegacyProbeOptions LegacyProbeOptions `cfg:",squash"` Options Options `cfg:",squash"` @@ -170,6 +171,8 @@ func (l *LegacyOptions) ToOptions() (*Options, error) { l.Options.PageTemplates = l.LegacyPageTemplates.convert() + l.Options.ProxyOptions = l.LegacyProxyOptions.convert() + l.Options.ProbeOptions = l.LegacyProbeOptions.convert() l.Options.LegacyPreferEmailToUser = l.LegacyHeaders.PreferEmailToUser diff --git a/pkg/apis/options/legacy/legacy_options_test.go b/pkg/apis/options/legacy_options_test.go similarity index 99% rename from pkg/apis/options/legacy/legacy_options_test.go rename to pkg/apis/options/legacy_options_test.go index a0cce652a1..4ad7d9fcd1 100644 --- a/pkg/apis/options/legacy/legacy_options_test.go +++ b/pkg/apis/options/legacy_options_test.go @@ -1,9 +1,8 @@ -package legacy +package options import ( "time" - . "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" diff --git a/pkg/apis/options/legacy/legacy_page_templates.go b/pkg/apis/options/legacy_page_templates.go similarity index 97% rename from pkg/apis/options/legacy/legacy_page_templates.go rename to pkg/apis/options/legacy_page_templates.go index 35547a63b9..a1b1c9ed26 100644 --- a/pkg/apis/options/legacy/legacy_page_templates.go +++ b/pkg/apis/options/legacy_page_templates.go @@ -1,7 +1,6 @@ -package legacy +package options import ( - . "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/spf13/pflag" ) diff --git a/pkg/apis/options/legacy/legacy_proxy.go b/pkg/apis/options/legacy_proxy.go similarity index 98% rename from pkg/apis/options/legacy/legacy_proxy.go rename to pkg/apis/options/legacy_proxy.go index 3285d07bc2..bc444cefe6 100644 --- a/pkg/apis/options/legacy/legacy_proxy.go +++ b/pkg/apis/options/legacy_proxy.go @@ -1,7 +1,6 @@ -package legacy +package options import ( - . "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/spf13/pflag" ) diff --git a/pkg/apis/options/legacy/legacy_sessions.go b/pkg/apis/options/legacy_sessions.go similarity index 98% rename from pkg/apis/options/legacy/legacy_sessions.go rename to pkg/apis/options/legacy_sessions.go index c36f22a097..f6a4fbfe2f 100644 --- a/pkg/apis/options/legacy/legacy_sessions.go +++ b/pkg/apis/options/legacy_sessions.go @@ -1,7 +1,6 @@ -package legacy +package options import ( - . "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/spf13/pflag" ) diff --git a/pkg/apis/options/load_test.go b/pkg/apis/options/load_test.go index d99628c025..89b5596ee6 100644 --- a/pkg/apis/options/load_test.go +++ b/pkg/apis/options/load_test.go @@ -6,7 +6,6 @@ import ( "os" "time" - "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options/legacy" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" @@ -15,8 +14,8 @@ import ( ) var _ = Describe("Load", func() { - legacyOptionsWithNilProvider := &legacy.LegacyOptions{ - LegacyUpstreams: legacy.LegacyUpstreams{ + legacyOptionsWithNilProvider := &LegacyOptions{ + LegacyUpstreams: LegacyUpstreams{ PassHostHeader: true, ProxyWebSockets: true, FlushInterval: DefaultUpstreamFlushInterval,