shared

package
v1.29.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModeManaged is mode value for managed resources.
	ModeManaged = "managed"
	// AttributeKeyId is the key for the id attribute
	AttributeKeyId = "id"
	// AttributeKeyName is the key for the name attribute
	AttributeKeyName = "name"
)

Variables

This section is empty.

Functions

func AttributeAsString

func AttributeAsString(attributes map[string]interface{}, key string) (svalue string, found bool)

AttributeAsString returns the string value for the given key. `found` is only true if the map contains the key and the value is a string.

Types

type TFInstance

type TFInstance struct {
	SchemaVersion       int                    `json:"schema_version"`
	Attributes          map[string]interface{} `json:"attributes,omitempty"`
	SensitiveAttributes []string               `json:"sensitive_attributes,omitempty"`
	Private             string                 `json:"private,omitempty"`
	Dependencies        []string               `json:"dependencies"`
}

TFInstance holds the attributes of a terraformer state resource instance.

type TFOutput

type TFOutput struct {
	Value interface{} `json:"value"`
	Type  string      `json:"type"`
}

TFOutput holds the value and type for a terraformer state output variable.

type TFResource

type TFResource struct {
	Mode      string `json:"mode"`
	Type      string `json:"type"`
	Name      string `json:"name"`
	Provider  string `json:"provider"`
	Instances []TFInstance
}

TFResource holds the attributes of a terraformer state resource.

type TerraformState

type TerraformState struct {
	Version          int                 `json:"version"`
	TerraformVersion string              `json:"terraform_version"`
	Serial           int                 `json:"serial"`
	Lineage          string              `json:"lineage"`
	Outputs          map[string]TFOutput `json:"outputs,omitempty"`
	Resources        []TFResource        `json:"resources,omitempty"`
}

TerraformState holds the unmarshalled terraformer state.

func LoadTerraformStateFromConfigMapData

func LoadTerraformStateFromConfigMapData(data map[string]string) (*TerraformState, error)

LoadTerraformStateFromConfigMapData loads and unmarshalls the state from a config map data.

func UnmarshalTerraformState

func UnmarshalTerraformState(data []byte) (*TerraformState, error)

UnmarshalTerraformState unmarshalls the terraformer state from a byte array.

func UnmarshalTerraformStateFromTerraformer

func UnmarshalTerraformStateFromTerraformer(state *terraformer.RawState) (*TerraformState, error)

UnmarshalTerraformStateFromTerraformer unmarshalls the terraformer state from RawState.

func (*TerraformState) FindManagedResourceInstances

func (ts *TerraformState) FindManagedResourceInstances(tfType, resourceName string) []TFInstance

FindManagedResourceInstances finds all instances for a resource identified by type and name.

func (*TerraformState) FindManagedResourcesByType

func (ts *TerraformState) FindManagedResourcesByType(tfType string) []*TFResource

FindManagedResourcesByType finds all instances for all resources of the given type.

func (*TerraformState) GetManagedResourceInstanceAttribute

func (ts *TerraformState) GetManagedResourceInstanceAttribute(tfType, resourceName, attributeKey string) *string

GetManagedResourceInstanceAttribute returns the value of the given attribute keys of the only instance of a resource identified by type and name. It returns nil if either the resource is not found or the resource has not exactly one instance or the attribute key is not existing.

func (*TerraformState) GetManagedResourceInstanceID

func (ts *TerraformState) GetManagedResourceInstanceID(tfType, resourceName string) *string

GetManagedResourceInstanceID returns the value of the id attribute of the only instance of a resource identified by type and name. It returns nil if either the resource is not found or the resource has not exactly one instance.

func (*TerraformState) GetManagedResourceInstanceName

func (ts *TerraformState) GetManagedResourceInstanceName(tfType, resourceName string) *string

GetManagedResourceInstanceName returns the value of the name attribute of the only instance of a resource identified by type and name. It returns nil if either the resource is not found or the resource has not exactly one instance.

func (*TerraformState) GetManagedResourceInstances

func (ts *TerraformState) GetManagedResourceInstances(tfType string) map[string]string

GetManagedResourceInstances returns a map resource name to instance id for all resources of the given type. Only resources are included which have exactly one instance.

Jump to

Keyboard shortcuts

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