use of com.microsoft.azure.maven.auth.AzureAuthFailureException in project azure-maven-plugins by microsoft.
the class ConfigMojo method config.
protected void config(WebAppConfiguration configuration) throws MojoFailureException, AzureExecutionException, IOException, IllegalAccessException {
WebAppConfiguration result;
do {
if (configuration == null || !isProjectConfigured()) {
try {
result = chooseExistingWebappForConfiguration();
if (result == null) {
result = initConfig();
}
} catch (AzureAuthFailureException e) {
throw new AzureExecutionException(String.format("Cannot get Web App list due to error: %s.", e.getMessage()), e);
}
} else {
result = updateConfiguration(configuration.toBuilder().build());
}
} while (!confirmConfiguration(result));
Log.info(SAVING_TO_POM);
pomHandler.updatePluginConfiguration(result, configuration);
}
use of com.microsoft.azure.maven.auth.AzureAuthFailureException in project azure-maven-plugins by microsoft.
the class ConfigMojo method chooseExistingWebappForConfiguration.
private WebAppConfiguration chooseExistingWebappForConfiguration() throws AzureAuthFailureException {
try {
final AzureAppService az = getOrCreateAzureAppServiceClient();
if (Objects.isNull(az)) {
return null;
}
// get user selected sub id to persistent it in pom.xml
this.subscriptionId = az.getDefaultSubscription().getId();
// load configuration to detecting java or docker
Log.info(LONG_LOADING_HINT);
final List<WebAppOption> webAppOptionList = az.webapps().stream().map(WebAppOption::new).sorted().collect(Collectors.toList());
// check empty: first time
if (webAppOptionList.isEmpty()) {
Log.warn(NO_JAVA_WEB_APPS);
return null;
}
final boolean isContainer = !Utils.isJarPackagingProject(this.project.getPackaging());
final boolean isDockerOnly = Utils.isPomPackagingProject(this.project.getPackaging());
final List<WebAppOption> javaOrDockerWebapps = webAppOptionList.stream().filter(app -> app.isJavaWebApp() || app.isDockerWebapp()).filter(app -> checkWebAppVisible(isContainer, isDockerOnly, app.isJavaSE(), app.isDockerWebapp())).sorted().collect(Collectors.toList());
final TextIO textIO = TextIoFactory.getTextIO();
final WebAppOption selectedApp = selectAzureWebApp(textIO, javaOrDockerWebapps, getWebAppTypeByPackaging(this.project.getPackaging()), az.getDefaultSubscription());
if (selectedApp == null || selectedApp.isCreateNew()) {
return null;
}
final IWebApp webapp = az.webapp(selectedApp.getId());
final WebAppConfiguration.WebAppConfigurationBuilder<?, ?> builder = WebAppConfiguration.builder();
if (!AppServiceUtils.isDockerAppService(webapp)) {
builder.resources(Deployment.getDefaultDeploymentConfiguration(getProject().getPackaging()).getResources());
}
return getConfigurationFromExisting(webapp, builder);
} catch (AzureToolkitAuthenticationException ex) {
// if is valid for config goal to have error in authentication
getLog().warn(String.format("Cannot authenticate due to error: %s, select existing webapp is skipped.", ex.getMessage()));
return null;
}
}
Aggregations