Skip to content

Commit

Permalink
Ensure Service tests pass for k8s apply
Browse files Browse the repository at this point in the history
  • Loading branch information
willthames authored and fabianvf committed Mar 11, 2019
1 parent 2625660 commit 6754d37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 2 additions & 5 deletions openshift/dynamic/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def apply(resource, definition):
if patch:
return resource.patch(body=dict_merge(patch, desired_annotation),
name=definition['metadata']['name'],
namespace=definition['metadata']['namespace'])
namespace=definition['metadata']['namespace'],
content_type='application/merge-patch+json')
else:
return actual
else:
Expand Down Expand Up @@ -83,12 +84,8 @@ def get_delta(actual, desired):
actual_value = actual.get(k)
if actual_value is None:
patch[k] = desired_value
elif type(desired_value) != type(actual_value):
patch[k] = desired_value
elif isinstance(desired_value, dict):
p = get_delta(actual_value, desired_value)
if p:
patch[k] = p
elif actual_value != desired_value:
patch[k] = desired_value
return patch
10 changes: 10 additions & 0 deletions test/unit/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
metadata=dict(name="foo"),
spec=dict(ports=[dict(port=8080, name="http")])
),
actual = dict(
kind="Service",
metadata=dict(name="foo"),
spec=dict(ports=[dict(port=8080, protocol='TCP', name="http")])
),
desired = dict(
kind="Service",
metadata=dict(name="foo"),
Expand All @@ -62,6 +67,11 @@
metadata=dict(name="foo"),
spec=dict(ports=[dict(port=8080, name="http")])
),
actual = dict(
kind="Service",
metadata=dict(name="foo"),
spec=dict(ports=[dict(port=8080, protocol='TCP', name="http")])
),
desired = dict(
kind="Service",
metadata=dict(name="foo"),
Expand Down

0 comments on commit 6754d37

Please sign in to comment.