Documentation
¶
Index ¶
- func Compile(path string, out io.Writer) error
- func CompileDevParams(path string, out io.Writer) error
- func FillDevParam(prop jsonschema.Property, existingVal, exampleVal interface{}) interface{}
- func GenerateFiles(bundlePath string, srcDir string) error
- type TFOptionalVariable
- type TFRequiredVariable
- type TFVariable
- type TFVariableFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileDevParams ¶ added in v0.4.4
Compile a JSON Schema to JSON Values based on
func FillDevParam ¶ added in v0.4.4
func FillDevParam(prop jsonschema.Property, existingVal, exampleVal interface{}) interface{}
FillDevParam fills a parameter with a development value this function folows the following priority for filling in values: 1. If the parameter is already set, use that value 2. If there is a 'Development' example value, use that value 3. If the param defines a default use that value. 4. If the param is an array fallback to empty array. 5. If the param is a number and defines a minimum use that value. 4. Use a TODO string placeholder value
func GenerateFiles ¶
Types ¶
type TFOptionalVariable ¶
type TFOptionalVariable struct { Type string `json:"type"` DoNotSet *string `json:"default"` // DO NOT SET THIS. The intention is to get a nil value for this }
TFOptionalVariable is a representation of a terraform HCL "variable" with a default of null
func (TFOptionalVariable) IsTFVariable ¶
func (TFOptionalVariable) IsTFVariable()
type TFRequiredVariable ¶
type TFRequiredVariable struct {
Type string `json:"type"`
}
TFRequiredVariable is a representation of a terraform HCL "variable"
func (TFRequiredVariable) IsTFVariable ¶
func (TFRequiredVariable) IsTFVariable()
Dummy functions to satisfy the interface
type TFVariable ¶
type TFVariable interface {
IsTFVariable()
}
In terraform, we need to set "default: null" for non-required fields, however the "default" field should NOT be set if the field is required. There isn't a good way to solve this in Golang with a single struct. Thus, we need two structs: a TFRequiredVariable which *doesn't* serialize a default value (making it required by TF), and a TFOptionalVariable which does serialize a default value (represented as a nil pointer, which serializes to null) This interface allows us to work with them interchangably as needed
func NewTFVariable ¶
func NewTFVariable(p jsonschema.Property, required bool) TFVariable
NewTFVariable creates a new TFVariable from a JSON Schema Property
type TFVariableFile ¶
type TFVariableFile struct {
Variable map[string]TFVariable `json:"variable"`
}
TFVariableFile is a representation of a variables.tf file in JSON format