diff --git a/plugin.go b/plugin.go index f84a406..093e321 100644 --- a/plugin.go +++ b/plugin.go @@ -110,7 +110,7 @@ func installCaCert(cacert string) *exec.Cmd { func CopyTfEnv() { tfVar := regexp.MustCompile(`^TF_VAR_.*$`) for _, e := range os.Environ() { - pair := strings.Split(e, "=") + pair := strings.SplitN(e, "=", 2) if tfVar.MatchString(pair[0]) { name := strings.Split(pair[0], "TF_VAR_") os.Setenv(fmt.Sprintf("TF_VAR_%s", strings.ToLower(name[1])), pair[1]) diff --git a/plugin_test.go b/plugin_test.go index b951d8b..6073d9c 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -143,12 +143,14 @@ func TestPlugin(t *testing.T) { // Set some initial TF_VAR_ that are uppercase os.Setenv("TF_VAR_SOMETHING", "some value") os.Setenv("TF_VAR_SOMETHING_ELSE", "some other value") + os.Setenv("TF_VAR_BASE64", "dGVzdA==") CopyTfEnv() // Make sure new env vars exist with proper values g.Assert(os.Getenv("TF_VAR_something")).Equal("some value") g.Assert(os.Getenv("TF_VAR_something_else")).Equal("some other value") + g.Assert(os.Getenv("TF_VAR_base64")).Equal("dGVzdA==") }) }) }