Skip to content

Commit a774780

Browse files
committed
Use early variables for additional commands
Use early variables for: - tofu workspace - tofu show - tofu validate - tofu init, even when the backend is not needed
1 parent bc66212 commit a774780

File tree

21 files changed

+285
-67
lines changed

21 files changed

+285
-67
lines changed

.github/workflows/test-early-eval.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ jobs:
1010
s3-backend:
1111
runs-on: ubuntu-24.04
1212
name: Plan with early eval
13+
permissions:
14+
contents: read
15+
pull-requests: write
1316
env:
1417
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
1518
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1620
steps:
1721
- name: Checkout
1822
uses: actions/checkout@v4
@@ -21,9 +25,25 @@ jobs:
2125

2226
- name: tofu plan
2327
uses: ./tofu-plan
28+
id: plan
29+
with:
30+
path: tests/workflows/test-early-eval/s3
31+
variables: |
32+
passphrase = "tofuqwertyuiopasdfgh"
33+
34+
- name: Verify outputs
35+
env:
36+
JSON_PLAN_PATH: ${{ steps.plan.outputs.json_plan_path }}
37+
run: |
38+
if [[ ! -f "$JSON_PLAN_PATH" ]]; then
39+
echo "::error:: json_plan_path not set correctly"
40+
exit 1
41+
fi
42+
43+
- name: tofu apply
44+
uses: ./tofu-apply
2445
with:
2546
path: tests/workflows/test-early-eval/s3
26-
add_github_comment: false
2747
variables: |
2848
passphrase = "tofuqwertyuiopasdfgh"
2949

.github/workflows/test-version.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ jobs:
611611
run: |
612612
echo "The terraform version was $DETECTED_TERRAFORM_VERSION"
613613
614-
if [[ "$DETECTED_TERRAFORM_VERSION" != *"1.11"* ]]; then
614+
if [[ "$DETECTED_TERRAFORM_VERSION" != *"1.12"* ]]; then
615615
echo "::error:: Latest version was not used"
616616
exit 1
617617
fi
@@ -632,7 +632,7 @@ jobs:
632632
run: |
633633
echo "The terraform version was $DETECTED_TERRAFORM_VERSION"
634634
635-
if [[ "$DETECTED_TERRAFORM_VERSION" != *"1.11"* ]]; then
635+
if [[ "$DETECTED_TERRAFORM_VERSION" != *"1.12"* ]]; then
636636
echo "::error:: Latest version was not used"
637637
exit 1
638638
fi

.github/workflows/test.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ jobs:
119119
docs/*.md
120120
**/README.md
121121
122-
- name: ensure-sha-pinned-actions
123-
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@25ed13d0628a1601b4b44048e63cc4328ed03633 # v3
124-
with:
125-
allowlist: |
126-
actions/
127-
dflook/
128-
129122
- name: Lint Dockerfile
130123
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
131124
with:

