mirror of
https://github.com/ipedrazas/drone-helm.git
synced 2026-06-04 18:24:13 +08:00
add debug
This commit is contained in:
@@ -90,6 +90,6 @@ func run(c *cli.Context) error {
|
||||
},
|
||||
}
|
||||
resolveSecrets(&plugin)
|
||||
|
||||
plugin.debug()
|
||||
return plugin.Exec()
|
||||
}
|
||||
|
||||
@@ -147,6 +147,11 @@ func getEnvVars(envvars string) [][]string {
|
||||
return extracted
|
||||
}
|
||||
|
||||
func resolveEnvVar(key string, prefix string) string {
|
||||
envvars := getEnvVars(key)
|
||||
return replaceEnvvars(envvars, prefix, key)
|
||||
}
|
||||
|
||||
func replaceEnvvars(envvars [][]string, prefix string, s string) string {
|
||||
for _, envvar := range envvars {
|
||||
envvarName := envvar[0]
|
||||
@@ -160,18 +165,9 @@ func replaceEnvvars(envvars [][]string, prefix string, s string) string {
|
||||
s = strings.Replace(s, envvarName, envval, -1)
|
||||
}
|
||||
}
|
||||
// fmt.Println(s)
|
||||
return s
|
||||
}
|
||||
|
||||
// this functions checks if $VAR or ${VAR} exists and
|
||||
// returns the text with resolved vars
|
||||
func resolveEnvVar(key string, prefix string) string {
|
||||
envvars := getEnvVars(key)
|
||||
// fmt.Println(envvars)
|
||||
return replaceEnvvars(envvars, prefix, key)
|
||||
}
|
||||
|
||||
func (p *Plugin) debug() {
|
||||
fmt.Println(p)
|
||||
// debug env vars
|
||||
|
||||
+20
-3
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -60,8 +59,6 @@ func TestGetHelmCommand(t *testing.T) {
|
||||
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 --dry-run --debug"
|
||||
fmt.Println(res)
|
||||
fmt.Println(expected)
|
||||
if res != expected {
|
||||
t.Errorf("Result is %s and we expected %s", res, expected)
|
||||
}
|
||||
@@ -126,3 +123,23 @@ func TestReplaceEnvvars(t *testing.T) {
|
||||
t.Errorf("EnvVar MY_TAG no replaced by %s ", tag)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetHelmHelp(t *testing.T) {
|
||||
plugin := &Plugin{
|
||||
Config: Config{
|
||||
HelmCommand: nil,
|
||||
Namespace: "default",
|
||||
SkipTLSVerify: true,
|
||||
Debug: true,
|
||||
DryRun: true,
|
||||
Chart: "./chart/test",
|
||||
Release: "test-release",
|
||||
Prefix: "MY",
|
||||
Values: "image.tag=$TAG,api=${API_SERVER},nameOverride=my-over-app,second.tag=${TAG}",
|
||||
},
|
||||
}
|
||||
setHelmHelp(plugin)
|
||||
if plugin.Config.HelmCommand == nil {
|
||||
t.Error("Helm help is not displayed")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user