Skip to content

Commit cea9b18

Browse files
authored
Cover scenario when connectionType is none for kubelogin in HelmDeployV0 (#18517)
* fix helmdeploy getAllPods undefined; make warning into error * upgrade 0.224 to 0.224.1
1 parent e9c2a84 commit cea9b18

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Tasks/HelmDeployV0/src/helm.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,21 @@ function runHelmSaveCommand(helmCli: helmcli, kubectlCli: kubernetescli, failOnS
7878

7979
async function run() {
8080
var command = tl.getInput("command", true).toLowerCase();
81+
var connectionType = tl.getInput("connectionType", true);
8182
var isKubConfigRequired = isKubConfigSetupRequired(command);
8283
var kubectlCli: kubernetescli;
83-
if (isKubConfigRequired) {
84-
var kubeconfigfilePath = command === "logout" ? tl.getVariable("KUBECONFIG") : await getKubeConfigFile();
84+
var externalAuth = connectionType === "None" && (command === "install" || command === "upgrade");
85+
if (externalAuth && !tl.getVariable("KUBECONFIG")) {
86+
tl.error("KUBECONFIG kube configuration file path must be set when connectionType is none and command is install or upgrade.");
87+
}
88+
if (isKubConfigRequired || externalAuth) {
89+
var kubeconfigfilePath = (command === "logout" || externalAuth) ? tl.getVariable("KUBECONFIG") : await getKubeConfigFile();
8590
kubectlCli = new kubernetescli(kubeconfigfilePath);
8691
kubectlCli.login();
8792
}
8893

8994
var helmCli: helmcli = new helmcli();
9095
helmCli.login();
91-
var connectionType = tl.getInput("connectionType", true);
9296
var telemetry = {
9397
connectionType: connectionType,
9498
command: command,
@@ -120,7 +124,7 @@ async function run() {
120124
tl.setResult(tl.TaskResult.Failed, err.message);
121125
}
122126
finally {
123-
if (isKubConfigLogoutRequired(command)) {
127+
if (isKubConfigLogoutRequired(command) || externalAuth) {
124128
kubectlCli.logout();
125129
}
126130

@@ -202,7 +206,7 @@ function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli, f
202206
}
203207
}
204208
catch (e) {
205-
tl.warning("Capturing deployment metadata failed with error: " + e);
209+
tl.error("Capturing deployment metadata failed with error: " + e);
206210
}
207211
}
208212
}

Tasks/HelmDeployV0/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 0,
1616
"Minor": 224,
17-
"Patch": 0
17+
"Patch": 1
1818
},
1919
"demands": [],
2020
"groups": [

Tasks/HelmDeployV0/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": {
1515
"Major": 0,
1616
"Minor": 224,
17-
"Patch": 0
17+
"Patch": 1
1818
},
1919
"demands": [],
2020
"groups": [

0 commit comments

Comments
 (0)