.github/zizmor.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rules:
2+
unpinned-uses:
3+
config:
4+
policies:
5+
dflook/terraform-apply: ref-pin
6+
dflook/terraform-plan: ref-pin
7+
actions/*: ref-pin

docs-gen/actions/fmt.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import dataclasses
22

3-
from action import Action
3+
from action import Action, OpenTofu
44
from environment_variables.GITHUB_DOT_COM_TOKEN import GITHUB_DOT_COM_TOKEN
55
from environment_variables.TERRAFORM_CLOUD_TOKENS import TERRAFORM_CLOUD_TOKENS
66
from inputs.backend_config import backend_config
77
from inputs.backend_config_file import backend_config_file
88
from inputs.path import path
9+
from inputs.var_file import var_file
10+
from inputs.variables import variables
911
from inputs.workspace import workspace
1012

1113
fmt = Action(
@@ -20,6 +22,11 @@
2022
$ProductName workspace to inspect when discovering the $ProductName version to use, if the version is not otherwise specified.
2123
See [dflook/$ToolName-version](https://github.com/dflook/terraform-github-actions/tree/main/$ToolName-version#$ToolName-version-action) for details.
2224
'''),
25+
dataclasses.replace(variables, available_in=[OpenTofu], description='''
26+
Variables to set when initializing $ProductName. This should be valid $ProductName syntax - like a [variable definition file]($VariableDefinitionUrl).
27+
Variables set here override any given in `var_file`s.
28+
'''),
29+
dataclasses.replace(var_file, available_in=[OpenTofu]),
2330
dataclasses.replace(backend_config, description='''
2431
List of $ProductName backend config values, one per line. This is used for discovering the $ProductName version to use, if the version is not otherwise specified.
2532
See [dflook/$ToolName-version](https://github.com/dflook/terraform-github-actions/tree/main/$ToolName-version#$ToolName-version-action) for details.
@@ -70,4 +77,4 @@
7077
branch: automated-$ToolName-fmt
7178
```
7279
'''
73-
)
80+
)

docs-gen/actions/fmt_check.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import dataclasses
22

3-
from action import Action
3+
from action import Action, OpenTofu
44
from environment_variables.GITHUB_DOT_COM_TOKEN import GITHUB_DOT_COM_TOKEN
55
from environment_variables.TERRAFORM_CLOUD_TOKENS import TERRAFORM_CLOUD_TOKENS
66
from inputs.backend_config import backend_config
77
from inputs.backend_config_file import backend_config_file
88
from inputs.path import path
9+
from inputs.var_file import var_file
10+
from inputs.variables import variables
911
from inputs.workspace import workspace
1012
from outputs.failure_reason import failure_reason
1113

@@ -24,6 +26,11 @@
2426
$ProductName workspace to inspect when discovering the $ProductName version to use, if the version is not otherwise specified.
2527
See [dflook/$ToolName-version](https://github.com/dflook/terraform-github-actions/tree/main/$ToolName-version#$ToolName-version-action) for details.
2628
'''),
29+
dataclasses.replace(variables, available_in=[OpenTofu], description='''
30+
Variables to set when initializing $ProductName. This should be valid $ProductName syntax - like a [variable definition file]($VariableDefinitionUrl).
31+
Variables set here override any given in `var_file`s.
32+
'''),
33+
dataclasses.replace(var_file, available_in=[OpenTofu]),
2734
dataclasses.replace(backend_config, description='''
2835
List of $ProductName backend config values, one per line. This is used for discovering the $ProductName version to use, if the version is not otherwise specified.
2936
See [dflook/$ToolName-version](https://github.com/dflook/terraform-github-actions/tree/main/$ToolName-version#$ToolName-version-action) for details.
@@ -96,4 +103,4 @@
96103
run: echo "formatting check failed"
97104
```
98105
'''
99-
)
106+
)

docs-gen/actions/new_workspace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
inputs=[
2222
path,
2323
dataclasses.replace(workspace, description='The name of the $ProductName workspace to create.', required=True, default=None),
24-
dataclasses.replace(variables, description='''
24+
dataclasses.replace(variables, available_in=[OpenTofu], description='''
2525
Variables to set when initializing $ProductName. This should be valid $ProductName syntax - like a [variable definition file]($VariableDefinitionUrl).
2626
2727
Variables set here override any given in `var_file`s.
28-
''', available_in=[OpenTofu]),
28+
'''),
2929
dataclasses.replace(var_file, available_in=[OpenTofu]),
3030
backend_config,
3131
backend_config_file,

docs-gen/actions/output.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dataclasses
22

3-
from action import Action
3+
from action import Action, OpenTofu
44
from environment_variables.GITHUB_DOT_COM_TOKEN import GITHUB_DOT_COM_TOKEN
55
from environment_variables.TERRAFORM_CLOUD_TOKENS import TERRAFORM_CLOUD_TOKENS
66
from environment_variables.TERRAFORM_HTTP_CREDENTIALS import TERRAFORM_HTTP_CREDENTIALS
@@ -9,6 +9,8 @@
99
from inputs.backend_config import backend_config
1010
from inputs.backend_config_file import backend_config_file
1111
from inputs.path import path
12+
from inputs.var_file import var_file
13+
from inputs.variables import variables
1214
from inputs.workspace import workspace
1315
from outputs.terraform_outputs import terraform_outputs
1416

@@ -20,8 +22,14 @@
2022
inputs=[
2123
path,
2224
dataclasses.replace(workspace, description='$ProductName workspace to get outputs from'),
25+
dataclasses.replace(variables, available_in=[OpenTofu], description='''
26+
Variables to set when initializing $ProductName. This should be valid $ProductName syntax - like a [variable definition file]($VariableDefinitionUrl).
27+
28+
Variables set here override any given in `var_file`s.
29+
'''),
30+
dataclasses.replace(var_file, available_in=[OpenTofu]),
2331
backend_config,
24-
backend_config_file,
32+
backend_config_file
2533
],
2634
environment_variables=[
2735
GITHUB_DOT_COM_TOKEN,
@@ -106,4 +114,4 @@
106114
The subnet-ids are subnet-053008016a2c1768c,subnet-07d4ce437c43eba2f,subnet-0a5f8c3a20023b8c0
107115
```
108116
'''
109-
)
117+
)

0 commit comments

Comments
 (0)