Skip to content

Commit

Permalink
helper/schema: Compile valid field name regex once (#1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
skarimo committed Oct 10, 2022
1 parent 6c09938 commit 3495894
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,10 @@ func checkKeysAgainstSchemaFlags(k string, keys []string, topSchemaMap schemaMap
return nil
}

var validFieldNameRe = regexp.MustCompile("^[a-z0-9_]+$")

func isValidFieldName(name string) bool {
re := regexp.MustCompile("^[a-z0-9_]+$")
return re.MatchString(name)
return validFieldNameRe.MatchString(name)
}

// resourceDiffer is an interface that is used by the private diff functions.
Expand Down

0 comments on commit 3495894

Please sign in to comment.