From de6c32fdb130f023f29eac561f02a29cbafa6848 Mon Sep 17 00:00:00 2001 From: Wonkun Kim Date: Tue, 21 Jun 2022 08:13:38 -0500 Subject: [PATCH] Change Name to CredentialsRef --- .../cluster_main_with_availability_zones.yaml | 2 +- pkg/providers/cloudstack/validator.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/providers/cloudstack/testdata/cluster_main_with_availability_zones.yaml b/pkg/providers/cloudstack/testdata/cluster_main_with_availability_zones.yaml index 6b1644b7d61f..48a983213f9b 100644 --- a/pkg/providers/cloudstack/testdata/cluster_main_with_availability_zones.yaml +++ b/pkg/providers/cloudstack/testdata/cluster_main_with_availability_zones.yaml @@ -48,7 +48,7 @@ spec: name: "net1" managementApiEndpoint: "http://127.16.0.1:8080/client/api" availabilityZones: - - name: "zone2" + - credentialsRef: "zone2" account: "admin" domain: "domain2" managementApiEndpoint: "http://127.16.0.2:8080/client/api" diff --git a/pkg/providers/cloudstack/validator.go b/pkg/providers/cloudstack/validator.go index 1a829e857ff6..0fdeaec21e07 100644 --- a/pkg/providers/cloudstack/validator.go +++ b/pkg/providers/cloudstack/validator.go @@ -63,7 +63,7 @@ func (v *Validator) validateCloudStackAccess(ctx context.Context, datacenterConf azNamesToCheck = append(azNamesToCheck, decoder.CloudStackGlobalAZ) } for _, az := range datacenterConfig.Spec.AvailabilityZones { - azNamesToCheck = append(azNamesToCheck, az.Name) + azNamesToCheck = append(azNamesToCheck, az.CredentialsRef) } for _, azName := range azNamesToCheck { @@ -91,9 +91,9 @@ func (v *Validator) ValidateCloudStackDatacenterConfig(ctx context.Context, data return fmt.Errorf("checking management api endpoint: %v", err) } - cmk, ok := v.cmks[az.Name] + cmk, ok := v.cmks[az.CredentialsRef] if !ok { - return fmt.Errorf("cannot find CloudStack profile for availability zone %s", az.Name) + return fmt.Errorf("cannot find CloudStack profile for availability zone %s", az.CredentialsRef) } endpoint := cmk.GetManagementApiEndpoint(ctx) if endpoint != az.ManagementApiEndpoint { @@ -138,7 +138,7 @@ func (v *Validator) generateLocalAvailabilityZones(ctx context.Context, datacent for _, zone := range datacenterConfig.Spec.Zones { availabilityZone := localAvailabilityZone{ CloudStackAvailabilityZone: &anywherev1.CloudStackAvailabilityZone{ - Name: decoder.CloudStackGlobalAZ, + CredentialsRef: decoder.CloudStackGlobalAZ, Domain: datacenterConfig.Spec.Domain, Account: datacenterConfig.Spec.Account, ManagementApiEndpoint: datacenterConfig.Spec.ManagementApiEndpoint, @@ -150,9 +150,9 @@ func (v *Validator) generateLocalAvailabilityZones(ctx context.Context, datacent } } for _, az := range datacenterConfig.Spec.AvailabilityZones { - cmk, ok := v.cmks[az.Name] + cmk, ok := v.cmks[az.CredentialsRef] if !ok { - return fmt.Errorf("cannot find CloudStack profile for availability zone %s", az.Name) + return fmt.Errorf("cannot find CloudStack profile for availability zone %s", az.CredentialsRef) } domain, err := cmk.ValidateDomainPresent(ctx, az.Domain) if err != nil { @@ -286,9 +286,9 @@ func (v *Validator) validateMachineConfig(ctx context.Context, datacenterConfig } for _, az := range v.availabilityZones { - cmk, ok := v.cmks[az.Name] + cmk, ok := v.cmks[az.CredentialsRef] if !ok { - return fmt.Errorf("cannot find CloudStack profile for availability zone %s", az.Name) + return fmt.Errorf("cannot find CloudStack profile for availability zone %s", az.CredentialsRef) } if err := cmk.ValidateTemplatePresent(ctx, az.DomainId, az.CloudStackAvailabilityZone.Zone.Id, az.Account, machineConfig.Spec.Template); err != nil { return fmt.Errorf("validating template: %v", err)