Skip to content

Commit

Permalink
Bug fix - clear ReadOnly fields on PUT or PATCH for 2023-11-22 and 20…
Browse files Browse the repository at this point in the history
…24-08-12-preview APIs (#3538)

* add read only fields to ExternalNoReady

* run ExternalNoReadOnly on put or patch

* clear readonly fields in 2024-08-12-preview
  • Loading branch information
tony-schndr committed May 1, 2024
1 parent 666225b commit bc30095
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/api/v20231122/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,11 @@ func (c openShiftClusterConverter) ExternalNoReadOnly(_oc interface{}) {
if oc.Properties.NetworkProfile.LoadBalancerProfile != nil {
oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = nil
}
oc.SystemData = nil
oc.Properties.ConsoleProfile.URL = ""
oc.Properties.APIServerProfile.URL = ""
oc.Properties.APIServerProfile.IP = ""
for i := range oc.Properties.IngressProfiles {
oc.Properties.IngressProfiles[i].IP = ""
}
}
11 changes: 11 additions & 0 deletions pkg/api/v20240812preview/openshiftcluster_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,15 @@ func (c openShiftClusterConverter) ExternalNoReadOnly(_oc interface{}) {
if oc.Properties.NetworkProfile.LoadBalancerProfile != nil {
oc.Properties.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = nil
}
oc.SystemData = nil
oc.Properties.ConsoleProfile.URL = ""
oc.Properties.APIServerProfile.URL = ""
oc.Properties.APIServerProfile.IP = ""
for i := range oc.Properties.IngressProfiles {
oc.Properties.IngressProfiles[i].IP = ""
}
for i := range oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ClientID = ""
oc.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities[i].ObjectID = ""
}
}
3 changes: 2 additions & 1 deletion pkg/frontend/openshiftcluster_putorpatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
// Patch should be used for updating individual fields of the document.
case http.MethodPatch:
ext = converter.ToExternal(doc.OpenShiftCluster)
converter.ExternalNoReadOnly(ext)
}

converter.ExternalNoReadOnly(ext)

err = json.Unmarshal(body, &ext)
if err != nil {
return nil, api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidRequestContent, "", "The request content was invalid and could not be deserialized: %q.", err)
Expand Down

0 comments on commit bc30095

Please sign in to comment.