From 83cad16f598729008ca1618cbdef0eda723496ac Mon Sep 17 00:00:00 2001 From: Remi Vichery Date: Wed, 1 Apr 2020 15:53:10 -0700 Subject: [PATCH 1/2] feat: add aws-cli to support EKS deployments --- Dockerfile | 6 +++++- index.js | 13 ++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index ea1aa4fb..d7ff79a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,9 @@ ENV BASE_URL="https://get.helm.sh" ENV HELM_2_FILE="helm-v2.16.1-linux-amd64.tar.gz" ENV HELM_3_FILE="helm-v3.0.0-linux-amd64.tar.gz" -RUN apk add --no-cache ca-certificates jq curl bash nodejs && \ +RUN apk add --no-cache ca-certificates \ + --repository http://dl-3.alpinelinux.org/alpine/edge/community/ \ + jq curl bash nodejs aws-cli && \ # Install helm version 2: curl -L ${BASE_URL}/${HELM_2_FILE} |tar xvz && \ mv linux-amd64/helm /usr/bin/helm && \ @@ -19,5 +21,7 @@ RUN apk add --no-cache ca-certificates jq curl bash nodejs && \ # Init version 2 helm: helm init --client-only +ENV PYTHONPATH "/usr/lib/python3.8/site-packages/" + COPY . /usr/src/ ENTRYPOINT ["node", "/usr/src/index.js"] diff --git a/index.js b/index.js index c9b79e0c..8a6f9132 100644 --- a/index.js +++ b/index.js @@ -188,9 +188,6 @@ async function run() { // Setup command options and arguments. - const opts = { env: { - KUBECONFIG: process.env.KUBECONFIG, - }}; const args = [ "upgrade", release, @@ -220,12 +217,12 @@ async function run() { // Setup necessary files. if (process.env.KUBECONFIG_FILE) { - opts.env.KUBECONFIG = "./kubeconfig.yml"; - await writeFile(opts.env.KUBECONFIG, process.env.KUBECONFIG_FILE); + process.env.KUBECONFIG = "./kubeconfig.yml"; + await writeFile(process.env.KUBECONFIG, process.env.KUBECONFIG_FILE); } await writeFile("./values.yml", values); - core.debug(`env: KUBECONFIG="${opts.env.KUBECONFIG}"`); + core.debug(`env: KUBECONFIG="${process.env.KUBECONFIG}"`); // Render value files using github variables. await renderFiles(valueFiles.concat(["./values.yml"]), { @@ -237,7 +234,6 @@ async function run() { if (removeCanary) { core.debug(`removing canary ${appName}-canary`); await exec.exec(helm, deleteCmd(helm, namespace, `${appName}-canary`), { - ...opts, ignoreReturnCode: true }); } @@ -245,11 +241,10 @@ async function run() { // Actually execute the deployment here. if (task === "remove") { await exec.exec(helm, deleteCmd(helm, namespace, release), { - ...opts, ignoreReturnCode: true }); } else { - await exec.exec(helm, args, opts); + await exec.exec(helm, args); } await status(task === "remove" ? "inactive" : "success"); From 8b113e860e6061514f483467b80adc8a554e39e2 Mon Sep 17 00:00:00 2001 From: Remi Vichery Date: Wed, 1 Apr 2020 19:21:33 -0700 Subject: [PATCH 2/2] fix: Handle Helm home for both versions --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8a6f9132..498334b3 100644 --- a/index.js +++ b/index.js @@ -196,9 +196,17 @@ async function run() { "--wait", "--atomic", `--namespace=${namespace}`, - '--home=/root/.helm/', ]; + // Per https://helm.sh/docs/faq/#xdg-base-directory-support + if (helm === "helm3") { + process.env.XDG_DATA_HOME = "/root/.helm/" + process.env.XDG_CACHE_HOME = "/root/.helm/" + process.env.XDG_CONFIG_HOME = "/root/.helm/" + } else { + process.env.HELM_HOME = "/root/.helm/" + } + if (dryRun) args.push("--dry-run"); if (appName) args.push(`--set=app.name=${appName}`); if (version) args.push(`--set=app.version=${version}`);