Documentation ¶
Overview ¶
Package schemautil provides utilities for working with Terraform resource schemas.
Package schemautil provides utilities for working with Terraform resource schemas.
Note that this package uses legacy logging because the provider context is not available
Index ¶
- Constants
- func CronExpression(opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
- func MustNormalizeFieldName(fieldName string) string
- func MustNormalizeYamlString(yamlString interface{}) string
- func NormalizeFieldName(fieldName string) (string, error)
- func NormalizeYamlString(yamlString interface{}) (string, error)
- func StringIsValidRegExp(opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
- func StringIsValidYaml(opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
- func StringMatchesRegExp(regex string, opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
- func SuppressEquivalentYamlDiffs() schema.SchemaDiffSuppressFunc
- type CronValidationOptions
- type StringValidationOptions
- type ValidationOptionSetter
- func WithCronParser(parser cron.Parser) ValidationOptionSetter
- func WithDetailFormat(detailFormat string) ValidationOptionSetter
- func WithRegexOptions(options regexp2.RegexOptions) ValidationOptionSetter
- func WithSeverity(severity diag.Severity) ValidationOptionSetter
- func WithSummary(summary string) ValidationOptionSetter
- type ValidationOptions
Constants ¶
const (
NormalizedFieldNameRegex string = `[^a-z0-9_]+`
)
const ( // https://github.com/codefresh-io/hermes/blob/6d75b347cb8ff471ce970a766b2285788e5e19fe/pkg/backend/dev_compose_types.json#L226 ValidCronMessageRegex string = `^[a-zA-Z0-9_+\s-#?.:]{2,128}$` )
Variables ¶
This section is empty.
Functions ¶
func CronExpression ¶
func CronExpression(opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
CronExpression returns a SchemaValidateDiagFunc that validates a cron expression.
func MustNormalizeFieldName ¶
MustNormalizeFieldName is the same as NormalizeFieldName, but will log an error (legacy logging) instead of returning it.
func MustNormalizeYamlString ¶
func MustNormalizeYamlString(yamlString interface{}) string
MustNormalizeYamlString is the same as NormalizeYamlString, but will log an error (legacy logging) instead of returning it.
func NormalizeFieldName ¶
NormalizeFieldName normalizes a field name to be lowercase and contain only alphanumeric characters and dashes.
func NormalizeYamlString ¶
NormalizeYAMLString normalizes a YAML string to a standardized order, format and indentation.
func StringIsValidRegExp ¶
func StringIsValidRegExp(opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
StringIsValidRegExp returns a SchemaValidateDiagFunc which validates that a string is a valid regular expression.
This function has similar functionality to StringIsValidRegExp from the terraform plugin SDK. https://github.com/hashicorp/terraform-plugin-sdk/blob/695f0c7b92e26444786b8963e00c665f1b4ef400/helper/validation/strings.go#L225 It has been modified to use the library https://github.com/dlclark/regexp2 instead of the standard regex golang package in order to support complex regular expressions including perl regex syntax.
It has also been modified to conform to the SchemaValidateDiagFunc type instead of the deprecated SchemaValidateFunc type.
func StringIsValidYaml ¶
func StringIsValidYaml(opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
StringIsValidYaml returns a SchemaValidateDiagFunc which validates that a string is valid YAML.
func StringMatchesRegExp ¶
func StringMatchesRegExp(regex string, opts ...ValidationOptionSetter) schema.SchemaValidateDiagFunc
StringMatchesRegExp returns a SchemaValidateDiagFunc which validates that a string matches a regular expression.
func SuppressEquivalentYamlDiffs ¶
func SuppressEquivalentYamlDiffs() schema.SchemaDiffSuppressFunc
SuppressEquivalentYamlDiffs returns SchemaDiffSuppressFunc that suppresses diffs between equivalent YAML strings.
Types ¶
type CronValidationOptions ¶
type CronValidationOptions struct {
// contains filtered or unexported fields
}
CronValidationOptions contains options for validating cron expressions.
type StringValidationOptions ¶
type StringValidationOptions struct {
// contains filtered or unexported fields
}
StringValidationOptions contains options for validating strings.
type ValidationOptionSetter ¶
type ValidationOptionSetter func(*ValidationOptions)
func WithCronParser ¶
func WithCronParser(parser cron.Parser) ValidationOptionSetter
WithParser overrides the cron parser used to validate cron expressions.
func WithDetailFormat ¶
func WithDetailFormat(detailFormat string) ValidationOptionSetter
WithDetailFormat overrides the detail format string of the validation error.
This string is passed to fmt.Sprintf. The verbs used in the format string depend on the implementation of the validation function.
func WithRegexOptions ¶
func WithRegexOptions(options regexp2.RegexOptions) ValidationOptionSetter
WithRegexOptions overrides the regex options used to validate regular expressions.
func WithSeverity ¶
func WithSeverity(severity diag.Severity) ValidationOptionSetter
WithSeverity overrides the severity of the validation error.
func WithSummary ¶
func WithSummary(summary string) ValidationOptionSetter
WithSummary overrides the summary of the validation error.
type ValidationOptions ¶
type ValidationOptions struct {
// contains filtered or unexported fields
}
func NewValidationOptions ¶
func NewValidationOptions() *ValidationOptions
NewValidationOptions returns a new ValidationOptions struct with default values.