mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-09 11:35:51 +02:00
Merge branch 'main' into update_golang_lint
This commit is contained in:
+1
-1
@@ -987,7 +987,7 @@ func (a *App) visitStatesWithSelectorsAndRemoteSupport(fileOrDir string, converg
|
||||
envvals = append(envvals, v)
|
||||
}
|
||||
|
||||
if a.Set != nil {
|
||||
if len(a.Set) > 0 {
|
||||
envvals = append(envvals, a.Set)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/variantdev/vals"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||
"github.com/helmfile/helmfile/pkg/testhelper"
|
||||
"github.com/helmfile/helmfile/pkg/testutil"
|
||||
)
|
||||
|
||||
func TestListWithEnvironment(t *testing.T) {
|
||||
type testcase struct {
|
||||
environment string
|
||||
ns string
|
||||
error string
|
||||
selectors []string
|
||||
expected string
|
||||
}
|
||||
|
||||
check := func(t *testing.T, tc testcase) {
|
||||
t.Helper()
|
||||
|
||||
bs := &bytes.Buffer{}
|
||||
|
||||
func() {
|
||||
t.Helper()
|
||||
|
||||
logReader, logWriter := io.Pipe()
|
||||
|
||||
logFlushed := &sync.WaitGroup{}
|
||||
// Ensure all the log is consumed into `bs` by calling `logWriter.Close()` followed by `logFlushed.Wait()`
|
||||
logFlushed.Add(1)
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(logReader)
|
||||
for scanner.Scan() {
|
||||
bs.Write(scanner.Bytes())
|
||||
bs.WriteString("\n")
|
||||
}
|
||||
logFlushed.Done()
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
// This is here to avoid data-trace on bytes buffer `bs` to capture logs
|
||||
if err := logWriter.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logFlushed.Wait()
|
||||
}()
|
||||
|
||||
logger := helmexec.NewLogger(logWriter, "debug")
|
||||
|
||||
valsRuntime, err := vals.New(vals.Options{CacheSize: 32})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error creating vals runtime: %v", err)
|
||||
}
|
||||
|
||||
files := map[string]string{
|
||||
"/path/to/helmfile.d/helmfile_1.yaml": `
|
||||
environments:
|
||||
development: {}
|
||||
shared: {}
|
||||
|
||||
releases:
|
||||
- name: logging
|
||||
chart: incubator/raw
|
||||
namespace: kube-system
|
||||
|
||||
- name: kubernetes-external-secrets
|
||||
chart: incubator/raw
|
||||
namespace: kube-system
|
||||
needs:
|
||||
- kube-system/logging
|
||||
|
||||
- name: external-secrets
|
||||
chart: incubator/raw
|
||||
namespace: default
|
||||
labels:
|
||||
app: test
|
||||
needs:
|
||||
- kube-system/kubernetes-external-secrets
|
||||
|
||||
- name: my-release
|
||||
chart: incubator/raw
|
||||
namespace: default
|
||||
labels:
|
||||
app: test
|
||||
needs:
|
||||
- default/external-secrets
|
||||
|
||||
|
||||
# Disabled releases are treated as missing
|
||||
- name: disabled
|
||||
chart: incubator/raw
|
||||
namespace: kube-system
|
||||
installed: false
|
||||
|
||||
- name: test2
|
||||
chart: incubator/raw
|
||||
needs:
|
||||
- kube-system/disabled
|
||||
|
||||
- name: test3
|
||||
chart: incubator/raw
|
||||
needs:
|
||||
- test2
|
||||
`,
|
||||
"/path/to/helmfile.d/helmfile_2.yaml": `
|
||||
environments:
|
||||
test: {}
|
||||
shared: {}
|
||||
|
||||
repositories:
|
||||
- name: bitnami
|
||||
url: https://charts.bitnami.com/bitnami
|
||||
|
||||
releases:
|
||||
- name: cache
|
||||
namespace: my-app
|
||||
chart: bitnami/redis
|
||||
version: 17.0.7
|
||||
labels:
|
||||
app: test
|
||||
|
||||
- name: database
|
||||
namespace: my-app
|
||||
chart: bitnami/postgres
|
||||
version: 11.6.22
|
||||
`,
|
||||
"/path/to/helmfile.d/helmfile_3.yaml": `
|
||||
releases:
|
||||
- name: global
|
||||
chart: incubator/raw
|
||||
namespace: kube-system
|
||||
`,
|
||||
}
|
||||
|
||||
app := appWithFs(&App{
|
||||
OverrideHelmBinary: DefaultHelmBinary,
|
||||
glob: filepath.Glob,
|
||||
abs: filepath.Abs,
|
||||
OverrideKubeContext: "default",
|
||||
Env: tc.environment,
|
||||
Logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
}, files)
|
||||
|
||||
expectNoCallsToHelm(app)
|
||||
|
||||
if tc.ns != "" {
|
||||
app.Namespace = tc.ns
|
||||
}
|
||||
|
||||
if tc.selectors != nil {
|
||||
app.Selectors = tc.selectors
|
||||
}
|
||||
|
||||
var listErr error
|
||||
out := testutil.CaptureStdout(func() {
|
||||
listErr = app.ListReleases(configImpl{})
|
||||
})
|
||||
|
||||
var gotErr string
|
||||
if listErr != nil {
|
||||
gotErr = listErr.Error()
|
||||
}
|
||||
|
||||
if d := cmp.Diff(tc.error, gotErr); d != "" {
|
||||
t.Fatalf("unexpected error: want (-), got (+): %s", d)
|
||||
}
|
||||
|
||||
assert.Equal(t, tc.expected, out)
|
||||
}()
|
||||
|
||||
testhelper.RequireLog(t, "app_list_test", bs)
|
||||
}
|
||||
|
||||
t.Run("default environment includes all releases", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
environment: "default",
|
||||
expected: `NAME NAMESPACE ENABLED INSTALLED LABELS CHART VERSION
|
||||
logging kube-system true true incubator/raw
|
||||
kubernetes-external-secrets kube-system true true incubator/raw
|
||||
external-secrets default true true app:test incubator/raw
|
||||
my-release default true true app:test incubator/raw
|
||||
disabled kube-system true false incubator/raw
|
||||
test2 true true incubator/raw
|
||||
test3 true true incubator/raw
|
||||
cache my-app true true app:test bitnami/redis 17.0.7
|
||||
database my-app true true bitnami/postgres 11.6.22
|
||||
global kube-system true true incubator/raw
|
||||
`,
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("fail on unknown environment", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
environment: "staging",
|
||||
error: `err: no releases found that matches specified selector() and environment(staging), in any helmfile`,
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("list releases matching selector and environment", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
environment: "development",
|
||||
selectors: []string{"app=test"},
|
||||
expected: `NAME NAMESPACE ENABLED INSTALLED LABELS CHART VERSION
|
||||
external-secrets default true true app:test,chart:raw,name:external-secrets,namespace:default incubator/raw
|
||||
my-release default true true app:test,chart:raw,name:my-release,namespace:default incubator/raw
|
||||
`,
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("filters releases for environment used in one file only", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
environment: "test",
|
||||
expected: `NAME NAMESPACE ENABLED INSTALLED LABELS CHART VERSION
|
||||
cache my-app true true app:test bitnami/redis 17.0.7
|
||||
database my-app true true bitnami/postgres 11.6.22
|
||||
`,
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("filters releases for environment used in multiple files", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
environment: "shared",
|
||||
// 'global' release has no environments, so is still excluded
|
||||
expected: `NAME NAMESPACE ENABLED INSTALLED LABELS CHART VERSION
|
||||
logging kube-system true true incubator/raw
|
||||
kubernetes-external-secrets kube-system true true incubator/raw
|
||||
external-secrets default true true app:test incubator/raw
|
||||
my-release default true true app:test incubator/raw
|
||||
disabled kube-system true false incubator/raw
|
||||
test2 true true incubator/raw
|
||||
test3 true true incubator/raw
|
||||
cache my-app true true app:test bitnami/redis 17.0.7
|
||||
database my-app true true bitnami/postgres 11.6.22
|
||||
`,
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -34,6 +34,12 @@ func appWithFs(app *App, files map[string]string) *App {
|
||||
}
|
||||
|
||||
func injectFs(app *App, fs *testhelper.TestFs) *App {
|
||||
if app.Set == nil {
|
||||
// Consistent behavior with NewGlobalImpl.
|
||||
// Doesn't really belong here, but simplest place for it until some refactoring happens
|
||||
app.Set = make(map[string]interface{})
|
||||
}
|
||||
|
||||
app.readFile = fs.ReadFile
|
||||
app.glob = fs.Glob
|
||||
app.abs = fs.Abs
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
processing file "helmfile_1.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_1.yaml.part.0": inherited=&{default map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{default map[] map[]}
|
||||
first-pass rendering output of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
first-pass produced: &{default map[] map[]}
|
||||
first-pass rendering result of "helmfile_1.yaml.part.0": {default map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
merged environment: &{default map[] map[]}
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_2.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_2.yaml.part.0": inherited=&{default map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{default map[] map[]}
|
||||
first-pass rendering output of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
first-pass produced: &{default map[] map[]}
|
||||
first-pass rendering result of "helmfile_2.yaml.part.0": {default map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
merged environment: &{default map[] map[]}
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_3.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_3.yaml.part.0": inherited=&{default map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{default map[] map[]}
|
||||
first-pass rendering output of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
first-pass produced: &{default map[] map[]}
|
||||
first-pass rendering result of "helmfile_3.yaml.part.0": {default map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
merged environment: &{default map[] map[]}
|
||||
changing working directory back to "/path/to"
|
||||
@@ -0,0 +1,196 @@
|
||||
processing file "helmfile_1.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_1.yaml.part.0": inherited=&{staging map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{staging map[] map[]}
|
||||
first-pass rendering output of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
first-pass produced: &{staging map[] map[]}
|
||||
first-pass rendering result of "helmfile_1.yaml.part.0": {staging map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_2.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_2.yaml.part.0": inherited=&{staging map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{staging map[] map[]}
|
||||
first-pass rendering output of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
first-pass produced: &{staging map[] map[]}
|
||||
first-pass rendering result of "helmfile_2.yaml.part.0": {staging map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_3.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_3.yaml.part.0": inherited=&{staging map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{staging map[] map[]}
|
||||
first-pass rendering output of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
first-pass produced: &{staging map[] map[]}
|
||||
first-pass rendering result of "helmfile_3.yaml.part.0": {staging map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
processing file "helmfile_1.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_1.yaml.part.0": inherited=&{shared map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{shared map[] map[]}
|
||||
first-pass rendering output of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
first-pass produced: &{shared map[] map[]}
|
||||
first-pass rendering result of "helmfile_1.yaml.part.0": {shared map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
merged environment: &{shared map[] map[]}
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_2.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_2.yaml.part.0": inherited=&{shared map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{shared map[] map[]}
|
||||
first-pass rendering output of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
first-pass produced: &{shared map[] map[]}
|
||||
first-pass rendering result of "helmfile_2.yaml.part.0": {shared map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
merged environment: &{shared map[] map[]}
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_3.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_3.yaml.part.0": inherited=&{shared map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{shared map[] map[]}
|
||||
first-pass rendering output of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
first-pass produced: &{shared map[] map[]}
|
||||
first-pass rendering result of "helmfile_3.yaml.part.0": {shared map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
processing file "helmfile_1.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_1.yaml.part.0": inherited=&{test map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{test map[] map[]}
|
||||
first-pass rendering output of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
first-pass produced: &{test map[] map[]}
|
||||
first-pass rendering result of "helmfile_1.yaml.part.0": {test map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_2.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_2.yaml.part.0": inherited=&{test map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{test map[] map[]}
|
||||
first-pass rendering output of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
first-pass produced: &{test map[] map[]}
|
||||
first-pass rendering result of "helmfile_2.yaml.part.0": {test map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
merged environment: &{test map[] map[]}
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_3.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_3.yaml.part.0": inherited=&{test map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{test map[] map[]}
|
||||
first-pass rendering output of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
first-pass produced: &{test map[] map[]}
|
||||
first-pass rendering result of "helmfile_3.yaml.part.0": {test map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
processing file "helmfile_1.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_1.yaml.part.0": inherited=&{development map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{development map[] map[]}
|
||||
first-pass rendering output of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
first-pass produced: &{development map[] map[]}
|
||||
first-pass rendering result of "helmfile_1.yaml.part.0": {development map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_1.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: development: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: releases:
|
||||
6: - name: logging
|
||||
7: chart: incubator/raw
|
||||
8: namespace: kube-system
|
||||
9:
|
||||
10: - name: kubernetes-external-secrets
|
||||
11: chart: incubator/raw
|
||||
12: namespace: kube-system
|
||||
13: needs:
|
||||
14: - kube-system/logging
|
||||
15:
|
||||
16: - name: external-secrets
|
||||
17: chart: incubator/raw
|
||||
18: namespace: default
|
||||
19: labels:
|
||||
20: app: test
|
||||
21: needs:
|
||||
22: - kube-system/kubernetes-external-secrets
|
||||
23:
|
||||
24: - name: my-release
|
||||
25: chart: incubator/raw
|
||||
26: namespace: default
|
||||
27: labels:
|
||||
28: app: test
|
||||
29: needs:
|
||||
30: - default/external-secrets
|
||||
31:
|
||||
32:
|
||||
33: # Disabled releases are treated as missing
|
||||
34: - name: disabled
|
||||
35: chart: incubator/raw
|
||||
36: namespace: kube-system
|
||||
37: installed: false
|
||||
38:
|
||||
39: - name: test2
|
||||
40: chart: incubator/raw
|
||||
41: needs:
|
||||
42: - kube-system/disabled
|
||||
43:
|
||||
44: - name: test3
|
||||
45: chart: incubator/raw
|
||||
46: needs:
|
||||
47: - test2
|
||||
48:
|
||||
|
||||
merged environment: &{development map[] map[]}
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_2.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_2.yaml.part.0": inherited=&{development map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{development map[] map[]}
|
||||
first-pass rendering output of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
first-pass produced: &{development map[] map[]}
|
||||
first-pass rendering result of "helmfile_2.yaml.part.0": {development map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_2.yaml.part.0":
|
||||
0:
|
||||
1: environments:
|
||||
2: test: {}
|
||||
3: shared: {}
|
||||
4:
|
||||
5: repositories:
|
||||
6: - name: bitnami
|
||||
7: url: https://charts.bitnami.com/bitnami
|
||||
8:
|
||||
9: releases:
|
||||
10: - name: cache
|
||||
11: namespace: my-app
|
||||
12: chart: bitnami/redis
|
||||
13: version: 17.0.7
|
||||
14: labels:
|
||||
15: app: test
|
||||
16:
|
||||
17: - name: database
|
||||
18: namespace: my-app
|
||||
19: chart: bitnami/postgres
|
||||
20: version: 11.6.22
|
||||
21:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
processing file "helmfile_3.yaml" in directory "/path/to/helmfile.d"
|
||||
changing working directory to "/path/to/helmfile.d"
|
||||
first-pass rendering starting for "helmfile_3.yaml.part.0": inherited=&{development map[] map[]}, overrode=<nil>
|
||||
first-pass uses: &{development map[] map[]}
|
||||
first-pass rendering output of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
first-pass produced: &{development map[] map[]}
|
||||
first-pass rendering result of "helmfile_3.yaml.part.0": {development map[] map[]}
|
||||
vals:
|
||||
map[]
|
||||
defaultVals:[]
|
||||
second-pass rendering result of "helmfile_3.yaml.part.0":
|
||||
0:
|
||||
1: releases:
|
||||
2: - name: global
|
||||
3: chart: incubator/raw
|
||||
4: namespace: kube-system
|
||||
5:
|
||||
|
||||
changing working directory back to "/path/to"
|
||||
+1
-288
@@ -1,8 +1,6 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
@@ -13,46 +11,7 @@ import (
|
||||
"github.com/helmfile/helmfile/pkg/state"
|
||||
)
|
||||
|
||||
// nolint: golint
|
||||
type ConfigImpl struct {
|
||||
c *cli.Context
|
||||
|
||||
set map[string]interface{}
|
||||
}
|
||||
|
||||
func NewUrfaveCliConfigImpl(c *cli.Context) (ConfigImpl, error) {
|
||||
if c.NArg() > 0 {
|
||||
err := cli.ShowAppHelp(c)
|
||||
if err != nil {
|
||||
return ConfigImpl{}, err
|
||||
}
|
||||
return ConfigImpl{}, fmt.Errorf("err: extraneous arguments: %s", strings.Join(c.Args(), ", "))
|
||||
}
|
||||
|
||||
conf := ConfigImpl{
|
||||
c: c,
|
||||
}
|
||||
|
||||
optsSet := c.GlobalStringSlice("state-values-set")
|
||||
if len(optsSet) > 0 {
|
||||
set := map[string]interface{}{}
|
||||
for i := range optsSet {
|
||||
ops := strings.Split(optsSet[i], ",")
|
||||
for j := range ops {
|
||||
op := strings.SplitN(ops[j], "=", 2)
|
||||
k := maputil.ParseKey(op[0])
|
||||
v := op[1]
|
||||
|
||||
maputil.Set(set, k, v)
|
||||
}
|
||||
}
|
||||
conf.set = set
|
||||
}
|
||||
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
func NewUrfaveCliConfigImplIns(g *GlobalImpl) error {
|
||||
func NewCLIConfigImpl(g *GlobalImpl) error {
|
||||
optsSet := g.RawStateValuesSet()
|
||||
if len(optsSet) > 0 {
|
||||
set := map[string]interface{}{}
|
||||
@@ -71,249 +30,3 @@ func NewUrfaveCliConfigImplIns(g *GlobalImpl) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Set() []string {
|
||||
return c.c.StringSlice("set")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SkipRepos() bool {
|
||||
return c.c.Bool("skip-repos")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Wait() bool {
|
||||
return c.c.Bool("wait")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) WaitForJobs() bool {
|
||||
return c.c.Bool("wait-for-jobs")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Values() []string {
|
||||
return c.c.StringSlice("values")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Args() string {
|
||||
args := c.c.String("args")
|
||||
enableHelmDebug := c.c.GlobalBool("debug")
|
||||
|
||||
if enableHelmDebug {
|
||||
args = fmt.Sprintf("%s %s", args, "--debug")
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
func (c ConfigImpl) OutputDir() string {
|
||||
return strings.TrimRight(c.c.String("output-dir"), fmt.Sprintf("%c", os.PathSeparator))
|
||||
}
|
||||
|
||||
func (c ConfigImpl) OutputDirTemplate() string {
|
||||
return c.c.String("output-dir-template")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) OutputFileTemplate() string {
|
||||
return c.c.String("output-file-template")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Validate() bool {
|
||||
return c.c.Bool("validate")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Concurrency() int {
|
||||
return c.c.Int("concurrency")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) HasCommandName(name string) bool {
|
||||
return c.c.Command.HasName(name)
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SkipNeeds() bool {
|
||||
if !c.IncludeNeeds() {
|
||||
return c.c.Bool("skip-needs")
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (c ConfigImpl) IncludeNeeds() bool {
|
||||
return c.c.Bool("include-needs") || c.IncludeTransitiveNeeds()
|
||||
}
|
||||
|
||||
func (c ConfigImpl) IncludeTransitiveNeeds() bool {
|
||||
return c.c.Bool("include-transitive-needs")
|
||||
}
|
||||
|
||||
// DiffConfig
|
||||
|
||||
func (c ConfigImpl) SkipDeps() bool {
|
||||
return c.c.Bool("skip-deps")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) DetailedExitcode() bool {
|
||||
return c.c.Bool("detailed-exitcode")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) RetainValuesFiles() bool {
|
||||
return c.c.Bool("retain-values-files")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) IncludeTests() bool {
|
||||
return c.c.Bool("include-tests")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Suppress() []string {
|
||||
return c.c.StringSlice("suppress")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SuppressSecrets() bool {
|
||||
return c.c.Bool("suppress-secrets")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) ShowSecrets() bool {
|
||||
return c.c.Bool("show-secrets")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SuppressDiff() bool {
|
||||
return c.c.Bool("suppress-diff")
|
||||
}
|
||||
|
||||
// DeleteConfig
|
||||
|
||||
func (c ConfigImpl) Purge() bool {
|
||||
return c.c.Bool("purge")
|
||||
}
|
||||
|
||||
// TestConfig
|
||||
|
||||
func (c ConfigImpl) Cleanup() bool {
|
||||
return c.c.Bool("cleanup")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Logs() bool {
|
||||
return c.c.Bool("logs")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Timeout() int {
|
||||
if !c.c.IsSet("timeout") {
|
||||
return state.EmptyTimeout
|
||||
}
|
||||
return c.c.Int("timeout")
|
||||
}
|
||||
|
||||
// ListConfig
|
||||
|
||||
func (c ConfigImpl) Output() string {
|
||||
return c.c.String("output")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) KeepTempDir() bool {
|
||||
return c.c.Bool("keep-temp-dir")
|
||||
}
|
||||
|
||||
// GlobalConfig
|
||||
|
||||
func (c ConfigImpl) HelmBinary() string {
|
||||
return c.c.GlobalString("helm-binary")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) KubeContext() string {
|
||||
return c.c.GlobalString("kube-context")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Namespace() string {
|
||||
return c.c.GlobalString("namespace")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Chart() string {
|
||||
return c.c.GlobalString("chart")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) FileOrDir() string {
|
||||
return c.c.GlobalString("file")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Selectors() []string {
|
||||
return c.c.GlobalStringSlice("selector")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) StateValuesSet() map[string]interface{} {
|
||||
return c.set
|
||||
}
|
||||
|
||||
func (c ConfigImpl) StateValuesFiles() []string {
|
||||
return c.c.GlobalStringSlice("state-values-file")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Interactive() bool {
|
||||
return c.c.GlobalBool("interactive")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Color() bool {
|
||||
if c := c.c.GlobalBool("color"); c {
|
||||
return c
|
||||
}
|
||||
|
||||
if c.NoColor() {
|
||||
return false
|
||||
}
|
||||
|
||||
// We replicate the helm-diff behavior in helmfile
|
||||
// because when when helmfile calls helm-diff, helm-diff has no access to term and therefore
|
||||
// we can't rely on helm-diff's ability to auto-detect term for color output.
|
||||
// See https://github.com/roboll/helmfile/issues/2043
|
||||
|
||||
terminal := term.IsTerminal(int(os.Stdout.Fd()))
|
||||
// https://github.com/databus23/helm-diff/issues/281
|
||||
dumb := os.Getenv("TERM") == "dumb"
|
||||
return terminal && !dumb
|
||||
}
|
||||
|
||||
func (c ConfigImpl) NoColor() bool {
|
||||
return c.c.GlobalBool("no-color")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Context() int {
|
||||
return c.c.Int("context")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) DiffOutput() string {
|
||||
return c.c.String("output")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SkipCleanup() bool {
|
||||
return c.c.Bool("skip-cleanup")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SkipCRDs() bool {
|
||||
return c.c.Bool("skip-crds")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SkipDiffOnInstall() bool {
|
||||
return c.c.Bool("skip-diff-on-install")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) EmbedValues() bool {
|
||||
return c.c.Bool("embed-values")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) IncludeCRDs() bool {
|
||||
return c.c.Bool("include-crds")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) SkipTests() bool {
|
||||
return c.c.Bool("skip-tests")
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Logger() *zap.SugaredLogger {
|
||||
return c.c.App.Metadata["logger"].(*zap.SugaredLogger)
|
||||
}
|
||||
|
||||
func (c ConfigImpl) Env() string {
|
||||
env := c.c.GlobalString("environment")
|
||||
if env == "" {
|
||||
env = os.Getenv("HELMFILE_ENVIRONMENT")
|
||||
if env == "" {
|
||||
env = state.DefaultEnv
|
||||
}
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
@@ -38,8 +38,14 @@ func (st *Storage) resolveFile(missingFileHandler *string, tpe, path string) ([]
|
||||
if remote.IsRemote(path) {
|
||||
r := remote.NewRemote(st.logger, "", st.readFile, directoryExistsAt, fileExistsAt)
|
||||
|
||||
fetchedDir, _ := r.Fetch(path, "values")
|
||||
files = []string{fetchedDir}
|
||||
fetchedFilePath, err := r.Fetch(path, "values")
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
if fileExistsAt(fetchedFilePath) {
|
||||
files = []string{fetchedFilePath}
|
||||
}
|
||||
} else {
|
||||
files, err = st.ExpandPaths(path)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||
"github.com/helmfile/helmfile/pkg/remote"
|
||||
)
|
||||
|
||||
func TestStorage_resolveFile(t *testing.T) {
|
||||
type args struct {
|
||||
missingFileHandler *string
|
||||
title string
|
||||
path string
|
||||
}
|
||||
|
||||
cacheDir := remote.CacheDir()
|
||||
infoHandler := MissingFileHandlerInfo
|
||||
errorHandler := MissingFileHandlerError
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantFiles []string
|
||||
wantSkipped bool
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "non existing file in repo produce skip",
|
||||
args: args{
|
||||
path: "git::https://github.com/helmfile/helmfile.git@examples/values/non-existing-file.yaml?ref=v0.145.2",
|
||||
title: "values",
|
||||
missingFileHandler: &infoHandler,
|
||||
},
|
||||
wantSkipped: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "non existing file in repo produce skip",
|
||||
args: args{
|
||||
path: "git::https://github.com/helmfile/helmfile.git@examples/values/non-existing-file.yaml?ref=v0.145.2",
|
||||
title: "values",
|
||||
missingFileHandler: &errorHandler,
|
||||
},
|
||||
wantSkipped: false,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "existing remote value fetched",
|
||||
args: args{
|
||||
path: "git::https://github.com/helmfile/helmfile.git@examples/values/replica-values.yaml?ref=v0.145.2",
|
||||
title: "values",
|
||||
missingFileHandler: &infoHandler,
|
||||
},
|
||||
wantFiles: []string{fmt.Sprintf("%s/%s", cacheDir, "values/https_github_com_helmfile_helmfile_git.ref=v0.145.2/examples/values/replica-values.yaml")},
|
||||
wantSkipped: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "non existing remote repo produce an error",
|
||||
args: args{
|
||||
path: "https://github.com/helmfile/helmfiles.git@examples/values/replica-values.yaml?ref=v0.145.2",
|
||||
title: "values",
|
||||
missingFileHandler: &infoHandler,
|
||||
},
|
||||
wantSkipped: false,
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
st := NewStorage(cacheDir, helmexec.NewLogger(os.Stderr, "debug"), filepath.Glob)
|
||||
|
||||
files, skipped, err := st.resolveFile(tt.args.missingFileHandler, tt.args.title, tt.args.path)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("resolveFile() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(files, tt.wantFiles) {
|
||||
t.Errorf("resolveFile() files = %v, want %v", files, tt.wantFiles)
|
||||
}
|
||||
if skipped != tt.wantSkipped {
|
||||
t.Errorf("resolveFile() skipped = %v, want %v", skipped, tt.wantSkipped)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user