Skip to content

Commit 21c507c

Browse files
committed
Compressed mirror config setup into a single interface.
1 parent d55c152 commit 21c507c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

stackinator/builder.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,9 @@ def generate(self, recipe):
315315

316316
# generate a mirrors.yaml file if build caches have been configured
317317
if recipe.mirrors:
318+
self._logger.debug(f"Generating the spack mirror configs in '{config_path}'")
318319
recipe.mirrors.key_setup(config_path/'key_store')
319-
320-
self._logger.debug(f"Generating the spack mirrors.yaml in '{config_path}'")
321320
recipe.mirrors.create_spack_mirrors_yaml(config_path/'mirrors.yaml')
322-
323-
# Setup bootstrap mirror configs.
324321
recipe.mirrors.create_bootstrap_configs(config_path)
325322

326323
# Add custom spack package recipes, configured via Spack repos.

stackinator/mirror.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class MirrorError(RuntimeError):
1515
class Mirrors:
1616
"""Manage the definition of mirrors in a recipe."""
1717

18+
KEY_STORE_DIR = 'key_store'
19+
MIRRORS_YAML = 'mirrors.yaml'
20+
1821
def __init__(self, system_config_root: pathlib.Path, cmdline_cache: Optional[str] = None):
1922
"""Configure mirrors from both the system 'mirror.yaml' file and the command line."""
2023

@@ -92,7 +95,14 @@ def _check_mirrors(self):
9295
f"Could not reach the mirror url '{url}'. "
9396
f"Check the url listed in mirrors.yaml in system config. \n{e.reason}")
9497

95-
def create_spack_mirrors_yaml(self, dest: pathlib.Path):
98+
def setup_configs(self, config_root: pathlib.Path):
99+
"""Setup all mirror configs in the given config_root."""
100+
101+
self._key_setup(config_root/self.KEY_STORE_DIR)
102+
self._create_spack_mirrors_yaml(config_root/self.MIRRORS_YAML)
103+
self._create_bootstrap_configs(config_root)
104+
105+
def _create_spack_mirrors_yaml(self, dest: pathlib.Path):
96106
"""Generate the mirrors.yaml for our build directory."""
97107

98108
raw = {"mirrors": {}}
@@ -109,7 +119,7 @@ def create_spack_mirrors_yaml(self, dest: pathlib.Path):
109119
with dest.open("w") as file:
110120
yaml.dump(raw, file, default_flow_style=False)
111121

112-
def create_bootstrap_configs(self, config_root: pathlib.Path):
122+
def _create_bootstrap_configs(self, config_root: pathlib.Path):
113123
"""Create the bootstrap.yaml and bootstrap metadata dirs in our build dir."""
114124

115125
if not self.bootstrap_mirrors:
@@ -145,7 +155,7 @@ def create_bootstrap_configs(self, config_root: pathlib.Path):
145155
with (config_root/'bootstrap.yaml').open('w') as file:
146156
yaml.dump(bootstrap_yaml, file, default_flow_style=False)
147157

148-
def key_setup(self, key_store: pathlib.Path):
158+
def _key_setup(self, key_store: pathlib.Path):
149159
"""Validate mirror keys, relocate to key_store, and update mirror config with new key paths."""
150160

151161
for mirror in self.mirrors:

0 commit comments

Comments
 (0)