github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/builtin/providers/heroku/validators.go (about) 1 package heroku 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/satori/uuid" 8 ) 9 10 func validatePipelineStageName(v interface{}, k string) (ws []string, errors []error) { 11 validPipelineStageNames := []string{ 12 "review", 13 "development", 14 "staging", 15 "production", 16 } 17 18 for _, s := range validPipelineStageNames { 19 if v == s { 20 return 21 } 22 } 23 24 err := fmt.Errorf( 25 "%s is an invalid pipeline stage, must be one of [%s]", 26 v, 27 strings.Join(validPipelineStageNames, ", "), 28 ) 29 errors = append(errors, err) 30 return 31 } 32 33 func validateUUID(v interface{}, k string) (ws []string, errors []error) { 34 if _, err := uuid.FromString(v.(string)); err != nil { 35 errors = append(errors, fmt.Errorf("%q is an invalid UUID: %s", k, err)) 36 } 37 return 38 }