Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion support/globalconfig/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func ReconcileInfrastructure(infra *configv1.Infrastructure, hcp *hyperv1.Hosted
if infra.Status.PlatformStatus.Azure == nil {
infra.Status.PlatformStatus.Azure = &configv1.AzurePlatformStatus{}
}
infra.Status.PlatformStatus.Azure.CloudName = configv1.AzurePublicCloud
cloudName := configv1.AzureCloudEnvironment(hcp.Spec.Platform.Azure.Cloud)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not the same constants. I believe you'll need to add a mapping function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direct type conversion is actually valid here - both types use the same underlying string values. Looking at both APIs:

  • HyperShift API (hyperv1.AzurePlatformSpec.Cloud): string with enum AzurePublicCloud;AzureUSGovernmentCloud;AzureChinaCloud;AzureGermanCloud;AzureStackCloud
  • configv1 API (configv1.AzureCloudEnvironment): type AzureCloudEnvironment string with enum "";AzurePublicCloud;AzureUSGovernmentCloud;AzureChinaCloud;AzureGermanCloud;AzureStackCloud

The string values are identical between both APIs. The only difference is configv1 also allows empty string, which we handle on lines 86-88 by defaulting to AzurePublicCloud.

Since both are backed by string and use the exact same values, the type conversion configv1.AzureCloudEnvironment(hcp.Spec.Platform.Azure.Cloud) works correctly.

I did check for an existing mapping function - GetAzureCloudConfiguration in support/azureutil/azureutil.go maps to Azure SDK's cloud.Configuration, not to configv1.AzureCloudEnvironment. Happy to add an explicit mapping function if you'd prefer that for clarity, but the current approach is type-safe.


AI-assisted response via Claude Code

if cloudName == "" {
cloudName = configv1.AzurePublicCloud
}
infra.Status.PlatformStatus.Azure.CloudName = cloudName
infra.Status.PlatformStatus.Azure.ResourceGroupName = hcp.Spec.Platform.Azure.ResourceGroupName
Comment thread
bryan-cox marked this conversation as resolved.
case hyperv1.PowerVSPlatform:
infra.Status.PlatformStatus.PowerVS = &configv1.PowerVSPlatformStatus{
Expand Down