Skip to content

Commit

Permalink
Merge branch 'feat/no-prefix' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
uptickmetachu committed Jan 23, 2023
2 parents 938f8a4 + 13905b6 commit 110ca93
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/gitops/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "1.0"
description: GitOps Server Helm chart.
name: gitops
version: 0.9.10
version: 0.9.14
2 changes: 1 addition & 1 deletion gitops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion gitops/common/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gitops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion gitops/utils/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 12 additions & 3 deletions gitops/utils/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "BSD"
Expand Down

0 comments on commit 110ca93

Please sign in to comment.