1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package br.com.ingenieux.mojo.beanstalk.config;
18
19 import com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationSettingsRequest;
20 import com.amazonaws.services.elasticbeanstalk.model.EnvironmentDescription;
21
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugin.MojoFailureException;
24 import org.apache.maven.plugins.annotations.Mojo;
25 import org.apache.maven.plugins.annotations.Parameter;
26
27 import java.util.Collection;
28
29 import br.com.ingenieux.mojo.aws.util.GlobUtil;
30 import br.com.ingenieux.mojo.beanstalk.AbstractNeedsEnvironmentMojo;
31
32 import static org.apache.commons.lang.StringUtils.isNotBlank;
33
34
35
36
37
38
39
40
41
42 @Mojo(name = "describe-configuration-settings")
43 public class DescribeConfigurationSettingsMojo extends AbstractNeedsEnvironmentMojo {
44
45
46
47
48 @Parameter(property = "beanstalk.templateName")
49 String templateName;
50
51 @Override
52 protected EnvironmentDescription handleResults(Collection<EnvironmentDescription> environments) throws MojoExecutionException {
53 try {
54 return super.handleResults(environments);
55 } catch (Exception exc) {
56
57
58 return null;
59 }
60 }
61
62 protected Object executeInternal() throws MojoExecutionException, MojoFailureException {
63 boolean bTemplateNameDefined = isNotBlank(templateName) && !GlobUtil.hasWildcards(templateName);
64
65 DescribeConfigurationSettingsRequest req = new DescribeConfigurationSettingsRequest().withApplicationName(applicationName);
66
67 if (bTemplateNameDefined) {
68 req.withTemplateName(templateName);
69 } else if (null != curEnv) {
70 req.withEnvironmentName(curEnv.getEnvironmentName());
71 } else {
72 getLog().warn("You must supply a templateName or environmentName. Ignoring");
73
74 return null;
75 }
76
77 getLog().info("Request: " + req);
78
79 return getService().describeConfigurationSettings(req);
80 }
81 }