-
Notifications
You must be signed in to change notification settings - Fork 169
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
Allow defining a custom dir for each Helm Chart #706
Conversation
This allows a chartfile to contain multiple versions of the same chart. Example: ```yaml directory: charts repositories: - name: flagger url: https://flagger.app requires: - chart: flagger/flagger directory: flagger-1.16.1 version: 1.16.1 - chart: flagger/flagger directory: flagger-1.21.0 version: 1.21.0 version: 1 ```
@@ -40,18 +26,33 @@ func TestAddRepos(t *testing.T) { | |||
} | |||
|
|||
func TestAdd(t *testing.T) { | |||
c, err := InitChartfile(filepath.Join(t.TempDir(), Filename)) | |||
tempDir := t.TempDir() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests now depend on actual helm pulling the prometheus chart. Since the helm pull
behavior is a bit unusual, I believe that a full test is better than mocking the Helm process
0a2a1f6
to
ba8b817
Compare
4ae3fe5
to
6351ce4
Compare
6351ce4
to
f4e66d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick first round, will circle back later.
// It is not possible to tell `helm pull` to extract to a specific directory | ||
// so we extract to a temp dir and then move the files to the destination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my complete ignorance in regards with Helm, but would --untardir
help for this purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not. It just appends the directory and the untardir together and then also appends the chart's name. Which is completely weird IMO, untardir serves no purpose at all. And it's one of the reasons I decided to actually use Helm in the tests, it tests the unexpected behaviors of the helm
CLI like this
For completeness, I have checked out this branch and run a couple of manual tests, this is pretty neat 👍 ✅ Vendoring 2 different versions of the same chart to 2 different locations:
✅ Vendoring the same version of a chart to the default and a custom locations:
|
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A suggestion for pkg/helm/charts.go
(lines 117 and 120 on the new diff):
log.Printf(" %s@%s exists", r.Chart, r.Version.String())
log.Printf("Removing %s@%s", r.Chart, r.Version.String())
Could we include there r.Directory
?
Currently, on the second scenario described here: #706 (comment)
You get:
$ tk tool charts vendor
Pulling Charts ...
flagger/[email protected] exists
flagger/[email protected] exists
so is not clear to which one is referring to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG2M
pkg/helm/spec.go
Outdated
@@ -64,6 +66,14 @@ type Requirement struct { | |||
Directory string `json:"directory,omitempty"` | |||
} | |||
|
|||
func (r Requirement) String() string { | |||
s := r.Chart + "@" + r.Version.String() | |||
if r.Directory != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We are building Requirement
via parseReq
, which already splits the repo/name from the version. If Requirement would have RepoName and ChartName instead of Chart, we could also infer here the default directory (is ChartName).
directory: charts
repositories:
- name: stable
url: https://charts.helm.sh/stable
- name: flagger
url: https://flagger.app
requires:
- chart: flagger/flagger
version: 1.16.1
version: 1
crates the chart under charts/flagger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, also the call to helm show
I was doing just to get the chart name was unnecessary. Thanks
The chart name is the second part of the chart (repo/name)
This allows a chartfile to contain multiple versions of the same chart.
Example: