diff --git a/plugin/github/env.go b/plugin/github/env.go index 9aa0c39..9f2e867 100644 --- a/plugin/github/env.go +++ b/plugin/github/env.go @@ -100,15 +100,30 @@ func parseOwner(s string) (owner string) { } func getWith(envVars map[string]string) (map[string]string, error) { - if val, ok := envVars["PLUGIN_WITH"]; ok { + PLUGIN_WITH := "PLUGIN_WITH" + PLUGIN_WITH_PREFIX := "PLUGIN_WITH_" + + _, exists := envVars[PLUGIN_WITH] + + // TODO: Remove this once corresponding CI Manager changes are released on prod envs + if exists { + // PLUGIN_WITH is being set in older flow + val := envVars[PLUGIN_WITH] with, err := strToMap(val) if err != nil { return nil, errors.Wrap(err, "with attribute is not of map type with key & value as string") } - return with, nil + } else { + m := make(map[string]string) + for key := range envVars { + if strings.HasPrefix(key, PLUGIN_WITH_PREFIX) { + k := strings.TrimPrefix(key, PLUGIN_WITH_PREFIX) + m[k] = envVars[key] + } + } + return m, nil } - return nil, nil } func getEnv(envVars map[string]string) map[string]string { diff --git a/plugin/github/workflow.go b/plugin/github/workflow.go index 536e857..e06c21f 100644 --- a/plugin/github/workflow.go +++ b/plugin/github/workflow.go @@ -99,7 +99,7 @@ func getWorkflowEvent() string { func prePostStep(name, envFile string) step { var cmd string if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { - cmd = fmt.Sprintf("python3 -c 'import os; import base64; [print(k+\"=\"+str(base64.b64encode(bytes(v, \"utf-8\")), \"utf-8\")) for k, v in os.environ.items()]' > %s", envFile) + cmd = fmt.Sprintf("python3 -c 'import os; import base64; [print(k+\"=\"+str(base64.b64encode(bytes(v, \"utf-8\")), \"utf-8\")) for k, v in os.environ.items() if not k.startswith(\"PLUGIN_WITH_\")]' > %s", envFile) } else if runtime.GOOS == "windows" { script, err := dotenvScript(envFile) if err != nil { @@ -108,7 +108,7 @@ func prePostStep(name, envFile string) step { } cmd = fmt.Sprintf("python %s", script) } else { - cmd = fmt.Sprintf("python -c 'import os; import base64; [print(k+\"=\"+str(base64.b64encode(bytes(v, \"utf-8\")), \"utf-8\")) for k, v in os.environ.items()]' > %s", envFile) + cmd = fmt.Sprintf("python -c 'import os; import base64; [print(k+\"=\"+str(base64.b64encode(bytes(v, \"utf-8\")), \"utf-8\")) for k, v in os.environ.items() if not k.startswith(\"PLUGIN_WITH_\")]' > %s", envFile) } s := step{ Name: name, @@ -154,7 +154,7 @@ import base64 out = "" for k, v in os.environ.items(): - if "(" not in k and ")" not in k: + if "(" not in k and ")" not in k and not k.startswith("PLUGIN_WITH_"): out = out + "{}={}\n".format(k, str(base64.urlsafe_b64encode(bytes(v, "utf-8")), "utf-8")) with open(r"%s", "wb") as text_file: text_file.write(bytes(out, "UTF-8"))