diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index fb883a3a..9b8e0933 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -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; + } /** diff --git a/dist/index.js b/dist/index.js index cda04011..9dbc5bc5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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: @@ -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; @@ -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; @@ -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]; } }); });