Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate CI and ARM feedback from azure-rest-api-specs to v2024-08-12-preview API #3727

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d725641
api changes
cadenmarchese Jul 22, 2024
0054637
fix tag package-2023-11
cadenmarchese Jul 22, 2024
522ab81
remove UserAssignedIdentities
cadenmarchese Jul 23, 2024
a9d81c9
update the default tag to latest
cadenmarchese Jul 23, 2024
1e3ab7f
define a new IdentityType with x-ms-enum
cadenmarchese Jul 23, 2024
def9374
modelAsString on identityType x-ms-enum should be false
cadenmarchese Jul 26, 2024
16a9c8e
rename IdentityType to ResourceIdentityType to match v3/types.json
cadenmarchese Jul 26, 2024
abf3620
make client
cadenmarchese Jul 26, 2024
1b9483b
remove whitespace
cadenmarchese Jul 30, 2024
7449392
add descriptions to all new API fields
cadenmarchese Aug 2, 2024
de7a1dd
make client
cadenmarchese Aug 14, 2024
e045178
fix unit test that was failing as a result of removing the UserAssign…
cadenmarchese Aug 14, 2024
9fdd900
Adjust a doc comment according to feedback
cadenmarchese Aug 15, 2024
99f6f24
make client
cadenmarchese Aug 15, 2024
a4b108b
add platformworkloadidentityroleset to API definition and examples
cadenmarchese Sep 10, 2024
361e883
Update client generation to account for swagger subfolder
tsatam Sep 12, 2024
4fa7251
make client
tsatam Sep 12, 2024
8436ad3
fix pwip and validatestatic unit tests
cadenmarchese Sep 13, 2024
307f5e0
fix relative path to common-types
cadenmarchese Sep 18, 2024
5798bef
migrate from common-types/v3 to common-types/v6
cadenmarchese Sep 19, 2024
079b075
move from Identity to ManagedServiceIdentity type
cadenmarchese Sep 19, 2024
097539e
use modelerfour.lenient-model-deduplication=true
cadenmarchese Sep 24, 2024
afad85c
convert PlatformWorkloadIdentity to map
cadenmarchese Sep 26, 2024
d487580
ARO-4382 fix unit test cases
rajdeepc2792 Sep 27, 2024
ab0b59f
make generate swagger
cadenmarchese Sep 27, 2024
e7e466f
fix unit tests
cadenmarchese Sep 27, 2024
c0ca919
revert naming openShiftCluster.ManagedServiceIdentity to Identity
cadenmarchese Oct 8, 2024
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
2 changes: 1 addition & 1 deletion .sha256sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ b1f1de0fe40d05de90742b17928968923b936adc294000f58974f50a297581dd swagger/redhat
c023515341196746454c0ae7af077d40d3ec13f6b88b33cb558f0a7ab17a5a24 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/openshiftclusters/preview/2023-07-01-preview/redhatopenshift.json
440748951dd1c3b34b5ccbdcb7cd966e3b89490887a1f1d64429561fad789515 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/openshiftclusters/stable/2023-09-04/redhatopenshift.json
74a46fdde6ceb0121fe1515c7e11e902dd921b54cffe693307fb02b3dc88f26e swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/openshiftclusters/stable/2023-11-22/redhatopenshift.json
5849bcb518f6c7a6942a7eafb1d2edd107a18ad489c823e0262aad4bc509da9f swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/openshiftclusters/preview/2024-08-12-preview/redhatopenshift.json
f0fe964f4ea830ecadfac27e75c7753a1117daef5189ef499d766cb3974bed67 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/openshiftclusters/preview/2024-08-12-preview/redhatopenshift.json
3 changes: 2 additions & 1 deletion hack/build-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function checksum() {
local API_VERSION=$1
local FOLDER=$2

sha256sum swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/"$FOLDER"/"$API_VERSION"/redhatopenshift.json >>.sha256sum
sha256sum swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/openshiftclusters/"$FOLDER"/"$API_VERSION"/redhatopenshift.json >>.sha256sum
}

