Search in sources :

Example 1 with MavenRuntimeConfig

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;
}
Also used : AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) MavenRuntimeConfig(com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig) DeploymentSlotSetting(com.microsoft.azure.toolkit.lib.legacy.appservice.DeploymentSlotSetting)

Example 2 with MavenRuntimeConfig

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();
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) WebAppConfiguration(com.microsoft.azure.maven.webapp.WebAppConfiguration) MavenRuntimeConfig(com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig)

Example 3 with MavenRuntimeConfig

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;
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) MavenDockerCredentialProvider(com.microsoft.azure.maven.MavenDockerCredentialProvider) MavenRuntimeConfig(com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig) WebContainer(com.microsoft.azure.toolkit.lib.appservice.model.WebContainer) RuntimeConfig(com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig) MavenRuntimeConfig(com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)

Example 4 with MavenRuntimeConfig

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);
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) MavenRuntimeConfig(com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig) WebContainer(com.microsoft.azure.toolkit.lib.appservice.model.WebContainer) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)

Aggregations

MavenRuntimeConfig (com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig)4 OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)3 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)2 WebContainer (com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)2 MavenDockerCredentialProvider (com.microsoft.azure.maven.MavenDockerCredentialProvider)1 WebAppConfiguration (com.microsoft.azure.maven.webapp.WebAppConfiguration)1 RuntimeConfig (com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig)1 Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)1 AzureExecutionException (com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException)1 DeploymentSlotSetting (com.microsoft.azure.toolkit.lib.legacy.appservice.DeploymentSlotSetting)1