Skip to content

Commit

Permalink
Merge pull request openshift#1626 from openshift-cherrypick-robot/che…
Browse files Browse the repository at this point in the history
…rry-pick-1617-to-ocm-2.4

[ocm-2.4] BZ 2026853: Respect azure cloudName set for clusterpool.
  • Loading branch information
openshift-merge-robot authored Dec 6, 2021
2 parents 6c9c8e4 + f1c721e commit cce4cb9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/clusterresource/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type AzureCloudBuilder struct {

// Region is the Azure region to which to install the cluster.
Region string

// CloudName is the name of the Azure cloud environment which will be used for the cluster.
CloudName hivev1azure.CloudEnvironment
}

func NewAzureCloudBuilderFromSecret(credsSecret *corev1.Secret) *AzureCloudBuilder {
Expand Down Expand Up @@ -66,6 +69,7 @@ func (p *AzureCloudBuilder) GetCloudPlatform(o *Builder) hivev1.Platform {
},
Region: p.Region,
BaseDomainResourceGroupName: p.BaseDomainResourceGroupName,
CloudName: p.CloudName,
},
}
}
Expand All @@ -86,6 +90,7 @@ func (p *AzureCloudBuilder) addInstallConfigPlatform(o *Builder, ic *installerty
Azure: &azureinstallertypes.Platform{
Region: p.Region,
BaseDomainResourceGroupName: p.BaseDomainResourceGroupName,
CloudName: azureinstallertypes.CloudEnvironment(p.CloudName),
},
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/clusterresource/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ghodss/yaml"
"github.com/openshift/hive/apis"
hivev1 "github.com/openshift/hive/apis/hive/v1"
hivev1azure "github.com/openshift/hive/apis/hive/v1/azure"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand All @@ -31,6 +32,7 @@ const (
fakeAWSSecretAccessKey = "fakesecretAccessKey"
fakeAzureServicePrincipal = "fakeSP"
fakeAzureBaseDomainResourceGroup = "azure-resource-group"
fakeAzureCloudName = hivev1azure.CloudEnvironment("AzureUSGovernmentCloud")
fakeGCPServiceAccount = "fakeSA"
fakeGCPProjectID = "gcp-project-id"
adoptAdminKubeconfig = "adopted-admin-kubeconfig"
Expand Down Expand Up @@ -115,6 +117,7 @@ func createAzureClusterBuilder() *Builder {
b.CloudBuilder = &AzureCloudBuilder{
ServicePrincipal: []byte(fakeAzureServicePrincipal),
BaseDomainResourceGroupName: fakeAzureBaseDomainResourceGroup,
CloudName: fakeAzureCloudName,
}
return b
}
Expand Down Expand Up @@ -209,6 +212,8 @@ func TestBuildClusterResources(t *testing.T) {
assert.Equal(t, credsSecret.Name, cd.Spec.Platform.Azure.CredentialsSecretRef.Name)

assert.Equal(t, azureInstanceType, workerPool.Spec.Platform.Azure.InstanceType)

assert.Equal(t, fakeAzureCloudName, cd.Spec.Platform.Azure.CloudName)
},
},
{
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/clusterpool/clusterpool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ func (r *ReconcileClusterPool) createCloudBuilder(pool *hivev1.ClusterPool, logg
cloudBuilder := clusterresource.NewAzureCloudBuilderFromSecret(credsSecret)
cloudBuilder.BaseDomainResourceGroupName = platform.Azure.BaseDomainResourceGroupName
cloudBuilder.Region = platform.Azure.Region
cloudBuilder.CloudName = platform.Azure.CloudName
return cloudBuilder, nil
// TODO: OpenStack, VMware, and Ovirt.
default:
Expand Down

0 comments on commit cce4cb9

Please sign in to comment.