Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support private registry scenario #69

Merged
merged 61 commits into from
Nov 7, 2023
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
0383b9f
Initial commit to support private registry scenario
snehapar9 Nov 1, 2023
ce4ac15
Add global var to delegate build to CLI
snehapar9 Nov 2, 2023
30fd911
Update condition to use CLI
snehapar9 Nov 2, 2023
4d3b82e
Fix formatting
snehapar9 Nov 2, 2023
88c1664
Update validation for internal registry scenario
snehapar9 Nov 2, 2023
14be3d1
Address PR comments
snehapar9 Nov 2, 2023
68c4f2b
Update condition to use internal registry
snehapar9 Nov 3, 2023
5202836
Test validation for internal registry scenario
snehapar9 Nov 3, 2023
2c44254
Get value of imageToBuild before build
snehapar9 Nov 3, 2023
d60d1ad
Fetch imageToBuild arg and test
snehapar9 Nov 3, 2023
82fc8a6
Move code to fetch imageToBuild in validation
snehapar9 Nov 3, 2023
7504bcc
Install extension
snehapar9 Nov 3, 2023
91c1220
Trigger pipeline
snehapar9 Nov 3, 2023
9d3dbbe
Re-trigger pipeline to install extensions
snehapar9 Nov 3, 2023
f8db478
Re-trigger pipeline to isntall extension
snehapar9 Nov 3, 2023
5e7f726
Install extension and re-trigger pipeline
snehapar9 Nov 3, 2023
66a9c87
Explicitly install extension
snehapar9 Nov 3, 2023
ac8d5e0
Trigger pipeline
snehapar9 Nov 3, 2023
e65fde1
Re-trigger pipeline
snehapar9 Nov 3, 2023
392e298
Change whl name
snehapar9 Nov 4, 2023
fe94eb9
Fix pipeline failure and re-trigger
snehapar9 Nov 4, 2023
7d001e7
Fix pipeline failures
snehapar9 Nov 6, 2023
e6fd4b0
Install extension explicitly
snehapar9 Nov 6, 2023
aaa10e0
Fix valiation failures
snehapar9 Nov 6, 2023
030ce76
Fix validation failures
snehapar9 Nov 6, 2023
e8a0560
Test validation failures
snehapar9 Nov 6, 2023
fb20d01
Test validation failures
snehapar9 Nov 6, 2023
565772d
Remove location
snehapar9 Nov 6, 2023
eae94cc
Test validation pipeline
snehapar9 Nov 6, 2023
b24e0bd
Test validation pipeline
snehapar9 Nov 6, 2023
53b5515
Test validation pipeline
snehapar9 Nov 6, 2023
f8cf64f
Test validation pipeline
snehapar9 Nov 6, 2023
ea2178d
Test validation pipeline
snehapar9 Nov 6, 2023
7044f5d
Trigger validation pipeline
snehapar9 Nov 6, 2023
0df8476
Test validation pipeline
snehapar9 Nov 6, 2023
e06372b
Address validation failures
snehapar9 Nov 6, 2023
751a10d
Address PR discussion comments
snehapar9 Nov 6, 2023
8aeb783
Made `imageToDeploy` optional
snehapar9 Nov 6, 2023
2bb7743
Remove step to install whl
snehapar9 Nov 6, 2023
fbd86a2
Address PR comments
snehapar9 Nov 6, 2023
6c4911f
Addressed PR comments
snehapar9 Nov 6, 2023
bbe7c90
Fix typo
snehapar9 Nov 6, 2023
a90481a
Remove space
snehapar9 Nov 6, 2023
8772387
Merge branch 'snehapar/Suppor-private-registry
snehapar9 Nov 6, 2023
3af7b4a
Fix merge failure
snehapar9 Nov 6, 2023
3157879
Remove --debug
snehapar9 Nov 6, 2023
6cb173e
Test registry scenario
snehapar9 Nov 7, 2023
fd223cc
Fix merge failures and re-trigger pipeline
snehapar9 Nov 7, 2023
023d186
Add --debug
snehapar9 Nov 7, 2023
2b1f195
Create containerapp with up
snehapar9 Nov 7, 2023
c82c5bb
Create container app with up
snehapar9 Nov 7, 2023
8f4224e
Trigger validation pipeline
snehapar9 Nov 7, 2023
4afc10e
Test container app creation with up
snehapar9 Nov 7, 2023
6865750
Add location to up command
snehapar9 Nov 7, 2023
2b40846
Use up for just private registry scenario
snehapar9 Nov 7, 2023
0911425
Change rg for update scenario
snehapar9 Nov 7, 2023
2591105
Remove step to delete pushed image
snehapar9 Nov 7, 2023
a881a4e
Test containerapp update with up
snehapar9 Nov 7, 2023
f089aa7
Merge branch 'v2-main' of https://github.com/azure/container-apps-dep…
cormacpayne Nov 7, 2023
b4f92f9
Hardcode location to northcentralusstage
snehapar9 Nov 7, 2023
b917eb7
Remove app source path
snehapar9 Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial commit to support private registry scenario
  • Loading branch information
