View Javadoc
1   /*
2    * Copyright (c) 2016 ingenieux Labs
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package br.com.ingenieux.mojo.beanstalk.env;
18  
19  import org.apache.maven.plugins.annotations.Mojo;
20  import org.apache.maven.plugins.annotations.Parameter;
21  
22  import br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo;
23  import br.com.ingenieux.mojo.beanstalk.cmd.env.waitfor.WaitForEnvironmentCommand;
24  import br.com.ingenieux.mojo.beanstalk.cmd.env.waitfor.WaitForEnvironmentContext;
25  import br.com.ingenieux.mojo.beanstalk.cmd.env.waitfor.WaitForEnvironmentContextBuilder;
26  
27  /**
28   * Waits for Environment Status to Change
29   *
30   * @since 0.2.2
31   */
32  @Mojo(name = "wait-for-environment")
33  public class WaitForEnvironmentMojo extends AbstractBeanstalkMojo {
34  
35    /**
36     * Beanstalk Application Name
37     */
38    @Parameter(property = "beanstalk.applicationName", defaultValue = "${project.artifactId}", required = true)
39    String applicationName;
40  
41    /**
42     * Minutes until timeout
43     */
44    @Parameter(property = "beanstalk.timeoutMins", defaultValue = "20")
45    Integer timeoutMins;
46  
47    /**
48     * Status to Wait For
49     */
50    @Parameter(property = "beanstalk.statusToWaitFor", defaultValue = "Ready")
51    String statusToWaitFor;
52  
53    /**
54     * Health to Wait For
55     */
56    @Parameter(property = "beanstalk.healthToWaitFor", defaultValue = "Green")
57    String healthToWaitFor;
58  
59    /**
60     * Environment Ref
61     */
62    @Parameter(property = "beanstalk.environmentRef", defaultValue = "${project.artifactId}.elasticbeanstalk.com")
63    String environmentRef;
64  
65    @Override
66    protected Object executeInternal() throws Exception {
67      WaitForEnvironmentContext context =
68          new WaitForEnvironmentContextBuilder()
69              .withApplicationName(applicationName) //
70              .withStatusToWaitFor(statusToWaitFor) //
71              .withTimeoutMins(timeoutMins) //
72              .withHealth(healthToWaitFor) //
73              .withEnvironmentRef(environmentRef) //
74              .build();
75  
76      WaitForEnvironmentCommanditfor/WaitForEnvironmentCommand.html#WaitForEnvironmentCommand">WaitForEnvironmentCommand command = new WaitForEnvironmentCommand(this);
77  
78      return command.execute(context);
79    }
80  }