Skip to content

Commit

Permalink
Test containerapp update with up
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapar9 committed Nov 7, 2023
1 parent 2591105 commit a881a4e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ jobs:
uses: ./
with:
appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp'
containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }}
containerAppName: ${{ env.TEST_EXISTING_CONTAINER_APP }}
containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}
resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }}
disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }}
Expand Down
9 changes: 6 additions & 3 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,13 @@ export class azurecontainerapps {
* Creates or updates the Container App.
*/
private static async createOrUpdateContainerApp() {
var createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry
if (!this.containerAppExists) {
if (!this.util.isNullOrEmpty(this.yamlConfigPath)) {
// Create the Container App from the YAML configuration file
await this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath);
} else if ((!this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry)) {
await this.appHelper.createContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs);
} else if (createOrUpdateContainerAppWithUp) {
await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs);
} else {
// Create the Container App from command line arguments
await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs);
Expand All @@ -561,14 +562,16 @@ export class azurecontainerapps {
return;
}

if (this.shouldUseUpdateCommand) {
if (this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp) {
// Update the Container Registry details on the existing Container App, if provided as an input
if (!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword)) {
await this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword);
}

// Update the Container App using the 'update' command
await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs);
} else if (createOrUpdateContainerAppWithUp) {
await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs);
} else {
// Update the Container App using the 'up' command
await this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort);
Expand Down
36 changes: 22 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,11 @@ var azurecontainerapps = /** @class */ (function () {
*/
azurecontainerapps.createOrUpdateContainerApp = function () {
return __awaiter(this, void 0, void 0, function () {
var createOrUpdateContainerAppWithUp;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry;
if (!!this.containerAppExists) return [3 /*break*/, 7];
if (!!this.util.isNullOrEmpty(this.yamlConfigPath)) return [3 /*break*/, 2];
// Create the Container App from the YAML configuration file
Expand All @@ -638,8 +640,8 @@ var azurecontainerapps = /** @class */ (function () {
_a.sent();
return [3 /*break*/, 6];
case 2:
if (!(!this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry)) return [3 /*break*/, 4];
return [4 /*yield*/, this.appHelper.createContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs)];
if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 4];
return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)];
case 3:
_a.sent();
return [3 /*break*/, 6];
Expand All @@ -660,7 +662,7 @@ var azurecontainerapps = /** @class */ (function () {
_a.sent();
return [2 /*return*/];
case 9:
if (!this.shouldUseUpdateCommand) return [3 /*break*/, 13];
if (!(this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp)) return [3 /*break*/, 13];
if (!(!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 11];
return [4 /*yield*/, this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword)];
case 10:
Expand All @@ -672,21 +674,27 @@ var azurecontainerapps = /** @class */ (function () {
case 12:
// Update the Container App using the 'update' command
_a.sent();
return [3 /*break*/, 15];
case 13:
return [3 /*break*/, 17];
case 13:
if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 15];
return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)];
case 14:
_a.sent();
return [3 /*break*/, 17];
case 15:
// Update the Container App using the 'up' command
return [4 /*yield*/, this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort)];
case 14:
case 16:
// Update the Container App using the 'up' command
_a.sent();
_a.label = 15;
case 15:
if (!(this.ingress == 'disabled')) return [3 /*break*/, 17];
_a.label = 17;
case 17:
if (!(this.ingress == 'disabled')) return [3 /*break*/, 19];
return [4 /*yield*/, this.appHelper.disableContainerAppIngress(this.containerAppName, this.resourceGroup)];
case 16:
case 18:
_a.sent();
_a.label = 17;
case 17: return [2 /*return*/];
_a.label = 19;
case 19: return [2 /*return*/];
}
});
});
Expand Down Expand Up @@ -4752,7 +4760,7 @@ var ContainerAppHelper = /** @class */ (function () {
* @param environment - the Container App Environment that will be associated with the Container App
* @param optionalCmdArgs - a set of optional command line arguments
*/
ContainerAppHelper.prototype.createContainerAppWithUp = function (containerAppName, resourceGroup, environment, optionalCmdArgs) {
ContainerAppHelper.prototype.createOrUpdateContainerAppWithUp = function (containerAppName, resourceGroup, environment, location, optionalCmdArgs) {
return __awaiter(this, void 0, void 0, function () {
var command_2, err_2;
return __generator(this, function (_a) {
Expand All @@ -4762,7 +4770,7 @@ var ContainerAppHelper = /** @class */ (function () {
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " --environment " + environment + " --location northcentralusstage";
command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " --environment " + environment + " -l " + location;
optionalCmdArgs.forEach(function (val) {
command_2 += " " + val;
});
Expand Down
5 changes: 3 additions & 2 deletions src/ContainerAppHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ export class ContainerAppHelper {
* @param environment - the Container App Environment that will be associated with the Container App
* @param optionalCmdArgs - a set of optional command line arguments
*/
public async createContainerAppWithUp(
public async createOrUpdateContainerAppWithUp(
containerAppName: string,
resourceGroup: string,
environment: string,
location: string,
optionalCmdArgs: string[]) {
toolHelper.writeDebug(`Attempting to create Container App with name "${containerAppName}" in resource group "${resourceGroup}"`);
try {
let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --environment ${environment} --location northcentralusstage`;
let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --environment ${environment} -l ${location}`;
optionalCmdArgs.forEach(function (val: string) {
command += ` ${val}`;
});
Expand Down

0 comments on commit a881a4e

Please sign in to comment.