diff --git a/acceptance-tests/test.sh b/acceptance-tests/test.sh index 2d998fd..bfa701b 100755 --- a/acceptance-tests/test.sh +++ b/acceptance-tests/test.sh @@ -3,12 +3,12 @@ set -exv mkdir -p $HOME/.crda -export AUTH_TOKEN=${THREE_SCALE_KEY:-3e42fa66f65124e6b1266a23431e3d08}; +export CRDA_AUTH_TOKEN=${THREE_SCALE_KEY:-3e42fa66f65124e6b1266a23431e3d08}; export CRDA_KEY=${CRDA_KEY:-d931dd95-ab1f-4f74-9a9f-fb50f60e4ea9}; -export HOST=https://f8a-analytics-preview-2445582058137.staging.gw.apicast.io +export CRDA_HOST=https://f8a-analytics-preview-2445582058137.staging.gw.apicast.io export snyk_token=${SNYK_TOKEN} -printf 'auth_token: %s\nconsent_telemetry: false\ncrda_key: %s\nhost: %s' "${AUTH_TOKEN}" "${CRDA_KEY}" "${HOST}" >> $HOME/.crda/config.yaml +printf 'crda_auth_token: %s\nconsent_telemetry: false\ncrda_key: %s\nhost: %s' "${CRDA_AUTH_TOKEN}" "${CRDA_KEY}" "${HOST}" >> $HOME/.crda/config.yaml cat $HOME/.crda/config.yaml diff --git a/cmd/analyse.go b/cmd/analyse.go index f3c76d9..4e8d61b 100644 --- a/cmd/analyse.go +++ b/cmd/analyse.go @@ -77,8 +77,8 @@ func runAnalyse(cmd *cobra.Command, args []string) error { manifestPath := getAbsPath(args[0]) requestParams := driver.RequestType{ UserID: viper.GetString("crda_key"), - ThreeScaleToken: viper.GetString("auth_token"), - Host: viper.GetString("host"), + ThreeScaleToken: viper.GetString("crda_auth_token"), + Host: viper.GetString("crda_host"), Client: client, RawManifestFile: manifestPath, } diff --git a/cmd/auth.go b/cmd/auth.go index 575d08a..9f01a07 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -61,8 +61,8 @@ func runAuth(cmd *cobra.Command, _ []string) error { requestParams := auth.RequestServerType{ UserID: viper.GetString("crda_key"), SynkToken: snykToken, - ThreeScaleToken: viper.GetString("auth_token"), - Host: viper.GetString("host"), + ThreeScaleToken: viper.GetString("crda_auth_token"), + Host: viper.GetString("crda_host"), Client: client, } userID, err := auth.RequestServer(cmd.Context(), requestParams) diff --git a/cmd/root.go b/cmd/root.go index 9d69c53..cc7cc95 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -154,11 +154,11 @@ func initConfig() { log.Fatal().Err(err).Msgf(err.Error()) } } - if !viper.IsSet("host") { - viper.Set("host", utils.Host) + if !viper.IsSet("crda_host") { + viper.Set("crda_host", utils.CRDAHost) } - if !viper.IsSet("auth_token") { - viper.Set("auth_token", utils.AuthToken) + if !viper.IsSet("crda_auth_token") { + viper.Set("crda_auth_token", utils.CRDAAuthToken) } err = viper.WriteConfig() diff --git a/pkg/auth/server.go b/pkg/auth/server.go index 12c77a8..83500f8 100644 --- a/pkg/auth/server.go +++ b/pkg/auth/server.go @@ -7,7 +7,7 @@ import ( "github.com/fabric8-analytics/cli-tools/pkg/telemetry" "net/http" - utils "github.com/fabric8-analytics/cli-tools/utils" + "github.com/fabric8-analytics/cli-tools/utils" "github.com/rs/zerolog/log" ) diff --git a/pkg/config/viper_config.go b/pkg/config/viper_config.go index fcd799f..71a97fb 100644 --- a/pkg/config/viper_config.go +++ b/pkg/config/viper_config.go @@ -6,8 +6,8 @@ import ( ) type viperConfigs struct { - Host string `mapstructure:"HOST" yaml:"host"` - AuthToken string `mapstructure:"AUTH_TOKEN" yaml:"auth_token"` + Host string `mapstructure:"CRDA_HOST" yaml:"crda_host"` + AuthToken string `mapstructure:"CRDA_AUTH_TOKEN" yaml:"crda_auth_token"` CrdaKey string `mapstructure:"CRDA_KEY" yaml:"crda_key"` ConsentTelemetry string `mapstructure:"CONSENT_TELEMETRY" yaml:"consent_telemetry"` } @@ -20,8 +20,8 @@ func ViperUnMarshal() *viperConfigs { viper.AutomaticEnv() // Have to bind individual variables: https://github.com/spf13/viper/issues/188 viper.BindEnv("CONSENT_TELEMETRY") - viper.BindEnv("AUTH_TOKEN") - viper.BindEnv("HOST") + viper.BindEnv("CRDA_AUTH_TOKEN") + viper.BindEnv("CRDA_HOST") viper.BindEnv("CRDA_KEY") err := viper.Unmarshal(&ActiveConfigValues) if err != nil { diff --git a/pkg/config/viper_config_test.go b/pkg/config/viper_config_test.go index 0607028..ae4d860 100644 --- a/pkg/config/viper_config_test.go +++ b/pkg/config/viper_config_test.go @@ -8,8 +8,8 @@ import ( ) func TestViperUnMarshal(t *testing.T) { - os.Setenv("HOST", "host") - os.Setenv("AUTH_TOKEN", "token") + os.Setenv("CRDA_HOST", "host") + os.Setenv("CRDA_AUTH_TOKEN", "token") os.Setenv("CONSENT_TELEMETRY", "false") os.Setenv("CRDA_KEY", "abc") want := &viperConfigs{ diff --git a/utils/constants.go b/utils/constants.go index 65b7004..0ccbcc3 100644 --- a/utils/constants.go +++ b/utils/constants.go @@ -2,8 +2,8 @@ package utils // Flag Defaults const ( - Host string = "https://f8a-analytics-2445582058137.production.gw.apicast.io" - AuthToken string = "9e7da76708fe374d8c10fa752e72989f" - Debug bool = false - ActualHost string = "https://recommender.api.openshift.io" + CRDAHost string = "https://f8a-analytics-2445582058137.production.gw.apicast.io" + CRDAAuthToken string = "9e7da76708fe374d8c10fa752e72989f" + Debug bool = false + ActualHost string = "https://recommender.api.openshift.io" )