Skip to content

Commit

Permalink
Fix validation failures
Browse files Browse the repository at this point in the history
  • Loading branch information
snehapar9 committed Nov 9, 2023
1 parent 64289e5 commit 67f2e61
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
46 changes: 22 additions & 24 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class azurecontainerapps {
this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl);

// Set up property to trigger cloud build with 'up' command
this.createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry;
this.shouldCreateOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry;

// If the application source was provided, build a runnable application image from it
if (!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath)) {
Expand Down Expand Up @@ -105,7 +105,7 @@ export class azurecontainerapps {
private static targetPort: string;
private static shouldUseUpdateCommand: boolean;
private static useInternalRegistry: boolean;
private static createOrUpdateContainerAppWithUp: boolean;
private static shouldCreateOrUpdateContainerAppWithUp: boolean;

/**
* Initializes the helpers used by this task.
Expand Down Expand Up @@ -180,7 +180,7 @@ export class azurecontainerapps {
* setting the Azure CLI to install missing extensions.
*/
private static async setupAzureCli() {
// Set the Azure CLI to install missing extensions
// Set the Azure CLI to install missing extension
await this.util.installAzureCliExtension();
}

Expand Down Expand Up @@ -350,21 +350,21 @@ export class azurecontainerapps {
* Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry.
*/
private static async buildAndPushImageAsync() {
// Get the name of the image to build if it was provided, or generate it from build variables
this.imageToBuild = this.toolHelper.getInput('imageToBuild', false);

if (this.util.isNullOrEmpty(this.imageToBuild)) {
const imageRepository = this.toolHelper.getDefaultImageRepository()
// Constructs the image to build based on the provided registry URL, image repository, build ID, and build number.
this.imageToBuild = `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`;
this.toolHelper.writeInfo(`Default image to build: ${this.imageToBuild}`);
}

// Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild'
if (this.util.isNullOrEmpty(this.imageToDeploy)) {
this.imageToDeploy = this.imageToBuild;
this.toolHelper.writeInfo(`Default image to deploy: ${this.imageToDeploy}`);
}
// Get the name of the image to build if it was provided, or generate it from build variables
this.imageToBuild = this.toolHelper.getInput('imageToBuild', false);

if (this.util.isNullOrEmpty(this.imageToBuild)) {
const imageRepository = this.toolHelper.getDefaultImageRepository()
// Constructs the image to build based on the provided registry URL, image repository, build ID, and build number.
this.imageToBuild = `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`;
this.toolHelper.writeInfo(`Default image to build: ${this.imageToBuild}`);
}

// Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild'
if (this.util.isNullOrEmpty(this.imageToDeploy)) {
this.imageToDeploy = this.imageToBuild;
this.toolHelper.writeInfo(`Default image to deploy: ${this.imageToDeploy}`);
}

// Get Dockerfile to build, if provided, or check if one exists at the root of the provided application
let dockerfilePath: string = this.toolHelper.getInput('dockerfilePath', false);
Expand Down Expand Up @@ -531,9 +531,7 @@ export class azurecontainerapps {
// Ensure '-i' argument and '--source' argument are not both provided
if (!this.util.isNullOrEmpty(this.imageToDeploy)) {
this.commandLineArgs.push(`-i ${this.imageToDeploy}`);
}

if (this.createOrUpdateContainerApp) {
} else if (this.shouldCreateOrUpdateContainerAppWithUp) {
this.commandLineArgs.push(`--source ${this.appSourcePath}`);
}

Expand All @@ -547,7 +545,7 @@ export class azurecontainerapps {
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.createOrUpdateContainerAppWithUp) {
} else if (this.shouldCreateOrUpdateContainerAppWithUp) {
await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs);
} else {
// Create the Container App from command line arguments
Expand All @@ -564,15 +562,15 @@ export class azurecontainerapps {
return;
}

if (this.shouldUseUpdateCommand && !this.createOrUpdateContainerAppWithUp) {
if (this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp) {
// 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 (this.createOrUpdateContainerAppWithUp) {
} else if (this.shouldCreateOrUpdateContainerAppWithUp) {
await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs);
} else {
// Update the Container App using the 'up' command
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var azurecontainerapps = /** @class */ (function () {
// Set up property to determine if the internal registry should be used
this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl);
// Set up property to trigger cloud build with 'up' command
this.createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry;
this.shouldCreateOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry;
if (!(!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath))) return [3 /*break*/, 9];
return [4 /*yield*/, this.buildAndPushImageAsync()];
case 8:
Expand Down Expand Up @@ -191,10 +191,10 @@ var azurecontainerapps = /** @class */ (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// Set the Azure CLI to install missing extensions
// Set the Azure CLI to install missing extension
return [4 /*yield*/, this.util.installAzureCliExtension()];
case 1:
// Set the Azure CLI to install missing extensions
// Set the Azure CLI to install missing extension
_a.sent();
return [2 /*return*/];
}
Expand Down Expand Up @@ -611,7 +611,7 @@ var azurecontainerapps = /** @class */ (function () {
if (!this.util.isNullOrEmpty(this.imageToDeploy)) {
this.commandLineArgs.push("-i " + this.imageToDeploy);
}
if (this.createOrUpdateContainerApp) {
else if (this.shouldCreateOrUpdateContainerAppWithUp) {
this.commandLineArgs.push("--source " + this.appSourcePath);
}
};
Expand All @@ -632,7 +632,7 @@ var azurecontainerapps = /** @class */ (function () {
_a.sent();
return [3 /*break*/, 6];
case 2:
if (!this.createOrUpdateContainerAppWithUp) return [3 /*break*/, 4];
if (!this.shouldCreateOrUpdateContainerAppWithUp) return [3 /*break*/, 4];
return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)];
case 3:
_a.sent();
Expand All @@ -654,7 +654,7 @@ var azurecontainerapps = /** @class */ (function () {
_a.sent();
return [2 /*return*/];
case 9:
if (!(this.shouldUseUpdateCommand && !this.createOrUpdateContainerAppWithUp)) return [3 /*break*/, 13];
if (!(this.shouldUseUpdateCommand && !this.shouldCreateOrUpdateContainerAppWithUp)) 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 @@ -668,7 +668,7 @@ var azurecontainerapps = /** @class */ (function () {
_a.sent();
return [3 /*break*/, 17];
case 13:
if (!this.createOrUpdateContainerAppWithUp) return [3 /*break*/, 15];
if (!this.shouldCreateOrUpdateContainerAppWithUp) return [3 /*break*/, 15];
return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)];
case 14:
_a.sent();
Expand Down

0 comments on commit 67f2e61

Please sign in to comment.