-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARO-13916 populate client/object IDs after dynamic validation
- Loading branch information
1 parent
70851a2
commit 02f3498
Showing
9 changed files
with
78 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
pkg/util/platformworkloadidentity/platformworkloadidentities.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package platformworkloadidentity | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" | ||
sdkmsi "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi" | ||
|
||
"github.com/Azure/ARO-RP/pkg/api" | ||
"github.com/Azure/ARO-RP/pkg/util/azureclient/azuresdk/armmsi" | ||
) | ||
|
||
func GetPlatformWorkloadIdentityIDs(ctx context.Context, identities map[string]api.PlatformWorkloadIdentity, userAssignedIdentitiesClient armmsi.UserAssignedIdentitiesClient) (map[string]api.PlatformWorkloadIdentity, error) { | ||
updatedIdentities := make(map[string]api.PlatformWorkloadIdentity, len(identities)) | ||
|
||
for operatorName, identity := range identities { | ||
resourceId, err := arm.ParseResourceID(identity.ResourceID) | ||
if err != nil { | ||
return nil, fmt.Errorf("platform workload identity '%s' invalid: %w", operatorName, err) | ||
} | ||
|
||
identityDetails, err := userAssignedIdentitiesClient.Get(ctx, resourceId.ResourceGroupName, resourceId.Name, &sdkmsi.UserAssignedIdentitiesClientGetOptions{}) | ||
if err != nil { | ||
return nil, fmt.Errorf("error occured when retrieving platform workload identity '%s' details: %w", operatorName, err) | ||
} | ||
|
||
updatedIdentities[operatorName] = api.PlatformWorkloadIdentity{ | ||
ResourceID: identity.ResourceID, | ||
ClientID: *identityDetails.Properties.ClientID, | ||
ObjectID: *identityDetails.Properties.PrincipalID, | ||
} | ||
} | ||
|
||
return updatedIdentities, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters