Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Resource ¶
type Resource struct { Values map[string]Value `json:"values"` // contains filtered or unexported fields }
Resource is the data structure that is actually written into our data stores.
It currently only publicly contains the Values mapping of attribute names to actual values. It is designed as a bridge between the Terraform SDK representation of a value and a generic JSON representation that can be read/written externally. In theory, any terraform object can be represented as a Resource. In practice, there will probably be edge cases and types that have been missed.
If we could write tftypes.Value into a human friendly format, and read back any changes from that then we wouldn't need this bridge. But, we can't do that using the current SDK so we handle it ourselves here.
You must call the WithType function manually to attach the object type before attempting to convert a Resource into a Terraform SDK value.
The types are attached automatically when converting from a Terraform SDK object.
func (*Resource) FromTerraform5Value ¶
FromTerraform5Value ensures that Resource implements the tftypes.ValueConverter interface, and so can be converted from Terraform types easily.
func (Resource) GetId ¶
GetId returns the ID of the resource.
It assumes the ID value exists and is a string type.
func (Resource) ToTerraform5Value ¶
ToTerraform5Value ensures that Resource implements the tftypes.ValueCreator interface, and so can be converted into Terraform types easily.
func (*Resource) WithType ¶
WithType adds type information into a Resource as this is not stored as part of our external API.
You must call this function to set the type information before using ToTerraform5Value(). The type information can usually be retrieved from the Terraform SDK, so this information should be readily available it just needs to be added after the Resource has been created.
type Value ¶
type Value struct { Boolean *bool `json:"boolean,omitempty"` Number *big.Float `json:"number,omitempty"` String *string `json:"string,omitempty"` List *[]Value `json:"list,omitempty"` Map *map[string]Value `json:"map,omitempty"` Object *map[string]Value `json:"object,omitempty"` Set *[]Value `json:"set,omitempty"` }
Value is the mock provider's representation of any generic Terraform Value.
It can be converted from/to a tftypes.Value using the functions in this package, and it can be marshalled to/from JSON using the Golang JSON package.
Only a single field in the struct will be set at a given time.
We use pointers where appropriate to make sure the omitempty metadata works to keep the produced structs as small and relevant as possible as they are intended to be consumed by humans.
We introduce pointers to the complex objects because there is a difference between unset (or nil) and an empty list and we want to record that difference.
func FromTerraform5Value ¶
FromTerraform5Value accepts a tftypes.Value and returns our representation of a Value.
Note, that unlike the reverse ToTerraform5Value function we do not need to include the type information as this is not embedded in our representation of the type (the expectation is that the type information will always be provided by the SDK regardless of which direction we need to go).