Merge pull request #26 from ipedrazas/wait

Wait
This commit is contained in:
Ivan Pedrazas
2017-03-14 06:02:39 +00:00
committed by GitHub
4 changed files with 19 additions and 5 deletions
+3
View File
@@ -17,6 +17,7 @@ pipeline:
values: secret.password=${SECRET_PASSWORD},image.tag=${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:7}
prefix: STAGING
debug: true
wait: true
when:
branch: [master]
```
@@ -66,6 +67,7 @@ pipeline:
values: secret.password=${SECRET_PASSWORD},image.tag=${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:7}
prefix: STAGING
debug: true
wait: true
when:
branch:
exclude: [ master ]
@@ -79,6 +81,7 @@ pipeline_production:
values: secret.password=${SECRET_PASSWORD},image.tag=${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:7}
prefix: PROD
debug: true
wait: true
when:
branch: [master]
```
+6
View File
@@ -73,6 +73,11 @@ func main() {
Usage: "Namespace to install Tiller",
EnvVar: "PLUGIN_TILLER_NS,TILLER_NS",
},
cli.BoolFlag{
Name: "wait",
Usage: "if set, will wait until all Pods, PVCs, and Services are in a ready state before marking the release as successful.",
EnvVar: "PLUGIN_WAIT,WAIT",
},
}
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
@@ -99,6 +104,7 @@ func run(c *cli.Context) error {
Secrets: c.StringSlice("secrets"),
Prefix: c.String("prefix"),
TillerNs: c.String("tiller-ns"),
Wait: c.Bool("wait"),
},
}
resolveSecrets(&plugin)
+8 -4
View File
@@ -32,6 +32,7 @@ type (
Secrets []string `json:"secrets"`
Prefix string `json:"prefix"`
TillerNs string `json:"tiller_ns"`
Wait bool `json:"wait"`
}
// Plugin default
Plugin struct {
@@ -64,10 +65,10 @@ func setPushEventCommand(p *Plugin) {
upgrade = append(upgrade, p.Config.Values)
}
if p.Config.ValuesFiles != "" {
for _, valuesFile := range strings.Split(p.Config.ValuesFiles, ",") {
upgrade = append(upgrade, "--values")
upgrade = append(upgrade, valuesFile)
}
for _, valuesFile := range strings.Split(p.Config.ValuesFiles, ",") {
upgrade = append(upgrade, "--values")
upgrade = append(upgrade, valuesFile)
}
}
if p.Config.Namespace != "" {
upgrade = append(upgrade, "--namespace")
@@ -79,6 +80,9 @@ func setPushEventCommand(p *Plugin) {
if p.Config.Debug {
upgrade = append(upgrade, "--debug")
}
if p.Config.Wait {
upgrade = append(upgrade, "--wait")
}
p.Config.HelmCommand = upgrade
}
+2 -1
View File
@@ -54,11 +54,12 @@ func TestGetHelmCommand(t *testing.T) {
Chart: "./chart/test",
Release: "test-release",
Values: "image.tag=v.0.1.0,nameOverride=my-over-app",
Wait: true,
},
}
setHelmCommand(plugin)
res := strings.Join(plugin.Config.HelmCommand[:], " ")
expected := "upgrade --install test-release ./chart/test --set image.tag=v.0.1.0,nameOverride=my-over-app --namespace default --dry-run --debug"
expected := "upgrade --install test-release ./chart/test --set image.tag=v.0.1.0,nameOverride=my-over-app --namespace default --dry-run --debug --wait"
if res != expected {
t.Errorf("Result is %s and we expected %s", res, expected)
}