Skip to content

Commit

Permalink
ensure the case folding of cluster MSI resourceID
Browse files Browse the repository at this point in the history
  • Loading branch information
gniranjan committed Oct 7, 2024
1 parent 5f098c0 commit d5c6efb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 2 additions & 6 deletions pkg/cluster/deploybaseresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ func (m *manager) deployBaseResourceTemplate(ctx context.Context) error {
m.storageAccount(m.doc.OpenShiftCluster.Properties.ImageRegistryStorageAccountName, azureRegion, ocpSubnets, true),
m.storageAccountBlobContainer(m.doc.OpenShiftCluster.Properties.ImageRegistryStorageAccountName, "image-registry"),
m.clusterNSG(infraID, azureRegion),
m.networkPrivateLinkService(azureRegion),
m.networkInternalLoadBalancer(azureRegion),
}

if m.doc.OpenShiftCluster.UsesWorkloadIdentity() {
Expand All @@ -210,12 +212,6 @@ func (m *manager) deployBaseResourceTemplate(ctx context.Context) error {
resources = append(resources, m.clusterServicePrincipalRBAC())
}

resources = append(
resources,
m.networkPrivateLinkService(azureRegion),
m.networkInternalLoadBalancer(azureRegion),
)

// Create a public load balancer routing if needed
if m.doc.OpenShiftCluster.Properties.NetworkProfile.OutboundType == api.OutboundTypeLoadbalancer {
m.newPublicLoadBalancer(ctx, &resources)
Expand Down
11 changes: 10 additions & 1 deletion pkg/cluster/deploybaseresources_additional.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ func (m *manager) ensureWorkloadIdentityRBAC() ([]*arm.Resource, error) {
if err != nil {
return nil, err
}
clusterMSI := m.doc.OpenShiftCluster.Identity.UserAssignedIdentities[clusterMSIResourceId.String()]

var clusterMSI api.ClusterUserAssignedIdentity
// we iterate through the existing identities to find the identity matching
// the expected resourceID with casefolding
for k, _ := range m.doc.OpenShiftCluster.Identity.UserAssignedIdentities {

Check failure on line 108 in pkg/cluster/deploybaseresources_additional.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
if strings.EqualFold(k, clusterMSIResourceId.String()) {
clusterMSI = m.doc.OpenShiftCluster.Identity.UserAssignedIdentities[k]
}
}

if strings.TrimSpace(clusterMSI.PrincipalID) == "" {
return nil, fmt.Errorf("cluster MSI principal ID '%s' is invalid for clusterMSIResourceId %s", clusterMSI.PrincipalID, clusterMSIResourceId.String())
}
Expand Down

0 comments on commit d5c6efb

Please sign in to comment.