Search in sources :

Example 1 with AppRawConfig

use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.

the class ConfigMojo method doExecute.

@Override
protected void doExecute() throws AzureExecutionException {
    if (!settings.isInteractiveMode()) {
        throw new UnsupportedOperationException("The goal 'config' must be run at interactive mode.");
    }
    if (!MavenConfigUtils.isPomPackaging(this.project) && !MavenConfigUtils.isJarPackaging(this.project)) {
        throw new UnsupportedOperationException(String.format("The project (%s) with packaging %s is not supported for azure spring cloud service.", this.project.getName(), this.project.getPackaging()));
    }
    if (isProjectConfigured(this.project)) {
        getLog().warn(String.format("Project (%s) is already configured and won't be affected by this command.", this.project.getName()));
        return;
    }
    appSettings = new AppRawConfig();
    deploymentSettings = new AppDeploymentRawConfig();
    parentMode = MavenConfigUtils.isPomPackaging(this.project);
    if (parentMode && advancedOptions) {
        throw new UnsupportedOperationException("The \"advancedOptions\" mode is not supported at parent folder.");
    }
    final ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);
    try {
        this.wrapper = new ConfigurationPrompter(expressionEvaluator, getLog());
        this.wrapper.initialize();
        this.wrapper.putCommonVariable("project", this.project);
        selectProjects();
        if (targetProjects == null || targetProjects.isEmpty()) {
            // no need to proceed when there are no projects need to be configured
            return;
        }
        // select subscription in spring cloud -> config is different from other goals since it is prompted after select project.
        // set up account and select subscription here
        getAzureAccount();
        promptAndSelectSubscription();
        selectAppCluster();
        configCommon();
        confirmAndSave();
    } catch (IOException | InvalidConfigurationException | UnsupportedOperationException | MavenDecryptException | LoginFailureException e) {
        throw new AzureExecutionException(e.getMessage());
    } finally {
        if (this.wrapper != null) {
            try {
                this.wrapper.close();
            } catch (IOException e) {
            // ignore at final step
            }
        }
    }
}
Also used : ConfigurationPrompter(com.microsoft.azure.maven.springcloud.config.ConfigurationPrompter) PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) LoginFailureException(com.microsoft.azure.toolkit.lib.auth.exception.LoginFailureException) AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) AppDeploymentRawConfig(com.microsoft.azure.maven.springcloud.config.AppDeploymentRawConfig) MavenDecryptException(com.microsoft.azure.maven.exception.MavenDecryptException) AppRawConfig(com.microsoft.azure.maven.springcloud.config.AppRawConfig) IOException(java.io.IOException) PluginParameterExpressionEvaluator(org.apache.maven.plugin.PluginParameterExpressionEvaluator) ExpressionEvaluator(org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator) InvalidConfigurationException(com.microsoft.azure.toolkit.lib.common.exception.InvalidConfigurationException)

Example 2 with AppRawConfig

use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.

the class SpringCloudAppSettingsTest method testSetSubscriptionId.

@Test
public void testSetSubscriptionId() {
    final AppRawConfig app = new AppRawConfig();
    app.setSubscriptionId("subscriptionId1");
    assertEquals("subscriptionId1", app.getSubscriptionId());
}
Also used : AppRawConfig(com.microsoft.azure.maven.springcloud.config.AppRawConfig) Test(org.junit.Test)

Example 3 with AppRawConfig

use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.

the class SpringCloudAppSettingsTest method testSetClusterName.

@Test
public void testSetClusterName() {
    final AppRawConfig app = new AppRawConfig();
    app.setClusterName("clusterName1");
    assertEquals("clusterName1", app.getClusterName());
}
Also used : AppRawConfig(com.microsoft.azure.maven.springcloud.config.AppRawConfig) Test(org.junit.Test)

Example 4 with AppRawConfig

use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.

the class SpringCloudAppSettingsTest method testSetIsPublic.

@Test
public void testSetIsPublic() {
    final AppRawConfig app = new AppRawConfig();
    app.setIsPublic("true");
    assertEquals("true", app.getIsPublic());
}
Also used : AppRawConfig(com.microsoft.azure.maven.springcloud.config.AppRawConfig) Test(org.junit.Test)

Example 5 with AppRawConfig

use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.

the class SpringCloudAppSettingsTest method testSetAppName.

@Test
public void testSetAppName() {
    final AppRawConfig app = new AppRawConfig();
    app.setAppName("appName1");
    assertEquals("appName1", app.getAppName());
}
Also used : AppRawConfig(com.microsoft.azure.maven.springcloud.config.AppRawConfig) Test(org.junit.Test)

Aggregations

AppRawConfig (com.microsoft.azure.maven.springcloud.config.AppRawConfig)9 Test (org.junit.Test)8 AppDeploymentRawConfig (com.microsoft.azure.maven.springcloud.config.AppDeploymentRawConfig)3 File (java.io.File)2 Model (org.apache.maven.model.Model)2 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)2 MavenProject (org.apache.maven.project.MavenProject)2 Document (org.dom4j.Document)2 Element (org.dom4j.Element)2 MavenDecryptException (com.microsoft.azure.maven.exception.MavenDecryptException)1 ConfigurationPrompter (com.microsoft.azure.maven.springcloud.config.ConfigurationPrompter)1 LoginFailureException (com.microsoft.azure.toolkit.lib.auth.exception.LoginFailureException)1 AzureExecutionException (com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException)1 InvalidConfigurationException (com.microsoft.azure.toolkit.lib.common.exception.InvalidConfigurationException)1 IOException (java.io.IOException)1 Plugin (org.apache.maven.model.Plugin)1 PluginParameterExpressionEvaluator (org.apache.maven.plugin.PluginParameterExpressionEvaluator)1 ExpressionEvaluator (org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator)1