Skip to content

Commit

Permalink
Change Name to CredentialsRef
Browse files Browse the repository at this point in the history
  • Loading branch information
wongni committed Jun 21, 2022
1 parent 5b3a347 commit de6c32f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions pkg/providers/cloudstack/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit de6c32f

Please sign in to comment.