From cd1901bbc87527c0725d45da678fb0bfc3e79f88 Mon Sep 17 00:00:00 2001 From: Logan Harbour Date: Thu, 14 Mar 2024 08:48:33 -0600 Subject: [PATCH] Add --to-project-suffix option refs #27091 --- scripts/apptainer_generator.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/apptainer_generator.py b/scripts/apptainer_generator.py index 6c31f796cdf6..8e5b0d2cf1a1 100755 --- a/scripts/apptainer_generator.py +++ b/scripts/apptainer_generator.py @@ -164,6 +164,8 @@ def add_def_args(parser): help='An alternate tag to push to') push_parser.add_argument('--to-tag-prefix', type=str, help='A prefix to add to the pushed tag') + push_parser.add_argument('--to-project-suffix', type=str, + help='A suffix to add to the project to push to') uri_parser = action_parser.add_parser('uri', parents=[parent], help='Get the URI to a container') @@ -259,10 +261,12 @@ def container_path(self, name: str, tag: str, image=True): ext = 'sif' if image else 'def' return os.path.join(self.dir, f'{name}_{tag}.{ext}') - def oras_uri(self, project: str, name: str, tag: str): + def oras_uri(self, project: str, name: str, tag: str, project_suffix = None): """ Gets the ORAS URI for the given image """ + if project_suffix is not None: + project = f'{project}-{project_suffix}' return f'oras://{self.args.oras_url}/{project}/{name}:{tag}' def apptainer_pull(self, project: str, name: str, tag: str, args=None): @@ -751,7 +755,7 @@ def _action_push(self): if not os.path.exists(container_path): self.error(f'Container {container_path} does not exist') - uri = self.oras_uri(self.project, self.name, to_tag) + uri = self.oras_uri(self.project, self.name, to_tag, project_suffix=self.args.to_project_suffix) if self.oras_exists(uri): if self.args.overwrite: self.warn(f'Overwriting {uri}')