Handle unknown ini options
This commit is contained in:
@ -14,7 +14,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jessevdk/go-flags"
|
||||
"github.com/thomseddon/go-flags"
|
||||
"github.com/thomseddon/traefik-forward-auth/internal/provider"
|
||||
)
|
||||
|
||||
@ -141,7 +141,7 @@ func NewConfig(args []string) (Config, error) {
|
||||
}
|
||||
|
||||
func (c *Config) parseFlags(args []string) error {
|
||||
p := flags.NewParser(c, flags.Default)
|
||||
p := flags.NewParser(c, flags.Default | flags.IniUnknownOptionHandler)
|
||||
p.UnknownOptionHandler = c.parseUnknownFlag
|
||||
|
||||
i := flags.NewIniParser(p)
|
||||
@ -157,6 +157,7 @@ func (c *Config) parseFlags(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("config format deprecated, please use ini format")
|
||||
return i.Parse(converted)
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,18 @@ func TestConfigParseIni(t *testing.T) {
|
||||
assert.Equal("inicookiename", c.CookieName, "should be read from ini file")
|
||||
assert.Equal("csrfcookiename", c.CSRFCookieName, "should be read from ini file")
|
||||
assert.Equal("/two", c.Path, "variable in second ini file should override first ini file")
|
||||
assert.Equal(map[string]*Rule{
|
||||
"1": {
|
||||
Action: "allow",
|
||||
Rule: "PathPrefix(`/one`)",
|
||||
Provider: "google",
|
||||
},
|
||||
"two": {
|
||||
Action: "auth",
|
||||
Rule: "Host(`two.com`) && Path(`/two`)",
|
||||
Provider: "google",
|
||||
},
|
||||
}, c.Rules)
|
||||
}
|
||||
|
||||
func TestConfigFileBackwardsCompatability(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user