Actual drone-invokable helm commands

This commit is contained in:
Erin Call
2019-12-05 14:35:25 -08:00
parent e77f6842b9
commit 238ede6f9e
11 changed files with 130 additions and 53 deletions

View File

@@ -2,25 +2,23 @@ package main
import (
"fmt"
"github.com/urfave/cli"
"os"
"github.com/urfave/cli"
"github.com/pelotech/drone-helm3/internal/run"
)
func main() {
_ = fmt.Println
_ = os.Exit
app := cli.NewApp()
app.Name = "helm plugin"
app.Usage = "helm plugin"
app.Action = run
app.Action = execute
app.Version = "0.0.1α"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "echo, e",
Usage: "this text'll be ech'll",
EnvVar: "ECHO",
Name: "helm_command",
Usage: "Helm command to execute",
EnvVar: "PLUGIN_HELM_COMMAND,HELM_COMMAND",
},
}
@@ -29,7 +27,19 @@ func main() {
}
}
func run(c *cli.Context) error {
fmt.Println(c.String("echo"))
func execute(c *cli.Context) error {
switch c.String("helm_command") {
case "upgrade":
run.Upgrade()
case "help":
run.Help()
default:
switch os.Getenv("DRONE_BUILD_EVENT") {
case "push", "tag", "deployment", "pull_request", "promote", "rollback":
run.Upgrade()
default:
run.Help()
}
return nil
}