Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport master] Strip the alt tag name, simplify #1232

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions c2cciutils/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ def docker(
image_config: c2cciutils.configuration.PublishDockerImage,
tag_src: str,
tag_dst: str,
latest: bool,
alt_tags: list[str],
images_full: list[str],
) -> bool:
Expand Down Expand Up @@ -378,17 +377,6 @@ def docker(
check=True,
)
new_images_full.append(f"{config['server']}/{image_config['name']}:{tag_dst}")
if latest:
subprocess.run(
[
"docker",
"tag",
f"{image_config['name']}:{tag_src}",
f"{config['server']}/{image_config['name']}:{tag_src}",
],
check=True,
)
new_images_full.append(f"{config['server']}/{image_config['name']}:{tag_src}")
for alt_tag in alt_tags:
subprocess.run(
[
Expand All @@ -412,18 +400,17 @@ def docker(
check=True,
)
new_images_full.append(f"{image_config['name']}:{tag_dst}")
if latest and tag_src != tag_dst:
new_images_full.append(f"{image_config['name']}:{tag_src}")
for alt_tag in alt_tags:
subprocess.run(
[
"docker",
"tag",
f"{image_config['name']}:{tag_src}",
f"{image_config['name']}:{alt_tag}",
],
check=True,
)
if tag_src != alt_tag:
subprocess.run(
[
"docker",
"tag",
f"{image_config['name']}:{tag_src}",
f"{image_config['name']}:{alt_tag}",
],
check=True,
)
new_images_full.append(f"{image_config['name']}:{alt_tag}")

for image in new_images_full:
Expand Down
19 changes: 5 additions & 14 deletions c2cciutils/scripts/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def main() -> None:
config.get("publish", {}).get("docker", {}) if config.get("publish", {}).get("docker", False) else {},
)
if docker_config:
latest = False
full_repo = c2cciutils.get_repository()
full_repo_split = full_repo.split("/")
master_branch, _ = c2cciutils.get_master_branch(full_repo_split)
Expand All @@ -216,18 +215,19 @@ def main() -> None:

security = c2cciutils.security.Security(security_text)
version_index = security.headers.index("Version")
latest = security.data[-1][version_index] == version

row_index = -1
for index, row in enumerate(security.data):
if row[version_index] == version:
row_index = index
break

alt_tags = []
alt_tags = set()
if "Alternate Tag" in security.headers:
tag_index = security.headers.index("Alternate Tag")
alt_tags = security.data[row_index][tag_index].split(",")
alt_tags = {t.strip() for t in security.data[row_index][tag_index].split(",")}
if security.data[-1][version_index] == version:
alt_tags.add("latest")

images_src: set[str] = set()
images_full: list[str] = []
Expand Down Expand Up @@ -285,22 +285,13 @@ def main() -> None:

if args.dry_run:
print(f"Publishing {image_dst} to {name}, skipping (dry run)")
if latest:
print(f"Publishing {image_source} to {name}, skipping (dry run)")
for alt_tag in current_alt_tag:
print(
f"Publishing {image_conf['name']}:{alt_tag} to {name}, skipping (dry run)"
)
else:
success &= c2cciutils.publish.docker(
conf,
name,
image_conf,
tag_src,
tag_dst,
latest,
current_alt_tag,
images_full,
conf, name, image_conf, tag_src, tag_dst, current_alt_tag, images_full
)

if google_calendar_publish:
Expand Down
Loading