Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
chang(render): overriden vars split to not break values with = signal
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiego committed Oct 16, 2020
1 parent a888a6c commit 7c1381b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion kuberender/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def render(filename):

def parse_overriden_vars(overriden_vars):
def parse_statement(override_statement):
key, value = override_statement.split('=')
equal_idx = override_statement.index('=')
key = override_statement[:equal_idx]
value = override_statement[equal_idx + 1:]
obj = {}
dpath.util.new(obj, key, value, separator='.')
return obj
Expand Down
1 change: 1 addition & 0 deletions tests/resources/test-basic-manifest/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
containers:
- name: {{NAME}}
image: "{{image.repository}}:{{image.tag}}"
test: "{{ other.test }}"
imagePullPolicy: {{ image.pullPolicy }}
resources:
limits:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_kuberender.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ def test_overriding_vars(self):

manifest = self._load_template_manifest(self._partial_render()(
context_files=['base.yaml'],
overriden_vars=['image.tag=3.0.7', 'image.repository=bitnami/redis']
overriden_vars=['image.tag=3.0.7', 'image.repository=bitnami/redis', 'other.key=test=']
))

# Image and tag were overriden but pullPolicy (which is a sibling) wasn't modified
assert 'bitnami/redis:3.0.7' == get_value(manifest, 'spec/template/spec/containers/0/image')
assert 'test=' == get_value(manifest, 'spec/template/spec/containers/0/test')
assert 'Always' == get_value(manifest, 'spec/template/spec/containers/0/imagePullPolicy')


Expand Down

0 comments on commit 7c1381b

Please sign in to comment.