-
Notifications
You must be signed in to change notification settings - Fork 50
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
[HCP Vault Secrets] fix app & secret name validation #750
Conversation
@@ -50,19 +50,23 @@ func (r *resourceVaultsecretsSecret) Schema(_ context.Context, _ resource.Schema | |||
Description: "The name of the application the secret can be found in", | |||
Required: true, | |||
Validators: []validator.String{ | |||
stringvalidator.LengthAtLeast(3), |
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.
Apps use this common "hcp user settable slug":
https://github.com/hashicorp/cloud-vault-secrets/blob/main/internal/service/validation/service.go#L37
Wonder if it make sense to adopt this:
https://github.com/hashicorp/terraform-provider-hcp/blob/main/internal/providersdkv2/validators.go#L138
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.
Great find, did not know it exists! Thanks @VinnyHC
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.
Unfortunately, it seems like these helpers are internal to providersdkv2
package and can't be used here cleanly.
regexp.MustCompile(`^[-\da-zA-Z]{3,36}$`), | ||
"must contain only letters, numbers or hyphens", | ||
regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9\-]+[a-zA-Z0-9]$`), | ||
"must contain only ASCII letters, numbers, and hyphens; must not start or end with a hyphen", |
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.
@averche Error message should contain min/max length as well.
🛠️ Description
Fixing the validation rules for HCP Vault Secrets app and secret names to match what we have on the server.
Fixes #728
🏗️ Acceptance tests