Skip to content

Add support for a KV V2 Secret Metadata resource - #1687

Merged
vinay-gopalan merged 13 commits into
mainfrom
VAULT-11817/add-kvv2-metadata
Jan 5, 2023
Merged

Add support for a KV V2 Secret Metadata resource#1687
vinay-gopalan merged 13 commits into
mainfrom
VAULT-11817/add-kvv2-metadata

Conversation

@vinay-gopalan

@vinay-gopalan vinay-gopalan commented Dec 2, 2022

Copy link
Copy Markdown
Contributor

Adds support for adding custom metadata to a KV V2 secret resource.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccKVSecretV2'
=== RUN   TestAccKVSecretV2
--- PASS: TestAccKVSecretV2 (2.35s)
PASS
...

@github-actions github-actions Bot added the size/L label Dec 2, 2022
@joao-oneill-unbabel

Copy link
Copy Markdown

@vinay-gopalan Seems like this is the same as #1239

@vinay-gopalan

vinay-gopalan commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

@vinay-gopalan Seems like this is the same as #1239

@joao-oneill-unbabel the two are definitely similar! Though the code in this PR slightly differs from the one you mentioned, in that this resource is compatible with the latest dedicated KV V2 Secret engine support that was added to the TFVP in v3.7.0 as opposed to the legacy resource vault_generic_secret 😄

Comment thread website/docs/r/kv_secret_metadata_v2.html.md Outdated
Comment thread website/docs/r/kv_secret_metadata_v2.html.md Outdated
Comment thread website/docs/r/kv_secret_metadata_v2.html.md Outdated
@github-actions github-actions Bot added size/L and removed size/XL labels Dec 23, 2022
@vinay-gopalan
vinay-gopalan marked this pull request as draft December 23, 2022 21:57
@vinay-gopalan
vinay-gopalan marked this pull request as ready for review January 3, 2023 21:21

@benashz benashz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking good. Have some initial feedback for you.

Comment thread website/docs/r/kv_secret_v2.html.md Outdated
Comment thread website/docs/r/kv_secret_backend_v2.html.md Outdated
Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread vault/resource_kv_secret_v2.go Outdated
consts.FieldData: {
Type: schema.TypeMap,
Optional: true,
Computed: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this ever be a computed value? Presumably the default is empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted to make sure we are able to import the custom metadata and set it to the TF state for the KV secret, specifically in the cases that the secret metadata was created outside of TF and via Vault. That was my thought process around setting this field to also be possibly computed. Is that overkill/unnecessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed the Computed from the individual nested fields, but still set Computed: true for the parent custom_metadata field

Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread vault/resource_kv_secret_v2_test.go
@vinay-gopalan
vinay-gopalan requested a review from benashz January 4, 2023 17:32

@benashz benashz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few minor nits to address, then 👍

Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread vault/resource_kv_secret_v2.go Outdated
Comment thread website/docs/r/kv_secret_v2.html.md Outdated
@vinay-gopalan

Copy link
Copy Markdown
Contributor Author

1 acceptance test suite is failing due to GH request rate limiting; proceeding to merge since the work done here does not affect the failing tests

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.

4 participants