From bdd423abdd1b734d1d491234782923d4f0183719 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Sun, 17 Sep 2023 22:12:04 -0700 Subject: [PATCH] Update and test env show execution --- dist/index.js | 25 +++++++++++-------------- src/ContainerAppHelper.js | 25 +++++++++++-------------- src/ContainerAppHelper.ts | 10 ++++++---- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0226da34..c3a5b7ae 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4991,27 +4991,24 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.doesContainerAppEnvironmentExist = function (containerAppEnvironment, resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, pathToTool, result, err_7; - return __generator(this, function (_a) { - switch (_a.label) { + var command, _a, stdout, stderr, err_7; + return __generator(this, function (_b) { + switch (_b.label) { case 0: core.debug("Attempting to determine if Container App Environment with name \"" + containerAppEnvironment + "\" exists in resource group \"" + resourceGroup + "\""); - _a.label = 1; + _b.label = 1; case 1: - _a.trys.push([1, 4, , 5]); - command = "containerapp env show -n " + containerAppEnvironment + " -g " + resourceGroup + " -o none"; - return [4 /*yield*/, io.which('az', true)]; + _b.trys.push([1, 3, , 4]); + command = "az containerapp env show -n " + containerAppEnvironment + " -g " + resourceGroup + " -o none"; + return [4 /*yield*/, cpExec("" + command)]; case 2: - pathToTool = _a.sent(); - return [4 /*yield*/, new Utility_1.Utility().executeAndReturnExitCode(pathToTool, command)]; + _a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr; + return [2 /*return*/, !stderr]; case 3: - result = _a.sent(); - return [2 /*return*/, result == 0]; - case 4: - err_7 = _a.sent(); + err_7 = _b.sent(); core.warning(err_7.message); return [2 /*return*/, false]; - case 5: return [2 /*return*/]; + case 4: return [2 /*return*/]; } }); }); diff --git a/src/ContainerAppHelper.js b/src/ContainerAppHelper.js index 31146be6..57ce0153 100644 --- a/src/ContainerAppHelper.js +++ b/src/ContainerAppHelper.js @@ -268,27 +268,24 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.doesContainerAppEnvironmentExist = function (containerAppEnvironment, resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, pathToTool, result, err_7; - return __generator(this, function (_a) { - switch (_a.label) { + var command, _a, stdout, stderr, err_7; + return __generator(this, function (_b) { + switch (_b.label) { case 0: core.debug("Attempting to determine if Container App Environment with name \"" + containerAppEnvironment + "\" exists in resource group \"" + resourceGroup + "\""); - _a.label = 1; + _b.label = 1; case 1: - _a.trys.push([1, 4, , 5]); - command = "containerapp env show -n " + containerAppEnvironment + " -g " + resourceGroup + " -o none"; - return [4 /*yield*/, io.which('az', true)]; + _b.trys.push([1, 3, , 4]); + command = "az containerapp env show -n " + containerAppEnvironment + " -g " + resourceGroup + " -o none"; + return [4 /*yield*/, cpExec("" + command)]; case 2: - pathToTool = _a.sent(); - return [4 /*yield*/, new Utility_1.Utility().executeAndReturnExitCode(pathToTool, command)]; + _a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr; + return [2 /*return*/, !stderr]; case 3: - result = _a.sent(); - return [2 /*return*/, result == 0]; - case 4: - err_7 = _a.sent(); + err_7 = _b.sent(); core.warning(err_7.message); return [2 /*return*/, false]; - case 5: return [2 /*return*/]; + case 4: return [2 /*return*/]; } }); }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index d6068dc5..9f23db66 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -202,10 +202,12 @@ export class ContainerAppHelper { public async doesContainerAppEnvironmentExist(containerAppEnvironment: string, resourceGroup: string): Promise { core.debug(`Attempting to determine if Container App Environment with name "${containerAppEnvironment}" exists in resource group "${resourceGroup}"`); try { - const command = `containerapp env show -n ${containerAppEnvironment} -g ${resourceGroup} -o none`; - const pathToTool = await io.which('az', true); - const result = await new Utility().executeAndReturnExitCode(pathToTool, command); - return result == 0; + const command = `az containerapp env show -n ${containerAppEnvironment} -g ${resourceGroup} -o none`; + const {stdout, stderr} = await cpExec(`${command}`); + return !stderr; + // const pathToTool = await io.which('az', true); + // const result = await new Utility().executeAndReturnExitCode(pathToTool, command); + // return result == 0; } catch (err) { core.warning(err.message); return false;