Skip to content

Refactor helm image replacement handlers#1894

Open
scme0 wants to merge 14 commits intomainfrom
scme/refactor-helm-image-replacement
Open

Refactor helm image replacement handlers#1894
scme0 wants to merge 14 commits intomainfrom
scme/refactor-helm-image-replacement

Conversation

@scme0
Copy link
Copy Markdown
Collaborator

@scme0 scme0 commented Apr 17, 2026

⚠️ Does this change require a corresponding Server Change?
⚠️ If so - please add a "Requires Server Change" label to this PR!

We had two distinct processing paths for Helm - one via annotations and one via variables. This refactor unifies them - the only difference is the annotations are preprocessed into image paths so the image replacer can do its thing!

I realised as well that the AbstractHelmUpdater didn't have an "is-a" relationship with BaseUpdater anymore, so I removed the inheritance and move the one static helper method to a static utils class so it can be shared. Also renamed to BaseHelmUpdater because it's now the base.

@scme0 scme0 changed the base branch from main to tmm/helm_fails_patch April 17, 2026 08:33
Comment thread source/Calamari/ArgoCD/HelmValuesImageReplaceStepVariables.cs
@scme0 scme0 force-pushed the scme/refactor-helm-image-replacement branch from ef9c058 to f1da315 Compare April 17, 2026 09:55
AssertNotUpdatedWithExpectedPatch(getCapturedResults,
expectedPatchPointer: "/0/image/tag",
expectedPatchValue: "1.27.1",
expectedPatchedFilePath: Path.Combine("otherRepoPath", "values.yaml"));
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We had a weird round trip in the original code where we would take file paths from relative -> absolute -> relative which meant that the paths were normalised to the machine (windows and nix). We don't actually need to do this because calamari handles that down stream automatically. This refactor removes the round-trip so the path here can be a normal string with explicit file path separator.


public static class HelmHelpers
{
public static void LogHelmSourceConfigurationProblems(ILog log, IReadOnlyCollection<HelmSourceConfigurationProblem> helmSourceConfigurationProblems)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

After refactor, it was only used in AbstractHelmUpdater once so I made it a private static method in that file.

{
if (valueToUpdate == newImageTag.ContainerReference.Tag)
{
alreadyUpToDate.Add(newImageTag.ContainerReference.Tag);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you see if this is a real bug? Add test?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've extracted the tests I added to find this and the fix into this PR: #1896

@scme0 scme0 force-pushed the scme/refactor-helm-image-replacement branch from 002cad1 to 9cbfdd3 Compare April 22, 2026 15:08
Base automatically changed from tmm/helm_fails_patch to main April 23, 2026 00:59
scme0 and others added 12 commits April 24, 2026 11:49
AbstractHelmUpdater.cs retained its filename (rename didn't apply cleanly)
and needed MakePlaceholderRef updated to JsonPatchUtils.MakePlaceholderRef.
HelmValuesImageReplaceStepVariablesTests.cs was missing the Calamari.ArgoCD
using directive added during conflict resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@scme0 scme0 force-pushed the scme/refactor-helm-image-replacement branch from 9cbfdd3 to 8798cf3 Compare April 24, 2026 09:51
@scme0 scme0 marked this pull request as ready for review April 24, 2026 14:02
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.

2 participants