diff --git a/charts/gitops/Chart.yaml b/charts/gitops/Chart.yaml index bc60430..bb9bacb 100644 --- a/charts/gitops/Chart.yaml +++ b/charts/gitops/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: GitOps Server Helm chart. name: gitops -version: 0.9.10 +version: 0.9.14 diff --git a/gitops/__init__.py b/gitops/__init__.py index 41be6b1..6148b01 100644 --- a/gitops/__init__.py +++ b/gitops/__init__.py @@ -5,7 +5,7 @@ from . import monkeypatches # NOQA from .utils.cli import success, warning -__version__ = "0.9.13" +__version__ = "0.9.14" # Checking gitops version matches cluster repo version. diff --git a/gitops/common/app.py b/gitops/common/app.py index ff3c755..fdc7863 100644 --- a/gitops/common/app.py +++ b/gitops/common/app.py @@ -108,7 +108,10 @@ def image_prefix(self) -> str: """Gets the image prefix portion of {prefix}-{git hash} 305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/uptick:[yoink]-9f03ac80f3 - eg: qa-server-12345 -> qa-server""" + eg: qa-server-12345 -> qa-server + """ + if "-" not in self.image_tag: + return "" return self.image_tag.rsplit("-", 1)[0] @property diff --git a/gitops/core.py b/gitops/core.py index 0115c80..cb1d641 100644 --- a/gitops/core.py +++ b/gitops/core.py @@ -75,6 +75,7 @@ def bump( app_name = app.name prev_image_tag = app.image_tag if image_tag is None: + # if we haven't specified a prefix if prefix is None: new_image_prefix = app.image_prefix else: diff --git a/gitops/utils/apps.py b/gitops/utils/apps.py index bc68115..f3d3a81 100644 --- a/gitops/utils/apps.py +++ b/gitops/utils/apps.py @@ -91,7 +91,7 @@ def get_apps( app = get_app_details(entry.name, load_secrets=load_secrets) pseudotags = [app.name, app.cluster] - if app.image: + if app.image and app.image_prefix: pseudotags.append(app.image_prefix) tags = set(app.tags + pseudotags) diff --git a/gitops/utils/images.py b/gitops/utils/images.py index af734c6..3f42309 100644 --- a/gitops/utils/images.py +++ b/gitops/utils/images.py @@ -28,11 +28,20 @@ def get_latest_image(repository_name: str, prefix: str) -> str: maxResults=BATCH_SIZE, ): for image in ecr_response["imageDetails"]: - if prefix_tags := [tag for tag in image["imageTags"] if tag.startswith(prefix + "-")]: - results.append((prefix_tags[0], image["imagePushedAt"])) + if prefix != "": + if prefix_tags := [ + tag for tag in image["imageTags"] if tag.startswith(prefix + "-") + ]: + results.append((prefix_tags[0], image["imagePushedAt"])) + else: + if prefix_tags := [tag for tag in image["imageTags"] if "-" not in tag]: + results.append((prefix_tags[0], image["imagePushedAt"])) if not results: - print(f'No images with tag "{prefix}-*".') + if prefix: + print(f'No images found in repository: {repository_name} with tag "{prefix}-*".') + else: + print(f"No images found in repository: {repository_name}") return None latest_image_tag = sorted(results, key=lambda image: image[1], reverse=True)[0][0] diff --git a/pyproject.toml b/pyproject.toml index 40b3a1d..08fdf8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gitops" -version = "0.9.13" +version = "0.9.14" description = "Manage multiple apps across one or more k8s clusters." authors = ["Jarek GÅ‚owacki "] license = "BSD"