Merge "Adding --repo-dir argument"
This commit is contained in:
commit
466b5a3adf
@ -169,7 +169,6 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
||||
(
|
||||
"volumes",
|
||||
[
|
||||
"/etc/yum.repos.d:/etc/distro.repos.d:z",
|
||||
"/etc/pki/rpm-gpg:/etc/pki/rpm-gpg:z",
|
||||
"bind/mount",
|
||||
],
|
||||
@ -180,6 +179,35 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
||||
|
||||
self._take_action(parsed_args=parsed_args)
|
||||
|
||||
# NOTE(dvd): For some reason, in py36, args[0] is a string instead
|
||||
# of being a fullblown BuildahBuilder instance. I wasn't able to find
|
||||
# the instance anywhere, everything is mocked.
|
||||
builder_obj = self.mock_buildah.call_args.args[0]
|
||||
if not isinstance(builder_obj, str):
|
||||
self.assertIn(
|
||||
'/etc/yum.repos.d:/etc/distro.repos.d:z',
|
||||
builder_obj.volumes
|
||||
)
|
||||
|
||||
assert self.mock_buildah.called
|
||||
|
||||
def test_image_build_with_repo_dir(self):
|
||||
arglist = ["--repo-dir", "/somewhere"]
|
||||
verifylist = [
|
||||
("repo_dir", "/somewhere"),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self._take_action(parsed_args=parsed_args)
|
||||
|
||||
builder_obj = self.mock_buildah.call_args.args[0]
|
||||
if not isinstance(builder_obj, str):
|
||||
self.assertIn(
|
||||
'/somewhere:/etc/distro.repos.d:z',
|
||||
builder_obj.volumes
|
||||
)
|
||||
|
||||
assert self.mock_buildah.called
|
||||
|
||||
def test_image_build_with_exclude(self):
|
||||
|
@ -208,7 +208,6 @@ class Build(command.Command):
|
||||
dest="volumes",
|
||||
metavar="<volume-path>",
|
||||
default=[
|
||||
"/etc/yum.repos.d:/etc/distro.repos.d:z",
|
||||
"/etc/pki/rpm-gpg:/etc/pki/rpm-gpg:z",
|
||||
],
|
||||
action="append",
|
||||
@ -218,6 +217,16 @@ class Build(command.Command):
|
||||
"(default: %(default)s)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--repo-dir",
|
||||
dest="repo_dir",
|
||||
metavar="<repo-dir>",
|
||||
default="/etc/yum.repos.d",
|
||||
help=_(
|
||||
"Define a custom directory containing the repo files. This is "
|
||||
"useful when building containers from a different OS release."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--work-dir",
|
||||
dest="work_dir",
|
||||
@ -687,6 +696,10 @@ class Build(command.Command):
|
||||
# Ensure anything not intended to be built is excluded
|
||||
excludes.extend(self.rectify_excludes(images_to_prepare))
|
||||
self.log.info("Images being excluded: {}".format(excludes))
|
||||
volumes = parsed_args.volumes
|
||||
volumes.append(
|
||||
f"{parsed_args.repo_dir}:/etc/distro.repos.d:z"
|
||||
)
|
||||
|
||||
if not parsed_args.skip_build:
|
||||
bb = buildah.BuildahBuilder(
|
||||
@ -698,7 +711,7 @@ class Build(command.Command):
|
||||
namespace=parsed_args.namespace,
|
||||
registry_address=parsed_args.registry,
|
||||
push_containers=parsed_args.push,
|
||||
volumes=parsed_args.volumes,
|
||||
volumes=volumes,
|
||||
excludes=list(set(excludes)),
|
||||
build_timeout=parsed_args.build_timeout,
|
||||
debug=self.app.options.debug
|
||||
|
Loading…
Reference in New Issue
Block a user