Search in sources :

Example 1 with RuntimeConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig in project azure-maven-plugins by microsoft.

the class ConfigParser method getRuntimeConfig.

public RuntimeConfig getRuntimeConfig() throws AzureExecutionException {
    final RuntimeConfiguration runtime = mojo.getRuntimeConfiguration();
    if (runtime == null) {
        return null;
    }
    final OperatingSystem os = Optional.ofNullable(runtime.getOs()).map(OperatingSystem::fromString).orElse(null);
    final JavaVersion javaVersion = Optional.ofNullable(runtime.getJavaVersion()).map(JavaVersion::fromString).orElse(null);
    final RuntimeConfig result = new RuntimeConfig().os(os).javaVersion(javaVersion).webContainer(WebContainer.JAVA_OFF).image(runtime.getImage()).registryUrl(runtime.getRegistryUrl());
    if (StringUtils.isNotEmpty(runtime.getServerId())) {
        final MavenDockerCredentialProvider credentialProvider = MavenDockerCredentialProvider.fromMavenSettings(mojo.getSettings(), 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) RuntimeConfig(com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) RuntimeConfiguration(com.microsoft.azure.toolkit.lib.legacy.function.configurations.RuntimeConfiguration)

Example 2 with RuntimeConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig in project azure-maven-plugins by microsoft.

the class AppServiceConfigUtils method fromAppService.

public static AppServiceConfig fromAppService(IAppService<?> appService, IAppServicePlan servicePlan) {
    AppServiceConfig config = new AppServiceConfig();
    config.appName(appService.name());
    config.resourceGroup(appService.entity().getResourceGroup());
    config.subscriptionId(Utils.getSubscriptionId(appService.id()));
    config.region(appService.entity().getRegion());
    config.pricingTier(servicePlan.entity().getPricingTier());
    RuntimeConfig runtimeConfig = new RuntimeConfig();
    if (AppServiceUtils.isDockerAppService(appService)) {
        runtimeConfig.os(OperatingSystem.DOCKER);
        final Map<String, String> settings = appService.entity().getAppSettings();
        final String imageSetting = settings.get(SETTING_DOCKER_IMAGE);
        if (StringUtils.isNotBlank(imageSetting)) {
            runtimeConfig.image(imageSetting);
        } else {
            runtimeConfig.image(appService.entity().getDockerImageName());
        }
        final String registryServerSetting = settings.get(SETTING_REGISTRY_SERVER);
        if (StringUtils.isNotBlank(registryServerSetting)) {
            runtimeConfig.registryUrl(registryServerSetting);
        }
    } else {
        runtimeConfig.os(appService.getRuntime().getOperatingSystem());
        runtimeConfig.webContainer(appService.getRuntime().getWebContainer());
        runtimeConfig.javaVersion(appService.getRuntime().getJavaVersion());
    }
    config.runtime(runtimeConfig);
    if (servicePlan.entity() != null) {
        config.pricingTier(servicePlan.entity().getPricingTier());
        config.servicePlanName(servicePlan.name());
        config.servicePlanResourceGroup(servicePlan.entity().getResourceGroup());
    }
    return config;
}
Also used : AppServiceConfig(com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig) RuntimeConfig(com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig)

Example 3 with RuntimeConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig in project azure-gradle-plugins by microsoft.

the class DeployHandler method getRuntimeConfig.

private RuntimeConfig getRuntimeConfig() {
    final GradleRuntimeConfig runtime = ctx.getRuntime();
    if (runtime == null) {
        return null;
    }
    final OperatingSystem os = Optional.ofNullable(runtime.os()).map(OperatingSystem::fromString).orElse(null);
    final JavaVersion javaVersion = Optional.ofNullable(runtime.javaVersion()).map(JavaVersion::fromString).orElse(null);
    return new RuntimeConfig().os(os).javaVersion(javaVersion).webContainer(WebContainer.JAVA_OFF).image(runtime.image()).registryUrl(runtime.registryUrl()).username(runtime.username()).password(runtime.password());
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) GradleRuntimeConfig(com.microsoft.azure.gradle.configuration.GradleRuntimeConfig) RuntimeConfig(com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig) GradleRuntimeConfig(com.microsoft.azure.gradle.configuration.GradleRuntimeConfig) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)

Example 4 with RuntimeConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig 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 5 with RuntimeConfig

use of com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig in project azure-maven-plugins by microsoft.

the class DeployMojo method validateArtifactCompileVersion.

protected void validateArtifactCompileVersion() throws AzureExecutionException {
    final RuntimeConfig runtimeConfig = getParser().getRuntimeConfig();
    if (runtimeConfig.os() == OperatingSystem.DOCKER) {
        return;
    }
    final JavaVersion javaVersion = Optional.ofNullable(runtimeConfig.javaVersion()).orElse(CreateOrUpdateFunctionAppTask.DEFAULT_FUNCTION_JAVA_VERSION);
    final ComparableVersion runtimeVersion = new ComparableVersion(javaVersion.getValue());
    final ComparableVersion artifactVersion = new ComparableVersion(Utils.getArtifactCompileVersion(getArtifactToDeploy()));
    if (runtimeVersion.compareTo(artifactVersion) >= 0) {
        return;
    }
    if (javaVersion.isExpandedValue()) {
        AzureMessager.getMessager().warning(AzureString.format(ARTIFACT_INCOMPATIBLE_WARNING, artifactVersion.toString(), runtimeVersion.toString()));
    } else {
        final String errorMessage = AzureString.format(ARTIFACT_INCOMPATIBLE_ERROR, artifactVersion.toString(), runtimeVersion.toString()).toString();
        throw new AzureExecutionException(errorMessage);
    }
}
Also used : AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) RuntimeConfig(com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) ComparableVersion(org.apache.maven.artifact.versioning.ComparableVersion)

Aggregations

RuntimeConfig (com.microsoft.azure.toolkit.lib.appservice.config.RuntimeConfig)5 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)4 OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)3 MavenDockerCredentialProvider (com.microsoft.azure.maven.MavenDockerCredentialProvider)2 GradleRuntimeConfig (com.microsoft.azure.gradle.configuration.GradleRuntimeConfig)1 MavenRuntimeConfig (com.microsoft.azure.maven.webapp.configuration.MavenRuntimeConfig)1 AppServiceConfig (com.microsoft.azure.toolkit.lib.appservice.config.AppServiceConfig)1 WebContainer (com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 AzureExecutionException (com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException)1 RuntimeConfiguration (com.microsoft.azure.toolkit.lib.legacy.function.configurations.RuntimeConfiguration)1 ComparableVersion (org.apache.maven.artifact.versioning.ComparableVersion)1