use of com.microsoft.azure.toolkit.lib.legacy.appservice.DeploymentSlotSetting 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.toolkit.lib.legacy.appservice.DeploymentSlotSetting in project azure-maven-plugins by microsoft.
the class ConfigMojo method confirmConfiguration.
protected boolean confirmConfiguration(WebAppConfiguration configuration) throws AzureExecutionException, MojoFailureException {
System.out.println("Please confirm webapp properties");
if (StringUtils.isNotBlank(configuration.getSubscriptionId())) {
System.out.println("Subscription Id : " + configuration.getSubscriptionId());
}
System.out.println("AppName : " + configuration.getAppName());
System.out.println("ResourceGroup : " + configuration.getResourceGroup());
System.out.println("Region : " + configuration.getRegion());
if (configuration.getPricingTier() != null) {
System.out.println("PricingTier : " + configuration.getPricingTier());
}
if (configuration.getOs() == null) {
System.out.println(CONFIGURATION_NO_RUNTIME);
} else {
System.out.println("OS : " + configuration.getOs().toString());
switch(configuration.getOs()) {
case WINDOWS:
case LINUX:
System.out.println("Java : " + configuration.getJavaVersion());
System.out.println("Web server stack: " + configuration.getWebContainer());
break;
case DOCKER:
System.out.println("Image : " + configuration.getImage());
if (StringUtils.isNotBlank(configuration.getServerId())) {
System.out.println("ServerId : " + configuration.getServerId());
}
if (StringUtils.isNotBlank(configuration.getRegistryUrl())) {
System.out.println("RegistryUrl : " + configuration.getRegistryUrl());
}
break;
default:
throw new AzureExecutionException("The value of <os> is unknown.");
}
}
System.out.println("Deploy to slot : " + (configuration.getDeploymentSlotSetting() != null));
if (configuration.getDeploymentSlotSetting() != null) {
final DeploymentSlotSetting slotSetting = configuration.getDeploymentSlotSetting();
System.out.println("Slot name : " + slotSetting.getName());
System.out.println("ConfigurationSource : " + slotSetting.getConfigurationSource());
}
final String result = queryer.assureInputFromUser("confirm", "Y", BOOLEAN_REGEX, "Confirm (Y/N)", null);
return result.equalsIgnoreCase("Y");
}
use of com.microsoft.azure.toolkit.lib.legacy.appservice.DeploymentSlotSetting in project azure-maven-plugins by microsoft.
the class V2ConfigurationSerializer method saveToXML.
@Override
public void saveToXML(Element configurationElement) throws MojoFailureException {
createOrUpdateAttribute("schemaVersion", "v2", oldConfigs.getSchemaVersion(), configurationElement);
createOrUpdateAttribute("subscriptionId", newConfigs.getSubscriptionId(), oldConfigs.getSubscriptionId(), configurationElement);
createOrUpdateAttribute("resourceGroup", newConfigs.getResourceGroup(), oldConfigs.getResourceGroup(), configurationElement);
createOrUpdateAttribute("appName", newConfigs.getAppName(), oldConfigs.getAppName(), configurationElement);
createOrUpdateAttribute("pricingTier", newConfigs.getPricingTier(), oldConfigs.getPricingTier(), configurationElement);
if (newConfigs.getRegion() != null) {
final String oldRegion = oldConfigs.getRegion() == null ? null : oldConfigs.getRegion().toString();
createOrUpdateAttribute("region", newConfigs.getRegion().toString(), oldRegion, configurationElement);
}
createOrUpdateAttribute("appServicePlanName", newConfigs.getServicePlanName(), oldConfigs.getServicePlanName(), configurationElement);
createOrUpdateAttribute("appServicePlanResourceGroup", newConfigs.getServicePlanResourceGroup(), oldConfigs.getServicePlanResourceGroup(), configurationElement);
if (newConfigs.getOs() != null) {
updateRunTimeNode(newConfigs, oldConfigs, configurationElement);
}
// remove or update deploymentSlot node
if (newConfigs.getDeploymentSlotSetting() == null) {
XMLUtils.removeNode(configurationElement, "deploymentSlot");
} else {
final Element deploymentSlot = XMLUtils.getOrCreateSubElement("deploymentSlot", configurationElement);
final DeploymentSlotSetting oldDeploymentSlotSetting = oldConfigs.getDeploymentSlotSetting() == null ? new DeploymentSlotSetting() : oldConfigs.getDeploymentSlotSetting();
updateDeploymentSlotNode(newConfigs.getDeploymentSlotSetting(), oldDeploymentSlotSetting, deploymentSlot);
}
// only add deployment when init or convert
if (configurationElement.element("deployment") == null && (newConfigs.getResources() != null)) {
configurationElement.add(createDeploymentNode(newConfigs));
}
}
use of com.microsoft.azure.toolkit.lib.legacy.appservice.DeploymentSlotSetting in project azure-maven-plugins by microsoft.
the class ConfigMojo method getSlotConfiguration.
private WebAppConfiguration getSlotConfiguration(WebAppConfiguration configuration) throws MojoFailureException {
final WebAppConfiguration.WebAppConfigurationBuilder<?, ?> builder = configuration.toBuilder();
final DeploymentSlotSetting deploymentSlotSetting = configuration.getDeploymentSlotSetting();
final String defaultIsSlotDeploy = deploymentSlotSetting == null ? "N" : "Y";
final String isSlotDeploy = queryer.assureInputFromUser("isSlotDeploy", defaultIsSlotDeploy, BOOLEAN_REGEX, "Deploy to slot?(Y/N)", null);
if (StringUtils.equalsIgnoreCase(isSlotDeploy, "n")) {
return builder.deploymentSlotSetting(null).build();
}
final String defaultSlotName = deploymentSlotSetting == null ? String.format("%s-slot", configuration.getAppName()) : deploymentSlotSetting.getName();
final String slotName = queryer.assureInputFromUser("slotName", defaultSlotName, SLOT_NAME_PATTERN, null, null);
final String defaultConfigurationSource = deploymentSlotSetting == null ? null : deploymentSlotSetting.getConfigurationSource();
final String configurationSource = queryer.assureInputFromUser("configurationSource", defaultConfigurationSource, null, null, null);
final DeploymentSlotSetting result = new DeploymentSlotSetting();
result.setName(slotName);
result.setConfigurationSource(configurationSource);
return builder.deploymentSlotSetting(result).build();
}
Aggregations