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
19 lines (18 loc) · 964 Bytes
/
Copy pathrest_client_patch.diff
File metadata and controls
19 lines (18 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/kubernetes/client/rest.py b/kubernetes/client/rest.py
--- a/kubernetes/client/rest.py
+++ b/kubernetes/client/rest.py
@@ -239,6 +239,15 @@
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
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 contenttype_matches(content_type, 'application', 'json')