Search in sources :

Example 1 with GradleDeploymentSlotConfig

use of com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig in project azure-gradle-plugins by microsoft.

the class AzureWebappPluginExtension method getTelemetryProperties.

public Map<String, String> getTelemetryProperties() {
    final Map<String, String> result = new HashMap<>();
    final GradleRuntimeConfig runtime = getRuntime();
    final String os = java.util.Optional.ofNullable(runtime).map(GradleRuntimeConfig::os).orElse(null);
    result.put(OS_KEY, os);
    result.put(JAVA_VERSION_KEY, java.util.Optional.ofNullable(runtime).map(GradleRuntimeConfig::javaVersion).orElse(null));
    result.put(JAVA_WEB_CONTAINER_KEY, java.util.Optional.ofNullable(runtime).map(GradleRuntimeConfig::webContainer).orElse(null));
    result.put(PRICING_TIER_KEY, pricingTier);
    result.put(REGION_KEY, region);
    if (runtime != null && StringUtils.equalsIgnoreCase(os, OperatingSystem.DOCKER.getValue())) {
        final boolean isCustomRegistry = StringUtils.isNotEmpty(runtime.registryUrl());
        final DockerImageType imageType;
        if (isCustomRegistry) {
            imageType = StringUtils.isEmpty(runtime.password()) ? DockerImageType.PRIVATE_REGISTRY : DockerImageType.UNKNOWN;
        } else {
            imageType = StringUtils.isEmpty(runtime.password()) ? DockerImageType.PRIVATE_DOCKER_HUB : DockerImageType.PUBLIC_DOCKER_HUB;
        }
        result.put(DOCKER_IMAGE_TYPE_KEY, imageType.name());
    } else {
        result.put(DOCKER_IMAGE_TYPE_KEY, DockerImageType.NONE.toString());
    }
    final boolean isDeployToSlot = java.util.Optional.ofNullable(getDeploymentSlot()).map(GradleDeploymentSlotConfig::name).map(StringUtils::isNotEmpty).orElse(false);
    result.put(DEPLOY_TO_SLOT_KEY, String.valueOf(isDeployToSlot));
    result.put(SKIP_CREATE_RESOURCE_KEY, System.getProperty("azure.resource.create.skip", "false"));
    return result;
}
Also used : GradleRuntimeConfig(com.microsoft.azure.gradle.configuration.GradleRuntimeConfig) DockerImageType(com.microsoft.azure.toolkit.lib.legacy.appservice.DockerImageType) GradleDeploymentSlotConfig(com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig) HashMap(java.util.HashMap)

Example 2 with GradleDeploymentSlotConfig

use of com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig in project azure-gradle-plugins by microsoft.

the class AzureWebappPluginExtension method setDeploymentSlot.

public void setDeploymentSlot(Closure closure) {
    deploymentSlot = new GradleDeploymentSlotConfig();
    project.configure(deploymentSlot, closure);
}
Also used : GradleDeploymentSlotConfig(com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig)

Example 3 with GradleDeploymentSlotConfig

use of com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig in project azure-gradle-plugins by microsoft.

the class DeployTask method parseConfiguration.

private GradleWebAppConfig parseConfiguration() {
    final AzureWebappPluginExtension ctx = this.azureWebappExtension;
    GradleWebAppConfig config = new GradleWebAppConfig();
    config.subscriptionId(ctx.getSubscription());
    config.resourceGroup(ctx.getResourceGroup());
    config.appName(ctx.getAppName());
    config.pricingTier(ctx.getPricingTier());
    config.region(ctx.getRegion());
    config.runtime(ctx.getRuntime());
    config.appSettings(ctx.getAppSettings());
    config.servicePlanName(ctx.getAppServicePlanName());
    config.servicePlanResourceGroup(ctx.getAppServicePlanResourceGroup());
    config.deploymentSlotName(Optional.ofNullable(ctx.getDeploymentSlot()).map(GradleDeploymentSlotConfig::name).orElse(null));
    config.deploymentSlotConfigurationSource(Optional.ofNullable(ctx.getDeploymentSlot()).map(GradleDeploymentSlotConfig::configurationSource).orElse(null));
    if (StringUtils.isNotBlank(this.artifactFile)) {
        File file = new File(this.artifactFile);
        if (!file.exists()) {
            throw new AzureToolkitRuntimeException(String.format("artifact file(%s) cannot be found.", file.getAbsolutePath()));
        }
        final WebAppArtifact webAppArtifact = WebAppArtifact.builder().deployType(Utils.getDeployTypeByFileExtension(file)).file(file).build();
        config.webAppArtifacts(Collections.singletonList(webAppArtifact));
    }
    return config;
}
Also used : GradleDeploymentSlotConfig(com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig) GradleWebAppConfig(com.microsoft.azure.gradle.configuration.GradleWebAppConfig) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) File(java.io.File) WebAppArtifact(com.microsoft.azure.toolkit.lib.appservice.model.WebAppArtifact)

Example 4 with GradleDeploymentSlotConfig

use of com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig in project azure-gradle-plugins by microsoft.

the class AzureFunctionsExtension method setDeploymentSlot.

public void setDeploymentSlot(Closure closure) {
    deploymentSlot = new GradleDeploymentSlotConfig();
    project.configure(deploymentSlot, closure);
}
Also used : GradleDeploymentSlotConfig(com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig)

Aggregations

GradleDeploymentSlotConfig (com.microsoft.azure.gradle.configuration.GradleDeploymentSlotConfig)4 GradleRuntimeConfig (com.microsoft.azure.gradle.configuration.GradleRuntimeConfig)1 GradleWebAppConfig (com.microsoft.azure.gradle.configuration.GradleWebAppConfig)1 WebAppArtifact (com.microsoft.azure.toolkit.lib.appservice.model.WebAppArtifact)1 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)1 DockerImageType (com.microsoft.azure.toolkit.lib.legacy.appservice.DockerImageType)1 File (java.io.File)1 HashMap (java.util.HashMap)1