forked from kubernetes-client/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrest_client_patch.diff
More file actions
17 lines (17 loc) · 903 Bytes
/
Copy pathrest_client_patch.diff
File metadata and controls
17 lines (17 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/kubernetes/client/rest.py b/kubernetes/client/rest.py
--- a/kubernetes/client/rest.py
+++ b/kubernetes/client/rest.py
@@ -223,4 +223,13 @@ class RESTClientObject:
content_type = headers.get('Content-Type')
+ # JSON Patch is a list of operations; object patches for built-in
+ # APIs use strategic merge:
+ # https://kubernetes.io/docs/reference/using-api/api-concepts/#updates-to-existing-resources
+ if (
+ content_type == 'application/json-patch+json'
+ and not isinstance(body, list)
+ ):
+ headers['Content-Type'] = content_type = \
+ 'application/strategic-merge-patch+json'
is_json = (
not content_type
or re.search('json', content_type, re.IGNORECASE)