Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapar9 committed Nov 13, 2023
1 parent ecc3356 commit 601c03d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
45 changes: 24 additions & 21 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,37 +235,40 @@ export class azurecontainerapps {
let resourceGroup: string = this.toolHelper.getInput('resourceGroup', false);
let containerAppEnvironment: string = this.toolHelper.getInput('containerAppEnvironment', false);

if (!this.util.isNullOrEmpty(location)) {
return location;
}

// If no location was provided, attempt to discover the location of the existing Container App Environment linked to the Container App
// or Container App Environment provided in the resource group or use the default location.
if (this.util.isNullOrEmpty(location)) {
if (!this.util.isNullOrEmpty(resourceGroup)) {
// Check if Container App exists in the resource group provided and get the location from the Container App Environment linked to it
let doesContainerAppExist = await this.appHelper.doesContainerAppExist(this.containerAppName, resourceGroup);
if (doesContainerAppExist) {
// Get the name of the Container App Environment linked to the Container App
var environmentName = await this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup);
// Check if environment exists in the resource group provided and get the location
var doesContainerAppEnvironmentExistInResourceGroup = !this.util.isNullOrEmpty(environmentName) ? await this.appHelper.doesContainerAppEnvironmentExist(environmentName, resourceGroup) : null;
if (doesContainerAppEnvironmentExistInResourceGroup) {
// Get the location of the Container App Environment linked to the Container App
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, resourceGroup);
return location;
}
}

// Check if Container App Environment is provided and exits in the resource group provided and get the location
let doesContainerAppEnvironmentExist = !this.util.isNullOrEmpty(containerAppEnvironment) ? await this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup) : null;
if (doesContainerAppEnvironmentExist) {
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment, resourceGroup);
if (!this.util.isNullOrEmpty(resourceGroup)) {
// Check if Container App exists in the resource group provided and get the location from the Container App Environment linked to it
let doesContainerAppExist = await this.appHelper.doesContainerAppExist(this.containerAppName, resourceGroup);
if (doesContainerAppExist) {
// Get the name of the Container App Environment linked to the Container App
var environmentName = await this.appHelper.getExistingContainerAppEnvironmentName(this.containerAppName, resourceGroup);
// Check if environment exists in the resource group provided and get the location
var doesContainerAppEnvironmentExistInResourceGroup = !this.util.isNullOrEmpty(environmentName) ? await this.appHelper.doesContainerAppEnvironmentExist(environmentName, resourceGroup) : false;
if (doesContainerAppEnvironmentExistInResourceGroup) {
// Get the location of the Container App Environment linked to the Container App
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(environmentName, resourceGroup);
return location;
}
}

// Get the default location for if the Container App or Container App Environment was not found in the resource group provided.
location = await this.appHelper.getDefaultContainerAppLocation();
// Check if Container App Environment is provided and exits in the resource group provided and get the location
let doesContainerAppEnvironmentExist = !this.util.isNullOrEmpty(containerAppEnvironment) ? await this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup) : false;
if (doesContainerAppEnvironmentExist) {
location = await this.appHelper.getExistingContainerAppEnvironmentLocation(containerAppEnvironment, resourceGroup);
return location;
}
}

// Get the default location for if the Container App or Container App Environment was not found in the resource group provided.
location = await this.appHelper.getDefaultContainerAppLocation();
return location;

}

/**
Expand Down
11 changes: 6 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ var azurecontainerapps = /** @class */ (function () {
location = this.toolHelper.getInput('location', false);
resourceGroup = this.toolHelper.getInput('resourceGroup', false);
containerAppEnvironment = this.toolHelper.getInput('containerAppEnvironment', false);
if (!this.util.isNullOrEmpty(location)) return [3 /*break*/, 14];
if (!this.util.isNullOrEmpty(location)) {
return [2 /*return*/, location];
}
if (!!this.util.isNullOrEmpty(resourceGroup)) return [3 /*break*/, 12];
return [4 /*yield*/, this.appHelper.doesContainerAppExist(this.containerAppName, resourceGroup)];
case 1:
Expand All @@ -286,7 +288,7 @@ var azurecontainerapps = /** @class */ (function () {
_a = _c.sent();
return [3 /*break*/, 5];
case 4:
_a = null;
_a = false;
_c.label = 5;
case 5:
doesContainerAppEnvironmentExistInResourceGroup = _a;
Expand All @@ -303,7 +305,7 @@ var azurecontainerapps = /** @class */ (function () {
_b = _c.sent();
return [3 /*break*/, 10];
case 9:
_b = null;
_b = false;
_c.label = 10;
case 10:
doesContainerAppEnvironmentExist = _b;
Expand All @@ -316,8 +318,7 @@ var azurecontainerapps = /** @class */ (function () {
case 13:
// Get the default location for if the Container App or Container App Environment was not found in the resource group provided.
location = _c.sent();
_c.label = 14;
case 14: return [2 /*return*/, location];
return [2 /*return*/, location];
}
});
});
Expand Down

0 comments on commit 601c03d

Please sign in to comment.