function generate_golang() {
Expand Down Expand Up @@ -68,6 +68,7 @@ function generate_python() {
"${AUTOREST_IMAGE}" \
--use=@autorest/python@~5.12.0 \
--use=@autorest/modelerfour@~4.20.0 \
--modelerfour.lenient-model-deduplication=true \
--version=~3.6.2 \
--python \
--azure-arm \
Expand Down
56 changes: 40 additions & 16 deletions pkg/api/admin/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type OpenShiftCluster struct {
Location string `json:"location,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
Properties OpenShiftClusterProperties `json:"properties,omitempty"`
Identity *Identity `json:"identity,omitempty"`
Identity *ManagedServiceIdentity `json:"managedServiceIdentity,omitempty"`
}

// OpenShiftClusterProperties represents an OpenShift cluster's properties.
Expand Down Expand Up @@ -419,34 +419,58 @@ type IngressProfile struct {

// PlatformWorkloadIdentityProfile encapsulates all information that is specific to workload identity clusters.
type PlatformWorkloadIdentityProfile struct {
UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"`
PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"`
UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"`
PlatformWorkloadIdentities map[string]PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"`
}

// UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to
type UpgradeableTo string

// PlatformWorkloadIdentity stores information representing a single workload identity.
type PlatformWorkloadIdentity struct {
OperatorName string `json:"operatorName,omitempty"`
ResourceID string `json:"resourceId,omitempty"`
ClientID string `json:"clientId,omitempty" swagger:"readOnly"`
ObjectID string `json:"objectId,omitempty" swagger:"readOnly"`
// The resource ID of the PlatformWorkloadIdentity resource
ResourceID string `json:"resourceId,omitempty"`

// The ClientID of the PlatformWorkloadIdentity resource
ClientID string `json:"clientId,omitempty" swagger:"readOnly"`

// The ObjectID of the PlatformWorkloadIdentity resource
ObjectID string `json:"objectId,omitempty" swagger:"readOnly"`
}

// ClusterUserAssignedIdentity stores information about a user-assigned managed identity in a predefined format required by Microsoft's Managed Identity team.
type ClusterUserAssignedIdentity struct {
ClientID string `json:"clientId,omitempty"`
// UserAssignedIdentity stores information about a user-assigned managed identity in a predefined format required by Microsoft's Managed Identity team.
type UserAssignedIdentity struct {
// The ClientID of the ClusterUserAssignedIdentity resource
ClientID string `json:"clientId,omitempty"`

// The PrincipalID of the ClusterUserAssignedIdentity resource
PrincipalID string `json:"principalId,omitempty"`
}

// UserAssignedIdentities stores a mapping from resource IDs of managed identities to their client/principal IDs.
type UserAssignedIdentities map[string]ClusterUserAssignedIdentity
// The ManagedServiceIdentity type.
type ManagedServiceIdentityType string

// ManagedServiceIdentityType constants
const (
ManagedServiceIdentityNone ManagedServiceIdentityType = "None"
ManagedServiceIdentitySystemAssigned ManagedServiceIdentityType = "SystemAssigned"
ManagedServiceIdentityUserAssigned ManagedServiceIdentityType = "UserAssigned"
ManagedServiceIdentitySystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned"
)

// ManagedServiceIdentity stores information about the cluster MSI(s) in a workload identity cluster.
type ManagedServiceIdentity struct {
// The type of the ManagedServiceIdentity resource.
Type ManagedServiceIdentityType `json:"type,omitempty"`

// The PrincipalID of the Identity resource.
PrincipalID string `json:"principalId,omitempty" swagger:"readOnly"`

// The TenantID provided by the MSI RP
TenantID string `json:"tenantId,omitempty" swagger:"readOnly"`

// Identity stores information about the cluster MSI(s) in a workload identity cluster.
type Identity struct {
Type string `json:"type,omitempty"`
UserAssignedIdentities UserAssignedIdentities `json:"userAssignedIdentities,omitempty"`
// A map of user assigned identities attached to the cluster, specified in a type required by Microsoft's Managed Identity team.
UserAssignedIdentities map[string]UserAssignedIdentity `json:"userAssignedIdentities,omitempty"`
}

// Install represents an install process.
Expand Down
60 changes: 42 additions & 18 deletions pkg/api/admin/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
}

if oc.Identity != nil {
out.Identity.Type = oc.Identity.Type
out.Identity.UserAssignedIdentities = make(map[string]ClusterUserAssignedIdentity, len(oc.Identity.UserAssignedIdentities))
out.Identity.Type = ManagedServiceIdentityType(oc.Identity.Type)
out.Identity.UserAssignedIdentities = make(map[string]UserAssignedIdentity, len(oc.Identity.UserAssignedIdentities))
for k := range oc.Identity.UserAssignedIdentities {
var temp ClusterUserAssignedIdentity
var temp UserAssignedIdentity
temp.ClientID = oc.Identity.UserAssignedIdentities[k].ClientID
temp.PrincipalID = oc.Identity.UserAssignedIdentities[k].PrincipalID
out.Identity.UserAssignedIdentities[k] = temp
Expand All @@ -190,13 +190,16 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac

if oc.Properties.PlatformWorkloadIdentityProfile != nil && oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities != nil {
out.Properties.PlatformWorkloadIdentityProfile = &PlatformWorkloadIdentityProfile{}
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities = make([]PlatformWorkloadIdentity, len(oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities))
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities = make(map[string]PlatformWorkloadIdentity, len(oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities))

for i := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].OperatorName = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].OperatorName
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ResourceID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ResourceID
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ClientID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ClientID
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ObjectID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ObjectID
for k := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
if entry, ok := out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k]; ok {
entry.ClientID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ClientID
entry.ObjectID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ObjectID
entry.ResourceID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ResourceID

out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k] = entry
}
}
}

