Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide_args option #279

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/tf_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
strategy:
fail-fast: false
matrix:
tool: [tofu, terraform]
tool: [tofu] # [tofu, terraform]
path:
- fail_invalid_resource_type
- fail_data_source_error
# - fail_invalid_resource_type
# - fail_data_source_error
- pass_one
- pass_character_limit
# - pass_character_limit
- pass_format_diff

steps:
Expand All @@ -50,6 +50,7 @@ jobs:
arg_chdir: tests/${{ matrix.path }}
arg_command: ${{ github.event.pull_request.merged && 'apply' || 'plan' }}
arg_lock: ${{ github.event.pull_request.merged && 'true' || 'false' }}
hide_args: arg_lock
tf_tool: ${{ matrix.tool }}
tf_version: ~> 1.8.0

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ In order to locally decrypt the TF plan file, use the following command (noting
| `comment_pr`</br>Default: `true` | Boolean flag to add PR comment of TF command output. |
| `encrypt_passphrase`</br>Example: `${{ secrets.KEY }}` | String passphrase to encrypt the TF plan file. |
| `fmt_enable`</br>Default: `true` | Boolean flag to enable TF fmt command and display diff of changes. |
| `hide_args`</br>Example: [arg_var] | String list of TF arguments to hide from the command input. |
| `label_pr`</br>Default: `true` | Boolean flag to add PR label of TF command to run. |
| `plan_parity`</br>Default: `false` | Boolean flag to compare the TF plan file with a newly-generated one to prevent stale apply. |
| `tenv_version`</br>Example: `v3.1.0` | String version tag of the tenv tool to install and use. |
Expand Down
4 changes: 3 additions & 1 deletion action.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ module.exports = async ({ context, core, exec, github }) => {
// Function to execute TF commands.
const exec_tf = async (input_arguments, input_header, input_header_slice) => {
const arguments = input_arguments.filter((arg) => arg);
const header = input_header.filter((arg) => arg);
const header = input_header.filter(
(arg) => arg && !Object.values(JSON.parse(process.env.hide_args)).includes(arg)
);
cli_input = header.concat(arguments.slice(input_header_slice)).join(" ");
cli_result = "";
core.setOutput("header", cli_input);
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
description: Boolean flag to enable TF fmt command and display diff of changes.
required: false
default: "true"
hide_args:
description: String list of TF arguments to hide from the command input.
required: false
default: ""
label_pr:
description: Boolean flag to add PR label of TF command to run.
required: false
Expand Down Expand Up @@ -291,6 +295,7 @@ runs:
comment_pr: ${{ inputs.comment_pr }}
encrypt_passphrase: ${{ inputs.encrypt_passphrase }}
fmt_enable: ${{ inputs.fmt_enable }}
hide_args: ${{ toJSON(inputs.hide_args) }}
label_pr: ${{ inputs.label_pr }}
plan_parity: ${{ inputs.plan_parity }}
tf_tool: ${{ inputs.tf_tool }}
Expand Down