debug conditional added

This commit is contained in:
Ivan Pedrazas
2016-12-12 17:41:09 +00:00
parent 1ee5296ef2
commit 109876995c
3 changed files with 15 additions and 6 deletions
+3 -2
View File
@@ -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!
+5 -1
View File
@@ -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()
}
+7 -3
View File
@@ -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[:], " "))