github.com/arvindram03/terraform@v0.3.7-0.20150212015210-408f838db36d/helper/schema/valuetype.go (about)

     1  package schema
     2  
     3  //go:generate stringer -type=ValueType valuetype.go
     4  
     5  import "fmt"
     6  
     7  // ValueType is an enum of the type that can be represented by a schema.
     8  type ValueType int
     9  
    10  const (
    11  	TypeInvalid ValueType = iota
    12  	TypeBool
    13  	TypeInt
    14  	TypeFloat
    15  	TypeString
    16  	TypeList
    17  	TypeMap
    18  	TypeSet
    19  	typeObject
    20  )
    21  
    22  // Zero returns the zero value for a type.
    23  func (t ValueType) Zero() interface{} {
    24  	switch t {
    25  	case TypeInvalid:
    26  		return nil
    27  	case TypeBool:
    28  		return false
    29  	case TypeInt:
    30  		return 0
    31  	case TypeFloat:
    32  		return 0.0
    33  	case TypeString:
    34  		return ""
    35  	case TypeList:
    36  		return []interface{}{}
    37  	case TypeMap:
    38  		return map[string]interface{}{}
    39  	case TypeSet:
    40  		return nil
    41  	case typeObject:
    42  		return map[string]interface{}{}
    43  	default:
    44  		panic(fmt.Sprintf("unknown type %s", t))
    45  	}
    46  }