diff --git a/pkg/config/corscfg/flags.go b/pkg/config/corscfg/flags.go index 2a01b4225da..c71bd2a4a1e 100644 --- a/pkg/config/corscfg/flags.go +++ b/pkg/config/corscfg/flags.go @@ -32,8 +32,8 @@ type Flags struct { } func (c Flags) AddFlags(flags *flag.FlagSet) { - flags.String(c.Prefix+corsAllowedHeaders, "content-type", "Allowed headers for the HTTP port , default content-type") - flags.String(c.Prefix+corsAllowedOrigins, "*", "Allowed origins for the HTTP port , default accepts all") + flags.String(c.Prefix+corsAllowedHeaders, "content-type", "Comma-separated CORS allowed headers, default accepts content-type. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers") + flags.String(c.Prefix+corsAllowedOrigins, "*", "Comma-separated CORS allowed headers, default accepts all. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin") } func (c Flags) InitFromViper(v *viper.Viper) Options { diff --git a/pkg/config/corscfg/flags_test.go b/pkg/config/corscfg/flags_test.go index daf1508e7ff..94a9fce5fef 100644 --- a/pkg/config/corscfg/flags_test.go +++ b/pkg/config/corscfg/flags_test.go @@ -15,14 +15,13 @@ package corscfg import ( - "flag" "fmt" "testing" - "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/jaegertracing/jaeger/pkg/config" ) func TestCORSFlags(t *testing.T) { @@ -31,15 +30,10 @@ func TestCORSFlags(t *testing.T) { "--prefix.cors.allowed-origins=http://example.domain.com, http://*.domain.com", } t.Run("CORS Flags", func(t *testing.T) { - v := viper.New() - command := cobra.Command{} - flagSet := &flag.FlagSet{} flagCfg := Flags{ Prefix: "prefix", } - flagCfg.AddFlags(flagSet) - command.PersistentFlags().AddGoFlagSet(flagSet) - v.BindPFlags(command.PersistentFlags()) + v, command := config.Viperize(flagCfg.AddFlags) err := command.ParseFlags(cmdFlags) require.NoError(t, err) diff --git a/pkg/config/corscfg/options.go b/pkg/config/corscfg/options.go index 3d2220a1d1d..7deffbf4e1e 100644 --- a/pkg/config/corscfg/options.go +++ b/pkg/config/corscfg/options.go @@ -15,6 +15,6 @@ package corscfg type Options struct { - AllowedOrigins []string `mapstructure:"allowed_origins"` - AllowedHeaders []string `mapstructure:"allowed_headers"` + AllowedOrigins []string + AllowedHeaders []string }