diff --git a/kubernetes/base/dynamic/test_client.py b/kubernetes/base/dynamic/test_client.py index f0ca26b549..1c9fa6d94c 100644 --- a/kubernetes/base/dynamic/test_client.py +++ b/kubernetes/base/dynamic/test_client.py @@ -15,7 +15,6 @@ import time import unittest import uuid -import json from kubernetes.e2e_test import base from kubernetes.client import api_client @@ -527,9 +526,8 @@ def test_server_side_apply_api(self): 'ports': [{'containerPort': 80, 'protocol': 'TCP'}]}]}} - body = json.dumps(pod_manifest).encode() resp = api.server_side_apply( - name=name, namespace='default', body=body, + namespace='default', body=pod_manifest, field_manager='kubernetes-unittests', dry_run="All") self.assertEqual('kubernetes-unittests', resp.metadata.managedFields[0].manager) diff --git a/kubernetes/client/rest.py b/kubernetes/client/rest.py index f6e476c271..3fc0eb92a3 100644 --- a/kubernetes/client/rest.py +++ b/kubernetes/client/rest.py @@ -157,7 +157,8 @@ def request(self, method, url, query_params=None, headers=None, if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: url += '?' + urlencode(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): + if (re.search('json', headers['Content-Type'], re.IGNORECASE) or + headers['Content-Type'] == 'application/apply-patch+yaml'): if headers['Content-Type'] == 'application/json-patch+json': if not isinstance(body, list): headers['Content-Type'] = \ diff --git a/scripts/rest_client_patch.diff b/scripts/rest_client_patch.diff index b47e6e0a78..2a6c0bca93 100644 --- a/scripts/rest_client_patch.diff +++ b/scripts/rest_client_patch.diff @@ -5,7 +5,9 @@ index 65fbe95..e174317 100644 @@ -152,6 +152,10 @@ class RESTClientObject(object): if query_params: url += '?' + urlencode(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): +- if re.search('json', headers['Content-Type'], re.IGNORECASE): ++ if (re.search('json', headers['Content-Type'], re.IGNORECASE) or ++ headers['Content-Type'] == 'application/apply-patch+yaml'): + if headers['Content-Type'] == 'application/json-patch+json': + if not isinstance(body, list): + headers['Content-Type'] = \