Create AddRepo steps when there are repos to add [#26]

This commit is contained in:
Erin Call
2019-12-30 11:57:19 -08:00
parent 22e30fea56
commit 48b6b3f5b3
3 changed files with 96 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/pelotech/drone-helm3/internal/run"
"os"
"strings"
)
const (
@@ -96,6 +97,7 @@ func (p *Plan) Execute() error {
var upgrade = func(cfg Config) []Step {
steps := initKube(cfg)
steps = append(steps, addRepos(cfg)...)
if cfg.UpdateDependencies {
steps = append(steps, depUpdate(cfg)...)
}
@@ -127,7 +129,7 @@ var uninstall = func(cfg Config) []Step {
}
var lint = func(cfg Config) []Step {
steps := make([]Step, 0)
steps := addRepos(cfg)
if cfg.UpdateDependencies {
steps = append(steps, depUpdate(cfg)...)
}
@@ -157,6 +159,23 @@ func initKube(cfg Config) []Step {
}
}
func addRepos(cfg Config) []Step {
steps := make([]Step, 0)
for _, repo := range cfg.AddRepos {
split := strings.SplitN(repo, "=", 2)
if len(split) != 2 {
fmt.Fprintf(cfg.Stderr, "Warning: skipping bad repo spec '%s'.\n", repo)
continue
}
steps = append(steps, &run.AddRepo{
Name: split[0],
URL: split[1],
})
}
return steps
}
func depUpdate(cfg Config) []Step {
return []Step{
&run.DepUpdate{