From 0f44cfacc431b228dda1b380c4753d8be52106f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lassi=20P=C3=B6l=C3=B6nen?= Date: Sat, 12 Nov 2022 01:59:56 +0200 Subject: [PATCH] Add the ability to specify a lock file (#432) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow configuring the lockfile in the state. This makes it possible for example maintain a lock per environment. Signed-off-by: Lassi Pölönen Signed-off-by: Lassi Pölönen --- docs/advanced-features.md | 18 +++++++ docs/index.md | 6 +++ pkg/app/desired_state_file_loader.go | 4 +- pkg/state/chart_dependency.go | 29 +++++++---- pkg/state/create.go | 8 ++- pkg/state/create_test.go | 6 +-- pkg/state/state.go | 2 + pkg/state/state_test.go | 50 +++++++++++++++++++ test/e2e/template/helmfile/snapshot_test.go | 24 ++++++--- .../charts/{raw => raw-0.0.1}/.gitignore | 0 .../charts/{raw => raw-0.0.1}/.helmignore | 0 .../testdata/charts/raw-0.0.1/Chart.yaml | 6 +++ .../testdata/charts/raw-0.0.1/README.md | 1 + .../templates/resources.yaml | 0 .../charts/{raw => raw-0.0.1}/values.yaml | 0 .../testdata/charts/raw-0.1.0/.gitignore | 1 + .../testdata/charts/raw-0.1.0/.helmignore | 23 +++++++++ .../charts/{raw => raw-0.1.0}/Chart.yaml | 0 .../charts/{raw => raw-0.1.0}/README.md | 0 .../charts/raw-0.1.0/templates/resources.yaml | 6 +++ .../testdata/charts/raw-0.1.0/values.yaml | 48 ++++++++++++++++++ .../testdata/snapshot/chart_need/input.yaml | 2 +- .../chart_need_enable_live_output/input.yaml | 2 +- .../testdata/snapshot/oci_need/input.yaml | 2 +- .../snapshot/templated_lockfile/config.yaml | 8 +++ .../snapshot/templated_lockfile/input.yaml | 18 +++++++ .../snapshot/templated_lockfile/output.yaml | 8 +++ .../templated_lockfile/test-lock-file-prod | 7 +++ 28 files changed, 254 insertions(+), 25 deletions(-) rename test/e2e/template/helmfile/testdata/charts/{raw => raw-0.0.1}/.gitignore (100%) rename test/e2e/template/helmfile/testdata/charts/{raw => raw-0.0.1}/.helmignore (100%) create mode 100644 test/e2e/template/helmfile/testdata/charts/raw-0.0.1/Chart.yaml create mode 100644 test/e2e/template/helmfile/testdata/charts/raw-0.0.1/README.md rename test/e2e/template/helmfile/testdata/charts/{raw => raw-0.0.1}/templates/resources.yaml (100%) rename test/e2e/template/helmfile/testdata/charts/{raw => raw-0.0.1}/values.yaml (100%) create mode 100644 test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.gitignore create mode 100644 test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.helmignore rename test/e2e/template/helmfile/testdata/charts/{raw => raw-0.1.0}/Chart.yaml (100%) rename test/e2e/template/helmfile/testdata/charts/{raw => raw-0.1.0}/README.md (100%) create mode 100644 test/e2e/template/helmfile/testdata/charts/raw-0.1.0/templates/resources.yaml create mode 100644 test/e2e/template/helmfile/testdata/charts/raw-0.1.0/values.yaml create mode 100644 test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/config.yaml create mode 100644 test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/input.yaml create mode 100644 test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/output.yaml create mode 100644 test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/test-lock-file-prod diff --git a/docs/advanced-features.md b/docs/advanced-features.md index 16c561a2..3b335237 100644 --- a/docs/advanced-features.md +++ b/docs/advanced-features.md @@ -312,3 +312,21 @@ releases: - chart: oci://my-oci-registry/helm-repo/envoy version: 1.5 ``` + +### Lockfile per environment + +In some cases it can be handy for CI/CD pipelines to be able to roll out updates gradually for environments, such as staging and production while using the same +set of charts. This can be achieved by using `lockFilePath` in combination with environments, such as: + +```yaml +environments: + staging: + production + +--- +lockFilePath: .helmfile.{{ .Environment.Name}}.lock + +releases: +- name: myapp + chart: charts/myapp +``` diff --git a/docs/index.md b/docs/index.md index caacff2c..7604c80f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -169,6 +169,10 @@ repositories: # Path to alternative helm binary (--helm-binary) helmBinary: path/to/helm3 + +# Path to alternative lock file. The default is .lock, i.e for helmfile.yaml it's helmfile.lock. +lockFilePath: path/to/lock.file + # Default values to set for args along with dedicated keys that can be set by contributors, cli args take precedence over these. # In other words, unset values results in no flags passed to helm. # See the helm usage (helm SUBCOMMAND -h) for more info on default values when those flags aren't provided. @@ -568,6 +572,8 @@ All the other `helmfile` sub-commands like `sync` use chart versions recorded in For example, the lock file for a helmfile state file named `helmfile.1.yaml` will be `helmfile.1.lock`. The lock file for a local chart would be `requirements.lock`, which is the same as `helm`. +The lock file can be changed using `lockFilePath` in helm state, which makes it possible to for example have a different lock file per environment via templating. + It is recommended to version-control all the lock files, so that they can be used in the production deployment pipeline for extra reproducibility. To bring in chart updates systematically, it would also be a good idea to run `helmfile deps` regularly, test it, and then update the lock files in the version-control system. diff --git a/pkg/app/desired_state_file_loader.go b/pkg/app/desired_state_file_loader.go index 719e01de..efa91994 100644 --- a/pkg/app/desired_state_file_loader.go +++ b/pkg/app/desired_state_file_loader.go @@ -36,6 +36,8 @@ type desiredStateLoader struct { remote *remote.Remote logger *zap.SugaredLogger valsRuntime vals.Evaluator + + lockFilePath string } func (ld *desiredStateLoader) Load(f string, opts LoadOpts) (*state.HelmState, error) { @@ -163,7 +165,7 @@ func (ld *desiredStateLoader) loadFileWithOverrides(inheritedEnv, overrodeEnv *e } func (a *desiredStateLoader) underlying() *state.StateCreator { - c := state.NewCreator(a.logger, a.fs, a.valsRuntime, a.getHelm, a.overrideHelmBinary, a.remote, a.enableLiveOutput) + c := state.NewCreator(a.logger, a.fs, a.valsRuntime, a.getHelm, a.overrideHelmBinary, a.remote, a.enableLiveOutput, a.lockFilePath) c.LoadFile = a.loadFile return c } diff --git a/pkg/state/chart_dependency.go b/pkg/state/chart_dependency.go index 66023bd2..515d3c9b 100644 --- a/pkg/state/chart_dependency.go +++ b/pkg/state/chart_dependency.go @@ -145,7 +145,7 @@ func (st *HelmState) mergeLockedDependencies() (*HelmState, error) { return st, nil } - depMan := NewChartDependencyManager(filename, st.logger) + depMan := NewChartDependencyManager(filename, st.logger, st.LockFile) if st.fs.ReadFile != nil { depMan.readFile = st.fs.ReadFile @@ -258,7 +258,7 @@ func getUnresolvedDependenciess(st *HelmState) (string, *UnresolvedDependencies, } func updateDependencies(st *HelmState, shell helmexec.DependencyUpdater, unresolved *UnresolvedDependencies, filename, wd string) (*HelmState, error) { - depMan := NewChartDependencyManager(filename, st.logger) + depMan := NewChartDependencyManager(filename, st.logger, st.LockFile) _, err := depMan.Update(shell, wd, unresolved) if err != nil { @@ -271,6 +271,8 @@ func updateDependencies(st *HelmState, shell helmexec.DependencyUpdater, unresol type chartDependencyManager struct { Name string + lockFilePath string + logger *zap.SugaredLogger readFile func(string) ([]byte, error) @@ -278,17 +280,22 @@ type chartDependencyManager struct { } // nolint: golint -func NewChartDependencyManager(name string, logger *zap.SugaredLogger) *chartDependencyManager { +func NewChartDependencyManager(name string, logger *zap.SugaredLogger, lockFilePath string) *chartDependencyManager { return &chartDependencyManager{ - Name: name, - readFile: os.ReadFile, - writeFile: os.WriteFile, - logger: logger, + Name: name, + readFile: os.ReadFile, + writeFile: os.WriteFile, + logger: logger, + lockFilePath: lockFilePath, } } func (m *chartDependencyManager) lockFileName() string { - return fmt.Sprintf("%s.lock", m.Name) + if m.lockFilePath != "" { + return m.lockFilePath + } else { + return fmt.Sprintf("%s.lock", m.Name) + } } func (m *chartDependencyManager) Update(shell helmexec.DependencyUpdater, wd string, unresolved *UnresolvedDependencies) (*ResolvedDependencies, error) { @@ -334,9 +341,9 @@ func (m *chartDependencyManager) updateHelm2(shell helmexec.DependencyUpdater, w func (m *chartDependencyManager) doUpdate(chartLockFile string, unresolved *UnresolvedDependencies, shell helmexec.DependencyUpdater, wd string) (*ResolvedDependencies, error) { // Generate `requirements.lock` of the temporary local chart by coping `.lock` - lockFile := m.lockFileName() + lockFilePath := m.lockFileName() - originalLockFileContent, err := m.readBytes(lockFile) + originalLockFileContent, err := m.readBytes(lockFilePath) if err != nil && !os.IsNotExist(err) { return nil, err } @@ -394,7 +401,7 @@ func (m *chartDependencyManager) doUpdate(chartLockFile string, unresolved *Unre } // Commit the lock file if and only if everything looks ok - if err := m.writeBytes(lockFile, updatedLockFileContent); err != nil { + if err := m.writeBytes(lockFilePath, updatedLockFileContent); err != nil { return nil, err } diff --git a/pkg/state/create.go b/pkg/state/create.go index 85eee473..3aa02201 100644 --- a/pkg/state/create.go +++ b/pkg/state/create.go @@ -58,9 +58,11 @@ type StateCreator struct { enableLiveOutput bool remote *remote.Remote + + lockFile string } -func NewCreator(logger *zap.SugaredLogger, fs *filesystem.FileSystem, valsRuntime vals.Evaluator, getHelm func(*HelmState) helmexec.Interface, overrideHelmBinary string, remote *remote.Remote, enableLiveOutput bool) *StateCreator { +func NewCreator(logger *zap.SugaredLogger, fs *filesystem.FileSystem, valsRuntime vals.Evaluator, getHelm func(*HelmState) helmexec.Interface, overrideHelmBinary string, remote *remote.Remote, enableLiveOutput bool, lockFile string) *StateCreator { return &StateCreator{ logger: logger, @@ -73,6 +75,8 @@ func NewCreator(logger *zap.SugaredLogger, fs *filesystem.FileSystem, valsRuntim enableLiveOutput: enableLiveOutput, remote: remote, + + lockFile: lockFile, } } @@ -84,6 +88,8 @@ func (c *StateCreator) Parse(content []byte, baseDir, file string) (*HelmState, state.FilePath = file state.basePath = baseDir + state.LockFile = c.lockFile + decoder := yaml.NewDecoder(bytes.NewReader(content)) decoder.KnownFields(c.Strict) diff --git a/pkg/state/create_test.go b/pkg/state/create_test.go index 18a1ab70..d60fde85 100644 --- a/pkg/state/create_test.go +++ b/pkg/state/create_test.go @@ -83,7 +83,7 @@ func (testEnv stateTestEnv) MustLoadStateWithEnableLiveOutput(t *testing.T, file } r := remote.NewRemote(logger, testFs.Cwd, testFs.ToFileSystem()) - state, err := NewCreator(logger, testFs.ToFileSystem(), nil, nil, "", r, enableLiveOutput). + state, err := NewCreator(logger, testFs.ToFileSystem(), nil, nil, "", r, enableLiveOutput, ""). ParseAndLoad([]byte(yamlContent), filepath.Dir(file), file, envName, true, nil) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -153,7 +153,7 @@ releaseNamespace: mynamespace env := environment.Environment{ Name: "production", } - state, err := NewCreator(logger, testFs.ToFileSystem(), nil, nil, "", r, false). + state, err := NewCreator(logger, testFs.ToFileSystem(), nil, nil, "", r, false, ""). ParseAndLoad(yamlContent, filepath.Dir(yamlFile), yamlFile, "production", true, &env) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -240,7 +240,7 @@ overrideNamespace: myns testFs.Cwd = "/example/path/to" r := remote.NewRemote(logger, testFs.Cwd, testFs.ToFileSystem()) - state, err := NewCreator(logger, testFs.ToFileSystem(), nil, nil, "", r, false). + state, err := NewCreator(logger, testFs.ToFileSystem(), nil, nil, "", r, false, ""). ParseAndLoad(yamlContent, filepath.Dir(yamlFile), yamlFile, "production", true, nil) if err != nil { t.Fatalf("unexpected error: %v", err) diff --git a/pkg/state/state.go b/pkg/state/state.go index 388b9a95..fcfc63d5 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -79,6 +79,8 @@ type ReleaseSetSpec struct { // non-existent path. The default behavior is to print a warning. Note the // differing default compared to other MissingFileHandlers. MissingFileHandler string `yaml:"missingFileHandler,omitempty"` + + LockFile string `yaml:"lockFilePath,omitempty"` } // HelmState structure for the helmfile diff --git a/pkg/state/state_test.go b/pkg/state/state_test.go index ef6223a7..0765e9dd 100644 --- a/pkg/state/state_test.go +++ b/pkg/state/state_test.go @@ -2030,6 +2030,56 @@ func TestHelmState_ResolveDeps_NoLockFile(t *testing.T) { } } +func TestHelmState_ResolveDeps_NoLockFile_WithCustomLockFile(t *testing.T) { + logger := helmexec.NewLogger(io.Discard, "debug") + state := &HelmState{ + basePath: "/src", + FilePath: "/src/helmfile.yaml", + ReleaseSetSpec: ReleaseSetSpec{ + LockFile: "custom-lock-file", + Releases: []ReleaseSpec{ + { + Chart: "./..", + }, + { + Chart: "../examples", + }, + { + Chart: "../../helmfile", + }, + { + Chart: "published", + }, + { + Chart: "published/deeper", + }, + { + Chart: "stable/envoy", + }, + }, + Repositories: []RepositorySpec{ + { + Name: "stable", + URL: "https://kubernetes-charts.storage.googleapis.com", + }, + }, + }, + logger: logger, + fs: &filesystem.FileSystem{ + ReadFile: func(f string) ([]byte, error) { + if f != "custom-lock-file" { + return nil, fmt.Errorf("stub: unexpected file: %s", f) + } + return nil, os.ErrNotExist + }, + }, + } + + _, err := state.ResolveDeps() + if err != nil { + t.Errorf("unexpected error: %v", err) + } +} func TestHelmState_ReleaseStatuses(t *testing.T) { tests := []struct { name string diff --git a/test/e2e/template/helmfile/snapshot_test.go b/test/e2e/template/helmfile/snapshot_test.go index cc94e0c3..571cf853 100644 --- a/test/e2e/template/helmfile/snapshot_test.go +++ b/test/e2e/template/helmfile/snapshot_test.go @@ -134,13 +134,8 @@ func TestHelmfileTemplateWithBuildCommand(t *testing.T) { if !c.IsDir() { t.Fatalf("%s is not a directory", c) } + chartName, chartVersion := execHelmShowChart(t, chartPath) tgzFile := execHelmPackage(t, chartPath) - - // Extract chart version from the name of chart package archival - chartName := c.Name() - chartNameWithVersion := strings.TrimSuffix(filepath.Base(tgzFile), filepath.Ext(tgzFile)) - chartVersion := strings.TrimPrefix(chartNameWithVersion, fmt.Sprintf("%s-", chartName)) - chartDigest, err := execHelmPush(t, tgzFile, fmt.Sprintf("oci://localhost:%d/myrepo", hostPort)) require.NoError(t, err, "Unable to run helm push to local registry: %v", err) @@ -235,6 +230,23 @@ func execDocker(t *testing.T, args ...string) { } } +func execHelmShowChart(t *testing.T, localChart string) (string, string) { + t.Helper() + + name, version := "", "" + out := execHelm(t, "show", "chart", localChart) + sc := bufio.NewScanner(strings.NewReader(out)) + for sc.Scan() { + if strings.HasPrefix(sc.Text(), "name:") { + name = strings.TrimPrefix(sc.Text(), "name: ") + } + if strings.HasPrefix(sc.Text(), "version:") { + version = strings.TrimPrefix(sc.Text(), "version: ") + } + } + return name, version +} + func execHelmPackage(t *testing.T, localChart string) string { t.Helper() diff --git a/test/e2e/template/helmfile/testdata/charts/raw/.gitignore b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/.gitignore similarity index 100% rename from test/e2e/template/helmfile/testdata/charts/raw/.gitignore rename to test/e2e/template/helmfile/testdata/charts/raw-0.0.1/.gitignore diff --git a/test/e2e/template/helmfile/testdata/charts/raw/.helmignore b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/.helmignore similarity index 100% rename from test/e2e/template/helmfile/testdata/charts/raw/.helmignore rename to test/e2e/template/helmfile/testdata/charts/raw-0.0.1/.helmignore diff --git a/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/Chart.yaml b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/Chart.yaml new file mode 100644 index 00000000..5a3b7362 --- /dev/null +++ b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: raw +description: A Helm chart for Kubernetes +type: application +version: 0.0.1 +appVersion: "1.16.0" diff --git a/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/README.md b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/README.md new file mode 100644 index 00000000..4e55030b --- /dev/null +++ b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/README.md @@ -0,0 +1 @@ +A copy of chart ../raw, but older version to test locking. diff --git a/test/e2e/template/helmfile/testdata/charts/raw/templates/resources.yaml b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/templates/resources.yaml similarity index 100% rename from test/e2e/template/helmfile/testdata/charts/raw/templates/resources.yaml rename to test/e2e/template/helmfile/testdata/charts/raw-0.0.1/templates/resources.yaml diff --git a/test/e2e/template/helmfile/testdata/charts/raw/values.yaml b/test/e2e/template/helmfile/testdata/charts/raw-0.0.1/values.yaml similarity index 100% rename from test/e2e/template/helmfile/testdata/charts/raw/values.yaml rename to test/e2e/template/helmfile/testdata/charts/raw-0.0.1/values.yaml diff --git a/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.gitignore b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.gitignore new file mode 100644 index 00000000..aa1ec1ea --- /dev/null +++ b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.gitignore @@ -0,0 +1 @@ +*.tgz diff --git a/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.helmignore b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/test/e2e/template/helmfile/testdata/charts/raw/Chart.yaml b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/Chart.yaml similarity index 100% rename from test/e2e/template/helmfile/testdata/charts/raw/Chart.yaml rename to test/e2e/template/helmfile/testdata/charts/raw-0.1.0/Chart.yaml diff --git a/test/e2e/template/helmfile/testdata/charts/raw/README.md b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/README.md similarity index 100% rename from test/e2e/template/helmfile/testdata/charts/raw/README.md rename to test/e2e/template/helmfile/testdata/charts/raw-0.1.0/README.md diff --git a/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/templates/resources.yaml b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/templates/resources.yaml new file mode 100644 index 00000000..422d2bfd --- /dev/null +++ b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/templates/resources.yaml @@ -0,0 +1,6 @@ +{{- range $i, $r := $.Values.templates }} +{{- if gt $i 0 }} +--- +{{- end }} +{{- (tpl $r $) }} +{{- end }} diff --git a/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/values.yaml b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/values.yaml new file mode 100644 index 00000000..b761f2f6 --- /dev/null +++ b/test/e2e/template/helmfile/testdata/charts/raw-0.1.0/values.yaml @@ -0,0 +1,48 @@ +templates: [] + +## +## Example: Uncomment the below and run `helm template ./`: +## +# +# templates: +# - | +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: {{ .Release.Name }}-1 +# namespace: {{ .Release.Namespace }} +# data: +# foo: {{ .Values.foo }} +# - | +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: {{ .Release.Name }}-2 +# namespace: {{ .Release.Namespace }} +# data: +# foo: {{ .Values.foo }} +# values: +# foo: FOO +# +## +## Expected Output: +## +# +# --- +# # Source: raw/templates/resources.yaml +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: release-name-1 +# namespace: default +# data: +# foo: +# --- +# # Source: raw/templates/resources.yaml +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: release-name-2 +# namespace: default +# data: +# foo: diff --git a/test/e2e/template/helmfile/testdata/snapshot/chart_need/input.yaml b/test/e2e/template/helmfile/testdata/snapshot/chart_need/input.yaml index 13fd58a0..b37a1299 100644 --- a/test/e2e/template/helmfile/testdata/snapshot/chart_need/input.yaml +++ b/test/e2e/template/helmfile/testdata/snapshot/chart_need/input.yaml @@ -4,7 +4,7 @@ repositories: releases: - name: foo - chart: ../../charts/raw + chart: ../../charts/raw-0.1.0 values: - templates: - | diff --git a/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/input.yaml b/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/input.yaml index 13fd58a0..b37a1299 100644 --- a/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/input.yaml +++ b/test/e2e/template/helmfile/testdata/snapshot/chart_need_enable_live_output/input.yaml @@ -4,7 +4,7 @@ repositories: releases: - name: foo - chart: ../../charts/raw + chart: ../../charts/raw-0.1.0 values: - templates: - | diff --git a/test/e2e/template/helmfile/testdata/snapshot/oci_need/input.yaml b/test/e2e/template/helmfile/testdata/snapshot/oci_need/input.yaml index 9df3458c..1824b051 100644 --- a/test/e2e/template/helmfile/testdata/snapshot/oci_need/input.yaml +++ b/test/e2e/template/helmfile/testdata/snapshot/oci_need/input.yaml @@ -1,6 +1,6 @@ releases: - name: foo - chart: ../../charts/raw + chart: ../../charts/raw-0.1.0 values: - templates: - | diff --git a/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/config.yaml b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/config.yaml new file mode 100644 index 00000000..3c0659b7 --- /dev/null +++ b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/config.yaml @@ -0,0 +1,8 @@ +localChartRepoServer: + enabled: true + port: 18080 +chartifyTempDir: temp1 +helmfileArgs: +- --environment +- prod +- template diff --git a/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/input.yaml b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/input.yaml new file mode 100644 index 00000000..1ff49e2e --- /dev/null +++ b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/input.yaml @@ -0,0 +1,18 @@ +repositories: +- name: myrepo + url: http://localhost:18080/ + +environments: + prod: + staging: + +--- +lockFilePath: test-lock-file-{{ .Environment.Name }} + +releases: +- name: raw + chart: myrepo/raw + values: + - templates: + - | + chartVersion: {{`{{ .Chart.Version }}`}} diff --git a/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/output.yaml b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/output.yaml new file mode 100644 index 00000000..3fb38130 --- /dev/null +++ b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/output.yaml @@ -0,0 +1,8 @@ +Adding repo myrepo http://localhost:18080/ +"myrepo" has been added to your repositories + +Templating release=raw, chart=myrepo/raw +--- +# Source: raw/templates/resources.yaml +chartVersion: 0.0.1 + diff --git a/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/test-lock-file-prod b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/test-lock-file-prod new file mode 100644 index 00000000..5c044c02 --- /dev/null +++ b/test/e2e/template/helmfile/testdata/snapshot/templated_lockfile/test-lock-file-prod @@ -0,0 +1,7 @@ +version: 0.0.0-dev +dependencies: + - name: raw + repository: http://localhost:18080/ + version: 0.0.1 +digest: sha256:5401817b653c4eeb186cbfbb8d77dda6b72f84a548fc9cd128cbd478d5b2e705 +generated: "2022-10-12T20:17:15.98786845+03:00"