Skip to content

Commit 146a041

Browse files
authored
Complete Refactor (#9)
1 parent d912cd1 commit 146a041

26 files changed

+1275
-428
lines changed

.github/workflows/CICD.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Build"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
Matrix:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Generate Matrix
11+
id: matrix
12+
uses: Invicton-Labs/terraform-module-testing/matrix@main
13+
with:
14+
minimum_tf_version: '0.13.1'
15+
# 0.15.0 - 0.15.3 has a bug where it doesn't like sensitive-marked outputs
16+
excluded_tf_versions: '0.15.0,0.15.1,0.15.2,0.15.3,1.3.0'
17+
18+
- name: Output Matrix
19+
run: |
20+
echo "Strategy: ${{ steps.matrix.outputs.strategy }}"
21+
22+
outputs:
23+
strategy: ${{ steps.matrix.outputs.strategy }}
24+
25+
Test:
26+
needs: [Matrix]
27+
strategy: ${{ fromJSON(needs.Matrix.outputs.strategy)}}
28+
runs-on: ${{ matrix.runs-on }}
29+
container: ${{ matrix.container }}
30+
steps:
31+
- name: Run Tests
32+
id: tests
33+
uses: Invicton-Labs/terraform-module-testing/test@main
34+
with:
35+
testing_path: tester
36+
37+
# This job just waits for all other jobs to pass. We have it here
38+
# so our branch protection rule can reference a single job, instead
39+
# of needing to list every matrix value of every job above.
40+
Passed:
41+
runs-on: ubuntu-latest
42+
needs: [Test]
43+
steps:
44+
- name: Mark tests as passed
45+
run: echo "🎉"

dynamic-depends-on/main.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

main.tf

Lines changed: 386 additions & 130 deletions
Large diffs are not rendered by default.

outputs.tf

Lines changed: 97 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,107 @@
1+
//==================================================
2+
// Outputs that match the input variables
3+
//==================================================
4+
output "command_unix" {
5+
description = "The value of the `command_unix` input variable, or the default value if the input was `null`, with all carriage returns removed."
6+
value = local.command_create_unix
7+
}
8+
output "command_windows" {
9+
description = "The value of the `command_windows` input variable, or the default value if the input was `null`, with all carriage returns removed."
10+
value = local.command_create_windows
11+
}
12+
output "command_destroy_unix" {
13+
description = "The value of the `command_destroy_unix` input variable, or the default value if the input was `null`, with all carriage returns removed."
14+
value = local.command_destroy_unix
15+
}
16+
output "command_destroy_windows" {
17+
description = "The value of the `command_destroy_windows` input variable, or the default value if the input was `null`, with all carriage returns removed."
18+
value = local.command_destroy_windows
19+
}
20+
output "environment" {
21+
description = "The value of the `environment` input variable, or the default value if the input was `null`, with all carriage returns removed."
22+
value = local.env_vars
23+
}
24+
output "environment_sensitive" {
25+
description = "The value of the `environment_sensitive` input variable, or the default value if the input was `null`, with all carriage returns removed."
26+
value = local.env_vars_sensitive
27+
}
28+
output "environment_triggerless" {
29+
description = "The value of the `environment_triggerless` input variable, or the default value if the input was `null`, with all carriage returns removed."
30+
value = local.env_vars_triggerless
31+
}
32+
output "triggers" {
33+
description = "The value of the `triggers` input variable, or the default value if the input was `null`."
34+
value = local.var_triggers
35+
}
36+
output "working_dir" {
37+
description = "The value of the `working_dir` input variable."
38+
value = local.var_working_dir
39+
}
40+
output "fail_create_on_nonzero_exit_code" {
41+
description = "The value of the `fail_create_on_nonzero_exit_code` input variable, or the default value if the input was `null`."
42+
value = local.var_fail_create_on_nonzero_exit_code
43+
}
44+
output "fail_create_on_stderr" {
45+
description = "The value of the `fail_create_on_stderr` input variable, or the default value if the input was `null`."
46+
value = local.var_fail_create_on_stderr
47+
}
48+
output "fail_create_on_timeout" {
49+
description = "The value of the `fail_create_on_timeout` input variable, or the default value if the input was `null`."
50+
value = local.var_fail_create_on_timeout
51+
}
52+
output "fail_destroy_on_nonzero_exit_code" {
53+
description = "The value of the `fail_destroy_on_nonzero_exit_code` input variable, or the default value if the input was `null`."
54+
value = local.var_fail_create_on_nonzero_exit_code
55+
}
56+
output "fail_destroy_on_stderr" {
57+
description = "The value of the `fail_destroy_on_stderr` input variable, or the default value if the input was `null`."
58+
value = local.var_fail_create_on_stderr
59+
}
60+
output "fail_destroy_on_timeout" {
61+
description = "The value of the `fail_destroy_on_timeout` input variable, or the default value if the input was `null`."
62+
value = local.var_fail_create_on_timeout
63+
}
64+
output "timeout_create" {
65+
description = "The value of the `timeout_create` input variable, or the default value if the input was `null`."
66+
value = local.var_timeout_create
67+
}
68+
output "timeout_destroy" {
69+
description = "The value of the `timeout_destroy` input variable, or the default value if the input was `null`."
70+
value = local.var_timeout_destroy
71+
}
72+
output "suppress_console" {
73+
description = "The value of the `suppress_console` input variable, or the default value if the input was `null`."
74+
value = local.var_suppress_console
75+
}
76+
output "unix_interpreter" {
77+
description = "The value of the `unix_interpreter` input variable, or the default value if the input was `null`."
78+
value = local.var_unix_interpreter
79+
}
80+
81+
//==================================================
82+
// Outputs generated by this module
83+
//==================================================
184
output "id" {
285
description = "A unique ID for this resource. The ID does not change when the shell command is re-run."
3-
value = random_uuid.uuid.result
86+
value = local.execution_id
487
}
5-
688
output "stdout" {
7-
description = "The stdout output of the shell command."
8-
value = local.outputs.stdout
89+
description = "The stdout output of the shell command, with all carriage returns and trailing newlines removed."
90+
value = local.stdout_censored
991
}
10-
1192
output "stderr" {
12-
description = "The stderr output of the shell command."
13-
value = local.outputs.stderr
93+
description = "The stderr output of the shell command, with all carriage returns and trailing newlines removed."
94+
value = local.stderr_censored
1495
}
15-
1696
output "exit_code" {
17-
description = "The exit status code of the shell command."
18-
value = tonumber(local.outputs.exit_code)
97+
description = "The exit status code of the shell command. If the `timeout` input variable was provided and the command timed out, this will be `null`."
98+
value = local.outputs.exit_code == null ? null : tonumber(local.outputs.exit_code)
1999
}
20-
21-
output "version" {
22-
description = "The version of the shell resource (see the `track_version` input variable)."
23-
value = var.track_version ? module.state_keeper[0].output : null
100+
output "null_command_windows" {
101+
description = "A command that does nothing on Windows systems. You can use this output as the value for the `command_windows` input if you don't want the module to do anything on Windows systems."
102+
value = local.null_command_windows
103+
}
104+
output "null_command_unix" {
105+
description = "A command that does nothing on Unix-based systems. You can use this output as the value for the `command_unix` input if you don't want the module to do anything on Unix-based systems."
106+
value = local.null_command_unix
24107
}

0 commit comments

Comments
 (0)