mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 06:29:31 -02:30
Restore ability of parsing extra_vars string for provisioning callback.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# Copyright (c) 2017 Ansible, Inc.
|
# Copyright (c) 2017 Ansible, Inc.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
import pytest
|
||||||
|
|
||||||
from awx.conf.models import Setting
|
from awx.conf.models import Setting
|
||||||
from awx.main.utils import common
|
from awx.main.utils import common
|
||||||
@@ -52,3 +53,13 @@ def test_encrypt_field_with_ask():
|
|||||||
def test_encrypt_field_with_empty_value():
|
def test_encrypt_field_with_empty_value():
|
||||||
encrypted = common.encrypt_field(Setting(value=None), 'value')
|
encrypted = common.encrypt_field(Setting(value=None), 'value')
|
||||||
assert encrypted is None
|
assert encrypted is None
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('input_, output', [
|
||||||
|
({"foo": "bar"}, {"foo": "bar"}),
|
||||||
|
('{"foo": "bar"}', {"foo": "bar"}),
|
||||||
|
('---\nfoo: bar', {"foo": "bar"}),
|
||||||
|
(4399, {}),
|
||||||
|
])
|
||||||
|
def test_parse_yaml_or_json(input_, output):
|
||||||
|
assert common.parse_yaml_or_json(input_) == output
|
||||||
|
|||||||
@@ -863,8 +863,8 @@ class OutputEventFilter(object):
|
|||||||
|
|
||||||
def callback_filter_out_ansible_extra_vars(extra_vars):
|
def callback_filter_out_ansible_extra_vars(extra_vars):
|
||||||
extra_vars_redacted = {}
|
extra_vars_redacted = {}
|
||||||
|
extra_vars = parse_yaml_or_json(extra_vars)
|
||||||
for key, value in extra_vars.iteritems():
|
for key, value in extra_vars.iteritems():
|
||||||
if not key.startswith('ansible_'):
|
if not key.startswith('ansible_'):
|
||||||
extra_vars_redacted[key] = value
|
extra_vars_redacted[key] = value
|
||||||
return extra_vars_redacted
|
return extra_vars_redacted
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user