types

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool bool

Bool represents a 'bool' value

func (Bool) HasDefault

func (b Bool) HasDefault() bool

HasDefault indicates a Terraform variable has a default value set.

func (Bool) Length

func (b Bool) Length() int

Length returns the length of underlying item

type Empty

type Empty string

Empty represents an empty 'string' which is marshaled to `""` in JSON and YAML

func (Empty) HasDefault

func (e Empty) HasDefault() bool

HasDefault indicates a Terraform variable has a default value set.

func (Empty) Length

func (e Empty) Length() int

Length returns the length of underlying item

func (Empty) MarshalJSON

func (e Empty) MarshalJSON() ([]byte, error)

MarshalJSON custom marshal function which sets the value to `""`

type List

type List []interface{}

List represents a 'list' of values

func (List) HasDefault

func (l List) HasDefault() bool

HasDefault indicates a Terraform variable has a default value set.

func (List) Length

func (l List) Length() int

Length returns the length of underlying item

func (List) MarshalXML

func (l List) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML custom marshal function which wraps list items in '<default></default>' tag and each items of the list will be wrapped in a '<item></item>' tag

func (List) Underlying

func (l List) Underlying() []interface{}

Underlying returns the underlying elements in the form of '[]interface {}'

type Map

type Map map[string]interface{}

Map represents a 'map' of values

func (Map) HasDefault

func (m Map) HasDefault() bool

HasDefault indicates a Terraform variable has a default value set.

func (Map) Length

func (m Map) Length() int

Length returns the length of underlying item

func (Map) MarshalXML

func (m Map) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML custom marshal function which converts map to its literal XML representation. For example:

m := Map{
    "a": 1,
    "b": 2,
    "c": 3,
}
type foo struct {
    Value Map `xml:"value"`
}

will get marshaled to:

<foo>

<value>
  <a>1</a>
  <b>2</b>
  <c>3</c>
</value>

</foo>

func (Map) Underlying

func (m Map) Underlying() map[string]interface{}

Underlying returns the underlying elements in the form of 'map[string]interface {}'

type Nil

type Nil types.Nil

Nil represents a 'nil' value which is marshaled to `null` when empty for JSON and YAML

func (Nil) HasDefault

func (n Nil) HasDefault() bool

HasDefault return false for Nil, because there's no value set for the variable

func (Nil) Length

func (n Nil) Length() int

Length returns the length of underlying item

func (Nil) MarshalJSON

func (n Nil) MarshalJSON() ([]byte, error)

MarshalJSON custom marshal function which sets the value to literal `null`

func (Nil) MarshalXML

func (n Nil) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML custom marshal function which adds property 'xsi:nil="true"' to a tag of a 'nil' item

func (Nil) MarshalYAML

func (n Nil) MarshalYAML() (interface{}, error)

MarshalYAML custom marshal function which sets the value to literal `null`

type Number

type Number float64

Number represents a 'number' value which is marshaled to `null` when emty in JSON and YAML

func (Number) HasDefault

func (n Number) HasDefault() bool

HasDefault indicates a Terraform variable has a default value set.

func (Number) Length

func (n Number) Length() int

Length returns the length of underlying item

type String

type String string

String represents a 'string' value which is marshaled to `null` when empty for JSON and YAML

func TypeOf

func TypeOf(t string, v interface{}) String

TypeOf returns Terraform type of a value based on provided type by terraform-inspect or by looking the underlying type of the value

func (String) HasDefault

func (s String) HasDefault() bool

HasDefault indicates a Terraform variable has a default value set.

func (String) Length

func (s String) Length() int

Length returns the length of underlying item

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

MarshalJSON custom marshal function which sets the value to literal `null` when empty

func (String) MarshalXML

func (s String) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML custom marshal function which adds property 'xsi:nil="true"' to a tag if the underlying item is 'nil'

func (String) MarshalYAML

func (s String) MarshalYAML() (interface{}, error)

MarshalYAML custom marshal function which sets the value to literal `null` when empty

type Value

type Value interface {
	HasDefault() bool
	Length() int
}

Value is a default value of an input or output. it can be of several types:

- Nil - String - Empty - Number - Bool - List - Map

func ValueOf

func ValueOf(v interface{}) Value

ValueOf returns actual value of a variable casted to 'Default' interface. This is done to be able to attach specific marshaller func to the type (if such a custom function was needed)

Jump to

Keyboard shortcuts

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