Skip to content

Commit

Permalink
release-docker: add tags-only option
Browse files Browse the repository at this point in the history
Add option to only print the tags of Docker images to be released.
  • Loading branch information
mdonadoni committed Nov 14, 2023
1 parent 4459102 commit fc70577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions reana/reana_dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ def release_commands():
multiple=True,
help="Platforms for multi-arch images [default=current architecture]",
)
@click.option("--tags-only", is_flag=True, help="Only print the Docker image tags")

Check warning on line 99 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L99

Added line #L99 was not covered by tests
@release_commands.command(name="release-docker")
@click.pass_context
def release_docker(ctx, component, user, image_name, registry, platform): # noqa: D301
def release_docker(

Check warning on line 102 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L102

Added line #L102 was not covered by tests
ctx, component, user, image_name, registry, platform, tags_only
): # noqa: D301
"""Release a component on a Docker image registry.
\b
Expand All @@ -121,11 +124,13 @@ def release_docker(ctx, component, user, image_name, registry, platform): # noq
:param image_name: Custom name of the local Docker image.
:param registry: Registry to use in the image tag. [default=docker.io]
:param platform: Platforms for multi-arch images. [default=current architecture]
:param tags_only: Only print the Docker image tags.
:type component: str
:type user: str
:type image_name: str
:type registry: str
:type platform: list
:type tags_only: bool
"""
components = select_components(component)

Expand All @@ -134,7 +139,7 @@ def release_docker(ctx, component, user, image_name, registry, platform): # noq
sys.exit(1)

Check warning on line 139 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L137-L139

Added lines #L137 - L139 were not covered by tests

is_multi_arch = len(platform) > 1
if is_multi_arch:
if is_multi_arch and not tags_only:

Check warning on line 142 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L141-L142

Added lines #L141 - L142 were not covered by tests
# check whether podman is installed
run_command("podman version", display=False, return_output=True)

Check warning on line 144 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L144

Added line #L144 was not covered by tests
# platforms are in the format OS/ARCH[/VARIANT], we are only interested in ARCH
Expand All @@ -150,6 +155,10 @@ def release_docker(ctx, component, user, image_name, registry, platform): # noq
target_image_name = f"{registry}/{user}/{image_name or component_}"

Check warning on line 155 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L154-L155

Added lines #L154 - L155 were not covered by tests
docker_tag = get_docker_tag(component_)

if tags_only:
click.echo(f"{target_image_name}:{docker_tag}")
continue

Check warning on line 160 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L158-L160

Added lines #L158 - L160 were not covered by tests

if is_multi_arch:
manifest = json.loads(

Check warning on line 163 in reana/reana_dev/release.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/release.py#L162-L163

Added lines #L162 - L163 were not covered by tests
run_command(
Expand Down
2 changes: 1 addition & 1 deletion reana/reana_dev/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ def get_git_tag(component):
:type component: str
"""
cmd = "git describe --tags --abbrev=0"
return run_command(cmd, component, return_output=True, display=True)
return run_command(cmd, component, return_output=True, display=False)

Check warning on line 903 in reana/reana_dev/utils.py

View check run for this annotation

Codecov / codecov/patch

reana/reana_dev/utils.py#L903

Added line #L903 was not covered by tests


def validate_mode_option(ctx, param, value):
Expand Down

0 comments on commit fc70577

Please sign in to comment.