From 9918b2581c4a75fdd0a95ce6e339b9a221a4c0b9 Mon Sep 17 00:00:00 2001 From: Aggelos Kolaitis Date: Sun, 13 Sep 2020 17:01:12 +0300 Subject: [PATCH 1/2] Support `!import` and `!include` in `awx import -f yaml` command --- awxkit/awxkit/cli/resource.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awxkit/awxkit/cli/resource.py b/awxkit/awxkit/cli/resource.py index 8e30accad2..13419357d2 100644 --- a/awxkit/awxkit/cli/resource.py +++ b/awxkit/awxkit/cli/resource.py @@ -2,7 +2,7 @@ import yaml import json import os -from awxkit import api, config +from awxkit import api, config, yaml_file from awxkit.exceptions import ImportExportError from awxkit.utils import to_str from awxkit.api.pages import Page @@ -140,7 +140,7 @@ class Import(CustomCommand): if fmt == 'json': data = json.load(client.stdin) elif fmt == 'yaml': - data = yaml.safe_load(client.stdin) + data = yaml.load(client.stdin, Loader=yaml_file.Loader) else: raise ImportExportError("Unsupported format for Import: " + fmt) From b8cf644959d43911fd10d1cda6253df08341e78f Mon Sep 17 00:00:00 2001 From: Aggelos Kolaitis Date: Sun, 13 Sep 2020 17:41:53 +0300 Subject: [PATCH 2/2] Add `name` to StringIO object to fix failing test --- awxkit/test/cli/test_format.py | 1 + 1 file changed, 1 insertion(+) diff --git a/awxkit/test/cli/test_format.py b/awxkit/test/cli/test_format.py index 5ab6e55d6c..7327f91518 100644 --- a/awxkit/test/cli/test_format.py +++ b/awxkit/test/cli/test_format.py @@ -63,6 +63,7 @@ def test_yaml_import(): - name: Workflow1 """ ) + yaml_fd.name = 'file.yaml' cli = CLI(stdin=yaml_fd) cli.parse_args(['--conf.format', 'yaml']) cli.v2 = MockedV2()