-
Notifications
You must be signed in to change notification settings - Fork 116
fix(KustomizeUpdater): non docker.io image registries were ignored for image updates #2011
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
Open
oleksandr-codefresh
wants to merge
15
commits into
release/2026.2
Choose a base branch
from
osaulyak/YOS-368-kustomize-image-registry-2
base: release/2026.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fa33faf
KustomizeUpdater.cs: fixed bug with loosing image registry, hence not…
oleksandr-codefresh db2f787
added missing non docker.io registry test cases to othe updaters
oleksandr-codefresh 3d284da
not a nice fix, but a fix
rain-on 255dfe5
tests: fixed expected UpdatedImages values in assertions
oleksandr-codefresh 9a3c20b
Consolidate on list matches the yaml text, it may or may not include …
rain-on d745990
inline/kustomize: fixed wrong expected valued for UpdatedImageReferen…
oleksandr-codefresh 332b2bd
Merge remote-tracking branch 'origin/osaulyak/YOS-368-kustomize-image…
rain-on 88f3a02
sorting tests - kustomizeUpdater is harder than hoped
rain-on 1f60a1a
caught some toString() issues
rain-on ac5762b
refactor yaml update tests to not include the registry if orinal didn…
rain-on de4615d
make all the tests pass
rain-on 4c49630
uncomment code in test
rain-on 248c95c
uncommented and added back tag
oleksandr-codefresh 1ffd0ef
all replacers: added UpdateImages test cases to cover returning origi…
oleksandr-codefresh 5896271
Merge branch 'osaulyak/YOS-368-kustomize-image-registry-2' of github.…
oleksandr-codefresh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using Calamari.ArgoCD; | ||
| using Calamari.ArgoCD.Conventions; | ||
| using Calamari.ArgoCD.Conventions.UpdateImageTag; | ||
| using Calamari.ArgoCD.Domain; | ||
| using Calamari.ArgoCD.Models; | ||
| using Calamari.Common.Plumbing.FileSystem; | ||
| using Calamari.Common.Plumbing.Logging; | ||
| using Calamari.Testing.Helpers; | ||
| using Calamari.Tests.Fixtures.Integration.FileSystem; | ||
| using FluentAssertions; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Calamari.Tests.ArgoCD | ||
| { | ||
| /// <summary> | ||
| /// Integration tests for DirectoryUpdater.Process() workflow. | ||
| /// Mirrors KustomizeUpdaterTests, focusing on non-default container registries. | ||
| /// </summary> | ||
| [TestFixture] | ||
| public class DirectoryUpdaterTests | ||
| { | ||
| ILog log; | ||
| ICalamariFileSystem fileSystem; | ||
| string tempDir; | ||
|
|
||
| [SetUp] | ||
| public void SetUp() | ||
| { | ||
| log = new InMemoryLog(); | ||
| fileSystem = TestCalamariPhysicalFileSystem.GetPhysicalFileSystem(); | ||
| tempDir = fileSystem.CreateTemporaryDirectory(); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public void TearDown() | ||
| { | ||
| fileSystem?.DeleteDirectory(tempDir); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Process_WithImageOnNonDefaultRegistry_ProducesPatchSoChangesAreCommitted() | ||
| { | ||
| // Regression: an image on a non-default registry (e.g. GAR/GCR/ECR) must update the | ||
| // manifest AND produce a JSON patch, so HasChanges() is true and the commit/push isn't | ||
| // silently skipped. | ||
| const string deployment = @"apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: helloworld | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - name: helloworld | ||
| image: us-docker.pkg.dev/shared-gke-dev-gqtrxy/argo-test/helloworld:v1 | ||
| "; | ||
| fileSystem.OverwriteFile(Path.Combine(tempDir, "deployment.yaml"), deployment); | ||
|
|
||
| var garImages = new List<ContainerImageReferenceAndHelmReference> | ||
| { | ||
| new(ContainerImageReference.FromReferenceString( | ||
| "us-docker.pkg.dev/shared-gke-dev-gqtrxy/argo-test/helloworld:v2", | ||
| ArgoCDConstants.DefaultContainerRegistry)), | ||
| }; | ||
|
|
||
| var sourceWithMetadata = new ApplicationSourceWithMetadata( | ||
| new ApplicationSource { Path = "." }, | ||
| SourceType.Directory, | ||
| 0); | ||
|
|
||
| var updater = new DirectoryUpdater(garImages, ArgoCDConstants.DefaultContainerRegistry, log, fileSystem); | ||
|
|
||
| var result = updater.Process(sourceWithMetadata, tempDir); | ||
|
|
||
| result.UpdatedImages.Should().NotBeEmpty(); | ||
| result.HasChanges().Should().BeTrue("a JSON patch must be produced so the commit/push is not skipped"); | ||
| result.PatchedFiles.Should().NotBeEmpty(); | ||
|
|
||
| var updatedContent = fileSystem.ReadFile(Path.Combine(tempDir, "deployment.yaml")); | ||
| updatedContent.Should().Contain("us-docker.pkg.dev/shared-gke-dev-gqtrxy/argo-test/helloworld:v2"); | ||
| updatedContent.Should().NotContain("helloworld:v1"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using Calamari.ArgoCD; | ||
| using Calamari.ArgoCD.Conventions; | ||
| using Calamari.ArgoCD.Conventions.UpdateImageTag; | ||
|
|
@@ -13,7 +12,6 @@ | |
| using Calamari.Testing.Helpers; | ||
| using Calamari.Tests.Fixtures.Integration.FileSystem; | ||
| using FluentAssertions; | ||
| using NSubstitute; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Calamari.Tests.ArgoCD | ||
|
|
@@ -27,8 +25,8 @@ public class KustomizeUpdaterTests | |
| { | ||
| readonly List<ContainerImageReferenceAndHelmReference> imagesToUpdate = new() | ||
| { | ||
| new(ContainerImageReference.FromReferenceString("nginx:1.25", ArgoCDConstants.DefaultContainerRegistry)), | ||
| new(ContainerImageReference.FromReferenceString("busybox:stable", "my-registry.com")), | ||
| new(ContainerImageReference.FromReferenceString("docker.io/nginx:1.25")), | ||
| new(ContainerImageReference.FromReferenceString("my-registry.com/busybox:stable")) | ||
| }; | ||
|
|
||
| ILog log; | ||
|
|
@@ -279,7 +277,7 @@ public void Process_WithMixedPatchTypes_UpdatesAllFiles() | |
| var result = updater.Process(sourceWithMetadata, tempDir); | ||
|
|
||
| result.UpdatedImages.Should().Contain("nginx:1.25"); | ||
| result.UpdatedImages.Should().Contain("busybox:stable"); | ||
| result.UpdatedImages.Should().Contain("my-registry.com/busybox:stable"); | ||
| result.UpdatedImages.Count.Should().Be(2); | ||
|
|
||
| var updatedDeploymentContent = fileSystem.ReadFile(Path.Combine(tempDir,"deployment-patch.yaml")); | ||
|
|
@@ -289,7 +287,45 @@ public void Process_WithMixedPatchTypes_UpdatesAllFiles() | |
| updatedServiceContent.Should().Contain("busybox:stable"); | ||
|
|
||
| var updatedKustomizationContent = fileSystem.ReadFile(Path.Combine(tempDir, "kustomization.yaml")); | ||
| updatedKustomizationContent.Should().Contain("busybox:stable"); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this intentional deletion of tag?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checked this, we can add it back |
||
| updatedKustomizationContent.Should().Contain("my-registry.com/busybox:"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Process_WithImageOnNonDefaultRegistry_ProducesPatchSoChangesAreCommitted() | ||
| { | ||
| // Regression test: an image whose registry differs from the default (e.g. GAR/GCR/ECR) | ||
| // must still produce a JSON patch. Previously the recorded image reference had its | ||
| // registry stripped, so CreateJsonPatch re-parsed it, defaulted the registry to | ||
| // docker.io, failed to match, and returned no patch — meaning HasChanges() was false | ||
| // and the working-copy edit was silently discarded (never committed). | ||
| const string kustomizationContent = @"apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| images: | ||
| - name: us-docker.pkg.dev/shared-gke-dev-gqtrxy/argo-test/helloworld | ||
| newTag: ""latest"" | ||
| "; | ||
|
|
||
| var garImages = new List<ContainerImageReferenceAndHelmReference> | ||
| { | ||
| new(ContainerImageReference.FromReferenceString( | ||
| "us-docker.pkg.dev/shared-gke-dev-gqtrxy/argo-test/helloworld:v2", | ||
| ArgoCDConstants.DefaultContainerRegistry)), | ||
| }; | ||
|
|
||
| var sourceWithMetadata = new ApplicationSourceWithMetadata( | ||
| new ApplicationSource { Path = "." }, | ||
| SourceType.Kustomize, | ||
| 0); | ||
|
|
||
| CreateKustomizationFile(kustomizationContent); | ||
|
|
||
| var updater = new KustomizeUpdater(CreateMockDeploymentConfig(garImages), ArgoCDConstants.DefaultContainerRegistry, log, fileSystem); | ||
|
|
||
| var result = updater.Process(sourceWithMetadata, tempDir); | ||
|
|
||
| result.UpdatedImages.Should().Contain("us-docker.pkg.dev/shared-gke-dev-gqtrxy/argo-test/helloworld:v2"); | ||
| result.HasChanges().Should().BeTrue("a JSON patch must be produced so the commit/push is not skipped"); | ||
| result.PatchedFiles.Should().NotBeEmpty(); | ||
| } | ||
|
|
||
| [Test] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.