From 510f8898364a82b5ba0522b80b9134b6f630a70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Wiesm=C3=BCller?= Date: Mon, 13 May 2019 18:31:25 +0200 Subject: [PATCH 1/3] add documentation on how to strip managedFields --- .../en/docs/reference/using-api/api-concepts.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/en/docs/reference/using-api/api-concepts.md b/content/en/docs/reference/using-api/api-concepts.md index b9aaada90cca7..0954c2708a3d5 100644 --- a/content/en/docs/reference/using-api/api-concepts.md +++ b/content/en/docs/reference/using-api/api-concepts.md @@ -430,3 +430,17 @@ Another difference is that an applier using Client Side Apply is unable to chang ### Custom Resources Server Side Apply currently treats all custom resources as unstructured data. All keys are treated the same as struct fields, and all lists are considered atomic. In the future, it will use the validation field in Custom Resource Definitions to allow Custom Resource authors to define how to how to merge their own objects. + +### Clearing ManagedFields + +It is possible to strip all managedFields from an object by overwriting them using `MergePatch`. +This can be done via a `POST` request with content type `application/merge-patch+json` on the targeted object and the following data: + +```json +POST /api/v1/namespaces/default/configmaps/example-cm +Content-Type: application/json +Accept: application/json +Data: {"metadata":{"managedFields": [{}]}} +``` + +This will overwrite the managedFields with a list containing a single empty entry that then results in the managedFields being stripped entirely from the object. From aa49c932c002cd4b96fdeef6aaf8543f7641d857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Wiesm=C3=BCller?= Date: Tue, 4 Jun 2019 16:09:53 +0200 Subject: [PATCH 2/3] update and fix clearing managed fields documentation --- .../en/docs/reference/using-api/api-concepts.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/content/en/docs/reference/using-api/api-concepts.md b/content/en/docs/reference/using-api/api-concepts.md index 0954c2708a3d5..5fee80f00885b 100644 --- a/content/en/docs/reference/using-api/api-concepts.md +++ b/content/en/docs/reference/using-api/api-concepts.md @@ -433,14 +433,21 @@ Server Side Apply currently treats all custom resources as unstructured data. Al ### Clearing ManagedFields -It is possible to strip all managedFields from an object by overwriting them using `MergePatch`. -This can be done via a `POST` request with content type `application/merge-patch+json` on the targeted object and the following data: +It is possible to strip all managedFields from an object by overwriting them using `MergePatch` or `JSONPatch`. +This can be done via a `PATCH` request with the respective content type on the targeted object. Two examples are: ```json -POST /api/v1/namespaces/default/configmaps/example-cm -Content-Type: application/json +PATCH /api/v1/namespaces/default/configmaps/example-cm +Content-Type: application/merge-patch+json Accept: application/json Data: {"metadata":{"managedFields": [{}]}} ``` +```json +PATCH /api/v1/namespaces/default/configmaps/example-cm +Content-Type: application/json-patch+json +Accept: application/json +Data: [{"op": "replace", "path": "/metadata/managedFields", "value": [{}]}] +``` + This will overwrite the managedFields with a list containing a single empty entry that then results in the managedFields being stripped entirely from the object. From f6601f0dac16a10e6e6d9a683f3d18d3f89b804c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Wiesm=C3=BCller?= Date: Tue, 11 Jun 2019 20:12:55 +0200 Subject: [PATCH 3/3] add more details on managedFields reset paths --- content/en/docs/reference/using-api/api-concepts.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/en/docs/reference/using-api/api-concepts.md b/content/en/docs/reference/using-api/api-concepts.md index 5fee80f00885b..cbc451f4d4ded 100644 --- a/content/en/docs/reference/using-api/api-concepts.md +++ b/content/en/docs/reference/using-api/api-concepts.md @@ -433,8 +433,8 @@ Server Side Apply currently treats all custom resources as unstructured data. Al ### Clearing ManagedFields -It is possible to strip all managedFields from an object by overwriting them using `MergePatch` or `JSONPatch`. -This can be done via a `PATCH` request with the respective content type on the targeted object. Two examples are: +It is possible to strip all managedFields from an object by overwriting them using `MergePatch`, `StrategicMergePatch`, `JSONPatch` or `Update`, so every non-apply operation. +This can be done by overwriting the managedFields field with an empty entry. Two examples are: ```json PATCH /api/v1/namespaces/default/configmaps/example-cm @@ -450,4 +450,4 @@ Accept: application/json Data: [{"op": "replace", "path": "/metadata/managedFields", "value": [{}]}] ``` -This will overwrite the managedFields with a list containing a single empty entry that then results in the managedFields being stripped entirely from the object. +This will overwrite the managedFields with a list containing a single empty entry that then results in the managedFields being stripped entirely from the object. Note that just setting the managedFields to an empty list will not reset the field. This is on purpose, so managedFields never get stripped by clients not aware of the field.