Implement dependencies restore functionallity

This commit is contained in:
Tomas Dabasinskas
2018-06-12 11:19:14 +03:00
parent 05120a8ad7
commit dab0b45caf
2 changed files with 27 additions and 0 deletions
+17
View File
@@ -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 {
+10
View File
@@ -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 {