From 8644b0b236a75cbd3126712e198b747d0789333f Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 9 Apr 2024 14:26:38 -0400 Subject: [PATCH] frontend: Fix logic in ArmResourceCreateOrUpdate An updating PUT request must be a complete resource specification. The old version of the resource only comes into play when applying idempotency to read-only or create-only fields in an update request, but this has not yet been implemented. --- frontend/frontend.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/frontend.go b/frontend/frontend.go index d96d751a6..feec801fa 100644 --- a/frontend/frontend.go +++ b/frontend/frontend.go @@ -213,20 +213,19 @@ func (f *Frontend) ArmResourceCreateOrUpdate(writer http.ResponseWriter, request // URL path is already lowercased by middleware. resourceID := request.URL.Path - cluster, updating := f.cache.GetCluster(resourceID) - if !updating { - cluster = api.NewDefaultHCPOpenShiftCluster() - } + _, updating := f.cache.GetCluster(resourceID) + newCluster := api.NewDefaultHCPOpenShiftCluster() body := ctx.Value(ContextKeyBody).([]byte) - err := versionedInterface.UnmarshalHCPOpenShiftCluster(body, cluster, request.Method, updating) + err := versionedInterface.UnmarshalHCPOpenShiftCluster(body, newCluster, request.Method, updating) if err != nil { f.logger.Error(err.Error()) arm.WriteUnmarshalError(err, writer) return } - f.cache.SetCluster(resourceID, cluster) + // FIXME Enforce visibility tags on newCluster. + f.cache.SetCluster(resourceID, newCluster) - versionedResource := versionedInterface.NewHCPOpenShiftCluster(cluster) + versionedResource := versionedInterface.NewHCPOpenShiftCluster(newCluster) resp, err := json.Marshal(versionedResource) if err != nil { f.logger.Error(err.Error())