-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent multiple component versions (#2094)
* Use --set forceIncompatibleKubernetes=true so show-docker-images always works * Remove deprecated remote_docker_version, use cimg/base:stable * Add verify_image_tags.py and verify-image-tags pre-commit hook
- Loading branch information
1 parent
a805460
commit d67a3e9
Showing
6 changed files
with
72 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
"""Verify that every image has only one tag version.""" | ||
|
||
import subprocess | ||
from pathlib import Path | ||
|
||
|
||
GIT_ROOT = next( | ||
iter([x for x in Path(__file__).resolve().parents if (x / ".git").is_dir()]), None | ||
) | ||
command = "helm template . --set forceIncompatibleKubernetes=true -f tests/enable_all_features.yaml | grep -o 'quay.io/astronomer[^\"]*' | sort -u" | ||
|
||
result = subprocess.run( | ||
command, | ||
shell=True, | ||
cwd=GIT_ROOT, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
text=True, | ||
) | ||
|
||
if result.returncode != 0: | ||
print(f"Error running the command:\n{result.stderr}") | ||
raise SystemExit(1) | ||
|
||
output_lines = result.stdout.strip().split("\n") | ||
|
||
image_dict = {} | ||
images_with_multiple_tags = [] | ||
|
||
for line in output_lines: | ||
if ":" not in line: | ||
continue | ||
|
||
image = line.strip() | ||
parts = image.rsplit(":", 1) | ||
image_name = parts[0] | ||
tag = parts[1].strip(" \"'\t\n\r") | ||
|
||
if image_name not in image_dict: | ||
image_dict[image_name] = [] | ||
|
||
if tag and tag not in image_dict[image_name]: | ||
image_dict[image_name].append(tag) | ||
|
||
for image, tags in image_dict.items(): | ||
if len(tags) > 1: | ||
print(f"ERROR: image {image} has multiple tags: {', '.join(tags)}") | ||
|
||
if any(len(tags) > 1 for tags in image_dict.values()): | ||
raise SystemExit(1) |