terraform

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(path string, out io.Writer) error

Compile a JSON Schema to Terraform Variable Definition JSON

func CompileDevParams added in v0.4.4

func CompileDevParams(path string, out io.Writer) error

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

func GenerateFiles(bundlePath string, srcDir string) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL