mirror of
https://github.com/ipedrazas/drone-helm.git
synced 2026-06-04 18:24:13 +08:00
support timeout
This commit is contained in:
@@ -98,6 +98,11 @@ func main() {
|
||||
Usage: "when upgrading, reuse the last release's values, and merge in any new values",
|
||||
EnvVar: "PLUGIN_REUSE_VALUES,REUSE_VALUES",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "timeout",
|
||||
Usage: "time in seconds to wait for any individual kubernetes operation (like Jobs for hooks) (default 300)",
|
||||
EnvVar: "PLUGIN_TIMEOUT,TIMEOUT",
|
||||
},
|
||||
}
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logrus.Fatal(err)
|
||||
@@ -129,6 +134,7 @@ func run(c *cli.Context) error {
|
||||
ClientOnly: c.Bool("client-only"),
|
||||
Upgrade: c.Bool("upgrade"),
|
||||
ReuseValues: c.Bool("reuse-values"),
|
||||
Timeout: c.String("timeout"),
|
||||
},
|
||||
}
|
||||
resolveSecrets(&plugin)
|
||||
|
||||
@@ -38,6 +38,7 @@ type (
|
||||
Upgrade bool `json:"upgrade"`
|
||||
ClientOnly bool `json:"client_only"`
|
||||
ReuseValues bool `json:"reuse_values"`
|
||||
Timeout string `json:"timeout"`
|
||||
}
|
||||
// Plugin default
|
||||
Plugin struct {
|
||||
@@ -98,6 +99,10 @@ func setPushEventCommand(p *Plugin) {
|
||||
if p.Config.ReuseValues {
|
||||
upgrade = append(upgrade, "--reuse-values")
|
||||
}
|
||||
if p.Config.Timeout != "" {
|
||||
upgrade = append(upgrade, "--timeout")
|
||||
upgrade = append(upgrade, p.Config.Timeout)
|
||||
}
|
||||
p.Config.HelmCommand = upgrade
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -56,11 +56,12 @@ func TestGetHelmCommand(t *testing.T) {
|
||||
Values: "image.tag=v.0.1.0,nameOverride=my-over-app",
|
||||
Wait: true,
|
||||
ReuseValues: true,
|
||||
Timeout: "500",
|
||||
},
|
||||
}
|
||||
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 --wait --reuse-values"
|
||||
expected := "upgrade --install test-release ./chart/test --set image.tag=v.0.1.0,nameOverride=my-over-app --namespace default --dry-run --debug --wait --reuse-values --timeout 500"
|
||||
if res != expected {
|
||||
t.Errorf("Result is %s and we expected %s", res, expected)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user