forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pillar serialization for jinja saltstack#60083
- Loading branch information
Showing
3 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
Tests for the templates utils | ||
""" | ||
import os | ||
|
||
import pytest | ||
|
||
|
||
def test_issue_60083( | ||
salt_call_cli, tmp_path, base_env_state_tree_root_dir, | ||
): | ||
""" | ||
Validate that we can serialize pillars to json in states. | ||
Issue #60083 | ||
""" | ||
target_path = tmp_path / "issue-60083-target.txt" | ||
assert not os.path.exists(target_path) | ||
sls_name = "issue-60083" | ||
sls_contents = """ | ||
{{ pillar["target-path"] }}: | ||
file.managed: | ||
- contents: | | ||
{{ pillar|json }} | ||
""" | ||
sls_tempfile = pytest.helpers.temp_file( | ||
"{}.sls".format(sls_name), sls_contents, base_env_state_tree_root_dir | ||
) | ||
with sls_tempfile: # , issue_50221_ext_pillar_tempfile: | ||
ret = salt_call_cli.run( | ||
"state.apply", sls_name, pillar={"target-path": str(target_path)} | ||
) | ||
assert ret.stdout.find("Jinja error") == -1 | ||
assert ret.json | ||
keys = list(ret.json.keys()) | ||
assert len(keys) == 1 | ||
key = keys[0] | ||
assert ret.json[key]["changes"]["diff"] == "New file" |