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.dns;
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.AbstractNeedsEnvironmentMojo;
23  import br.com.ingenieux.mojo.beanstalk.cmd.dns.BindDomainsCommand;
24  import br.com.ingenieux.mojo.beanstalk.cmd.dns.BindDomainsContext;
25  import br.com.ingenieux.mojo.beanstalk.cmd.dns.BindDomainsContextBuilder;
26  
27  import static java.util.Arrays.asList;
28  
29  /**
30   * <p> Binds an Elastic Beanstalk Environment into a set of Route53 records </p>
31   *
32   * <p> NOTE: THIS IS HIGHLY EXPERIMENTAL CODE </p>
33   *
34   * @since 0.2.9
35   */
36  @Mojo(name = "bind-domains")
37  public class BindDomainsMojo extends AbstractNeedsEnvironmentMojo {
38  
39    /**
40     * <p>List of Domains</p>
41     *
42     * <p>Could be set as either:</p> <ul> <li>fqdn:hostedZoneId (e.g.
43     * "services.modafocas.org:Z3DJ4DL0DIEEJA")</li> <li>hosted zone name - will be set to root.
44     * (e.g., "modafocas.org")</li> </ul>
45     */
46    @Parameter(property = "beanstalk.domains")
47    String[] domains;
48  
49    @Override
50    protected Object executeInternal() throws Exception {
51      final BindDomainsContext ctx = new BindDomainsContextBuilder().withCurEnv(this.curEnv).withDomains(asList(domains)).build();
52  
53      new BindDomainsCommand(this).execute(ctx);
54  
55      return null;
56    }
57  }