diff --git a/pkg/executables/cmk_test.go b/pkg/executables/cmk_test.go index cefe72a76a53..7d6d8e428982 100644 --- a/pkg/executables/cmk_test.go +++ b/pkg/executables/cmk_test.go @@ -33,7 +33,7 @@ const ( ) var execConfig = decoder.CloudStackExecConfig{ - Instances: []decoder.CloudStackInstanceConfig{ + Instances: []decoder.CloudStackProfileConfig{ { ApiKey: "test", SecretKey: "test", diff --git a/pkg/providers/cloudstack/cloudstack_test.go b/pkg/providers/cloudstack/cloudstack_test.go index 689701c540e4..9cc478683627 100644 --- a/pkg/providers/cloudstack/cloudstack_test.go +++ b/pkg/providers/cloudstack/cloudstack_test.go @@ -32,7 +32,6 @@ const ( eksd119Release = "kubernetes-1-19-eks-4" /* Generated from ini file (like the following) then b64 encoded: `cat fake-cloud-config.ini | base64 | tr -d '\n'` - [Global] verify-ssl = false [Instance1] @@ -40,7 +39,7 @@ const ( secret-key = test-secret1 api-url = http://127.16.0.1:8080/client/api */ - expectedCloudStackCloudConfig = "W0dsb2JhbF0KdmVyaWZ5LXNzbCA9IGZhbHNlCgpbSW5zdGFuY2UxXQphcGkta2V5ID0gdGVzdC1rZXkxCnNlY3JldC1rZXkgPSB0ZXN0LXNlY3JldDEKYXBpLXVybCA9IGh0dHA6Ly8xMjcuMTYuMC4xOjgwODAvY2xpZW50L2FwaQ==" + expectedCloudStackCloudConfig = "dmVyaWZ5LXNzbCA9IGZhbHNlCgpbSW5zdGFuY2UxXQphcGkta2V5ID0gdGVzdC1rZXkxCnNlY3JldC1rZXkgPSB0ZXN0LXNlY3JldDEKYXBpLXVybCA9IGh0dHA6Ly8xMjcuMTYuMC4xOjgwODAvY2xpZW50L2FwaQo=" ) func givenClusterConfig(t *testing.T, fileName string) *v1alpha1.Cluster { diff --git a/pkg/providers/cloudstack/decoder/decoder.go b/pkg/providers/cloudstack/decoder/decoder.go index fc12b7b33ee3..50165b3e06aa 100644 --- a/pkg/providers/cloudstack/decoder/decoder.go +++ b/pkg/providers/cloudstack/decoder/decoder.go @@ -13,7 +13,6 @@ const ( EksacloudStackCloudConfigB64SecretKey = "EKSA_CLOUDSTACK_B64ENCODED_SECRET" CloudStackCloudConfigB64SecretKey = "CLOUDSTACK_B64ENCODED_SECRET" EksaCloudStackHostPathToMount = "EKSA_CLOUDSTACK_HOST_PATHS_TO_MOUNT" - defaultSectionName = "DEFAULT" ) // ParseCloudStackSecret parses the input b64 string into the ini object to extract out the api key, secret key, and url @@ -32,10 +31,10 @@ func ParseCloudStackSecret() (*CloudStackExecConfig, error) { } verifySslValue := "true" - cloudstackInstances := []CloudStackInstanceConfig{} + cloudstackInstances := []CloudStackProfileConfig{} sections := cfg.Sections() for _, section := range sections { - if section.Name() == defaultSectionName { + if section.Name() == "DEFAULT" { verifySsl, err := section.GetKey("verify-ssl") if err == nil { verifySslValue = verifySsl.Value() @@ -58,7 +57,7 @@ func ParseCloudStackSecret() (*CloudStackExecConfig, error) { if err != nil { return nil, fmt.Errorf("failed to extract value of 'api-url' from %s: %v", EksacloudStackCloudConfigB64SecretKey, err) } - cloudstackInstances = append(cloudstackInstances, CloudStackInstanceConfig{ + cloudstackInstances = append(cloudstackInstances, CloudStackProfileConfig{ Name: section.Name(), ApiKey: apiKey.Value(), SecretKey: secretKey.Value(), @@ -77,12 +76,12 @@ func ParseCloudStackSecret() (*CloudStackExecConfig, error) { } type CloudStackExecConfig struct { - Instances []CloudStackInstanceConfig + Instances []CloudStackProfileConfig VerifySsl string Timeout string } -type CloudStackInstanceConfig struct { +type CloudStackProfileConfig struct { Name string ApiKey string SecretKey string diff --git a/pkg/providers/cloudstack/decoder/decoder_test.go b/pkg/providers/cloudstack/decoder/decoder_test.go index 02520a68c6df..65ea9d572741 100644 --- a/pkg/providers/cloudstack/decoder/decoder_test.go +++ b/pkg/providers/cloudstack/decoder/decoder_test.go @@ -40,7 +40,7 @@ func TestCloudStackConfigDecoder(t *testing.T) { configFile: "../testdata/cloudstack_config_valid.ini", wantErr: false, wantConfig: &decoder.CloudStackExecConfig{ - Instances: []decoder.CloudStackInstanceConfig{ + Instances: []decoder.CloudStackProfileConfig{ { Name: "Instance1", ApiKey: "test-key1", @@ -57,7 +57,7 @@ func TestCloudStackConfigDecoder(t *testing.T) { configFile: "../testdata/cloudstack_config_multiple_instances.ini", wantErr: false, wantConfig: &decoder.CloudStackExecConfig{ - Instances: []decoder.CloudStackInstanceConfig{ + Instances: []decoder.CloudStackProfileConfig{ { Name: "Instance1", ApiKey: "test-key1", @@ -95,7 +95,7 @@ func TestCloudStackConfigDecoder(t *testing.T) { configFile: "../testdata/cloudstack_config_missing_verifyssl.ini", wantErr: false, wantConfig: &decoder.CloudStackExecConfig{ - Instances: []decoder.CloudStackInstanceConfig{ + Instances: []decoder.CloudStackProfileConfig{ { Name: "Instance1", ApiKey: "test-key1", @@ -132,7 +132,7 @@ func TestCloudStackConfigDecoder(t *testing.T) { g := NewWithT(t) configString := test.ReadFile(t, tc.configFile) encodedConfig := base64.StdEncoding.EncodeToString([]byte(configString)) - os.Setenv(decoder.EksacloudStackCloudConfigB64SecretKey, encodedConfig) + tt.Setenv(decoder.EksacloudStackCloudConfigB64SecretKey, encodedConfig) gotConfig, err := decoder.ParseCloudStackSecret() if tc.wantErr {