summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFeanil Patel <feanil@edx.org>2015-05-08 10:12:36 -0400
committerFeanil Patel <feanil@edx.org>2015-08-19 18:35:07 -0400
commit892e230514090dc9221ee01d289c3532aa6ef260 (patch)
treed8c54f951c4ec82aeca131999eb7ddb9621d324d /test
parent22a69e249875ca984d88679d582c1d1100f6e1f1 (diff)
downloadansible-892e230514090dc9221ee01d289c3532aa6ef260.tar.gz
Don't convert nulls to strings.
This change is similar to https://github.com/ansible/ansible/pull/10465 It extends the logic there to also support none types. Right now if you have a '!!null' in yaml, and that var gets passed around, it will get converted to a string. eg. defaults/main.yml ``` ENABLE_AWESOME_FEATURE: !!null # Yaml Null OTHER_CONFIG: secret1: "so_secret" secret2: "even_more_secret" CONFIG: hostname: "some_hostname" features: awesame_feature: "{{ ENABLE_AWESOME_FEATURE}}" secrets: "{{ OTHER_CONFIG }}" ``` If you output `CONFIG` to json or yaml, the feature flag would get represented in the output as a string instead of as a null, but secrets would get represented as a dictionary. This is a mis-match in behaviour where some "types" are retained and others are not. This change should fix the issue. I also updated the template test to test for this and made the changes to v2. Added a changelog entry specifically for the change from empty string to null as the default. Made the null representation configurable. It still defaults to the python NoneType but can be overriden to be an emptystring by updating the DEFAULT_NULL_REPRESENTATION config.
Diffstat (limited to 'test')
-rw-r--r--test/integration/roles/test_template/files/foo.txt1
-rw-r--r--test/integration/roles/test_template/vars/main.yml2
2 files changed, 3 insertions, 0 deletions
diff --git a/test/integration/roles/test_template/files/foo.txt b/test/integration/roles/test_template/files/foo.txt
index edd704da04..58af3be81b 100644
--- a/test/integration/roles/test_template/files/foo.txt
+++ b/test/integration/roles/test_template/files/foo.txt
@@ -3,6 +3,7 @@ templated_var_loaded
{
"bool": true,
"multi_part": "1Foo",
+ "null_type": null,
"number": 5,
"string_num": "5"
}
diff --git a/test/integration/roles/test_template/vars/main.yml b/test/integration/roles/test_template/vars/main.yml
index b79f95e6cf..16776cb7e8 100644
--- a/test/integration/roles/test_template/vars/main.yml
+++ b/test/integration/roles/test_template/vars/main.yml
@@ -5,10 +5,12 @@ string_num: "5"
bool_var: true
part_1: 1
part_2: "Foo"
+null_type: !!null
templated_dict:
number: "{{ number_var }}"
string_num: "{{ string_num }}"
+ null_type: "{{ null_type }}"
bool: "{{ bool_var }}"
multi_part: "{{ part_1 }}{{ part_2 }}"