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

feat: support kustomize image newName override #2470

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

jessesuen
Copy link
Member

@jessesuen jessesuen commented Aug 27, 2024

Some users will use different image repositories for prod vs. preprod. As part of their CI process, they might retag/push images to a production image repository. And so they would take advantage of kustomize's newName feature like so:

images:
- name: docker.io/example/guestbook-preprod
  newName: docker.io/example/guestbook-prod
  newTag: 1.0.0

The problem is that kargo will only run kustomize edit set image <image>:<tag> which blows away the newName setting.

This change introduces newName to the kustomize spec, and when specified, will run:

kustomize edit set image <image>=<newName>:<tag>

otherwise:

kustomize edit set image <image>:<tag>

Signed-off-by: Jesse Suen <jesse@akuity.io>
Copy link

netlify bot commented Aug 27, 2024

Deploy Preview for docs-kargo-akuity-io canceled.

Name Link
🔨 Latest commit 81d8106
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-akuity-io/deploys/66ce238c7079100008724a61

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 48.27%. Comparing base (fb7323a) to head (81d8106).
Report is 1 commits behind head on main.

Files Patch % Lines
internal/controller/promotion/kustomize.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2470      +/-   ##
==========================================
- Coverage   48.28%   48.27%   -0.01%     
==========================================
  Files         246      246              
  Lines       17736    17739       +3     
==========================================
+ Hits         8563     8564       +1     
- Misses       8748     8749       +1     
- Partials      425      426       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Jesse Suen <jesse@akuity.io>
@jessesuen jessesuen marked this pull request as ready for review August 27, 2024 19:54
@jessesuen jessesuen requested a review from a team as a code owner August 27, 2024 19:54
@jessesuen
Copy link
Member Author

Verified the feature is working. newName can be specified next to image:

    gitRepoUpdates:
      - repoURL: https://github.com/jessesuen/kargo-simple.git
        insecureSkipTLSVerify: false
        writeBranch: main
        kustomize:
          images:
            - image: ghcr.io/jessesuen/guestbook
              path: env/dev
              useDigest: false
              newName: ghcr.io/akuity/guestbook

Resulting git commit from kargo promotion will set the value:

image

@jessesuen jessesuen added this pull request to the merge queue Aug 27, 2024
Merged via the queue into akuity:main with commit 2ab4270 Aug 27, 2024
17 checks passed
@jessesuen jessesuen deleted the feat/kustomize-newName branch August 27, 2024 20:08
@akuitybot
Copy link

Backport failed for release-0.8, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-0.8
git worktree add -d .worktree/backport-2470-to-release-0.8 origin/release-0.8
cd .worktree/backport-2470-to-release-0.8
git switch --create backport-2470-to-release-0.8
git cherry-pick -x 2ab4270d14d2e8a5aa734592984053bc620fc971

@danielloader
Copy link

Is this also able to work with argoCDAppUpdates sourceUpdates?

@krancour
Copy link
Member

@danielloader it was only for git-based changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants