Documentation ¶
Index ¶
Constants ¶
View Source
const SchemaVersion = 3
Variables ¶
View Source
var Validate = func(fn ...schema.SchemaValidateDiagFunc) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics for _, validateFunc := range fn { diags = append(diags, validateFunc(i, p)...) } return diags } }
View Source
var ValidateMax = func(max int) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics var iv int switch v := i.(type) { case int: iv = v case string: var err error v = strings.TrimSpace(v) if strings.HasPrefix(v, "{{") && strings.HasSuffix(v, "}}") { return diags } iv, err = strconv.Atoi(v) if err != nil { diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%s is not a number", i.(string))}) return diags } } if iv > max { diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%v must not be greater than %d", i, max)}) } return diags } }
View Source
var ValidateMaxLength = func(maxLength int) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics if len(i.(string)) > maxLength { diag := diag.Diagnostic{ Severity: diag.Error, Summary: fmt.Sprintf("%s exceeds the maximum length of %d characters", i.(string), maxLength), } diags = append(diags, diag) } return diags } }
View Source
var ValidateMin = func(min int) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics var iv int switch v := i.(type) { case int: iv = v case string: var err error v = strings.TrimSpace(v) if strings.HasPrefix(v, "{{") && strings.HasSuffix(v, "}}") { return diags } iv, err = strconv.Atoi(v) if err != nil { diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%s is not a number", i.(string))}) return diags } } if iv < min { diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%v must not be less than %d", i, min)}) } return diags } }
View Source
var ValidateMinLength = func(min int) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics if len(i.(string)) < min { diag := diag.Diagnostic{ Severity: diag.Error, Summary: fmt.Sprintf("%s must be at least %d characters long", i.(string), min), } diags = append(diags, diag) } return diags } }
View Source
var ValidateRange = func(min int, max int) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics var iv int switch v := i.(type) { case int: iv = v case string: var err error v = strings.TrimSpace(v) if strings.HasPrefix(v, "{{") && strings.HasSuffix(v, "}}") { return diags } iv, err = strconv.Atoi(v) if err != nil { diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%s is not a number", i.(string))}) return diags } } if iv < min || iv > max { diags = append(diags, diag.Diagnostic{Severity: diag.Error, Summary: fmt.Sprintf("%v is not in range %d and %d", i, min, max)}) } return diags } }
View Source
var ValidateRegex = func(r *regexp.Regexp, errorMessage string) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics if !r.MatchString(i.(string)) { diag := diag.Diagnostic{ Severity: diag.Error, Summary: fmt.Sprintf("%s contains invalid characters", i.(string)), Detail: errorMessage, } diags = append(diags, diag) } return diags } }
View Source
var ValidateTypePossibleValues = func(valuesList []string) schema.SchemaValidateDiagFunc { return func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics if !isInList(i.(string), valuesList) { diag := diag.Diagnostic{ Severity: diag.Error, Summary: fmt.Sprintf("%s is not on the list of possible values: %s", i.(string), valuesList), } diags = append(diags, diag) } return diags } }
View Source
var ValidateUUID = func(i any, p cty.Path) diag.Diagnostics { var diags diag.Diagnostics if _, err := uuid.Parse(i.(string)); err != nil { diag := diag.Diagnostic{ Severity: diag.Error, Summary: "The value is expected to be a UUID", Detail: fmt.Sprintf("%v is not a UUID", i), } diags = append(diags, diag) } return diags }
Functions ¶
This section is empty.
Types ¶
type DirectShare ¶
type DirectShare struct {}
func (*DirectShare) MarshalHCL ¶
func (me *DirectShare) MarshalHCL(properties hcl.Properties) error
func (*DirectShare) MarshalJSON ¶
func (me *DirectShare) MarshalJSON() ([]byte, error)
func (*DirectShare) UnmarshalHCL ¶
func (me *DirectShare) UnmarshalHCL(decoder hcl.Decoder) error
type Recipient ¶
func (*Recipient) MarshalHCL ¶
func (me *Recipient) MarshalHCL(properties hcl.Properties) error
type Recipients ¶
type Recipients []*Recipient
func (*Recipients) MarshalHCL ¶
func (me *Recipients) MarshalHCL(properties hcl.Properties) error
func (*Recipients) UnmarshalHCL ¶
func (me *Recipients) UnmarshalHCL(decoder hcl.Decoder) error
Click to show internal directories.
Click to hide internal directories.