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

Add data field to KV data sources #1577

Merged
merged 2 commits into from
Aug 11, 2022
Merged

Conversation

vinay-gopalan
Copy link
Contributor

Adds a data schema field to vault_kv_secret_v2, vault_kv_secret and vault_kv_subkeys_v2 datasources. This field stores a serialized data map of the secret data to the TF state. Previously we were storing the secret data only as a string in order to preserve nested secrets.

Relates OR Closes #1520

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestDataSourceKVV2Secret'
=== RUN   TestDataSourceKVV2Secret
--- PASS: TestDataSourceKVV2Secret (1.76s)
PASS

$ make testacc TESTARGS='-run=TestDataSourceKVSecret'
=== RUN   TestDataSourceKVSecret
--- PASS: TestDataSourceKVSecret (3.09s)

$ make testacc TESTARGS='-run=TestDataSourceKVSubkeys'
=== RUN   TestDataSourceKVSubkeys
--- PASS: TestDataSourceKVSubkeys (1.78s)
PASS

vault/data_source_kv_secret.go Outdated Show resolved Hide resolved
@@ -27,6 +27,10 @@ func TestDataSourceKVSecret(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, consts.FieldPath, fmt.Sprintf("%s/%s", mount, name)),
resource.TestCheckResourceAttr(resourceName, consts.FieldLeaseRenewable, "false"),
resource.TestCheckResourceAttr(resourceName, "data.zip", "zap"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to check the length of data.%

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in latest commit

vault/data_source_kv_secret_test.go Show resolved Hide resolved
vault/data_source_kv_secret_v2_test.go Show resolved Hide resolved
vault/data_source_kv_subkeys_v2_test.go Show resolved Hide resolved
website/docs/d/kv_secret_v2.html.md Outdated Show resolved Hide resolved
website/docs/d/kv_secret.html.md Outdated Show resolved Hide resolved
Copy link
Contributor

@benashz benashz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it!

@vinay-gopalan vinay-gopalan merged commit 02917fc into main Aug 11, 2022
@vinay-gopalan vinay-gopalan deleted the VAULT-6881/add-data-to-kv branch August 11, 2022 20:23
marcboudreau pushed a commit to marcboudreau/terraform-provider-vault that referenced this pull request Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vault_kv_secret_v2 and friends incorrect docs
2 participants