github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/fastly/validators.go (about)

     1  package fastly
     2  
     3  import "fmt"
     4  
     5  func validateLoggingFormatVersion(v interface{}, k string) (ws []string, errors []error) {
     6  	value := uint(v.(int))
     7  	validVersions := map[uint]struct{}{
     8  		1: {},
     9  		2: {},
    10  	}
    11  
    12  	if _, ok := validVersions[value]; !ok {
    13  		errors = append(errors, fmt.Errorf(
    14  			"%q must be one of ['1', '2']", k))
    15  	}
    16  	return
    17  }
    18  
    19  func validateLoggingMessageType(v interface{}, k string) (ws []string, errors []error) {
    20  	value := v.(string)
    21  	validTypes := map[string]struct{}{
    22  		"classic": {},
    23  		"loggly":  {},
    24  		"logplex": {},
    25  		"blank":   {},
    26  	}
    27  
    28  	if _, ok := validTypes[value]; !ok {
    29  		errors = append(errors, fmt.Errorf(
    30  			"%q must be one of ['classic', 'loggly', 'logplex', 'blank']", k))
    31  	}
    32  	return
    33  }