diff --git a/UPGRADE.md b/UPGRADE.md index 671b3354b620..47fa21d8da6c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,6 +8,10 @@ does not have any particular instructions. ## Upgrade to `2.10.x` +### API Server + +A successful PUT request without any warnings will now set "content-type: application/json" header and return empty json. + ### MeshLoadBalancingStrategy #### Deprecation of `hashPolicies.type: SourceIP` and `maglev.type: SourceIP` diff --git a/pkg/api-server/resource_endpoints.go b/pkg/api-server/resource_endpoints.go index 3989d8c19940..fa57ff126b30 100644 --- a/pkg/api-server/resource_endpoints.go +++ b/pkg/api-server/resource_endpoints.go @@ -419,12 +419,9 @@ func (r *resourceEndpoints) createResource( return } - if warnings := model.Deprecations(res); len(warnings) > 0 { - if err := response.WriteHeaderAndJson(201, api_server_types.CreateOrUpdateSuccessResponse{Warnings: warnings}, "application/json"); err != nil { - log.Error(err, "Could not write the response") - } - } else { - response.WriteHeader(201) + resp := api_server_types.CreateOrUpdateSuccessResponse{Warnings: model.Deprecations(res)} + if err := response.WriteHeaderAndJson(http.StatusCreated, resp, "application/json"); err != nil { + log.Error(err, "Could not write the response") } } @@ -471,12 +468,9 @@ func (r *resourceEndpoints) updateResource( return } - if warnings := model.Deprecations(currentRes); len(warnings) > 0 { - if err := response.WriteHeaderAndJson(200, api_server_types.CreateOrUpdateSuccessResponse{Warnings: warnings}, "application/json"); err != nil { - log.Error(err, "Could not write the response") - } - } else { - response.WriteHeader(200) + resp := api_server_types.CreateOrUpdateSuccessResponse{Warnings: model.Deprecations(currentRes)} + if err := response.WriteHeaderAndJson(http.StatusOK, resp, "application/json"); err != nil { + log.Error(err, "Could not write the response") } } diff --git a/pkg/api-server/testdata/resources/crud/put_circuitbreaker_00.golden.json b/pkg/api-server/testdata/resources/crud/put_circuitbreaker_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_circuitbreaker_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_dataplanes_00.golden.json b/pkg/api-server/testdata/resources/crud/put_dataplanes_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_dataplanes_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_faultinjection_00.golden.json b/pkg/api-server/testdata/resources/crud/put_faultinjection_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_faultinjection_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_globalsecret_00.golden.json b/pkg/api-server/testdata/resources/crud/put_globalsecret_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_globalsecret_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_healthcheck_00.golden.json b/pkg/api-server/testdata/resources/crud/put_healthcheck_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_healthcheck_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_meshes_02.golden.json b/pkg/api-server/testdata/resources/crud/put_meshes_02.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_meshes_02.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_meshes_03.golden.json b/pkg/api-server/testdata/resources/crud/put_meshes_03.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_meshes_03.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_meshservice_00.golden.json b/pkg/api-server/testdata/resources/crud/put_meshservice_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_meshservice_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_secret_00.golden.json b/pkg/api-server/testdata/resources/crud/put_secret_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_secret_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_trafficroute_00.golden.json b/pkg/api-server/testdata/resources/crud/put_trafficroute_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_trafficroute_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_traffictrace_00.golden.json b/pkg/api-server/testdata/resources/crud/put_traffictrace_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_traffictrace_00.golden.json @@ -0,0 +1 @@ +{} diff --git a/pkg/api-server/testdata/resources/crud/put_update_dataplanes_00.golden.json b/pkg/api-server/testdata/resources/crud/put_update_dataplanes_00.golden.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/pkg/api-server/testdata/resources/crud/put_update_dataplanes_00.golden.json @@ -0,0 +1 @@ +{}