X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=vendor%2Fgithub.com%2Fhashicorp%2Fterraform%2Fhelper%2Fschema%2Fschema.go;h=acb5618ba2656b259ce165faf7f1ccb6913ec012;hb=00a66330be57dc8d7f987b4235d65d372f6b471f;hp=632672ae069381ba0c9f91daeaacce78b26e5faa;hpb=9b12e4fe6f3c95986f1f3ec791636c58ca7e7583;p=github%2Ffretlink%2Fterraform-provider-statuscake.git diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go index 632672a..acb5618 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go @@ -15,6 +15,7 @@ import ( "fmt" "os" "reflect" + "regexp" "sort" "strconv" "strings" @@ -661,7 +662,13 @@ func (m schemaMap) InternalValidate(topSchemaMap schemaMap) error { if v.ValidateFunc != nil { switch v.Type { case TypeList, TypeSet: - return fmt.Errorf("ValidateFunc is not yet supported on lists or sets.") + return fmt.Errorf("%s: ValidateFunc is not yet supported on lists or sets.", k) + } + } + + if v.Deprecated == "" && v.Removed == "" { + if !isValidFieldName(k) { + return fmt.Errorf("%s: Field name may only contain lowercase alphanumeric characters & underscores.", k) } } } @@ -669,6 +676,11 @@ func (m schemaMap) InternalValidate(topSchemaMap schemaMap) error { return nil } +func isValidFieldName(name string) bool { + re := regexp.MustCompile("^[a-z0-9_]+$") + return re.MatchString(name) +} + func (m schemaMap) diff( k string, schema *Schema,