Skip to content

fix: Use the specified version of Helm when templating with Kustomize#5636

Merged
Warashi merged 3 commits intopipe-cd:masterfrom
JohnTitor:fix/pass-helm-cmd-on-kustomize-build
Mar 11, 2025
Merged

fix: Use the specified version of Helm when templating with Kustomize#5636
Warashi merged 3 commits intopipe-cd:masterfrom
JohnTitor:fix/pass-helm-cmd-on-kustomize-build

Conversation

@JohnTitor
Copy link
Contributor

What this PR does: Pass the --helm-command flag with the installed Helm path when kustomize-templating.

Why we need it: Without this, Kustomize cannot find the specified version of Helm when templating.

Which issue(s) this PR fixes:

Fixes #5635

Does this PR introduce a user-facing change?: yes

  • How are users affected by this change: User can now use the desired version of Helm when Kustomize-templating.
  • Is this breaking change: No
  • How to migrate (if breaking change):

Signed-off-by: Yuki Okushi <okushi@canary-inc.jp>
Comment on lines +8 to +11
- name: datadog
releaseName: datadog-agent
repo: https://helm.datadoghq.com
version: 3.102.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps we could come up with a minimal testcase and put it on local, would like to leave the decision to the maintainers.

Copy link
Member

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

Thank you! Almost LGTM.
There is a lint error, so please fix it.


kustomizePath, _, err := toolregistry.DefaultRegistry().Kustomize(ctx, "")
require.NoError(t, err)
helmPath, _, err := toolregistry.DefaultRegistry().Helm(ctx, "")
Copy link
Member

Choose a reason for hiding this comment

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

Please check the error is nil?

Suggested change
helmPath, _, err := toolregistry.DefaultRegistry().Helm(ctx, "")
helmPath, _, err := toolregistry.DefaultRegistry().Helm(ctx, "")
require.NoError(t, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugh, fixed in e8860e1 (#5636)!

Signed-off-by: Yuki Okushi <okushi@canary-inc.jp>
Copy link
Member

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

Sorry, I overlooked the version comparison issue.

// Pass the Helm command path to kustomize to use the specified version of Helm.
// Unconditionally adding this flag as it's unharmful when Helm is not used.
// Note: It's only available on Kustomize v4.1.0 and higher.
if c.version >= "4.1.0" && helm != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I apologize for overlooking this version comparison issue.
We cannot compare semantic versions by simply comparing strings. For instance, versions greater than or equal to 10 are incorrectly evaluated as less than 9.
Could you please implement a feature to compare semantic versions and include corresponding tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right.
Fixed and added tests in 84bfe4d (#5636)

Signed-off-by: Yuki Okushi <okushi@canary-inc.jp>
Copy link
Member

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM

@Warashi Warashi enabled auto-merge (squash) March 11, 2025 00:07
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

Great! LGTM!

@Warashi Warashi merged commit 563d0b6 into pipe-cd:master Mar 11, 2025
15 checks passed
@JohnTitor JohnTitor deleted the fix/pass-helm-cmd-on-kustomize-build branch March 11, 2025 05:46
@github-actions github-actions bot mentioned this pull request Mar 25, 2025
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.

specifying Helm version doesn't seem to be used in plan-preview

4 participants