-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check resty log for header existence before redacting it Clean up test utility
- Loading branch information
Showing
4 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package string | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag" | ||
"github.com/hashicorp/terraform-plugin-framework/schema/validator" | ||
) | ||
|
||
// Ensure our implementation satisfies the validator.String interface. | ||
var _ validator.String = &repoKeyValidator{} | ||
|
||
type repoKeyValidator struct{} | ||
|
||
func (v repoKeyValidator) Description(_ context.Context) string { | ||
return "value must be a valid email address" | ||
} | ||
|
||
func (v repoKeyValidator) MarkdownDescription(ctx context.Context) string { | ||
return v.Description(ctx) | ||
} | ||
|
||
func (v repoKeyValidator) ValidateString(ctx context.Context, request validator.StringRequest, response *validator.StringResponse) { | ||
if request.ConfigValue.IsNull() || request.ConfigValue.IsUnknown() { | ||
return | ||
} | ||
|
||
value := request.ConfigValue.ValueString() | ||
|
||
if len(value) == 0 || len(value) > 64 { | ||
response.Diagnostics.Append(validatordiag.InvalidAttributeValueLengthDiagnostic( | ||
request.Path, | ||
"must be 1 - 64 alphanumeric and hyphen characters", | ||
value, | ||
)) | ||
} | ||
|
||
if strings.ContainsAny(value, " !@#$%^&*()+={}[]:;<>,/?~`|\\") { | ||
response.Diagnostics.Append(validatordiag.InvalidAttributeValueMatchDiagnostic( | ||
request.Path, | ||
"cannot contain spaces or special characters: !@#$%^&*()+={}[]:;<>,/?~`|\\", | ||
value, | ||
)) | ||
} | ||
} | ||
|
||
func RepoKey() validator.String { | ||
return repoKeyValidator{} | ||
} |