Add handling for no -e param in CIP

Container image prepare will fail with a traceback
if the -e param is not provided. Accordingly, this
change adds a default None value and handling for
cases where the -e param is not provided.

Resolves: rhbz#2158380
Change-Id: I81c157d499eda8cb8117aea322518bd2ce819f40
(cherry picked from commit fd7976906f)
This commit is contained in:
Brendan Shephard 2023-01-08 18:02:31 +10:00 committed by Takashi Kajinami
parent b598c6085d
commit 573a8cadf8
2 changed files with 24 additions and 1 deletions

View File

@ -508,6 +508,28 @@ class TestTripleoImagePrepareDefault(TestPluginV1):
}
self.assertEqual(expected, yaml.safe_load(result))
def test_prepare_default_no_env(self):
arglist = []
verifylist = []
self.app.command_options = [
'tripleo', 'container', 'image', 'prepare'
] + arglist
self.cmd.app.stdout = StringIO()
cmd = container_image.TripleOImagePrepareDefault(self.app, None)
parsed_args = self.check_parser(cmd, arglist, verifylist)
cmd.take_action(parsed_args)
result = self.app.stdout.getvalue()
expected_param = kolla_builder.CONTAINER_IMAGE_PREPARE_PARAM
expected = {
'parameter_defaults': {
'ContainerImagePrepare': expected_param
}
}
self.assertEqual(expected, yaml.safe_load(result))
def test_prepare_default_local_registry(self):
temp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, temp)

View File

@ -571,7 +571,8 @@ class TripleOImagePrepare(command.Command):
env_dirs = [os.path.abspath(x)
for x in parsed_args.environment_directories]
env_files = [os.path.abspath(x)
for x in parsed_args.environment_files]
for x in (parsed_args.environment_files or [])]
extra_vars = {
"roles_file": role_file,
"environment_directories": env_dirs,