Expand Down Expand Up @@ -254,10 +257,10 @@ func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShif
}
}
if oc.Identity != nil {
out.Identity.Type = oc.Identity.Type
out.Identity.UserAssignedIdentities = make(map[string]api.ClusterUserAssignedIdentity, len(oc.Identity.UserAssignedIdentities))
out.Identity.Type = api.ManagedServiceIdentityType(oc.Identity.Type)
out.Identity.UserAssignedIdentities = make(map[string]api.UserAssignedIdentity, len(oc.Identity.UserAssignedIdentities))
for k := range oc.Identity.UserAssignedIdentities {
var temp api.ClusterUserAssignedIdentity
var temp api.UserAssignedIdentity
temp.ClientID = oc.Identity.UserAssignedIdentities[k].ClientID
temp.PrincipalID = oc.Identity.UserAssignedIdentities[k].PrincipalID
out.Identity.UserAssignedIdentities[k] = temp
Expand Down Expand Up @@ -292,13 +295,16 @@ func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShif
}
if oc.Properties.PlatformWorkloadIdentityProfile != nil && oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities != nil {
out.Properties.PlatformWorkloadIdentityProfile = &api.PlatformWorkloadIdentityProfile{}
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities = make([]api.PlatformWorkloadIdentity, len(oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities))
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities = make(map[string]api.PlatformWorkloadIdentity, len(oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities))

for i := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].OperatorName = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].OperatorName
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ResourceID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ResourceID
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ClientID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ClientID
out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ObjectID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ObjectID
for k := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic should be able to be simplified similar to how the tags are formed, isn't it?

for k, v := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
    out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ClientId == v.ClientId
...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried that first, but was unable to get it to compile:

cannot assign to struct field out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ResourceID in map

etc...

if entry, ok := out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k]; ok {
entry.ClientID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ClientID
entry.ObjectID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ObjectID
entry.ResourceID = oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k].ResourceID

out.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[k] = entry
}
}
}
out.Properties.NetworkProfile.PodCIDR = oc.Properties.NetworkProfile.PodCIDR
Expand Down Expand Up @@ -418,4 +424,22 @@ func (c openShiftClusterConverter) ExternalNoReadOnly(_oc interface{}) {
if oc.Properties.NetworkProfile.LoadBalancerProfile != nil {
oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = nil
}
if oc.Properties.PlatformWorkloadIdentityProfile != nil {
for i := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
if entry, ok := oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i]; ok {
entry.ClientID = ""
entry.ObjectID = ""
oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i] = entry
}
}
}
if oc.Identity != nil {
for i := range oc.Identity.UserAssignedIdentities {
if entry, ok := oc.Identity.UserAssignedIdentities[i]; ok {
entry.ClientID = ""
entry.PrincipalID = ""
oc.Identity.UserAssignedIdentities[i] = entry
}
}
}
}
63 changes: 44 additions & 19 deletions pkg/api/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type OpenShiftCluster struct {
SystemData SystemData `json:"systemData,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
Properties OpenShiftClusterProperties `json:"properties,omitempty"`
Identity *Identity `json:"identity,omitempty"`
Identity *ManagedServiceIdentity `json:"managedServiceIdentity,omitempty"`

//this property is used in the enrichers. Should not be marshalled
Lock sync.Mutex `json:"-"`
Expand Down Expand Up @@ -817,8 +817,8 @@ type HiveProfile struct {
type PlatformWorkloadIdentityProfile struct {
MissingFields

UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"`
PlatformWorkloadIdentities []PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"`
UpgradeableTo *UpgradeableTo `json:"upgradeableTo,omitempty"`
PlatformWorkloadIdentities map[string]PlatformWorkloadIdentity `json:"platformWorkloadIdentities,omitempty"`
}

