Skip to content

Commit

Permalink
Merge pull request #27093 from loganharbour/27091_apptainer_project_s…
Browse files Browse the repository at this point in the history
…uffix

Add --to-project-suffix option
  • Loading branch information
loganharbour authored Mar 15, 2024
2 parents ad0099b + cd1901b commit c4aa6fa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/apptainer_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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}')
Expand Down

0 comments on commit c4aa6fa

Please sign in to comment.