mirror of
https://github.com/ipedrazas/drone-helm.git
synced 2026-06-04 18:24:13 +08:00
Implement dependencies restore functionallity
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user