diff --git a/kubernetes/client/rest.py b/kubernetes/client/rest.py index 5716565df6..9889b1295a 100644 --- a/kubernetes/client/rest.py +++ b/kubernetes/client/rest.py @@ -152,6 +152,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' request_body = None if body is not None: request_body = json.dumps(body) diff --git a/scripts/rest_client_patch.diff b/scripts/rest_client_patch.diff new file mode 100644 index 0000000000..b47e6e0a78 --- /dev/null +++ b/scripts/rest_client_patch.diff @@ -0,0 +1,15 @@ +diff --git a/kubernetes/client/rest.py b/kubernetes/client/rest.py +index 65fbe95..e174317 100644 +--- a/kubernetes/client/rest.py ++++ b/kubernetes/client/rest.py +@@ -152,6 +152,10 @@ class RESTClientObject(object): + 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' + request_body = None + if body is not None: + request_body = json.dumps(body) diff --git a/scripts/update-client.sh b/scripts/update-client.sh index 6e02f50192..118d95b221 100755 --- a/scripts/update-client.sh +++ b/scripts/update-client.sh @@ -65,4 +65,10 @@ sed -i'' "s/^CLIENT_VERSION = .*/CLIENT_VERSION = \\\"${CLIENT_VERSION}\\\"/" "$ sed -i'' "s/^__version__ = .*/__version__ = \\\"${CLIENT_VERSION}\\\"/" "${CLIENT_ROOT}/__init__.py" sed -i'' "s/^PACKAGE_NAME = .*/PACKAGE_NAME = \\\"${PACKAGE_NAME}\\\"/" "${SCRIPT_ROOT}/../setup.py" sed -i'' "s,^DEVELOPMENT_STATUS = .*,DEVELOPMENT_STATUS = \\\"${DEVELOPMENT_STATUS}\\\"," "${SCRIPT_ROOT}/../setup.py" + +# This is a terrible hack: +# first, this must be in gen repo not here +# second, this should be ported to swagger-codegen +echo ">>> patching client..." +git apply "${SCRIPT_ROOT}/rest_client_patch.diff" echo ">>> Done."