Skip to content

Commit e8a10b1

Browse files
authored
Merge pull request #1850 from kariya-mitsuru/fix-server-side-apply
Fix DynamicClient.server_side_apply
2 parents 2677e9c + 5529ded commit e8a10b1

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

kubernetes/base/dynamic/test_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import time
1616
import unittest
1717
import uuid
18-
import json
1918

2019
from kubernetes.e2e_test import base
2120
from kubernetes.client import api_client
@@ -527,9 +526,8 @@ def test_server_side_apply_api(self):
527526
'ports': [{'containerPort': 80,
528527
'protocol': 'TCP'}]}]}}
529528

530-
body = json.dumps(pod_manifest).encode()
531529
resp = api.server_side_apply(
532-
name=name, namespace='default', body=body,
530+
namespace='default', body=pod_manifest,
533531
field_manager='kubernetes-unittests', dry_run="All")
534532
self.assertEqual('kubernetes-unittests', resp.metadata.managedFields[0].manager)
535533

kubernetes/client/rest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ def request(self, method, url, query_params=None, headers=None,
157157
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
158158
if query_params:
159159
url += '?' + urlencode(query_params)
160-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
160+
if (re.search('json', headers['Content-Type'], re.IGNORECASE) or
161+
headers['Content-Type'] == 'application/apply-patch+yaml'):
161162
if headers['Content-Type'] == 'application/json-patch+json':
162163
if not isinstance(body, list):
163164
headers['Content-Type'] = \

scripts/rest_client_patch.diff

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ index 65fbe95..e174317 100644
55
@@ -152,6 +152,10 @@ class RESTClientObject(object):
66
if query_params:
77
url += '?' + urlencode(query_params)
8-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
8+
- if re.search('json', headers['Content-Type'], re.IGNORECASE):
9+
+ if (re.search('json', headers['Content-Type'], re.IGNORECASE) or
10+
+ headers['Content-Type'] == 'application/apply-patch+yaml'):
911
+ if headers['Content-Type'] == 'application/json-patch+json':
1012
+ if not isinstance(body, list):
1113
+ headers['Content-Type'] = \

0 commit comments

Comments
 (0)