terraform/builtin/providers/heroku/validators.go

39 lines
728 B
Go
Raw Normal View History

package heroku
import (
"fmt"
"strings"
"github.com/satori/uuid"
)
var validPipelineStageNames = []string{
"review",
"development",
"staging",
"production",
}
func validatePipelineStageName(v interface{}, k string) (ws []string, errors []error) {
for _, s := range validPipelineStageNames {
if v == s {
return
}
}
err := fmt.Errorf(
"%s is an invalid pipeline stage, must be one of [%s]",
v,
strings.Join(validPipelineStageNames, ", "),
)
errors = append(errors, err)
return
}
func validateUUID(v interface{}, k string) (ws []string, errors []error) {
if _, err := uuid.FromString(v.(string)); err != nil {
errors = append(errors, fmt.Errorf("%q is an invalid UUID: %s", k, err))
}
return
}