Repository: Azure/ARO-RP
Pull request #1343 (2021-02-25 16:01:15)

add missing admin API fields


Patch:
diff --git a/pkg/api/admin/openshiftcluster.go b/pkg/api/admin/openshiftcluster.go
index f775bdea9..296cc3f79 100644
--- a/pkg/api/admin/openshiftcluster.go
+++ b/pkg/api/admin/openshiftcluster.go
@@ -76,7 +76,8 @@ type ConsoleProfile struct {
 
 // ServicePrincipalProfile represents a service principal profile.
 type ServicePrincipalProfile struct {
-	ClientID string `json:"clientId,omitempty"`
+	ClientID   string `json:"clientId,omitempty"`
+	SPObjectID string `json:"spObjectId,omitempty"`
 }
 
 // NetworkProfile represents a network profile.
@@ -135,6 +136,7 @@ type APIServerProfile struct {
 	Visibility Visibility `json:"visibility,omitempty"`
 	URL        string     `json:"url,omitempty"`
 	IP         string     `json:"ip,omitempty"`
+	IntIP      string     `json:"intIp,omitempty"`
 }
 
 // Visibility represents visibility.
diff --git a/pkg/api/admin/openshiftcluster_convert.go b/pkg/api/admin/openshiftcluster_convert.go
index 7b48ca682..df3bfe307 100644
--- a/pkg/api/admin/openshiftcluster_convert.go
+++ b/pkg/api/admin/openshiftcluster_convert.go
@@ -37,7 +37,8 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
 				URL: oc.Properties.ConsoleProfile.URL,
 			},
 			ServicePrincipalProfile: ServicePrincipalProfile{
-				ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
+				ClientID:   oc.Properties.ServicePrincipalProfile.ClientID,
+				SPObjectID: oc.Properties.ServicePrincipalProfile.SPObjectID,
 			},
 			NetworkProfile: NetworkProfile{
 				PodCIDR:           oc.Properties.NetworkProfile.PodCIDR,
@@ -52,6 +53,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
 				Visibility: Visibility(oc.Properties.APIServerProfile.Visibility),
 				URL:        oc.Properties.APIServerProfile.URL,
 				IP:         oc.Properties.APIServerProfile.IP,
+				IntIP:      oc.Properties.APIServerProfile.IntIP,
 			},
 			StorageSuffix: oc.Properties.StorageSuffix,
 		},
@@ -151,6 +153,7 @@ func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShi
 	out.Properties.ClusterProfile.ResourceGroupID = oc.Properties.ClusterProfile.ResourceGroupID
 	out.Properties.ConsoleProfile.URL = oc.Properties.ConsoleProfile.URL
 	out.Properties.ServicePrincipalProfile.ClientID = oc.Properties.ServicePrincipalProfile.ClientID
+	out.Properties.ServicePrincipalProfile.SPObjectID = oc.Properties.ServicePrincipalProfile.SPObjectID
 	out.Properties.NetworkProfile.PodCIDR = oc.Properties.NetworkProfile.PodCIDR
 	out.Properties.NetworkProfile.ServiceCIDR = oc.Properties.NetworkProfile.ServiceCIDR
 	out.Properties.NetworkProfile.PrivateEndpointIP = oc.Properties.NetworkProfile.PrivateEndpointIP
@@ -171,6 +174,7 @@ func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShi
 	out.Properties.APIServerProfile.Visibility = api.Visibility(oc.Properties.APIServerProfile.Visibility)
 	out.Properties.APIServerProfile.URL = oc.Properties.APIServerProfile.URL
 	out.Properties.APIServerProfile.IP = oc.Properties.APIServerProfile.IP
+	out.Properties.APIServerProfile.IntIP = oc.Properties.APIServerProfile.IntIP
 	out.Properties.IngressProfiles = nil
 	if oc.Properties.IngressProfiles != nil {
 		out.Properties.IngressProfiles = make([]api.IngressProfile, len(oc.Properties.IngressProfiles))


Test patch:
diff --git a/pkg/api/admin/openshiftcluster_validatestatic_test.go b/pkg/api/admin/openshiftcluster_validatestatic_test.go
index 09562f5fa..2fdcc1b28 100644
--- a/pkg/api/admin/openshiftcluster_validatestatic_test.go
+++ b/pkg/api/admin/openshiftcluster_validatestatic_test.go
@@ -230,6 +230,20 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
 			modify:  func(oc *OpenShiftCluster) { oc.Properties.APIServerProfile.IP = "2.3.4.5" },
 			wantErr: "400: PropertyChangeNotAllowed: properties.apiserverProfile.ip: Changing property 'properties.apiserverProfile.ip' is not allowed.",
 		},
+		{
+			name: "apiServer intIp change is not allowed",
+			oc: func() *OpenShiftCluster {
+				return &OpenShiftCluster{
+					Properties: OpenShiftClusterProperties{
+						APIServerProfile: APIServerProfile{
+							IntIP: "1.2.3.4",
+						},
+					},
+				}
+			},
+			modify:  func(oc *OpenShiftCluster) { oc.Properties.APIServerProfile.IntIP = "2.3.4.5" },
+			wantErr: "400: PropertyChangeNotAllowed: properties.apiserverProfile.intIp: Changing property 'properties.apiserverProfile.intIp' is not allowed.",
+		},
 		{
 			name: "ingress private change is not allowed",
 			oc: func() *OpenShiftCluster {
@@ -280,6 +294,20 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
 			modify:  func(oc *OpenShiftCluster) { oc.Properties.ServicePrincipalProfile.ClientID = uuid.NewV4().String() },
 			wantErr: "400: PropertyChangeNotAllowed: properties.servicePrincipalProfile.clientId: Changing property 'properties.servicePrincipalProfile.clientId' is not allowed.",
 		},
+		{
+			name: "spObjectId change is not allowed",
+			oc: func() *OpenShiftCluster {
+				return &OpenShiftCluster{
+					Properties: OpenShiftClusterProperties{
+						ServicePrincipalProfile: ServicePrincipalProfile{
+							SPObjectID: "clientId",
+						},
+					},
+				}
+			},
+			modify:  func(oc *OpenShiftCluster) { oc.Properties.ServicePrincipalProfile.SPObjectID = uuid.NewV4().String() },
+			wantErr: "400: PropertyChangeNotAllowed: properties.servicePrincipalProfile.spObjectId: Changing property 'properties.servicePrincipalProfile.spObjectId' is not allowed.",
+		},
 		{
 			name: "podCidr change is not allowed",
 			oc: func() *OpenShiftCluster {