Skip to content

Commit

Permalink
Set location
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapar9 committed Nov 12, 2023
1 parent 145abc7 commit 24b2289
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
10 changes: 8 additions & 2 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,23 @@ export class azurecontainerapps {
// Set deployment location, if provided
let location: string = this.toolHelper.getInput('location', false);
let resourceGroup: string = this.toolHelper.getInput('resourceGroup', false);
let containerAppEnvironment: string = this.toolHelper.getInput('containerAppEnvironment', false);

// If no location was provided, use the default location for the Container App service
// If no location was provided, attempt to discover the location of the existing Container App
// or Container App Environment in the resource group or use the default location.
if (this.util.isNullOrEmpty(location)) {
if (!this.util.isNullOrEmpty(resourceGroup)) {
let doesContainerAppExist = await this.appHelper.doesContainerAppExist(this.containerAppName, resourceGroup);
let doesContainerAppEnvironmentExist = await this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup);
if (doesContainerAppExist) {
var environmentName = await this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup);
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, resourceGroup);
} else if (doesContainerAppEnvironmentExist) {
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment, resourceGroup);
} else {
location = await this.appHelper.getDefaultContainerAppLocation();
}
}
// location = await this.appHelper.getDefaultContainerAppLocation();
}

return location;
Expand Down
30 changes: 22 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,26 +256,40 @@ var azurecontainerapps = /** @class */ (function () {
*/
azurecontainerapps.getLocation = function () {
return __awaiter(this, void 0, void 0, function () {
var location, resourceGroup, doesContainerAppExist, environmentName;
var location, resourceGroup, containerAppEnvironment, doesContainerAppExist, doesContainerAppEnvironmentExist, environmentName;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
location = this.toolHelper.getInput('location', false);
resourceGroup = this.toolHelper.getInput('resourceGroup', false);
if (!this.util.isNullOrEmpty(location)) return [3 /*break*/, 4];
if (!!this.util.isNullOrEmpty(resourceGroup)) return [3 /*break*/, 4];
containerAppEnvironment = this.toolHelper.getInput('containerAppEnvironment', false);
if (!this.util.isNullOrEmpty(location)) return [3 /*break*/, 9];
if (!!this.util.isNullOrEmpty(resourceGroup)) return [3 /*break*/, 9];
return [4 /*yield*/, this.appHelper.doesContainerAppExist(this.containerAppName, resourceGroup)];
case 1:
doesContainerAppExist = _a.sent();
if (!doesContainerAppExist) return [3 /*break*/, 4];
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup)];
return [4 /*yield*/, this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup)];
case 2:
doesContainerAppEnvironmentExist = _a.sent();
if (!doesContainerAppExist) return [3 /*break*/, 5];
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup)];
case 3:
environmentName = _a.sent();
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, resourceGroup)];
case 3:
case 4:
location = _a.sent();
_a.label = 4;
case 4: return [2 /*return*/, location];
return [3 /*break*/, 9];
case 5:
if (!doesContainerAppEnvironmentExist) return [3 /*break*/, 7];
return [4 /*yield*/, this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment, resourceGroup)];
case 6:
location = _a.sent();
return [3 /*break*/, 9];
case 7: return [4 /*yield*/, this.appHelper.getDefaultContainerAppLocation()];
case 8:
location = _a.sent();
_a.label = 9;
case 9: return [2 /*return*/, location];
}
});
});
Expand Down

0 comments on commit 24b2289

Please sign in to comment.