diff --git a/plugin.go b/plugin.go index 7324b4c..b27c034 100644 --- a/plugin.go +++ b/plugin.go @@ -207,6 +207,17 @@ func doHelmInit(p *Plugin) []string { } +func doDependencyUpdate(chart string) []string { + dependencyUpdate := []string{ + "dependency", + "update", + chart, + } + + return dependencyUpdate +} + + // Exec default method func (p *Plugin) Exec() error { if p.Config.Debug { @@ -255,6 +266,12 @@ func (p *Plugin) Exec() error { } } + if p.Config.UpdateDependencies { + if err = runCommand(doDependencyUpdate(p.Config.Chart)); err != nil { + return fmt.Errorf("Error updating dependencies: " + err.Error()) + } + } + setHelmCommand(p) if p.Config.Debug { diff --git a/plugin_test.go b/plugin_test.go index d450ee0..4a45cb2 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -292,6 +292,16 @@ func TestDetHelmRepoAdd(t *testing.T) { } } +func TestDependencyUpdate(t *testing.T) { + chart := "./chart" + expected := "dependency update ./chart" + result := strings.Join(doDependencyUpdate(chart), " ") + + if expected != result { + t.Errorf("Helm cannot update repositories - expected %q - got %q", expected, result) + } +} + func TestHelmAddRepositoryError(t *testing.T) { _, err := doHelmRepoAdd("drone-helm=bad://drone-helm.example.com:443/stable") if err == nil {