mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
Merge pull request #8136 from neoaggelos/awxkit-import-yaml-loader
Support `!import` and `!include` in `awx import -f yaml` command Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -2,7 +2,7 @@ import yaml
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from awxkit import api, config
|
from awxkit import api, config, yaml_file
|
||||||
from awxkit.exceptions import ImportExportError
|
from awxkit.exceptions import ImportExportError
|
||||||
from awxkit.utils import to_str
|
from awxkit.utils import to_str
|
||||||
from awxkit.api.pages import Page
|
from awxkit.api.pages import Page
|
||||||
@@ -140,7 +140,7 @@ class Import(CustomCommand):
|
|||||||
if fmt == 'json':
|
if fmt == 'json':
|
||||||
data = json.load(client.stdin)
|
data = json.load(client.stdin)
|
||||||
elif fmt == 'yaml':
|
elif fmt == 'yaml':
|
||||||
data = yaml.safe_load(client.stdin)
|
data = yaml.load(client.stdin, Loader=yaml_file.Loader)
|
||||||
else:
|
else:
|
||||||
raise ImportExportError("Unsupported format for Import: " + fmt)
|
raise ImportExportError("Unsupported format for Import: " + fmt)
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ def test_yaml_import():
|
|||||||
- name: Workflow1
|
- name: Workflow1
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
yaml_fd.name = 'file.yaml'
|
||||||
cli = CLI(stdin=yaml_fd)
|
cli = CLI(stdin=yaml_fd)
|
||||||
cli.parse_args(['--conf.format', 'yaml'])
|
cli.parse_args(['--conf.format', 'yaml'])
|
||||||
cli.v2 = MockedV2()
|
cli.v2 = MockedV2()
|
||||||
|
|||||||
Reference in New Issue
Block a user