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

fix: modify SetKustomizeImage logic when use alias_name #251

Merged
merged 1 commit into from
Sep 9, 2021
Merged

fix: modify SetKustomizeImage logic when use alias_name #251

merged 1 commit into from
Sep 9, 2021

Conversation

nyuta01
Copy link
Contributor

@nyuta01 nyuta01 commented Sep 3, 2021

In the previous implementation, there was a problem that argocd-image-updater would create a new image when using newName of kustomize.
This is due to the fact that the current kustomize image information retrieved from the argucd API does not include the value of alias_name.
([<alias_name>=]<image_path>[:<version_constraint>])

So, in this PR, even if the current image information doesn't contain alias_name, we can update the kustomize image information appropriately

ex. update kustomize images by argocd-image-updater

manifest

application.yaml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: adservice
  annotations:
    argocd-image-updater.argoproj.io/image-list: adservice=nyuta01/adservice:^1.0.0
    argocd-image-updater.argoproj.io/write-back-target: kustomization
    argocd-image-updater.argoproj.io/adservice.kustomize.image-name: adservice
spec:
  project: default
  source:
    repoURL: git@github.com:nyuta01/xxx.git
    targetRevision: main
    path: xxx/adservice
...

xxx/adservice/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml

images:
- name: adservice
  newName: nyuta01/adservice
  newTag: v1.2.0

xxx/adservice/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: adservice
spec:
  selector:
    matchLabels:
      app: adservice
  template:
    metadata:
      labels:
        app: adservice
    spec:
      containers:
      - name: server
        image: adservice
...

result

before

images:
  - name: adservice
    newName: nyuta01/adservice
    newTag: v1.2.0
+  - name: nyuta01/adservice
+    newTag: v1.2.1

after

images:
  - name: adservice
    newName: nyuta01/adservice
-    newTag: v1.2.0
+    newTag: v1.2.1

@CLAassistant
Copy link

CLAassistant commented Sep 3, 2021

CLA assistant check
All committers have signed the CLA.

@nyuta01 nyuta01 changed the title fix: modify SetKustomizeImage logic when use alias-image fix: modify SetKustomizeImage logic when use alias-name Sep 3, 2021
@nyuta01 nyuta01 changed the title fix: modify SetKustomizeImage logic when use alias-name fix: modify SetKustomizeImage logic when use alias_name Sep 3, 2021
Copy link
Contributor

@jannfis jannfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you, @nyuta01

@jannfis jannfis merged commit 0dbd6cd into argoproj-labs:master Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants