Fix tcib build
The tcib build process assumes that all the container configs exist in a 'tcib' folder as defined via --config-path. This change documents this requirement and additionally we've hard coded 'container-images' in the image config to exclude this folder however if you define a custom --config-path, this fails. This change removes the hard coded 'container-images' while documenting the 'tcib' requirement. Change-Id: Iad987da5bedc30da7118a3aec5dbe96cd8d71d1e Closes-Bug: #1897616
This commit is contained in:
parent
04e9966b7f
commit
fe7380ddff
|
@ -208,6 +208,15 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
|||
|
||||
self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
def test_image_build_config_dir(self):
|
||||
arglist = ["--config-file", "config.yaml", "--config-path", "/foo"]
|
||||
verifylist = [("config_file", "config.yaml"), ("config_path", "/foo")]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self._take_action(parsed_args=parsed_args)
|
||||
self.assertEqual(self.cmd.tcib_config_path, '/foo/tcib')
|
||||
|
||||
def test_image_build_failure_no_config_dir(self):
|
||||
arglist = ["--config-path", "not-a-path"]
|
||||
verifylist = [
|
||||
|
@ -220,6 +229,28 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
|||
mock_isfile.return_value = True
|
||||
self.assertRaises(IOError, self.cmd.take_action, parsed_args)
|
||||
|
||||
def test_process_images(self):
|
||||
rtn_value = {'yay': 'values'}
|
||||
arglist = ["--config-path", "foobar/"]
|
||||
verifylist = [
|
||||
("config_path", "foobar/"),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
expected_images = ['foo', 'foobar']
|
||||
image_configs = {}
|
||||
self.cmd.tcib_config_path = '/foo/tcib'
|
||||
with mock.patch("tripleoclient.v2.tripleo_container_image.Build"
|
||||
".find_image", autospec=True) as mock_find_image:
|
||||
|
||||
mock_find_image.return_value = rtn_value
|
||||
cfgs = self.cmd.process_images(expected_images, parsed_args,
|
||||
image_configs)
|
||||
mock_find_image.assert_called_once_with(self.cmd, 'foo',
|
||||
'/foo/tcib', 'ubi8')
|
||||
self.assertEqual(cfgs, {'foo': rtn_value})
|
||||
|
||||
|
||||
class TestContainerImagesHotfix(deploy_fakes.TestDeployOvercloud):
|
||||
def setUp(self):
|
||||
|
|
|
@ -98,8 +98,9 @@ class Build(command.Command):
|
|||
default=BASE_PATH,
|
||||
help=_(
|
||||
"Base configuration path. This is the base path for all "
|
||||
"container-image files. If this option is set, the "
|
||||
"default path for <config-file> will be modified. "
|
||||
"container-image files. The defined containers must reside "
|
||||
"within a 'tcib' folder that is in this path. If this option "
|
||||
"is set, the default path for <config-file> will be modified. "
|
||||
"(default: %(default)s)"
|
||||
),
|
||||
)
|
||||
|
@ -373,8 +374,10 @@ class Build(command.Command):
|
|||
"""
|
||||
|
||||
image_configs = collections.OrderedDict()
|
||||
config_path_base = os.path.basename(
|
||||
os.path.abspath(parsed_args.config_path))
|
||||
for image in expected_images:
|
||||
if image != "container-images" and image not in image_configs:
|
||||
if (image != config_path_base and image not in image_configs):
|
||||
self.log.debug("processing image configs".format(image))
|
||||
image_config = self.find_image(
|
||||
image,
|
||||
|
@ -407,6 +410,7 @@ class Build(command.Command):
|
|||
self.tcib_config_path = os.path.join(
|
||||
self.config_path, DEFAULT_TCIB_CONFIG_BASE
|
||||
)
|
||||
|
||||
if not os.path.isdir(self.tcib_config_path):
|
||||
raise IOError(
|
||||
"Configuration directory {} was not found.".format(
|
||||
|
|
Loading…
Reference in New Issue