-
Notifications
You must be signed in to change notification settings - Fork 270
feat: support helm charts in kustomizations #4582
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
vincent-onebrief
wants to merge
1
commit into
zarf-dev:main
Choose a base branch
from
vincent-onebrief:vincent/kustomize-helm-support
base: main
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 all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // SPDX-FileCopyrightText: 2021-Present The Zarf Authors | ||
|
|
||
| // Package template provides functions for templating yaml files. | ||
| package kustomize | ||
|
|
||
| import ( | ||
| "os" | ||
| "path" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestBuild(t *testing.T) { | ||
| tests := []struct { | ||
| path string | ||
| kustomizeAllowAnyDirectory bool | ||
| enableKustomizePlugins bool | ||
| }{ | ||
| { | ||
| path: path.Join("testdata", "generators"), | ||
| kustomizeAllowAnyDirectory: false, | ||
| enableKustomizePlugins: false, | ||
| }, | ||
| { | ||
| path: path.Join("testdata", "helm"), | ||
| kustomizeAllowAnyDirectory: true, | ||
| enableKustomizePlugins: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| tmpdir := t.TempDir() | ||
|
|
||
| builtManifest := path.Join(tmpdir, "generated.yaml") | ||
|
|
||
| err := Build(test.path, builtManifest, test.kustomizeAllowAnyDirectory, test.enableKustomizePlugins) | ||
| require.NoError(t, err) | ||
| require.FileExists(t, builtManifest, "built manifest file should exist") | ||
|
|
||
| expectedContent, err := os.ReadFile(path.Join(test.path, "expected.yaml")) | ||
| buildContent, err := os.ReadFile(builtManifest) | ||
| require.NoError(t, err) | ||
|
|
||
| require.Equalf(t, expectedContent, buildContent, "Built kustomization should match expected") | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/internal/packager/kustomize/testdata/generators/expected.yaml
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,15 @@ | ||
| apiVersion: v1 | ||
| data: | ||
| key: value | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-t757gk2bmf | ||
| --- | ||
| apiVersion: v1 | ||
| data: | ||
| password: cGFzc3dvcmQ= | ||
| username: dXNlcm5hbWU= | ||
| kind: Secret | ||
| metadata: | ||
| name: auth-m84m9g76mm | ||
| type: Opaque |
9 changes: 9 additions & 0 deletions
9
src/internal/packager/kustomize/testdata/generators/kustomization.yaml
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,9 @@ | ||
| configMapGenerator: | ||
| - name: test | ||
| literals: | ||
| - key=value | ||
| secretGenerator: | ||
| - name: auth | ||
| literals: | ||
| - username=username | ||
| - password=password |
6 changes: 6 additions & 0 deletions
6
src/internal/packager/kustomize/testdata/helm/chart/Chart.yaml
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,6 @@ | ||
| apiVersion: v2 | ||
| name: chart | ||
| description: A Helm chart for Kubernetes | ||
| type: application | ||
| version: 0.0.0 | ||
| appVersion: "0.0.0" |
8 changes: 8 additions & 0 deletions
8
src/internal/packager/kustomize/testdata/helm/chart/templates/pod.yaml
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,8 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: pod | ||
| spec: | ||
| containers: | ||
| - name: busybox | ||
| image: {{ .Values.image.repository }}:{{ .Values.image.tag }} |
3 changes: 3 additions & 0 deletions
3
src/internal/packager/kustomize/testdata/helm/chart/values.yaml
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,3 @@ | ||
| image: | ||
| repository: busybox | ||
| tag: 1.0.0 |
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,8 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: pod | ||
| spec: | ||
| containers: | ||
| - image: busybox:1.0.0 | ||
| name: busybox |
6 changes: 6 additions & 0 deletions
6
src/internal/packager/kustomize/testdata/helm/kustomization.yaml
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,6 @@ | ||
| helmGlobals: | ||
| chartHome: . | ||
| helmCharts: | ||
| - releaseName: chart | ||
| name: chart | ||
| repo: ./chart |
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.
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.
I half wonder if after #4350 is merged we should update this to use
zarf tools helm.Not a blocker, but a potential follow-up pr.
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.
Yeah, #4350 is close but blocked by a bug in Helm that will be fixed in the next Helm release.
I do think we should block this PR on that, the quasi Helm fork currently in Zarf is outdated, and I would like to avoid relying on the host binary, so that package builds are the same across devices