diff --git a/README.md b/README.md index 0115316..5cccc7b 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,14 @@ To test the plugin, you can run `minikube` and just run the docker image as foll docker run --rm \ - -e PLUGIN_HELM_COMMAND="install --name my-release stable/jenkins --debug --dry-run" \ -e PLUGIN_API_SERVER=https://192.168.64.5:8443 \ -e PLUGIN_TOKEN="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ld..." \ -e PLUGIN_NAMESPACE=default \ -e PLUGIN_SKIP_TLS_VERIFY=true \ + -e PLUGIN_RELEASE=my-release \ + -e PLUGIMN_CHART=stable/jenkins \ quay.io/ipedrazas/drone-helm -Happy Helming! +Happy Helming! \ No newline at end of file diff --git a/main.go b/main.go index e0cdaff..6d9705f 100644 --- a/main.go +++ b/main.go @@ -90,7 +90,11 @@ func run(c *cli.Context) error { Chart: c.String("chart"), }, } - debug() + if plugin.Config.Debug { + // debug env vars + debug() + } + return plugin.Exec() } diff --git a/plugin.go b/plugin.go index b80c1e4..b771492 100644 --- a/plugin.go +++ b/plugin.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "log" "os" "os/exec" "strings" @@ -41,9 +42,6 @@ func setHelmCommand(p *Plugin) { upgrade = append(upgrade, p.Config.Release) } upgrade = append(upgrade, p.Config.Chart) - if p.Config.Debug { - upgrade = append(upgrade, "--debug") - } if p.Config.Values != "" { upgrade = append(upgrade, "--set") upgrade = append(upgrade, p.Config.Values) @@ -51,6 +49,9 @@ func setHelmCommand(p *Plugin) { if p.Config.DryRun { upgrade = append(upgrade, "--dry-run") } + if p.Config.Debug { + upgrade = append(upgrade, "--debug") + } p.Config.HelmCommand = upgrade } @@ -70,6 +71,9 @@ func (p *Plugin) Exec() error { if err != nil { return fmt.Errorf("Error running helm comand: " + strings.Join(init[:], " ")) } + if p.Config.Debug { + log.Println("helm comand: " + strings.Join(init[:], " ")) + } err = runCommand(p.Config.HelmCommand) if err != nil { return fmt.Errorf("Error running helm comand: " + strings.Join(p.Config.HelmCommand[:], " "))