Add excludes to container image build
Sometimes it would be beneficial to not build a specific container that we might normally build. This change adds an --exclude option that can be used to skip a container when passing it to kolla-build. Change-Id: Ia871e0a46078a33270516f98ec0e08c1c3a0b43f Depends-On: https://review.openstack.org/#/c/624530/
This commit is contained in:
parent
7a6432aa45
commit
678039164d
@ -146,7 +146,7 @@ testscenarios===0.4
|
||||
testtools==2.2.0
|
||||
tooz==1.58.0
|
||||
traceback2==1.4.0
|
||||
tripleo-common==9.3.0
|
||||
tripleo-common==10.2.0
|
||||
ujson==1.35
|
||||
unittest2==1.1.0
|
||||
vine==1.1.4
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added new `exclude` option to the container build command that allows the
|
||||
user to skip building a specific container. This option can be specified
|
||||
muiltiple times to skip building multiple containers.
|
@ -16,5 +16,5 @@ simplejson>=3.5.1 # MIT
|
||||
six>=1.10.0 # MIT
|
||||
osc-lib>=1.8.0 # Apache-2.0
|
||||
websocket-client>=0.44.0 # LGPLv2+
|
||||
tripleo-common>=9.3.0 # Apache-2.0
|
||||
tripleo-common>=10.2.0 # Apache-2.0
|
||||
cryptography>=2.1 # BSD/Apache-2.0
|
||||
|
@ -496,7 +496,39 @@ class TestContainerImageBuild(TestPluginV1):
|
||||
mock_builder.return_value.build_images.assert_called_once_with([
|
||||
self.default_kolla_conf, '/tmp/kolla.conf',
|
||||
path
|
||||
])
|
||||
], [])
|
||||
|
||||
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||
autospec=True)
|
||||
def test_container_image_build_with_exclude(self, mock_builder):
|
||||
arglist = [
|
||||
'--config-file',
|
||||
'/tmp/foo.yaml',
|
||||
'--config-file',
|
||||
'/tmp/bar.yaml',
|
||||
'--kolla-config-file',
|
||||
'/tmp/kolla.conf',
|
||||
'--exclude',
|
||||
'foo',
|
||||
'--exclude',
|
||||
'bar'
|
||||
]
|
||||
verifylist = []
|
||||
mock_builder.return_value.build_images.return_value = 'done'
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
f, path = tempfile.mkstemp(dir=self.temp_dir)
|
||||
with mock.patch('tempfile.mkstemp') as mock_mkstemp:
|
||||
mock_mkstemp.return_value = f, path
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_builder.assert_called_once_with([
|
||||
'/tmp/foo.yaml', '/tmp/bar.yaml'])
|
||||
mock_builder.return_value.build_images.assert_called_once_with([
|
||||
self.default_kolla_conf, '/tmp/kolla.conf',
|
||||
path
|
||||
], ['foo', 'bar'])
|
||||
|
||||
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||
autospec=True)
|
||||
|
@ -160,6 +160,16 @@ class BuildImage(command.Command):
|
||||
help=_('Show the image build dependencies instead of '
|
||||
'building them.')
|
||||
)
|
||||
parser.add_argument(
|
||||
"--exclude",
|
||||
dest="excludes",
|
||||
metavar='<container-name>',
|
||||
default=[],
|
||||
action="append",
|
||||
help=_("Name of a container to match against the list of "
|
||||
"containers to be built to skip. Can be specified multiple "
|
||||
"times."),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -175,7 +185,8 @@ class BuildImage(command.Command):
|
||||
|
||||
try:
|
||||
builder = kolla_builder.KollaImageBuilder(parsed_args.config_files)
|
||||
result = builder.build_images(kolla_config_files)
|
||||
result = builder.build_images(kolla_config_files,
|
||||
parsed_args.excludes)
|
||||
if parsed_args.list_dependencies:
|
||||
deps = json.loads(result)
|
||||
yaml.safe_dump(deps, self.app.stdout, indent=2,
|
||||
|
Loading…
Reference in New Issue
Block a user