From d417e61fd165276991bd8f28dd5b070f357296a2 Mon Sep 17 00:00:00 2001 From: william chu Date: Wed, 21 Dec 2022 10:01:28 +1100 Subject: [PATCH 1/3] feat: Gitops bump works for repos without a prefix --- gitops/common/app.py | 5 ++++- gitops/core.py | 1 + gitops/utils/apps.py | 2 +- gitops/utils/images.py | 15 ++++++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) 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] From 81119f1300cd82c13598c0e94f699e737da53cd4 Mon Sep 17 00:00:00 2001 From: william chu Date: Wed, 21 Dec 2022 10:11:09 +1100 Subject: [PATCH 2/3] chore: Bump version to 0.9.11 --- charts/gitops/Chart.yaml | 2 +- gitops/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/gitops/Chart.yaml b/charts/gitops/Chart.yaml index bc60430..ca23ca7 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.11 diff --git a/gitops/__init__.py b/gitops/__init__.py index f29ec17..ae712cf 100644 --- a/gitops/__init__.py +++ b/gitops/__init__.py @@ -4,7 +4,7 @@ from .utils.cli import success, warning -__version__ = "0.9.10" +__version__ = "0.9.11" # Checking gitops version matches cluster repo version. diff --git a/pyproject.toml b/pyproject.toml index d9afd4c..454b78d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gitops" -version = "0.9.10" +version = "0.9.11" description = "Manage multiple apps across one or more k8s clusters." authors = ["Jarek GÅ‚owacki "] license = "BSD" From 13905b6f334eb4d15a252ac91d2c6e701b120a0e Mon Sep 17 00:00:00 2001 From: william chu Date: Mon, 23 Jan 2023 11:53:36 +1100 Subject: [PATCH 3/3] build: Bump version to 0.9.14 --- charts/gitops/Chart.yaml | 2 +- gitops/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/gitops/Chart.yaml b/charts/gitops/Chart.yaml index ca23ca7..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.11 +version: 0.9.14 diff --git a/gitops/__init__.py b/gitops/__init__.py index ae712cf..f6e0657 100644 --- a/gitops/__init__.py +++ b/gitops/__init__.py @@ -4,7 +4,7 @@ from .utils.cli import success, warning -__version__ = "0.9.11" +__version__ = "0.9.14" # Checking gitops version matches cluster repo version. diff --git a/pyproject.toml b/pyproject.toml index 454b78d..08fdf8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gitops" -version = "0.9.11" +version = "0.9.14" description = "Manage multiple apps across one or more k8s clusters." authors = ["Jarek GÅ‚owacki "] license = "BSD"