-
Notifications
You must be signed in to change notification settings - Fork 150
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
Feature aca maven plugin #2501
Feature aca maven plugin #2501
Conversation
* init aca maven plugin * remove useless items * fix comments
* init aca maven plugin * remove useless items * init acr build * reuse timestamp * fix comments * add todo
* init aca maven plugin * remove useless items * init acr build * reuse timestamp * fix comments * add todo * support generate dockerfile * remove useless comments * fix comments
* init aca maven plugin * remove useless items * init acr build * reuse timestamp * fix comments * add todo * support generate dockerfile * remove useless comments * add unit tests and remove todo * merge fix comments * rename folder * fix * fix pom * small fix * small word fix
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<configuration> | ||
<goalPrefix>aca</goalPrefix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, let's remove this short prefix for now according to: Azure Container Apps branding guidelines
if (MavenConfigUtils.isJarPackaging(project)) { | ||
return true; | ||
} else if (MavenConfigUtils.isPomPackaging(project)) { | ||
log.info(PROJECT_SKIP); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a common practice to extract the log contents to constants, especially when they are not reused. Suggest to use plain text here and for the other 3 log constants.
@@ -8,13 +8,15 @@ user/functionapp.package=generate configuration files and prepare staging direct | |||
user/functionapp.run=run function app locally | |||
user/webapp.deploy_app=deploy to Azure Web App with resource creation or updating | |||
user/webapp.config=generate configuration for web app maven plugin | |||
user/containerapps.deploy_mojo=deploy Container app to Azure from config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When referring to a single Container Apps instance, use lower case singular container app
######################end mojo action operations###################### | ||
######################start auto action operations###################### | ||
auto/$resource.preload.type=preload {0}s | ||
auto/$resource.refresh_on_subscription_changed.type=refresh {0}s on subscription changed | ||
######################end auto action operations###################### | ||
######################start common service operations###################### | ||
internal/account.login.type=login with ({0}) | ||
internal/containerapps.create_update_app.app=create or update Container app({0}) from config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
container app
for single instance reference
* use mariner image * ifx * fix comments * use java 17 as default * modify dockerfile comments
} | ||
|
||
private void preCheck(ContainerAppsEnvironmentConfig environmentConfig) { | ||
Optional.ofNullable(environmentConfig).map(ContainerAppsEnvironmentConfig::getSubscriptionId).filter(StringUtils::isNotBlank).orElseThrow(() -> new AzureToolkitRuntimeException("'subscriptionId' is required")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract the common check to a method, and avoid repeated, too long lines.
<T> String checkNotBlank(T config, Function<T, String> getter, String name) {
if (config != null) {
String value = getter.apply(config);
if (StringUtils.isNotBlank(value)) {
return value;
}
}
throw new AzureToolkitRuntimeException(String.format("'%s' is required", name));
}
Call with
checkNotBlank(environmentConfig, ContainerAppsEnvironmentConfig::getSubscriptionId, "subscriptionId");
.getOrDraft(config.getResourceGroup(), config.getResourceGroup()); | ||
|
||
if (resourceGroup.isDraftForCreating() && !resourceGroup.exists()) { | ||
final String region = Optional.ofNullable(config.getRegion()).filter(StringUtils::isNotBlank).orElseThrow(() -> new AzureToolkitRuntimeException("'region' is required")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, to use common check.
* Boolean flag to control whether to wait the deployment status to be ready after deployment | ||
*/ | ||
@Parameter(property = "noWait") | ||
private Boolean noWait; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we use the two parameters anywhere else? Shall we remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
return null; | ||
} | ||
final String defaultImageName = String.format("%s%s/%s:%s", config.getRegistryConfig().getRegistryName(), ContainerRegistry.ACR_IMAGE_SUFFIX, mojo.getAppName(), timestamp); | ||
final String fullImageName = Optional.ofNullable(containers.get(0).getImage()).orElse(defaultImageName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we only accept the first container configuration, if so, why not change mojo.getContainers to AppContainerMavenConfig
instead of a List?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we will spike if we should support multi container payload later. For the first edition, we can just keep the list for future scalability
return null; | ||
} | ||
final ResourceConfiguration resourceConfiguration = new ResourceConfiguration(); | ||
resourceConfiguration.setCpu(containers.get(0).getCpu()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
.map(action -> action.bind("https://aka.ms/azure-container-apps-java")) | ||
.orElse(null); | ||
|
||
final Action<String> openPortal = Optional.ofNullable(AzureActionManager.getInstance().getAction(Action.OPEN_URL).withLabel("Open Portal")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before code is to open the portal page of this container app, do we need to change it to open portal instead? Besides, we should read the portal url from AzureEnvironment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert the URL. Sorry for the mistake.
@wangmingliang-ms Please help check the logic changes in aca deployments~ |
.orElse(null); | ||
|
||
final Action<String> openPortal = Optional.ofNullable(AzureActionManager.getInstance().getAction(Action.OPEN_URL).withLabel("Open Portal")) | ||
.map(action -> action.bind("https://portal.azure.com")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to change the url?
- this action is to open the portal page of this specific resource.
https://portal.azure.com
is not the right url of all Azure Environments' portal pages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert the URL. Sorry for the mistake.
final Action<String> learnMore = AzureActionManager.getInstance().getAction(Action.OPEN_URL).withLabel("Learn More").bind("https://aka.ms/azuretools-aca-stack"); | ||
final Action<String> openPortal = AzureActionManager.getInstance().getAction(Action.OPEN_URL).withLabel("Open Portal").bind(this.getPortalUrl()); | ||
final Action<String> learnMore = Optional.ofNullable(AzureActionManager.getInstance().getAction(Action.OPEN_URL).withLabel("Learn More")) | ||
.map(action -> action.bind("https://aka.ms/azure-container-apps-java")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to change this url?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert the URL. Sorry for the mistake.
@@ -0,0 +1,5 @@ | |||
ARG JAVA_VERSION=17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if user's project is developped upon Java 21?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will use Java 21 and 17 is a default version if no java version detected.
Here we detect the java version and add it into buildImageConfig.sourceBuildEnv (we just reuse this map). code link
And then we put this into ACR build args code link
These build args will override the JAVA_VERSION=17 in the dockerfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -128,7 +128,8 @@ public void testGetContainerAppConfigImage() { | |||
} | |||
|
|||
@Test | |||
public void testGetContainerAppConfigCode() { | |||
public void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this implement/fix? Explain your changes.
…
Implement aca maven plugin
Support 3 paths:
deploy image
deploy code
deploy artifact
Have breaking change in the azure-toolkit-containerapp-lib:
Will use generate dockerfile and use ACR to build if dockerfile doesn't exist instead of oryx. The intellij plugin can reuse this logic later.
Does this close any currently open issues?
Any relevant logs, screenshots, error output, etc.?
Any other comments?
…
Has this been tested?