diff --git a/harness/cd/cac/enums.go b/harness/cd/cac/enums.go index c6759a93..b60ee1cb 100644 --- a/harness/cd/cac/enums.go +++ b/harness/cd/cac/enums.go @@ -267,28 +267,6 @@ var EnvironmentFilterTypes = &struct { Selected: "SELECTED", } -type SecretManagerType string - -func (v SecretManagerType) String() string { - return string(v) -} - -var SecretManagerTypes = &struct { - GcpKMS SecretManagerType - AwsSecretsManager SecretManagerType - AwsKMS SecretManagerType - AzureKeyVault SecretManagerType - CyberArk SecretManagerType - HashicorpVault SecretManagerType -}{ - GcpKMS: "gcpkms", - AwsSecretsManager: "awssecretsmanager", - AwsKMS: "amazonkms", - AzureKeyVault: "azurekeyvault", - CyberArk: "cyberark", - HashicorpVault: "hashicorpvault", -} - type EnvironmentType string func (v EnvironmentType) String() string { diff --git a/harness/cd/cac/types.go b/harness/cd/cac/types.go index 14f64a00..59a45775 100644 --- a/harness/cd/cac/types.go +++ b/harness/cd/cac/types.go @@ -273,8 +273,7 @@ type EnvFilter struct { } type SecretRef struct { - SecretManagerType SecretManagerType - Name string + Name string } type YamlPath string diff --git a/harness/cd/cac/types_test.go b/harness/cd/cac/types_test.go index a15b99b4..6f7019a1 100644 --- a/harness/cd/cac/types_test.go +++ b/harness/cd/cac/types_test.go @@ -37,8 +37,7 @@ func TestSpotInstCloudProviderSerialization(t *testing.T) { testObj := NewEntity(ObjectTypes.SpotInstCloudProvider).(*SpotInstCloudProvider) testObj.AccountId = "accountId" testObj.Token = &SecretRef{ - SecretManagerType: SecretManagerTypes.GcpKMS, - Name: "secret_name", + Name: "secret_name", } expectedObjYaml := ` @@ -75,19 +74,16 @@ func TestKubernetesCLoudProviderSerialization(t *testing.T) { } testObj.MasterUrl = "masterurl" testObj.OIDCClientId = &SecretRef{ - SecretManagerType: SecretManagerTypes.GcpKMS, - Name: "secret_name", + Name: "secret_name", } testObj.OIDCIdentityProviderUrl = "providerUrl" testObj.OIDCPassword = &SecretRef{ - SecretManagerType: SecretManagerTypes.GcpKMS, - Name: "secret_name", + Name: "secret_name", } testObj.OIDCScopes = "scope1 scope2" testObj.OIDCUsername = "username" testObj.ServiceAccountToken = &SecretRef{ - SecretManagerType: SecretManagerTypes.GcpKMS, - Name: "token", + Name: "token", } testObj.SkipValidation = true testObj.UseEncryptedUsername = true @@ -136,8 +132,7 @@ func TestAwsCloudProviderSerialization(t *testing.T) { ExternalId: "externalId", } testObj.SecretKey = &SecretRef{ - SecretManagerType: SecretManagerTypes.GcpKMS, - Name: "secret_name", + Name: "secret_name", } testObj.UseEc2IamCredentials = true testObj.UseIRSA = true @@ -167,8 +162,7 @@ func TestAzureCloudProviderSerialization(t *testing.T) { testObj := NewEntity(ObjectTypes.AzureCloudProvider).(*AzureCloudProvider) testObj.ClientId = "clientId" testObj.Key = &SecretRef{ - SecretManagerType: SecretManagerTypes.GcpKMS, - Name: "secret_name", + Name: "secret_name", } testObj.TenantId = "tenantId" testObj.AzureEnvironmentType = AzureEnvironmentTypes.AzureGlobal @@ -193,8 +187,7 @@ func TestPcfCloudProviderSerialization(t *testing.T) { testObj := NewEntity(ObjectTypes.PcfCloudProvider).(*PcfCloudProvider) testObj.EndpointUrl = "http://endpoint.com" testObj.Password = &SecretRef{ - SecretManagerType: SecretManagerTypes.AwsKMS, - Name: "secret_name", + Name: "secret_name", } testObj.SkipValidation = true testObj.Username = "username" @@ -234,8 +227,7 @@ func TestGcpCloudProviderSerialization(t *testing.T) { DelegateSelectors: []string{"primary"}, SkipValidation: true, ServiceAccountKeyFileContent: &SecretRef{ - SecretManagerType: SecretManagerTypes.AwsKMS, - Name: "abc123", + Name: "abc123", }, UsageRestrictions: &UsageRestrictions{ AppEnvRestrictions: []*AppEnvRestriction{ @@ -301,20 +293,18 @@ func TestSecretRefMarshalYaml(t *testing.T) { testStruct := &TestSecretRefMarshal{ SecretKeyId: &SecretRef{ - SecretManagerType: SecretManagerTypes.AwsKMS, - Name: "abc123", + Name: "abc123", }, } bytes, err := yaml.Marshal(&testStruct) require.NoError(t, err) fmt.Println(string(bytes)) - require.Equal(t, "secretKeyId: amazonkms:abc123\n", string(bytes)) + require.Equal(t, "secretKeyId: secretName:abc123\n", string(bytes)) newStruct := &TestSecretRefMarshal{} err = yaml.Unmarshal(bytes, newStruct) require.NoError(t, err) - require.Equal(t, testStruct.SecretKeyId.SecretManagerType, newStruct.SecretKeyId.SecretManagerType) require.Equal(t, testStruct.SecretKeyId.Name, newStruct.SecretKeyId.Name) } diff --git a/harness/cd/cac/utils.go b/harness/cd/cac/utils.go index 6338bc29..a9edfae7 100644 --- a/harness/cd/cac/utils.go +++ b/harness/cd/cac/utils.go @@ -105,11 +105,7 @@ func (r *SecretRef) MarshalYAML() (interface{}, error) { return nil, errors.New("name must be set") } - if r.SecretManagerType == "" { - return r.Name, nil - } - - return fmt.Sprintf("%s:%s", r.SecretManagerType, r.Name), nil + return fmt.Sprintf("secretName:%s", r.Name), nil } func (r *SecretRef) UnmarshalYAML(unmarshal func(interface{}) error) error { @@ -127,7 +123,6 @@ func (r *SecretRef) UnmarshalYAML(unmarshal func(interface{}) error) error { if len(parts) == 1 { r.Name = parts[0] } else if len(parts) == 2 { - r.SecretManagerType = SecretManagerType(parts[0]) r.Name = parts[1] } diff --git a/harness/cd/cac/utils_test.go b/harness/cd/cac/utils_test.go index 27c75e5d..858809f9 100644 --- a/harness/cd/cac/utils_test.go +++ b/harness/cd/cac/utils_test.go @@ -41,7 +41,6 @@ func TestSecretRefUnmarshalYaml(t *testing.T) { require.NoError(t, err) require.Equal(t, "secretname", secretRef.Name) - require.Equal(t, SecretManagerTypes.GcpKMS, secretRef.SecretManagerType) yamlString = `secretname` @@ -50,5 +49,4 @@ func TestSecretRefUnmarshalYaml(t *testing.T) { require.NoError(t, err) require.Equal(t, "secretname", secretRef.Name) - require.Equal(t, SecretManagerType(""), secretRef.SecretManagerType) } diff --git a/harness/cd/cac_cloudprovider_test.go b/harness/cd/cac_cloudprovider_test.go index e01fc9fd..e4aac3c3 100644 --- a/harness/cd/cac_cloudprovider_test.go +++ b/harness/cd/cac_cloudprovider_test.go @@ -66,8 +66,7 @@ func TestCacSpotInstCloudProvider(t *testing.T) { cpInput.Name = expectedName cpInput.AccountId = helpers.TestEnvVars.SpotInstAccountId.Get() cpInput.Token = &cac.SecretRef{ - SecretManagerType: cac.SecretManagerTypes.GcpKMS, - Name: secret.Name, + Name: secret.Name, } c := getClient() @@ -76,7 +75,6 @@ func TestCacSpotInstCloudProvider(t *testing.T) { require.NotNil(t, cp) cpInput.Id = cp.Id - cp.Token.SecretManagerType = cac.SecretManagerTypes.GcpKMS require.Equal(t, cpInput, cp) err = c.CloudProviderClient.DeleteCloudProvider(cpInput.Id) @@ -95,8 +93,7 @@ func TestCacPcfCloudProvider(t *testing.T) { cpInput.EndpointUrl = "https://example.com" cpInput.Username = "username" cpInput.Password = &cac.SecretRef{ - SecretManagerType: cac.SecretManagerTypes.GcpKMS, - Name: secret.Name, + Name: secret.Name, } c := getClient() @@ -105,7 +102,6 @@ func TestCacPcfCloudProvider(t *testing.T) { require.NotNil(t, cp) cpInput.Id = cp.Id - cp.Password.SecretManagerType = cac.SecretManagerTypes.GcpKMS require.Equal(t, cpInput, cp) err = c.CloudProviderClient.DeleteCloudProvider(cpInput.Id) @@ -123,8 +119,7 @@ func TestCacKubernetesCloudProvider(t *testing.T) { cpInput.SkipValidation = true cpInput.MasterUrl = "https://example.com" cpInput.ServiceAccountToken = &cac.SecretRef{ - SecretManagerType: cac.SecretManagerTypes.GcpKMS, - Name: secret.Name, + Name: secret.Name, } c := getClient() @@ -133,7 +128,6 @@ func TestCacKubernetesCloudProvider(t *testing.T) { require.NotNil(t, cp) cpInput.Id = cp.Id - cp.ServiceAccountToken.SecretManagerType = cac.SecretManagerTypes.GcpKMS require.Equal(t, cpInput, cp) err = c.CloudProviderClient.DeleteCloudProvider(cpInput.Id) @@ -152,8 +146,7 @@ func TestCacUpsertAzureCloudProvider(t *testing.T) { cpInput.ClientId = helpers.TestEnvVars.AzureClientId.Get() cpInput.TenantId = helpers.TestEnvVars.AzureTenantId.Get() cpInput.Key = &cac.SecretRef{ - SecretManagerType: cac.SecretManagerTypes.GcpKMS, - Name: secret.Name, + Name: secret.Name, } c := getClient() @@ -162,7 +155,6 @@ func TestCacUpsertAzureCloudProvider(t *testing.T) { require.NotNil(t, cp) cpInput.Id = cp.Id - cp.Key.SecretManagerType = cac.SecretManagerTypes.GcpKMS require.Equal(t, cpInput, cp) err = c.CloudProviderClient.DeleteCloudProvider(cpInput.Id) @@ -216,8 +208,7 @@ func TestUpsertAwsCloudProvider(t *testing.T) { cpInput.Name = expectedName cpInput.AccessKey = helpers.TestEnvVars.AwsAccessKeyId.Get() cpInput.SecretKey = &cac.SecretRef{ - SecretManagerType: cac.SecretManagerTypes.GcpKMS, - Name: secret.Name, + Name: secret.Name, } c := getClient() @@ -226,7 +217,6 @@ func TestUpsertAwsCloudProvider(t *testing.T) { require.NoError(t, err) cpInput.Id = cp.Id - cp.SecretKey.SecretManagerType = cac.SecretManagerTypes.GcpKMS require.Equal(t, cpInput, cp) err = c.CloudProviderClient.DeleteCloudProvider(cpInput.Id)