Skip to content

Commit

Permalink
revert legacy package
Browse files Browse the repository at this point in the history
  • Loading branch information
tuunit committed Nov 5, 2023
1 parent 76a37fd commit 543993e
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 21 deletions.
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ redirect_url="http://localhost:4180/oauth2/callback"
}

testExpectedOptions := func() *options.Options {
opts, err := legacy.NewLegacyOptions().ToOptions()
opts, err := NewLegacyOptions().ToOptions()

Check failure on line 105 in main_test.go

View workflow job for this annotation

GitHub Actions / build

undeclared name: `NewLegacyOptions` (typecheck)
Expect(err).ToNot(HaveOccurred())

opts.Cookie.Secret = "OQINaROshtE9TcZkNAm-5Zs2Pv3xaWytBmc5W7sPX7w="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package legacy
package options

import (
"time"

. "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
"github.com/spf13/pflag"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package legacy
package options

import (
"fmt"
Expand All @@ -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"
)
Expand All @@ -34,6 +33,8 @@ type LegacyOptions struct {

LegacyPageTemplates LegacyPageTemplates `cfg:",squash"`

LegacyProxyOptions LegacyProxyOptions `cfg:",squash"`

LegacyProbeOptions LegacyProbeOptions `cfg:",squash"`

Options Options `cfg:",squash"`
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package legacy
package options

import (
. "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
"github.com/spf13/pflag"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package legacy
package options

import (
. "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
"github.com/spf13/pflag"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package legacy
package options

import (
. "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
"github.com/spf13/pflag"
)

Expand Down
5 changes: 2 additions & 3 deletions pkg/apis/options/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down

0 comments on commit 543993e

Please sign in to comment.