From 1abc612ad6ece80242050399b358fece70b63250 Mon Sep 17 00:00:00 2001 From: Anumita Shenoy Date: Thu, 14 Nov 2019 19:33:08 +0530 Subject: [PATCH 1/4] Helm installer fix for v3 --- Tasks/HelmInstallerV0/src/helmtoolinstaller.ts | 12 ++++++++++-- Tasks/HelmInstallerV0/task.json | 4 ++-- Tasks/HelmInstallerV0/task.loc.json | 6 +++--- Tasks/HelmInstallerV1/src/helmtoolinstaller.ts | 12 ++++++++++-- Tasks/HelmInstallerV1/task.json | 2 +- Tasks/HelmInstallerV1/task.loc.json | 4 ++-- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts index d15c6a7da0b1..8aef97491153 100644 --- a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts @@ -32,10 +32,18 @@ async function configureHelm() { async function verifyHelm() { console.log(tl.loc("VerifyHelmInstallation")); + var helmVersion = await helminstaller.getHelmVersion(); var helmToolPath = tl.which("helm", true); var helmTool = tl.tool(helmToolPath); - helmTool.arg("init"); - helmTool.arg("--client-only"); + + // Check if using Helm 2 or Helm 3 + if (helmVersion.startsWith("v2")) { + helmTool.arg("init"); + helmTool.arg("--client-only"); + } else { + helmTool.arg("version"); + } + return helmTool.exec() } diff --git a/Tasks/HelmInstallerV0/task.json b/Tasks/HelmInstallerV0/task.json index 7cd1a69d739b..11dc43ffee32 100644 --- a/Tasks/HelmInstallerV0/task.json +++ b/Tasks/HelmInstallerV0/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 155, - "Patch": 1 + "Minor": 161, + "Patch": 0 }, "demands": [], "satisfies": [ diff --git a/Tasks/HelmInstallerV0/task.loc.json b/Tasks/HelmInstallerV0/task.loc.json index 93e9263b9119..c14422b422f1 100644 --- a/Tasks/HelmInstallerV0/task.loc.json +++ b/Tasks/HelmInstallerV0/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 155, - "Patch": 1 + "Minor": 161, + "Patch": 0 }, "demands": [], "satisfies": [ @@ -93,4 +93,4 @@ "HelmLatestNotKnown": "ms-resource:loc.messages.HelmLatestNotKnown", "VerifyHelmInstallation": "ms-resource:loc.messages.VerifyHelmInstallation" } -} +} \ No newline at end of file diff --git a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts index 4bba1f906ecd..eb35f344d21f 100644 --- a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts @@ -20,10 +20,18 @@ async function configureHelm() { async function verifyHelm() { console.log(tl.loc("VerifyHelmInstallation")); + var helmVersion = await utils.getHelmVersion(); var helmToolPath = tl.which("helm", true); var helmTool = tl.tool(helmToolPath); - helmTool.arg("init"); - helmTool.arg("--client-only"); + + // Check if using Helm 2 or Helm 3 + if (helmVersion.startsWith("v2")) { + helmTool.arg("init"); + helmTool.arg("--client-only"); + } else { + helmTool.arg("version"); + } + return helmTool.exec() } diff --git a/Tasks/HelmInstallerV1/task.json b/Tasks/HelmInstallerV1/task.json index 94cd029d62e6..305546ebb903 100644 --- a/Tasks/HelmInstallerV1/task.json +++ b/Tasks/HelmInstallerV1/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 159, + "Minor": 161, "Patch": 0 }, "preview": true, diff --git a/Tasks/HelmInstallerV1/task.loc.json b/Tasks/HelmInstallerV1/task.loc.json index 2c2473b4a010..833653cba615 100644 --- a/Tasks/HelmInstallerV1/task.loc.json +++ b/Tasks/HelmInstallerV1/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 159, + "Minor": 161, "Patch": 0 }, "preview": true, @@ -41,4 +41,4 @@ "NotAValidSemverVersion": "ms-resource:loc.messages.NotAValidSemverVersion", "VerifyHelmInstallation": "ms-resource:loc.messages.VerifyHelmInstallation" } -} +} \ No newline at end of file From a1165d5d51c5a438c86c683a858d52772cf73e66 Mon Sep 17 00:00:00 2001 From: Anumita Shenoy Date: Thu, 14 Nov 2019 20:13:55 +0530 Subject: [PATCH 2/4] Helm v3 fix refactor --- Tasks/HelmInstallerV0/src/helmtoolinstaller.ts | 6 ++++-- Tasks/HelmInstallerV1/src/helmtoolinstaller.ts | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts index 8aef97491153..7729ffcafe1c 100644 --- a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts @@ -10,6 +10,8 @@ import * as helminstaller from "./helminstaller" tl.setResourcePath(path.join(__dirname, '..', 'task.json')); +var versionToInstall = "" + async function configureKubectl() { var version = await kubectlinstaller.getKuberctlVersion(); var kubectlPath = await kubectlinstaller.downloadKubectl(version); @@ -22,6 +24,7 @@ async function configureKubectl() { async function configureHelm() { var version = await helminstaller.getHelmVersion(); + versionToInstall = version var helmPath = await helminstaller.downloadHelm(version); // prepend the tools path. instructs the agent to prepend for future tasks @@ -32,12 +35,11 @@ async function configureHelm() { async function verifyHelm() { console.log(tl.loc("VerifyHelmInstallation")); - var helmVersion = await helminstaller.getHelmVersion(); var helmToolPath = tl.which("helm", true); var helmTool = tl.tool(helmToolPath); // Check if using Helm 2 or Helm 3 - if (helmVersion.startsWith("v2")) { + if (versionToInstall.startsWith("v2")) { helmTool.arg("init"); helmTool.arg("--client-only"); } else { diff --git a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts index eb35f344d21f..9cd9e85fc185 100644 --- a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts @@ -7,9 +7,11 @@ import utils = require("./utils"); tl.setResourcePath(path.join(__dirname, '..', 'task.json')); +var versionToInstall = "" async function configureHelm() { var version = await utils.getHelmVersion(); + versionToInstall = version; var helmPath = await utils.downloadHelm(version); // prepend the tools path. instructs the agent to prepend for future tasks @@ -20,12 +22,11 @@ async function configureHelm() { async function verifyHelm() { console.log(tl.loc("VerifyHelmInstallation")); - var helmVersion = await utils.getHelmVersion(); var helmToolPath = tl.which("helm", true); var helmTool = tl.tool(helmToolPath); // Check if using Helm 2 or Helm 3 - if (helmVersion.startsWith("v2")) { + if (versionToInstall.startsWith("v2")) { helmTool.arg("init"); helmTool.arg("--client-only"); } else { From b85e24d8f5d26e23d4cfc9402ca5634168d47166 Mon Sep 17 00:00:00 2001 From: Anumita Shenoy Date: Thu, 14 Nov 2019 20:34:30 +0530 Subject: [PATCH 3/4] Only check for v2 --- Tasks/HelmInstallerV0/src/helmtoolinstaller.ts | 11 ++++------- Tasks/HelmInstallerV1/src/helmtoolinstaller.ts | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts index 7729ffcafe1c..8c634817d4db 100644 --- a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts @@ -10,7 +10,7 @@ import * as helminstaller from "./helminstaller" tl.setResourcePath(path.join(__dirname, '..', 'task.json')); -var versionToInstall = "" +var helmVersion = "" async function configureKubectl() { var version = await kubectlinstaller.getKuberctlVersion(); @@ -23,9 +23,8 @@ async function configureKubectl() { } async function configureHelm() { - var version = await helminstaller.getHelmVersion(); - versionToInstall = version - var helmPath = await helminstaller.downloadHelm(version); + helmVersion = await helminstaller.getHelmVersion(); + var helmPath = await helminstaller.downloadHelm(helmVersion); // prepend the tools path. instructs the agent to prepend for future tasks if (!process.env['PATH'].startsWith(path.dirname(helmPath))) { @@ -39,11 +38,9 @@ async function verifyHelm() { var helmTool = tl.tool(helmToolPath); // Check if using Helm 2 or Helm 3 - if (versionToInstall.startsWith("v2")) { + if (helmVersion.startsWith("v2")) { helmTool.arg("init"); helmTool.arg("--client-only"); - } else { - helmTool.arg("version"); } return helmTool.exec() diff --git a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts index 1d10b9282075..4a88fd783bda 100644 --- a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts @@ -7,11 +7,10 @@ import utils = require("./utils"); tl.setResourcePath(path.join(__dirname, '..', 'task.json')); -var versionToInstall = "" +var version = "" async function configureHelm() { - var version = await utils.getHelmVersion(); - versionToInstall = version; + version = await utils.getHelmVersion(); var helmPath = await utils.downloadHelm(version); // prepend the tools path. instructs the agent to prepend for future tasks if (!process.env['PATH'].startsWith(path.dirname(helmPath))) { @@ -25,13 +24,11 @@ async function verifyHelm() { var helmTool = tl.tool(helmToolPath); // Check if using Helm 2 or Helm 3 - if (versionToInstall.startsWith("v2")) { + if (version.startsWith("v2")) { helmTool.arg("init"); helmTool.arg("--client-only"); - } else { - helmTool.arg("version"); } - + return helmTool.exec() } From cf55c07170a4447929c038325b4a6dee933aa8f0 Mon Sep 17 00:00:00 2001 From: Anumita Shenoy Date: Thu, 14 Nov 2019 20:49:57 +0530 Subject: [PATCH 4/4] fixing for v2 --- Tasks/HelmInstallerV0/src/helmtoolinstaller.ts | 5 ++--- Tasks/HelmInstallerV1/src/helmtoolinstaller.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts index 8c634817d4db..91deef295320 100644 --- a/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV0/src/helmtoolinstaller.ts @@ -35,15 +35,14 @@ async function configureHelm() { async function verifyHelm() { console.log(tl.loc("VerifyHelmInstallation")); var helmToolPath = tl.which("helm", true); - var helmTool = tl.tool(helmToolPath); // Check if using Helm 2 or Helm 3 if (helmVersion.startsWith("v2")) { + var helmTool = tl.tool(helmToolPath); helmTool.arg("init"); helmTool.arg("--client-only"); + return helmTool.exec() } - - return helmTool.exec() } configureHelm() diff --git a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts index 4a88fd783bda..de875b0eeeee 100644 --- a/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts +++ b/Tasks/HelmInstallerV1/src/helmtoolinstaller.ts @@ -21,15 +21,14 @@ async function configureHelm() { async function verifyHelm() { console.log(tl.loc("VerifyHelmInstallation")); var helmToolPath = tl.which("helm", true); - var helmTool = tl.tool(helmToolPath); // Check if using Helm 2 or Helm 3 if (version.startsWith("v2")) { + var helmTool = tl.tool(helmToolPath); helmTool.arg("init"); helmTool.arg("--client-only"); + return helmTool.exec() } - - return helmTool.exec() } configureHelm()