Skip to content

Commit

Permalink
Refactor and test
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapar9 committed Sep 19, 2023
1 parent cb01366 commit b27d861
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 69 deletions.
38 changes: 13 additions & 25 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5156,7 +5156,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [3 /*break*/, 4];
case 3:
err_10 = _b.sent();
core.setFailed(err_10.message);
core.error(err_10.message);
throw err_10;
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -5185,7 +5185,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [2 /*return*/, !stderr ? stdout : null];
case 3:
err_11 = _b.sent();
core.error(err_11.message);
core.warning(err_11.message);
return [2 /*return*/, null];
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -5223,7 +5223,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [3 /*break*/, 4];
case 3:
err_12 = _b.sent();
core.setFailed(err_12.message);
core.error(err_12.message);
throw err_12;
case 4: return [2 /*return*/];
}
Expand All @@ -5250,13 +5250,13 @@ var ContainerAppHelper = /** @class */ (function () {
case 2:
_a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr;
if (stderr) {
core.error('Failed to disable ingress for Container App, Error: ' + stderr);
core.warning('Failed to disable ingress for Container App, Error: ' + stderr);
throw new Error(stderr);
}
return [3 /*break*/, 4];
case 3:
err_13 = _b.sent();
core.setFailed(err_13.message);
core.error(err_13.message);
throw err_13;
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -5286,13 +5286,13 @@ var ContainerAppHelper = /** @class */ (function () {
case 2:
_a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr;
if (stderr) {
core.error('Failed to set the ACR details for Container App, Error: ' + stderr);
core.warning('Failed to set the ACR details for Container App, Error: ' + stderr);
throw new Error(stderr);
}
return [3 /*break*/, 4];
case 3:
err_14 = _b.sent();
core.setFailed(err_14.message);
core.error(err_14.message);
throw err_14;
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -5329,7 +5329,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [3 /*break*/, 4];
case 3:
err_15 = _b.sent();
core.setFailed(err_15.message);
core.error(err_15.message);
throw err_15;
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -5911,24 +5911,12 @@ var Utility = /** @class */ (function () {
*/
Utility.prototype.setAzureCliDynamicInstall = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, stdout, stderr, error_2;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, cpExec("az config set extension.use_dynamic_install=yes_without_prompt")];
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, cpExec("az config set extension.use_dynamic_install=yes_without_prompt")];
case 1:
_a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr;
if (stderr) {
core.error("Unable to set Azure CLI to dynamically install extensions. Error: " + stderr);
throw new Error("Unable to set Azure CLI to dynamically install extensions. Error: " + stderr);
}
return [3 /*break*/, 3];
case 2:
error_2 = _b.sent();
core.setFailed("Error: " + error_2.message);
throw error_2; // Re-throw the error
case 3: return [2 /*return*/];
_a.sent();
return [2 /*return*/];
}
});
});
Expand Down
16 changes: 8 additions & 8 deletions src/ContainerAppHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [3 /*break*/, 4];
case 3:
err_10 = _b.sent();
core.setFailed(err_10.message);
core.error(err_10.message);
throw err_10;
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -411,7 +411,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [2 /*return*/, !stderr ? stdout : null];
case 3:
err_11 = _b.sent();
core.error(err_11.message);
core.warning(err_11.message);
return [2 /*return*/, null];
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -449,7 +449,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [3 /*break*/, 4];
case 3:
err_12 = _b.sent();
core.setFailed(err_12.message);
core.error(err_12.message);
throw err_12;
case 4: return [2 /*return*/];
}
Expand All @@ -476,13 +476,13 @@ var ContainerAppHelper = /** @class */ (function () {
case 2:
_a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr;
if (stderr) {
core.error('Failed to disable ingress for Container App, Error: ' + stderr);
core.warning('Failed to disable ingress for Container App, Error: ' + stderr);
throw new Error(stderr);
}
return [3 /*break*/, 4];
case 3:
err_13 = _b.sent();
core.setFailed(err_13.message);
core.error(err_13.message);
throw err_13;
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -512,13 +512,13 @@ var ContainerAppHelper = /** @class */ (function () {
case 2:
_a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr;
if (stderr) {
core.error('Failed to set the ACR details for Container App, Error: ' + stderr);
core.warning('Failed to set the ACR details for Container App, Error: ' + stderr);
throw new Error(stderr);
}
return [3 /*break*/, 4];
case 3:
err_14 = _b.sent();
core.setFailed(err_14.message);
core.error(err_14.message);
throw err_14;
case 4: return [2 /*return*/];
}
Expand Down Expand Up @@ -555,7 +555,7 @@ var ContainerAppHelper = /** @class */ (function () {
return [3 /*break*/, 4];
case 3:
err_15 = _b.sent();
core.setFailed(err_15.message);
core.error(err_15.message);
throw err_15;
case 4: return [2 /*return*/];
}
Expand Down
16 changes: 8 additions & 8 deletions src/ContainerAppHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class ContainerAppHelper {
throw new Error(stderr);
}
} catch (err) {
core.setFailed(err.message);
core.error(err.message);
throw err;
}
}
Expand All @@ -265,7 +265,7 @@ export class ContainerAppHelper {
const {stdout, stderr} = await cpExec(`${command}`);
return !stderr ? stdout : null;
} catch (err) {
core.error(err.message);
core.warning(err.message);
return null;
}
}
Expand All @@ -290,7 +290,7 @@ export class ContainerAppHelper {
throw new Error(stderr);
}
} catch (err) {
core.setFailed(err.message);
core.error(err.message);
throw err;
}
}
Expand All @@ -306,11 +306,11 @@ export class ContainerAppHelper {
const command = `az containerapp ingress disable -n ${name} -g ${resourceGroup}`;
const {stdout, stderr} = await cpExec(`${command}`);
if (stderr) {
core.error('Failed to disable ingress for Container App, Error: ' + stderr);
core.warning('Failed to disable ingress for Container App, Error: ' + stderr);
throw new Error(stderr);
}
} catch (err) {
core.setFailed(err.message);
core.error(err.message);
throw err;
}
}
Expand All @@ -329,11 +329,11 @@ export class ContainerAppHelper {
const command = `az containerapp registry set -n ${name} -g ${resourceGroup} --server ${acrName}.azurecr.io --username ${acrUsername} --password ${acrPassword}`;
const {stdout, stderr} = await cpExec(`${command}`);
if (stderr) {
core.error('Failed to set the ACR details for Container App, Error: ' + stderr);
core.warning('Failed to set the ACR details for Container App, Error: ' + stderr);
throw new Error(stderr);
}
} catch (err) {
core.setFailed(err.message);
core.error(err.message);
throw err;
}
}
Expand All @@ -360,7 +360,7 @@ export class ContainerAppHelper {
throw new Error(stderr);
}
} catch (err) {
core.setFailed(err.message);
core.error(err.message);
throw err;
}
}
Expand Down
22 changes: 5 additions & 17 deletions src/Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,12 @@ var Utility = /** @class */ (function () {
*/
Utility.prototype.setAzureCliDynamicInstall = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, stdout, stderr, error_2;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, cpExec("az config set extension.use_dynamic_install=yes_without_prompt")];
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, cpExec("az config set extension.use_dynamic_install=yes_without_prompt")];
case 1:
_a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr;
if (stderr) {
core.error("Unable to set Azure CLI to dynamically install extensions. Error: " + stderr);
throw new Error("Unable to set Azure CLI to dynamically install extensions. Error: " + stderr);
}
return [3 /*break*/, 3];
case 2:
error_2 = _b.sent();
core.setFailed("Error: " + error_2.message);
throw error_2; // Re-throw the error
case 3: return [2 /*return*/];
_a.sent();
return [2 /*return*/];
}
});
});
Expand Down
12 changes: 1 addition & 11 deletions src/Utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,7 @@ export class Utility {
* Azure Container Apps module being dynamically installed while it's still in preview.
*/
public async setAzureCliDynamicInstall() {
try {
const { stdout, stderr } = await cpExec(`az config set extension.use_dynamic_install=yes_without_prompt`);
if (stderr) {
core.error(`Unable to set Azure CLI to dynamically install extensions. Error: ${stderr}`);
throw new Error(`Unable to set Azure CLI to dynamically install extensions. Error: ${stderr}`);
}
}
catch (error) {
core.setFailed(`Error: ${error.message}`);
throw error; // Re-throw the error
}
await cpExec(`az config set extension.use_dynamic_install=yes_without_prompt`);
}

/**
Expand Down

0 comments on commit b27d861

Please sign in to comment.