-
Notifications
You must be signed in to change notification settings - Fork 73
Add new local_command data source for running and retrieving data from local executables
#452
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
Conversation
|
Well the tests aren't running on this PR since it's pointed at a non-main branch 😅 , so I ran them locally with the latest Test logs $ make testacc
TF_ACC=1 go test -v -cover -timeout 120m ./...
github.com/terraform-providers/terraform-provider-local coverage: 0.0% of statements
=== RUN TestFilePermissionValueValidateAttribute
=== PAUSE TestFilePermissionValueValidateAttribute
=== CONT TestFilePermissionValueValidateAttribute
=== RUN TestFilePermissionValueValidateAttribute/00700
=== RUN TestFilePermissionValueValidateAttribute/-1
=== RUN TestFilePermissionValueValidateAttribute/0777
=== RUN TestFilePermissionValueValidateAttribute/0644
=== RUN TestFilePermissionValueValidateAttribute/9999
=== RUN TestFilePermissionValueValidateAttribute/7
--- PASS: TestFilePermissionValueValidateAttribute (0.00s)
--- PASS: TestFilePermissionValueValidateAttribute/00700 (0.00s)
--- PASS: TestFilePermissionValueValidateAttribute/-1 (0.00s)
--- PASS: TestFilePermissionValueValidateAttribute/0777 (0.00s)
--- PASS: TestFilePermissionValueValidateAttribute/0644 (0.00s)
--- PASS: TestFilePermissionValueValidateAttribute/9999 (0.00s)
--- PASS: TestFilePermissionValueValidateAttribute/7 (0.00s)
PASS
coverage: 27.8% of statements
ok github.com/terraform-providers/terraform-provider-local/internal/localtypes 0.530s coverage: 27.8% of statements
=== RUN TestLocalCommandAction_bash
--- PASS: TestLocalCommandAction_bash (0.64s)
=== RUN TestLocalCommandAction_bash_stdin
--- PASS: TestLocalCommandAction_bash_stdin (0.47s)
=== RUN TestLocalCommandAction_bash_all
--- PASS: TestLocalCommandAction_bash_all (0.55s)
=== RUN TestLocalCommandAction_bash_null_args
--- PASS: TestLocalCommandAction_bash_null_args (0.47s)
=== RUN TestLocalCommandAction_absolute_path_bash
--- PASS: TestLocalCommandAction_absolute_path_bash (0.49s)
=== RUN TestLocalCommandAction_not_found
--- PASS: TestLocalCommandAction_not_found (0.17s)
=== RUN TestLocalCommandAction_stderr
--- PASS: TestLocalCommandAction_stderr (4.83s)
=== RUN TestLocalCommandDataSource_stdout_json
--- PASS: TestLocalCommandDataSource_stdout_json (0.80s)
=== RUN TestLocalCommandDataSource_stdout_csv
--- PASS: TestLocalCommandDataSource_stdout_csv (0.52s)
=== RUN TestLocalCommandDataSource_stdout_yaml
--- PASS: TestLocalCommandDataSource_stdout_yaml (0.97s)
=== RUN TestLocalCommandDataSource_stdout_no_format_null_args
--- PASS: TestLocalCommandDataSource_stdout_no_format_null_args (0.58s)
=== RUN TestLocalCommandDataSource_stderr_zero_exit_code
--- PASS: TestLocalCommandDataSource_stderr_zero_exit_code (0.57s)
=== RUN TestLocalCommandDataSource_stdout_invalid_string
--- PASS: TestLocalCommandDataSource_stdout_invalid_string (0.52s)
=== RUN TestLocalCommandDataSource_non_zero_exit_code_error
--- PASS: TestLocalCommandDataSource_non_zero_exit_code_error (0.31s)
=== RUN TestLocalCommandDataSource_allow_non_zero_exit_code
--- PASS: TestLocalCommandDataSource_allow_non_zero_exit_code (0.49s)
=== RUN TestLocalCommandDataSource_absolute_path_with_working_directory
--- PASS: TestLocalCommandDataSource_absolute_path_with_working_directory (0.51s)
=== RUN TestLocalCommandDataSource_not_found
--- PASS: TestLocalCommandDataSource_not_found (0.19s)
=== RUN TestLocalFileDataSource
--- PASS: TestLocalFileDataSource (0.41s)
=== RUN TestLocalFileSensitiveDataSource
--- PASS: TestLocalFileSensitiveDataSource (0.41s)
=== RUN TestLocalFileSensitiveDataSourceCheckSensitiveAttributes
--- PASS: TestLocalFileSensitiveDataSourceCheckSensitiveAttributes (0.00s)
=== RUN TestDirectoryExists_basic
--- PASS: TestDirectoryExists_basic (0.40s)
=== RUN TestDirectoryExists_invalid_file
--- PASS: TestDirectoryExists_invalid_file (0.16s)
=== RUN TestDirectoryExists_invalid_symlink
--- PASS: TestDirectoryExists_invalid_symlink (0.15s)
=== RUN TestLocalFile_Basic
--- PASS: TestLocalFile_Basic (1.32s)
=== RUN TestLocalFile_Source
--- PASS: TestLocalFile_Source (0.46s)
=== RUN TestLocalFile_Permissions
--- PASS: TestLocalFile_Permissions (0.36s)
=== RUN TestLocalFile_Validators
--- PASS: TestLocalFile_Validators (0.20s)
=== RUN TestLocalFile_Upgrade
--- PASS: TestLocalFile_Upgrade (5.89s)
=== RUN TestLocalFile_Source_Upgrade
--- PASS: TestLocalFile_Source_Upgrade (2.19s)
=== RUN TestLocalFile_Permissions_Upgrade
--- PASS: TestLocalFile_Permissions_Upgrade (1.85s)
=== RUN TestLocalSensitiveFile_Basic
--- PASS: TestLocalSensitiveFile_Basic (1.10s)
=== RUN TestLocalSensitiveFile_source
--- PASS: TestLocalSensitiveFile_source (0.52s)
=== RUN TestLocalSensitiveFile_Permissions
--- PASS: TestLocalSensitiveFile_Permissions (0.42s)
=== RUN TestLocalSensitiveFile_Validators
--- PASS: TestLocalSensitiveFile_Validators (0.20s)
=== RUN TestLocalSensitiveFile_Upgrade
--- PASS: TestLocalSensitiveFile_Upgrade (4.10s)
=== RUN TestLocalSensitiveFile_Source_Upgrade
--- PASS: TestLocalSensitiveFile_Source_Upgrade (2.42s)
=== RUN TestLocalSensitiveFile_Permissions_Upgrade
--- PASS: TestLocalSensitiveFile_Permissions_Upgrade (1.83s)
PASS
coverage: 79.9% of statements
ok github.com/terraform-providers/terraform-provider-local/internal/provider 38.198s coverage: 79.9% of statements |
stephybun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks pretty good, just have one question/thought left in-line.
It's also a shame we can't link to a full list of available encoding/decoding functions in the docs.
|
This looks great! Are there plans for an ephemeral version of this? I would be more than happy to contribute. A |
stephybun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💯
SBGoods
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
b240685 to
829e754
Compare
The base branch was changed.
stephybun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🧇
Related Issue
Closes #63
There are a number of
externalprovider issues that this new data source would address, so I'll just link a few:queryandresultterraform-provider-external#2Description
This PR introduces a new
local_commanddata source, which achieves a similar goal to the existingexternaldata source in a more generic fashion, allowing practitioners to encode/decode the data going to and from a local executable.This is preferable to returning a dynamic type / pre-decoding data returned from a command, as providers ATM only really have a clear implementation of decoding JSON data, while this approach allows existing decoding definitions to be used, for example:
In addition, alternative decoding implementations could be introduced via provider defined functions.
Rollback Plan
Changes to Security Controls
No