maps

package
v2.3.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader interface {
	// GetString retrieves a string from the underlying data.
	//
	// If the value does not exist, or is not a string, returns an empty string.
	GetString(key string) string

	// GetStringPtr retrieves a string pointer from the underlying data.
	//
	// If the value does not exist, or is not a string, returns nil.
	GetStringPtr(key string) *string

	// GetStringSlice retrieves a slice of strings from the underlying data, or an empty slice if not present.
	GetStringSlice(key string) []string

	// GetInt retrieves an integer from the underlying data.
	//
	// If the value does not exist, or is not an int, returns 0.
	GetInt(key string) int

	// GetInt retrieves an integer from the underlying data, or a default value if not present.
	//
	// If the value does not exist, or is not an int, returns defaultValue.
	GetIntOr(key string, defaultValue int) int

	// GetIntPtr retrieves an integer pointer from the underlying data.
	//
	// If the value does not exist, or is not an int, returns nil.
	GetIntPtr(key string) *int

	// GetMapSlice retrieves a slice of sub-maps from the underlying data.
	//
	// If the value does not exist, or is not a slice of maps, returns an empty slice.
	GetMapSlice(key string) []map[string]interface{}

	// GetMapSliceElement retrieves the specified element from a slice of sub-maps.
	//
	// If the value does not exist, or is not a slice of maps, returns nil.
	GetMapSliceElement(key string, index int) map[string]interface{}
}

Reader provides an interface for reading from a Terraform value map.

Together, Reader and Writer provider a consistent interface.

func NewReader

func NewReader(data map[string]interface{}) Reader

NewReader creates a new Reader to read the values in the specified map.

type Writer

type Writer interface {
	// SetString creates or updates a string in the underlying data.
	SetString(key string, value string)

	// SetStringPtr creates or updates a string pointer in the underlying data.
	SetStringPtr(key string, value *string)

	// SetStringSlice creates or updates a string slice in the underlying data.
	SetStringSlice(key string, value ...string)

	// SetInt creates or updates an integer in the underlying data.
	SetInt(key string, value int)

	// SetIntPtr creates or updates an integer pointer in the underlying data.
	SetIntPtr(key string, value *int)

	// SetMapSlice creates or updates a slice of maps in the underlying data.
	SetMapSlice(key string, values ...map[string]interface{})
}

Writer provides an interface for writing to a Terraform value map.

ToSether, Reader and Writer provider a consistent interface.

func NewWriter

func NewWriter(data map[string]interface{}) Writer

NewWriter creates a new Writer to read the values in the specified map.

Jump to

Keyboard shortcuts

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