Skip to content

Commit

Permalink
mojo parameter annotations and lifecycle config (fixed issue #153)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clayton7510 committed Apr 22, 2020
1 parent b7b4eb5 commit 5130c35
Show file tree
Hide file tree
Showing 29 changed files with 450 additions and 91 deletions.
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## What Should I Know Before Getting Started?
### The project directory structure is as follows.
* examples - Maven parent examples project containing Maven Terraform example projects
* tf-s3 - an example Maven Terraform project that contains 2 s3 modules
* tf-s3-consumer - a Maven Terraform project that consumes tf-s3 as a dependency
* tf-build-tools - Maven parent project that builds all of the tf-maven related code; this is where you run 'mvn install' to validate the build
* tf-cmd-api - Maven project for a Java API that calls Terraform
* tf-maven-plugin - Maven project for the tf-maven-plugin plugin
* tf-s3-srchetype - Maven project for an archetype that sets up a working Maven Terrform project

## How Do I Contribute?
1. Create an Issue

If you want to work on the issue, specify in the issue that you would like to submit a contribution in the form of a PR to address the issue.

2. Work on the Issue

If the issue is accepted as either a Bug or an Enhancement, then it will be available to work, either by you or by another contributor.
If you specified in the issue that you wanted to work on the issue then once it's available to work, you may work on the issue.

_Note: Issues not accepted for work will not have their associated work reviewed or merged into the codebase._

Start working on an issue by forking the repository and making your updates from the 'develop' branch in your fork or a
branch off of your fork's 'develop' branch.

Don't forget to add your name/details as a contributor in the POM.

3. Submit a Pull Request

Once you have completed the work to resolve the issue, then submit a Pull Request to the 'develop' branch of the terraform-maven repository.
The PR will trigger a validation of the build. The TravisCI build logs for your PR can be found here: [https://travis-ci.org/github/deliveredtechnologies/terraform-maven/pull_requests](https://travis-ci.org/github/deliveredtechnologies/terraform-maven/pull_requests).

4. Code Review

Once your PR is free from merge conflicts and all of the automated checks pass (i.e. build validation + code coverage validation), one of the developers under the deliveredtechnologies project
will review the PR and leave comments and/or merge the PR.

5. Remediation

If any issues arise from the code review, please correct them. Once the PR has no more issues, it will be merged.

89 changes: 50 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[tf-cmd-api-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-cmd-api/
[tf-s3-archetype-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-s3-archetype/
[maven-badge]:https://img.shields.io/badge/maven%20central-0.8.1-green.svg
[maven-snapshot-badge]:https://img.shields.io/badge/SNAPSHOT-0.8-green.svg
[maven-snapshot-badge]:https://img.shields.io/badge/SNAPSHOT-0.9-green.svg
[tf-maven-plugin-synk-badge]:https://img.shields.io/badge/vulnerabilities-1-yellow.svg
[tf-maven-plugin-synk]:https://snyk.io/test/github/deliveredtechnologies/terraform-maven?targetFile=tf-build-tools%2Ftf-maven-plugin%2Fpom.xml
[tf-cmd-api-synk-badge]:https://img.shields.io/badge/vulnerabilities-0-green.svg
Expand Down Expand Up @@ -155,7 +155,7 @@ Optional Parameters:
| tfVarFiles | String | A comma delimited string of tfvars files (e.g. -var-file=foo) |
| tfVars | String | A comma delimited string of tfvars (e.g. -var 'name=value') |
| lockTimeout | Number | Duration to retry a state lock |
| target | Number | A resource address to target |
| target | String | A resource address to target |
| planInput | Boolean | If set to "true", input variables not directly set will be requested; otherwise, the plan will fail |
| noColor | Any | If this property exists, the -no-color flag is set |
| destroyPlan | Any | If this property exists, a destroy plan is outputted |
Expand All @@ -181,7 +181,7 @@ Optional Parameters:
| tfVarFiles | String | A comma delimited string of tfvars files (e.g. -var-file=foo) |
| tfVars | String | A comma delimited string of tfvars (e.g. -var 'name=value') |
| lockTimeout | Number | Duration to retry a state lock |
| target | Number | A resource address to target |
| target | String | A resource address to target |
| noColor | Any | If this property exists, the -no-color flag is set |
| plan | String | A terraform plan to apply; if both plan and tfRootDir are specified, only plan is used |
| tfRootDir | String | A terraform config directory to apply; defaults to `src/main/tf/{first dir found}`, then current directory |
Expand Down Expand Up @@ -285,7 +285,7 @@ the absolute path of the Git Bash executable.

```xml
<properties>
<tf-maven-version>0.7.3</tf-maven-version>
<tf-maven-version>0.8.1</tf-maven-version>
</properties>
```

Expand Down Expand Up @@ -319,39 +319,50 @@ the absolute path of the Git Bash executable.
</executions>
</plugin>
<plugin>
<groupId>com.deliveredtechnologies</groupId>
<artifactId>tf-maven-plugin</artifactId>
<version>${tf-maven-version}</version>
<executions>
<execution>
<id>terraform-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>terraform-install</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>terraform-package</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
<execution>
<id>terraform-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<groupId>com.deliveredtechnologies</groupId>
<artifactId>tf-maven-plugin</artifactId>
<version>${tf-maven-version}</version>
<executions>
<execution>
<id>terraform-clean</id>
<phase>clean</phase>
<goals>
<goal>init</goal>
<goal>destroy</goal>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>terraform-plan</id>
<phase>verify</phase>
<goals>
<goal>init</goal>
<goal>plan</goal>
</goals>
</execution>
<execution>
<id>terraform-install</id>
<phase>install</phase>
<goals>
<goal>init</goal>
<goal>apply</goal>
</goals>
</execution>
<execution>
<id>terraform-package</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
<execution>
<id>terraform-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -415,8 +426,8 @@ If you used the above configuration, the following Terraform Maven goals are map

| Maven Phase | Terraform Maven Goals |
|-------------|-----------------------|
| install | deploy |
| clean | clean |
| install | init, apply |
| clean | init, destroy, clean |
| package | package |
| deploy | deploy |

Expand Down
39 changes: 33 additions & 6 deletions examples/tf-s3-consumer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,28 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<tf-maven-version>0.8</tf-maven-version>
<tf-maven-version>0.9-SNAPSHOT</tf-maven-version>
</properties>
<artifactId>tf-s3-consumer</artifactId>
<groupId>com.deliveredtechnologies.example.maven.tf</groupId>
<version>1.0</version>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<tfVarFiles>tfvars/dev.tfvars</tfVarFiles>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<tfVarFiles>tfvars/test.tfvars</tfVarFiles>
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>local</id>
Expand Down Expand Up @@ -93,23 +110,33 @@
<id>terraform-clean</id>
<phase>clean</phase>
<goals>
<goal>init</goal>
<goal>destroy</goal>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>terraform-install</id>
<phase>install</phase>
<id>terraform-plan</id>
<phase>verify</phase>
<goals>
<goal>deploy</goal>
<goal>init</goal>
<goal>plan</goal>
</goals>
</execution>
<execution>
<id>terraform-package</id>
<id>terraform-pacakge</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
<execution>
<id>terraform-install</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>terraform-deploy</id>
<phase>deploy</phase>
Expand All @@ -119,7 +146,7 @@
</execution>
<execution>
<id>terraform-get</id>
<phase>test-compile</phase>
<phase>validate</phase>
<goals>
<goal>get</goal>
</goals>
Expand Down
44 changes: 39 additions & 5 deletions examples/tf-s3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,28 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<tf-maven-version>0.8</tf-maven-version>
<tf-maven-version>0.9-SNAPSHOT</tf-maven-version>
</properties>
<artifactId>tf-s3</artifactId>
<groupId>com.deliveredtechnologies.example.maven.tf</groupId>
<version>1.0</version>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<tfVarFiles>tfvars/dev.tfvars</tfVarFiles>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<tfVarFiles>tfvars/test.tfvars</tfVarFiles>
</properties>
</profile>
</profiles>
<pluginRepositories>
<pluginRepository>
<id>sonatype</id>
Expand Down Expand Up @@ -81,30 +98,47 @@
<id>terraform-clean</id>
<phase>clean</phase>
<goals>
<goal>init</goal>
<goal>destroy</goal>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>terraform-install</id>
<phase>install</phase>
<id>terraform-plan</id>
<phase>verify</phase>
<goals>
<goal>deploy</goal>
<goal>init</goal>
<goal>plan</goal>
</goals>
</execution>
<execution>
<id>terraform-package</id>
<id>terraform-pacakge</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
<execution>
<id>terraform-install</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>terraform-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>terraform-get</id>
<phase>validate</phase>
<goals>
<goal>get</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion tf-build-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.deliveredtechnologies</groupId>
<artifactId>tf-build-tools</artifactId>
<packaging>pom</packaging>
<version>0.8.1</version>
<version>0.9-SNAPSHOT</version>
<description>Terraform Build Tools: The parent POM project for Java and Terraform Tools</description>
<modules>
<module>tf-cmd-api</module>
Expand Down
2 changes: 1 addition & 1 deletion tf-build-tools/tf-cmd-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tf-build-tools</artifactId>
<groupId>com.deliveredtechnologies</groupId>
<version>0.8.1</version>
<version>0.9-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tf-cmd-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String execute(String command, int timeout) throws IOException, Interrupt
command
};
processBuilder = new ProcessBuilder(cmd);
processBuilder.directory(directory.toFile());
processBuilder.directory(directory.toAbsolutePath().toFile());
}
logger.debug(String.format("*** directory: %1$s ***", getDirectory().toAbsolutePath()));
logger.debug(String.format("*** command: %1$s ***", command));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public String execute(Properties properties) throws TerraformException {
continue;
}
if (param == TerraformApplyParam.tfVars) {
for (String var : ((String)properties.get(param.property)).split(",")) {
for (String var : (properties.get(param.property)).toString().split(",")) {
options.append(String.format("-%1$s '%2$s' ", param, var.trim()));
}
continue;
Expand All @@ -107,7 +107,7 @@ public String execute(Properties properties) throws TerraformException {
case plan:
break;
default:
options.append(String.format("-%1$s=%2$s ", param, properties.getProperty(param.property)));
options.append(String.format("-%1$s=%2$s ", param, properties.get(param.property)));
}
}
}
Expand All @@ -120,7 +120,7 @@ public String execute(Properties properties) throws TerraformException {
}

if (properties.containsKey("timeout")) {
return terraform.execute(options.toString(), Integer.parseInt(properties.getProperty("timeout")));
return terraform.execute(options.toString(), Integer.parseInt(properties.get("timeout").toString()));
} else {
return terraform.execute(options.toString());
}
Expand Down
Loading

0 comments on commit 5130c35

Please sign in to comment.