Skip to content

Commit

Permalink
fix: Helm3 compatibility on deletes
Browse files Browse the repository at this point in the history
Issue with using helm3 is that namespaces must be specified when
removing releases. Added this value in.
  • Loading branch information
colinjfw committed Sep 21, 2019
1 parent 7eddfb9 commit c9eafdd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: 'actions/checkout@v1'

- name: 'Deploy Canary'
uses: 'deliverybot/helm@ci-v2'
uses: 'deliverybot/helm@master'
with:
helm: helm3
token: '${{ github.token }}'
Expand All @@ -39,7 +39,7 @@ jobs:
KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}'

- name: 'Deploy Production'
uses: 'deliverybot/helm@ci-v2'
uses: 'deliverybot/helm@master'
with:
helm: helm3
token: '${{ github.token }}'
Expand Down
18 changes: 16 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ function renderFiles(files, data) {
return Promise.all(promises);
}

/**
* Makes a delete command for compatibility between helm 2 and 3.
*
* @param {string} helm
* @param {string} namespace
* @param {string} release
*/
function deleteCmd(helm, namespace, release) {
if (helm === "helm3") {
return ["delete", "-n", namespace, release];
}
return ["delete", release];
}

/**
* Run executes the helm deployment.
*/
Expand Down Expand Up @@ -206,15 +220,15 @@ async function run() {
// Remove the canary deployment before continuing.
if (removeCanary) {
core.debug(`removing canary ${appName}-canary`);
await exec.exec(helm, ["delete", `${appName}-canary`], {
await exec.exec(helm, deleteCmd(helm, namespace, `${appName}-canary`), {
...opts,
ignoreReturnCode: true
});
}

// Actually execute the deployment here.
if (task === "remove") {
await exec.exec(helm, ["delete", release], {
await exec.exec(helm, deleteCmd(helm, namespace, release), {
...opts,
ignoreReturnCode: true
});
Expand Down

0 comments on commit c9eafdd

Please sign in to comment.