// UpgradeableTo stores a single OpenShift version a workload identity cluster can be upgraded to
Expand All @@ -828,29 +828,54 @@ type UpgradeableTo string
type PlatformWorkloadIdentity struct {
MissingFields

OperatorName string `json:"operatorName,omitempty"`
ResourceID string `json:"resourceId,omitempty"`
ClientID string `json:"clientId,omitempty" swagger:"readOnly"`
ObjectID string `json:"objectId,omitempty" swagger:"readOnly"`
// The resource ID of the PlatformWorkloadIdentity resource
ResourceID string `json:"resourceId,omitempty"`

// The ClientID of the PlatformWorkloadIdentity resource
ClientID string `json:"clientId,omitempty" swagger:"readOnly"`

// The ObjectID of the PlatformWorkloadIdentity resource
ObjectID string `json:"objectId,omitempty" swagger:"readOnly"`
}

// ClusterUserAssignedIdentity stores information about a user-assigned managed identity in a predefined format required by Microsoft's Managed Identity team.
type ClusterUserAssignedIdentity struct {
// UserAssignedIdentity stores information about a user-assigned managed identity in a predefined format required by Microsoft's Managed Identity team.
type UserAssignedIdentity struct {
MissingFields

ClientID string `json:"clientId,omitempty"`
PrincipalID string `json:"principalId,omitempty"`
// The ClientID of the UserAssignedIdentity resource
ClientID string `json:"clientId,omitempty" swagger:"readOnly"`

// The PrincipalID of the UserAssignedIdentity resource
PrincipalID string `json:"principalId,omitempty" swagger:"readOnly"`
}

// UserAssignedIdentities stores a mapping from resource IDs of managed identities to their client/principal IDs.
type UserAssignedIdentities map[string]ClusterUserAssignedIdentity
// The ManagedServiceIdentity type.
type ManagedServiceIdentityType string

// ManagedServiceIdentityType constants
const (
ManagedServiceIdentityNone ManagedServiceIdentityType = "None"
ManagedServiceIdentitySystemAssigned ManagedServiceIdentityType = "SystemAssigned"
ManagedServiceIdentityUserAssigned ManagedServiceIdentityType = "UserAssigned"
ManagedServiceIdentitySystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned"
)

// Identity stores information about the cluster MSI(s) in a workload identity cluster.
type Identity struct {
// ManagedServiceIdentity stores information about the cluster MSI(s) in a workload identity cluster.
type ManagedServiceIdentity struct {
MissingFields

Type string `json:"type,omitempty"`
UserAssignedIdentities UserAssignedIdentities `json:"userAssignedIdentities,omitempty"`
IdentityURL string `json:"identityURL,omitempty" mutable:"true"`
TenantID string `json:"tenantId,omitempty" mutable:"true"`
// The type of the ManagedServiceIdentity resource.
Type ManagedServiceIdentityType `json:"type,omitempty"`

// The PrincipalID of the Identity resource.
PrincipalID string `json:"principalId,omitempty" swagger:"readOnly"`

// A map of user assigned identities attached to the cluster, specified in a type required by Microsoft's Managed Identity team.
UserAssignedIdentities map[string]UserAssignedIdentity `json:"userAssignedIdentities,omitempty"`

// The IdentityURL provided by the MSI RP
IdentityURL string `json:"identityURL,omitempty" mutable:"true"`

// The TenantID provided by the MSI RP
TenantID string `json:"tenantId,omitempty" swagger:"readOnly"`
}
Loading
Loading