github.com/mineiros-io/terradoc@v0.0.9-0.20220711062319-018bd4ae81f5/internal/entities/variable.go (about) 1 package entities 2 3 import ( 4 "encoding/json" 5 ) 6 7 type VariableCollection []Variable 8 9 func (vc VariableCollection) VarByName(name string) (Variable, bool) { 10 for _, v := range vc { 11 if v.Name == name { 12 return v, true 13 } 14 } 15 16 return Variable{}, false 17 } 18 19 // Variable represents a `variable` block from the input file. 20 type Variable struct { 21 // Name as defined in the `variable` block label. 22 Name string `json:"name"` 23 // Type is a type definition for the variable 24 Type Type `json:"type_definition"` 25 // Description is an optional variable description 26 Description string `json:"description,omitempty"` 27 // Default is an optional default value for this variable in case none is given. Must be a valid JSON value. 28 Default json.RawMessage `json:"default,omitempty"` 29 // Required specifies if the variable is required 30 Required bool `json:"required,omitempty"` 31 // ForcesRecreation specifies if a change in the variable triggers the recreation of the resource. 32 ForcesRecreation bool `json:"forces_recreation,omitempty"` 33 // ReadmeExample is an optional readme example to be used in the documentation 34 ReadmeExample string `json:"readme_example,omitempty"` 35 // Attributes is a collection attributes that make up the value of this variable. 36 Attributes []Attribute `json:"attributes,omitempty"` 37 }