Skip to content

Commit

Permalink
Allow to provide own repos.yaml file
Browse files Browse the repository at this point in the history
Several people use Kolla behind firewall/proxy. Internal mirrors are
often in use then. We do not provide a way to replace repos.yaml file in
an easy way which may lead to complicated solutions or template
overrides.

This patch adds a way to provide own copy of repos.yaml file.

Change-Id: I0b07da22fea27e0ff4e90aaad19e50d84ff9a121
(cherry picked from commit 213190a)
  • Loading branch information
Marcin Juszkiewicz authored and mmalchuk committed Jun 2, 2022
1 parent 6298c0e commit e90786a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion kolla/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@
cfg.BoolOpt('summary', default=True,
help='Show summary at the end of build'),
cfg.BoolOpt('infra-rename', default=False,
help='Rename infrastructure images to infra')
help='Rename infrastructure images to infra'),
cfg.StrOpt('repos-yaml', default='',
help='Path to alternative repos.yaml file'),
]

_BASE_OPTS = [
Expand Down
2 changes: 2 additions & 0 deletions kolla/image/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ def __init__(self, conf):
self.base_tag = conf.base_tag
self.install_type = conf.install_type
self.tag = conf.tag
self.repos_yaml = conf.repos_yaml
self.base_arch = conf.base_arch
self.debian_arch = self.base_arch
if self.base_arch == 'aarch64':
Expand Down Expand Up @@ -880,6 +881,7 @@ def create_dockerfiles(self):
'base_image': self.conf.base_image,
'base_distro_tag': self.base_tag,
'base_arch': self.base_arch,
'repos_yaml': self.repos_yaml,
'use_dumb_init': self.use_dumb_init,
'base_package_type': self.base_package_type,
'debian_arch': self.debian_arch,
Expand Down
6 changes: 5 additions & 1 deletion kolla/template/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def handle_repos(context, reponames, mode):
if not isinstance(reponames, list):
raise TypeError("First argument should be a list of repositories")

repofile = os.path.dirname(os.path.realpath(__file__)) + '/repos.yaml'
if context.get('repos_yaml'):
repofile = context.get('repos_yaml')
else:
repofile = os.path.dirname(os.path.realpath(__file__)) + '/repos.yaml'

with open(repofile, 'r') as repos_file:
repo_data = {}
for name, params in yaml.safe_load(repos_file).items():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
features:
- |
Added an `--repos-yaml` argument to allow user to provide own file with
definitions of external package repositories. Useful for those building
in offline environments with set of internal mirrors.

0 comments on commit e90786a

Please sign in to comment.