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

[HCP Vault Secrets] fix app & secret name validation #750

Merged
merged 4 commits into from
Feb 12, 2024

Conversation

averche
Copy link
Contributor

@averche averche commented Feb 9, 2024

🛠️ 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

  • Are there any feature flags that are required to use this functionality?
  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

@averche averche marked this pull request as ready for review February 9, 2024 03:13
@averche averche requested review from a team as code owners February 9, 2024 03:13
@averche averche requested a review from a team February 9, 2024 03:18
@@ -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),
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

@averche averche merged commit 6f90dae into main Feb 12, 2024
6 checks passed
@averche averche deleted the fix-secret-name-validation branch February 12, 2024 15:29
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",

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading validation error messages/validation doesn't match HCP web interface
5 participants