Skip to content

Commit

Permalink
feat: allow to disable terraform plan (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt authored May 9, 2022
1 parent 899356c commit a21f441
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
13 changes: 13 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const hybridModuleOptions: HybridModuleOptions = { ... }
| <code><a href="#projen-cdktf-hybrid-construct.HybridModuleOptions.property.constructExamples">constructExamples</a></code> | <code><a href="#projen-cdktf-hybrid-construct.ConstructExamplesOption">ConstructExamplesOption</a></code> | If set a construct examples folder will be created. |
| <code><a href="#projen-cdktf-hybrid-construct.HybridModuleOptions.property.constructVersion">constructVersion</a></code> | <code>string</code> | Construct version to use. |
| <code><a href="#projen-cdktf-hybrid-construct.HybridModuleOptions.property.projectId">projectId</a></code> | <code>string</code> | If set a terraform examples folder will be created Defaults to a uuid string as cdktf would Mostly used for testing to have a predictable result. |
| <code><a href="#projen-cdktf-hybrid-construct.HybridModuleOptions.property.runPlan">runPlan</a></code> | <code>boolean</code> | If set a terraform plan is being run as part of the tests. |
| <code><a href="#projen-cdktf-hybrid-construct.HybridModuleOptions.property.terraformExamples">terraformExamples</a></code> | <code><a href="#projen-cdktf-hybrid-construct.TerraformExamplesOption">TerraformExamplesOption</a></code> | If set a terraform examples folder will be created. |

---
Expand Down Expand Up @@ -2311,6 +2312,18 @@ If set a terraform examples folder will be created Defaults to a uuid string as

---

##### `runPlan`<sup>Optional</sup> <a name="runPlan" id="projen-cdktf-hybrid-construct.HybridModuleOptions.property.runPlan"></a>

```typescript
public readonly runPlan: boolean;
```

- *Type:* boolean

If set a terraform plan is being run as part of the tests.

---

##### `terraformExamples`<sup>Optional</sup> <a name="terraformExamples" id="projen-cdktf-hybrid-construct.HybridModuleOptions.property.terraformExamples"></a>

```typescript
Expand Down
15 changes: 7 additions & 8 deletions examples/hybrid-module/scripts/tf-module-test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash
# This script is created by projen, do not edit it directly.
set -e

terraform -chdir=terraform init --upgrade
terraform -chdir=terraform fmt
terraform -chdir=terraform validate

#!/bin/bash
# This script is created by projen, do not edit it directly.
set -e

terraform -chdir=terraform init --upgrade
terraform -chdir=terraform fmt
terraform -chdir=terraform validate
terraform -chdir=terraform plan

22 changes: 13 additions & 9 deletions src/hybrid-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export interface HybridModuleOptions extends ConstructLibraryOptions {
* Mostly used for testing to have a predictable result
*/
readonly projectId?: string;

/**
* If set a terraform plan is being run as part of the tests
*/
readonly runPlan?: boolean;
}

const constructSrcCode = `
Expand Down Expand Up @@ -259,15 +264,14 @@ terraform {
new ScriptFile(
this,
"./scripts/tf-module-test.sh",
`
#!/bin/bash
# This script is created by projen, do not edit it directly.
set -e
terraform -chdir=${examplesFolder} init --upgrade
terraform -chdir=${examplesFolder} fmt
terraform -chdir=${examplesFolder} validate
terraform -chdir=${examplesFolder} plan
`#!/bin/bash
# This script is created by projen, do not edit it directly.
set -e
terraform -chdir=${examplesFolder} init --upgrade
terraform -chdir=${examplesFolder} fmt
terraform -chdir=${examplesFolder} validate
${options.runPlan ? `terraform -chdir=${examplesFolder} plan` : ""}
`
);

Expand Down
17 changes: 8 additions & 9 deletions test/__snapshots__/hybrid-module.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a21f441

Please sign in to comment.