snehapar9 committed Nov 1, 2023
commit 0383b9f91fd64dbbcf3580a1b2a14987d7b74e56
34 changes: 31 additions & 3 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
@@ -150,8 +150,12 @@ export class azurecontainerapps {
// Get the YAML configuration file, if provided
this.yamlConfigPath = this.toolHelper.getInput('yamlConfigPath', false) as string;

// Get the name of the image to build, if provided
this.imageToBuild = this.toolHelper.getInput('imageToBuild', false) as string;
snehapar9 marked this conversation as resolved.
Show resolved Hide resolved

// Ensure that acrName or registryUrl is also provided if appSourcePath is provided
if (!this.util.isNullOrEmpty(this.appSourcePath) && this.util.isNullOrEmpty(this.acrName) && this.util.isNullOrEmpty(this.registryUrl)) {
// and if imageToBuild is either empty or doesn't start with 'default/' (i.e. it's not source to cloud scenario)
if (!this.util.isNullOrEmpty(this.appSourcePath) && this.util.isNullOrEmpty(this.acrName) && this.util.isNullOrEmpty(this.registryUrl) && (this.util.isNullOrEmpty(this.imageToBuild) || !this.imageToBuild.startsWith('default/'))) {
snehapar9 marked this conversation as resolved.
Show resolved Hide resolved
snehapar9 marked this conversation as resolved.
Show resolved Hide resolved
let missingRegistryUrlMessage = `The 'acrName' or 'registryUrl' argument must be provided when the 'appSourcePath' argument is provided.`;
snehapar9 marked this conversation as resolved.
Show resolved Hide resolved
this.toolHelper.writeError(missingRegistryUrlMessage);
throw Error(missingRegistryUrlMessage);
@@ -170,6 +174,20 @@ export class azurecontainerapps {
this.toolHelper.writeError(conflictingArgumentsMessage);
throw Error(conflictingArgumentsMessage);
}

// Ensure that the imageToBuild and source arguments are both provided and imageToBuild starts with 'default/'
if (!this.util.isNullOrEmpty(this.imageToBuild) && !this.util.isNullOrEmpty(this.appSourcePath) && !this.imageToBuild.startsWith('default/')) {
snehapar9 marked this conversation as resolved.
Show resolved Hide resolved
let conflictingArgumentsMessage = `The 'imageToBuild' and 'appSourcePath' arguments must both be provided and 'imageToBuild' must start with 'default/'.`;
this.toolHelper.writeError(conflictingArgumentsMessage);
throw Error(conflictingArgumentsMessage);
}

// Ensure that that the registryUrl is not provided if the imageToBuild starts with 'default/'
if (!this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith('default/')) {
let conflictingArgumentsMessage = `The 'registryUrl' argument cannot be provided if 'imageToBuild' starts with 'default/'.`;
this.toolHelper.writeError(conflictingArgumentsMessage);
throw Error(conflictingArgumentsMessage);
}
}

/**
@@ -521,7 +539,12 @@ 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 {
}
else if (!this.util.isNullOrEmpty(this.imageToDeploy) && this.imageToDeploy.startsWith('default/')) {
// Create the Container App from application source for the 'source to cloud' scenario
await this.appHelper.createOrUpdateContainerAppFromAppSource(this.containerAppEnvironment, this.resourceGroup, this.containerAppEnvironment, this.appSourcePath, this.commandLineArgs);
}
else {
// Create the Container App from command line arguments
await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.imageToDeploy, this.commandLineArgs);
}
@@ -544,7 +567,12 @@ export class azurecontainerapps {

// Update the Container App using the 'update' command
await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs);
} else {
}
else if (!this.util.isNullOrEmpty(this.imageToDeploy) && this.imageToDeploy.startsWith('default/')) {
// Create the Container App from application source for the 'source to cloud' scenario
await this.appHelper.createOrUpdateContainerAppFromAppSource(this.containerAppEnvironment, this.resourceGroup, this.containerAppEnvironment, this.appSourcePath, this.commandLineArgs);
}
else {
// Update the Container App using the 'up' command
await this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs, this.ingress, this.targetPort);
}
27 changes: 27 additions & 0 deletions src/ContainerAppHelper.ts
Original file line number Diff line number Diff line change
@@ -65,6 +65,33 @@ export class ContainerAppHelper {
}
}

/**
* Creates or updates an Azure Container App from application source for source to cloud scenario.
* @param containerAppEnvironment - the name of the Container App Environment
* @param resourceGroup - the resource group that the Container App Environment will be created in
* @param containerAppName - the name of the Container App
* @param appSourcePath - the path to the application source on the machine
* @param optionalCmdArgs - a set of optional command line arguments
*/
public async createOrUpdateContainerAppFromAppSource(
containerAppEnvironment: string,
resourceGroup: string,
containerAppName: string,
appSourcePath: string,
optionalCmdArgs: string[]) {
toolHelper.writeDebug(`Attempting to create or update Container App with name "${containerAppName}" in resource group "${resourceGroup}" from application source "${appSourcePath}"`);
try {
let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --environment ${containerAppEnvironment} --source ${appSourcePath} --output none`;
optionalCmdArgs.forEach(function (val: string) {
command += ` ${val}`;
});
await util.execute(command);
} catch (err) {
toolHelper.writeError(err.message);
throw err;
}
}

/**
* Updates an existing Azure Container App based from an image that was previously built.
* @param containerAppName - the name of the existing Container App