Skip to content

Release 11.0.0a1 #931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 11, 2019
4 changes: 4 additions & 0 deletions kubernetes/client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def request(self, method, url, query_params=None, headers=None,
if query_params:
url += '?' + urlencode(query_params)
if re.search('json', headers['Content-Type'], re.IGNORECASE):
if headers['Content-Type'] == 'application/json-patch+json':
if not isinstance(body, list):
headers['Content-Type'] = \
'application/strategic-merge-patch+json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this fix needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch is from https://github.com/kubernetes-client/python/blob/master/scripts/rest_client_patch.diff, which is a old hack for supporting strategic merge patch in the generated client.

This commit is needed, because the new code generator changed the generated client, and invalidates the old patch. I re-created the patch so the hack works again.

Filed #951 to track adding a test, which ensures strategic merge patch is always supported.

request_body = None
if body is not None:
request_body = json.dumps(body)
Expand Down
2 changes: 1 addition & 1 deletion scripts/rest_client_patch.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/kubernetes/client/rest.py b/kubernetes/client/rest.py
index 13b16c2f..41c53429 100644
index 0bb15d8..acf7b2b 100644
--- a/kubernetes/client/rest.py
+++ b/kubernetes/client/rest.py
@@ -155,6 +155,10 @@ class RESTClientObject(object):
Expand Down