buildah: exclude build and push, not only build

When adding exclude param, we put it in the build but buildah still
tries to pushes the images from exclude. Let's just move it to the
_generate_container method which takes care of both build & push.

Change-Id: I53108786e384215353b5db37b3d5a6d77e0c9d60
This commit is contained in:
Emilien Macchi 2020-05-05 10:47:50 -04:00
parent ffb1ac86a4
commit 78bcbfff50
2 changed files with 5 additions and 8 deletions

View File

@ -96,6 +96,9 @@ class BuildahBuilder(base.BaseBuilder):
:params container_name: Name of the container.
"""
if container_name in self.excludes:
return
self.build(container_name, self._find_container_dir(container_name))
if self.push_containers:
destination = "{}/{}/{}-{}-{}:{}".format(
@ -116,9 +119,6 @@ class BuildahBuilder(base.BaseBuilder):
Containerfile and other files are located to build the image.
"""
if container_name in self.excludes:
return
destination = "{}/{}/{}-{}-{}:{}".format(
self.registry_address,
self.namespace,

View File

@ -111,11 +111,8 @@ class TestBuildahBuilder(base.TestCase):
@mock.patch.object(process, 'execute', autospec=True)
def test_build_with_excludes(self, mock_process):
container_build_path = WORK_DIR + '/' + 'fedora-base'
bb(WORK_DIR, DEPS, excludes=['fedora-base']).build(
'fedora-base',
container_build_path
)
bb(WORK_DIR, DEPS, excludes=['fedora-base'])._generate_container(
'fedora-base')
assert not mock_process.called
@mock.patch.object(process, 'execute', autospec=True)