From 795f0dece7ec83fa16744bd23cef1f1d992af451 Mon Sep 17 00:00:00 2001 From: pmahindrakar-oss Date: Fri, 25 Mar 2022 13:04:02 +0530 Subject: [PATCH] Adding authType in pflags and also updated docs with valid values (#268) * Adding authType in pflags and also updated docs with valid values Signed-off-by: Prafulla Mahindrakar * removed the default message Signed-off-by: Prafulla Mahindrakar * fixed spaces in mesages Signed-off-by: Prafulla Mahindrakar --- flyteidl/clients/go/admin/config.go | 2 +- flyteidl/clients/go/admin/config_flags.go | 1 + flyteidl/clients/go/admin/config_flags_test.go | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/flyteidl/clients/go/admin/config.go b/flyteidl/clients/go/admin/config.go index 623622d49b..dd1e1bce30 100644 --- a/flyteidl/clients/go/admin/config.go +++ b/flyteidl/clients/go/admin/config.go @@ -44,7 +44,7 @@ type Config struct { MaxBackoffDelay config.Duration `json:"maxBackoffDelay" pflag:",Max delay for grpc backoff"` PerRetryTimeout config.Duration `json:"perRetryTimeout" pflag:",gRPC per retry timeout"` MaxRetries int `json:"maxRetries" pflag:",Max number of gRPC retries"` - AuthType AuthType `json:"authType" pflag:"-,Type of OAuth2 flow used for communicating with admin."` + AuthType AuthType `json:"authType" pflag:",Type of OAuth2 flow used for communicating with admin.ClientSecret,Pkce,ExternalCommand are valid values"` TokenRefreshWindow config.Duration `json:"tokenRefreshWindow" pflag:",Max duration between token refresh attempt and token expiry."` // Deprecated: settings will be discovered dynamically DeprecatedUseAuth bool `json:"useAuth" pflag:",Deprecated: Auth will be enabled/disabled based on admin's dynamically discovered information."` diff --git a/flyteidl/clients/go/admin/config_flags.go b/flyteidl/clients/go/admin/config_flags.go index df72d4244f..2a6fd7b3fd 100755 --- a/flyteidl/clients/go/admin/config_flags.go +++ b/flyteidl/clients/go/admin/config_flags.go @@ -57,6 +57,7 @@ func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet { cmdFlags.String(fmt.Sprintf("%v%v", prefix, "maxBackoffDelay"), defaultConfig.MaxBackoffDelay.String(), "Max delay for grpc backoff") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "perRetryTimeout"), defaultConfig.PerRetryTimeout.String(), "gRPC per retry timeout") cmdFlags.Int(fmt.Sprintf("%v%v", prefix, "maxRetries"), defaultConfig.MaxRetries, "Max number of gRPC retries") + cmdFlags.String(fmt.Sprintf("%v%v", prefix, "authType"), defaultConfig.AuthType.String(), "Type of OAuth2 flow used for communicating with admin.ClientSecret, Pkce, ExternalCommand are valid values") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "tokenRefreshWindow"), defaultConfig.TokenRefreshWindow.String(), "Max duration between token refresh attempt and token expiry.") cmdFlags.Bool(fmt.Sprintf("%v%v", prefix, "useAuth"), defaultConfig.DeprecatedUseAuth, "Deprecated: Auth will be enabled/disabled based on admin's dynamically discovered information.") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "clientId"), defaultConfig.ClientID, "Client ID") diff --git a/flyteidl/clients/go/admin/config_flags_test.go b/flyteidl/clients/go/admin/config_flags_test.go index e7a797e106..7ad8aa3130 100755 --- a/flyteidl/clients/go/admin/config_flags_test.go +++ b/flyteidl/clients/go/admin/config_flags_test.go @@ -197,6 +197,20 @@ func TestConfig_SetFlags(t *testing.T) { } }) }) + t.Run("Test_authType", func(t *testing.T) { + + t.Run("Override", func(t *testing.T) { + testValue := "1" + + cmdFlags.Set("authType", testValue) + if vString, err := cmdFlags.GetString("authType"); err == nil { + testDecodeJson_Config(t, fmt.Sprintf("%v", vString), &actual.AuthType) + + } else { + assert.FailNow(t, err.Error()) + } + }) + }) t.Run("Test_tokenRefreshWindow", func(t *testing.T) { t.Run("Override", func(t *testing.T) {