Skip to content

Commit

Permalink
Fix AdminAPI representation of PreconfiguredNSG status (#3933)
Browse files Browse the repository at this point in the history
* Fix spelling of preconfiguredNSG JSON tag

* Copy PreconfiguredNSG property during internal->admin conversion

* Fix nil pointer dereference when converting workload identity cluster doc to adminapi representation

* Update admin openshiftcluster_putorpatch tests to expect property for PreconfiguredNSG
  • Loading branch information
tsatam authored Nov 1, 2024
1 parent 8a2f3dd commit 9858073
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pkg/api/admin/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ type NetworkProfile struct {
APIServerPrivateEndpointIP string `json:"privateEndpointIp,omitempty"`
GatewayPrivateEndpointIP string `json:"gatewayPrivateEndpointIp,omitempty"`
GatewayPrivateLinkID string `json:"gatewayPrivateLinkId,omitempty"`
PreconfiguredNSG PreconfiguredNSG `json:"preconfigureNSG,omitempty"`
PreconfiguredNSG PreconfiguredNSG `json:"preconfiguredNSG,omitempty"`
LoadBalancerProfile *LoadBalancerProfile `json:"loadBalancerProfile,omitempty"`
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/admin/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
APIServerPrivateEndpointIP: oc.Properties.NetworkProfile.APIServerPrivateEndpointIP,
GatewayPrivateEndpointIP: oc.Properties.NetworkProfile.GatewayPrivateEndpointIP,
GatewayPrivateLinkID: oc.Properties.NetworkProfile.GatewayPrivateLinkID,
PreconfiguredNSG: PreconfiguredNSG(oc.Properties.NetworkProfile.PreconfiguredNSG),
},
MasterProfile: MasterProfile{
VMSize: VMSize(oc.Properties.MasterProfile.VMSize),
Expand Down Expand Up @@ -178,6 +179,7 @@ func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfac
}

if oc.Identity != nil {
out.Identity = &ManagedServiceIdentity{}
out.Identity.Type = ManagedServiceIdentityType(oc.Identity.Type)
out.Identity.UserAssignedIdentities = make(map[string]UserAssignedIdentity, len(oc.Identity.UserAssignedIdentities))
for k := range oc.Identity.UserAssignedIdentities {
Expand Down
51 changes: 34 additions & 17 deletions pkg/frontend/openshiftcluster_putorpatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: admin.MaintenanceTaskEverything,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -245,7 +246,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
LastProvisioningState: admin.ProvisioningStateSucceeded,
MaintenanceTask: admin.MaintenanceTaskOperator,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -343,7 +345,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
LastProvisioningState: admin.ProvisioningStateSucceeded,
MaintenanceTask: admin.MaintenanceTaskEverything,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -442,7 +445,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: admin.MaintenanceTaskOperator,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -551,7 +555,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
LastProvisioningState: admin.ProvisioningStateSucceeded,
MaintenanceTask: admin.MaintenanceTaskOperator,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -654,7 +659,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: admin.MaintenanceTaskOperator,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -835,7 +841,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: "",
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -935,7 +942,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: "",
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1034,7 +1042,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: admin.MaintenanceTaskEverything,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1134,7 +1143,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: "",
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1234,7 +1244,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: "",
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1332,7 +1343,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
},
MaintenanceTask: admin.MaintenanceTaskEverything,
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1433,7 +1445,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
FipsValidatedModules: admin.FipsValidatedModulesDisabled,
},
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1535,7 +1548,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
FipsValidatedModules: admin.FipsValidatedModulesDisabled,
},
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1637,7 +1651,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
FipsValidatedModules: admin.FipsValidatedModulesDisabled,
},
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1739,7 +1754,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
FipsValidatedModules: admin.FipsValidatedModulesDisabled,
},
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down Expand Up @@ -1842,7 +1858,8 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
FipsValidatedModules: admin.FipsValidatedModulesDisabled,
},
NetworkProfile: admin.NetworkProfile{
OutboundType: admin.OutboundTypeLoadbalancer,
OutboundType: admin.OutboundTypeLoadbalancer,
PreconfiguredNSG: admin.PreconfiguredNSGDisabled,
LoadBalancerProfile: &admin.LoadBalancerProfile{
ManagedOutboundIPs: &admin.ManagedOutboundIPs{
Count: 1,
Expand Down

0 comments on commit 9858073

Please sign in to comment.