mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-06 15:22:08 +02:00
Avoid --skip-refresh on local charts (#541)
All the dependencies get correctly installed when dealing with remote charts. If there's a local chart that depends on remote dependencies then those don't get automatically installed. See #526. They end up with this error: ``` Error: no cached repository for helm-manager-b6cf96b91af4f01317d185adfbe32610179e5246214be9646a52cb0b86032272 found. (try 'helm repo update'): open /root/.cache/helm/repository/helm-manager-b6cf96b91af4f01317d185adfbe32610179e5246214be9646a52cb0b86032272-index.yaml: no such file or directory ``` One workaround for that would be to add the repositories from the local charts. Something like this: ``` cd local-chart/ && helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done ``` This however is not trivial to parse and implement. An easier fix which I did here is just to not allow doing `--skip-refresh` for local repositories. Fixes #526 Signed-off-by: Indrek Juhkam <indrek@urgas.eu> Signed-off-by: Indrek Juhkam <indrek@urgas.eu>
This commit is contained in:
@@ -216,7 +216,7 @@ func (helm *execer) RegistryLogin(repository string, username string, password s
|
||||
return err
|
||||
}
|
||||
|
||||
func (helm *execer) BuildDeps(name, chart string) error {
|
||||
func (helm *execer) BuildDeps(name, chart string, flags ...string) error {
|
||||
helm.logger.Infof("Building dependency release=%v, chart=%v", name, chart)
|
||||
args := []string{
|
||||
"dependency",
|
||||
@@ -224,9 +224,7 @@ func (helm *execer) BuildDeps(name, chart string) error {
|
||||
chart,
|
||||
}
|
||||
|
||||
if helm.IsHelm3() {
|
||||
args = append(args, "--skip-refresh")
|
||||
}
|
||||
args = append(args, flags...)
|
||||
|
||||
out, err := helm.exec(args, map[string]string{}, nil)
|
||||
helm.info(out)
|
||||
|
||||
@@ -339,7 +339,7 @@ func Test_BuildDeps(t *testing.T) {
|
||||
logger := NewLogger(&buffer, "debug")
|
||||
helm3Runner := mockRunner{output: []byte("v3.2.4+ge29ce2a")}
|
||||
helm := New("helm", false, logger, "dev", &helm3Runner)
|
||||
err := helm.BuildDeps("foo", "./chart/foo")
|
||||
err := helm.BuildDeps("foo", "./chart/foo", []string{"--skip-refresh"}...)
|
||||
expected := `Building dependency release=foo, chart=./chart/foo
|
||||
exec: helm --kube-context dev dependency build ./chart/foo --skip-refresh
|
||||
v3.2.4+ge29ce2a
|
||||
@@ -352,9 +352,22 @@ v3.2.4+ge29ce2a
|
||||
}
|
||||
|
||||
buffer.Reset()
|
||||
helm.SetExtraArgs("--verify")
|
||||
err = helm.BuildDeps("foo", "./chart/foo")
|
||||
expected = `Building dependency release=foo, chart=./chart/foo
|
||||
exec: helm --kube-context dev dependency build ./chart/foo
|
||||
v3.2.4+ge29ce2a
|
||||
`
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if buffer.String() != expected {
|
||||
t.Errorf("helmexec.BuildDeps()\nactual = %v\nexpect = %v", buffer.String(), expected)
|
||||
}
|
||||
|
||||
buffer.Reset()
|
||||
helm.SetExtraArgs("--verify")
|
||||
err = helm.BuildDeps("foo", "./chart/foo", []string{"--skip-refresh"}...)
|
||||
expected = `Building dependency release=foo, chart=./chart/foo
|
||||
exec: helm --kube-context dev dependency build ./chart/foo --skip-refresh --verify
|
||||
v3.2.4+ge29ce2a
|
||||
`
|
||||
|
||||
@@ -18,7 +18,7 @@ type Interface interface {
|
||||
AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error
|
||||
UpdateRepo() error
|
||||
RegistryLogin(name string, username string, password string) error
|
||||
BuildDeps(name, chart string) error
|
||||
BuildDeps(name, chart string, flags ...string) error
|
||||
UpdateDeps(chart string) error
|
||||
SyncRelease(context HelmContext, name, chart string, flags ...string) error
|
||||
DiffRelease(context HelmContext, name, chart string, suppressDiff bool, flags ...string) error
|
||||
|
||||
Reference in New Issue
Block a user