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: Helm deploy was not working with variable templatinging chart path #9600

Merged

Conversation

travishein
Copy link
Contributor

I believe the chartPath property is supposed to be a templatable field.

In my use I have helm charts in a separate git repo from the application where the skaffold.yaml is. We defined a skaffold.env.template file, that we add to git and then on checkout we copy this to skaffold.env and modify as needed, so the path to the location to the other repo with a helm chart is a variable. and this skaffold.env file is added to the .gitignore

We noticed that we were getting
listing files: issue walking releases: lstat {{.HELM_REPO}}/helm/app/chart/path: no such file or directory

This PR fixes this issue.

Fixes: #nnn
Related: Relevant tracking issues, for context
Merge before/after: Dependent or prerequisite PRs

Description

User facing changes (remove if N/A)

Follow-up Work (remove if N/A)

I believe the chartPath property is supposed to be a templatable field.

In my use I have helm charts in a separate git repo from the application where the skaffold.yaml is.
We defined a skaffold.env.template file, that we add to git and then on checkout we copy this to skaffold.env and modify as needed,
so the path to the location to the other repo with a helm chart is a variable. and this skaffold.env file is added to the .gitignore

We noticed that we were getting
listing files: issue walking releases: lstat {{.HELM_REPO}}/helm/app/chart/path: no such file or directory

This PR fixes this issue.
@travishein travishein requested a review from a team as a code owner December 7, 2024 18:34
@travishein travishein requested a review from ChrisGe4 December 7, 2024 18:34
Copy link

google-cla bot commented Dec 7, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

pkg/skaffold/deploy/helm/helm.go Outdated Show resolved Hide resolved
@alphanota alphanota self-assigned this Dec 16, 2024
@travishein travishein requested a review from alphanota January 8, 2025 18:47
Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

Hi team,

I'm currently reviewing this pull request and will provide a full review shortly. In the meantime, here's a quick summary for you and other reviewers to get up to speed:

This pull request, submitted by @travishein, addresses an issue where Helm deployments were failing when using variable templating for the chartPath property. The problem stemmed from the chartPath not being correctly interpreted as a template, leading to errors like lstat {{.HELM_REPO}}/helm/app/chart/path: no such file or directory.

Intent: The primary goal is to enable the use of environment variables within the chartPath setting for Helm deployments, allowing for more flexible chart location management.

Changes:

The core change involves modifying the helm.go file (specifically lines 398-408). The original code directly used the release.ChartPath value, which was not being templated. The updated code now uses util.ExpandEnvTemplateOrFail to expand any environment variables present in release.ChartPath before using it to locate the Helm chart. This ensures that the path is correctly resolved, even if it's defined using variables from a skaffold.env file.

Summary Table:

File Change Summary
pkg/skaffold/deploy/helm/helm.go Added environment variable expansion to release.ChartPath before path traversal.

I'll provide a more detailed review shortly, including a check for potential edge cases and thorough testing.


And now, a little haiku to lighten the mood:

Paths once unclear,
Now templated, bright and bold,
Skaffold builds anew.

Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

This change correctly addresses the issue of the chartPath not being templatable by expanding the environment variable. The implementation is good, but a couple of minor suggestions for improved readability and a potential performance enhancement are included below.

@alphanota alphanota merged commit 06d20b8 into GoogleContainerTools:main Jan 14, 2025
11 checks passed
alphanota pushed a commit to alphanota/skaffold that referenced this pull request Jan 14, 2025
…th (GoogleContainerTools#9600)

* fix: Helm deployer was not working with variable templatingin chartPath

I believe the chartPath property is supposed to be a templatable field.

In my use I have helm charts in a separate git repo from the application where the skaffold.yaml is.
We defined a skaffold.env.template file, that we add to git and then on checkout we copy this to skaffold.env and modify as needed,
so the path to the location to the other repo with a helm chart is a variable. and this skaffold.env file is added to the .gitignore

We noticed that we were getting
listing files: issue walking releases: lstat {{.HELM_REPO}}/helm/app/chart/path: no such file or directory

This PR fixes this issue.

* fix: lint warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants