use of com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig in project azure-maven-plugins by microsoft.
the class AbstractWebAppMojo method getTelemetryProperties.
// endregion
// region Telemetry Configuration Interface
@Override
public Map<String, String> getTelemetryProperties() {
final Map<String, String> map = super.getTelemetryProperties();
final MavenRuntimeConfig runtimeConfig = getRuntime();
final String os = Optional.ofNullable(runtimeConfig).map(MavenRuntimeConfig::getOs).orElse(StringUtils.EMPTY);
map.put(SCHEMA_VERSION_KEY, schemaVersion);
map.put(OS_KEY, os);
if (StringUtils.equalsIgnoreCase(os, OperatingSystem.DOCKER.getValue())) {
final String imageType = AppServiceUtils.getDockerImageType(runtimeConfig.getImage(), StringUtils.isEmpty(runtimeConfig.getServerId()), runtimeConfig.getRegistryUrl()).name();
map.put(DOCKER_IMAGE_TYPE_KEY, imageType);
} else {
map.put(DOCKER_IMAGE_TYPE_KEY, DockerImageType.NONE.toString());
}
map.put(JAVA_VERSION_KEY, Optional.ofNullable(runtimeConfig).map(MavenRuntimeConfig::getJavaVersion).orElse(StringUtils.EMPTY));
map.put(JAVA_WEB_CONTAINER_KEY, Optional.ofNullable(runtimeConfig).map(MavenRuntimeConfig::getWebContainer).orElse(StringUtils.EMPTY));
try {
map.put(DEPLOYMENT_TYPE_KEY, getDeploymentType().toString());
} catch (AzureExecutionException e) {
map.put(DEPLOYMENT_TYPE_KEY, "Unknown deployment type.");
}
final boolean isDeployToSlot = Optional.ofNullable(getDeploymentSlotSetting()).map(DeploymentSlotSetting::getName).map(StringUtils::isNotEmpty).orElse(false);
map.put(DEPLOY_TO_SLOT_KEY, String.valueOf(isDeployToSlot));
map.put(SKIP_CREATE_RESOURCE_KEY, String.valueOf(skipAzureResourceCreate || skipCreateAzureResource));
return map;
}
use of com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig in project azure-maven-plugins by microsoft.
the class ConfigParser method getWebAppConfiguration.
// todo: replace WebAppConfiguration with WebAppConfig
public WebAppConfiguration getWebAppConfiguration() {
WebAppConfiguration.WebAppConfigurationBuilder<?, ?> builder = WebAppConfiguration.builder();
final Runtime runtime = getRuntime();
final OperatingSystem os = Optional.ofNullable(runtime).map(Runtime::getOperatingSystem).orElse(null);
if (os == null) {
Log.debug("No runtime related config is specified. It will cause error if creating a new web app.");
} else {
switch(os) {
case WINDOWS:
case LINUX:
builder = builder.javaVersion(Objects.toString(runtime.getJavaVersion())).webContainer(Objects.toString(runtime.getWebContainer()));
break;
case DOCKER:
final MavenRuntimeConfig runtimeConfig = mojo.getRuntime();
builder = builder.image(runtimeConfig.getImage()).serverId(runtimeConfig.getServerId()).registryUrl(runtimeConfig.getRegistryUrl());
break;
default:
Log.debug("Invalid operating system from the configuration.");
}
}
return builder.appName(getAppName()).resourceGroup(getResourceGroup()).region(getRegion()).pricingTier(Optional.ofNullable(getPricingTier()).map(PricingTier::getSize).orElse(null)).servicePlanName(mojo.getAppServicePlanName()).servicePlanResourceGroup(mojo.getAppServicePlanResourceGroup()).deploymentSlotSetting(mojo.getDeploymentSlotSetting()).os(os).mavenSettings(mojo.getSettings()).resources(Optional.ofNullable(mojo.getDeployment()).map(Deployment::getResources).orElse(null)).stagingDirectoryPath(mojo.getDeploymentStagingDirectoryPath()).buildDirectoryAbsolutePath(mojo.getBuildDirectoryAbsolutePath()).project(mojo.getProject()).session(mojo.getSession()).filtering(mojo.getMavenResourcesFiltering()).schemaVersion("v2").build();
}
use of com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig in project azure-maven-plugins by microsoft.
the class ConfigParser method getRuntimeConfig.
private RuntimeConfig getRuntimeConfig() throws AzureExecutionException {
final MavenRuntimeConfig runtime = mojo.getRuntime();
if (runtime == null || runtime.isEmpty()) {
return null;
}
final OperatingSystem os = getOs(runtime);
final JavaVersion javaVersion = StringUtils.isEmpty(runtime.getJavaVersion()) ? null : parseExpandableParameter(JavaVersion::fromString, runtime.getJavaVersion(), EXPANDABLE_JAVA_VERSION_WARNING);
final WebContainer webContainer = StringUtils.isEmpty(runtime.getWebContainer()) ? null : parseExpandableParameter(WebContainer::fromString, runtime.getWebContainer(), EXPANDABLE_WEB_CONTAINER_WARNING);
final RuntimeConfig result = new RuntimeConfig().os(os).javaVersion(javaVersion).webContainer(webContainer).image(runtime.getImage()).registryUrl(runtime.getRegistryUrl());
if (StringUtils.isNotEmpty(runtime.getServerId())) {
final MavenDockerCredentialProvider credentialProvider = getDockerCredential(runtime.getServerId());
result.username(credentialProvider.getUsername()).password(credentialProvider.getPassword());
}
return result;
}
use of com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig in project azure-maven-plugins by microsoft.
the class ConfigParser method getRuntime.
public Runtime getRuntime() {
final MavenRuntimeConfig runtime = mojo.getRuntime();
if (runtime == null || runtime.isEmpty()) {
return null;
}
final OperatingSystem os = getOs(runtime);
if (os == OperatingSystem.DOCKER) {
return Runtime.DOCKER;
}
final JavaVersion javaVersion = StringUtils.isEmpty(runtime.getJavaVersion()) ? null : parseExpandableParameter(JavaVersion::fromString, runtime.getJavaVersion(), EXPANDABLE_JAVA_VERSION_WARNING);
final WebContainer webContainer = StringUtils.isEmpty(runtime.getWebContainer()) ? null : parseExpandableParameter(WebContainer::fromString, runtime.getWebContainer(), EXPANDABLE_WEB_CONTAINER_WARNING);
return Runtime.getRuntime(os, webContainer, javaVersion);
}
Aggregations