Documentation ¶
Index ¶
- Constants
- func AttributeAsString(attributes map[string]interface{}, key string) (svalue string, found bool)
- func IsValidValue(value string) bool
- func ValidValue(value string) string
- type BasicFlowContext
- type FlatMap
- type FlowStatePersistor
- type StateExporter
- type TFInstance
- type TFOutput
- type TFResource
- type TaskOption
- type TerraformState
- func (ts *TerraformState) FindManagedResourceInstances(tfType, resourceName string) []TFInstance
- func (ts *TerraformState) FindManagedResourcesByType(tfType string) []*TFResource
- func (ts *TerraformState) GetManagedResourceInstanceAttribute(tfType, resourceName, attributeKey string) *string
- func (ts *TerraformState) GetManagedResourceInstanceID(tfType, resourceName string) *string
- func (ts *TerraformState) GetManagedResourceInstanceName(tfType, resourceName string) *string
- func (ts *TerraformState) GetManagedResourceInstances(tfType string) map[string]string
- type Whiteboard
Constants ¶
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" )
const (
// Separator is used to on translating keys to/from flat maps
Separator = "/"
)
Variables ¶
This section is empty.
Functions ¶
func AttributeAsString ¶
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.
func IsValidValue ¶
IsValidValue returns true if an exported value is valid, i.e. not empty and not special value for deleted.
func ValidValue ¶
ValidValue returns the value if the exported value is valid, otherwise an empty string.
Types ¶
type BasicFlowContext ¶
type BasicFlowContext struct { Log logr.Logger PersistInterval time.Duration // contains filtered or unexported fields }
BasicFlowContext provides logic for persisting the state and add tasks to the flow graph.
func NewBasicFlowContext ¶
func NewBasicFlowContext(log logr.Logger, exporter StateExporter, persistor FlowStatePersistor) *BasicFlowContext
NewBasicFlowContext creates a new `BasicFlowContext`.
func (*BasicFlowContext) AddTask ¶
func (c *BasicFlowContext) AddTask(g *flow.Graph, name string, fn flow.TaskFn, options ...TaskOption) flow.TaskIDer
AddTask adds a wrapped task for the given task function and options.
func (*BasicFlowContext) LogFromContext ¶
func (c *BasicFlowContext) LogFromContext(ctx context.Context) logr.Logger
LogFromContext returns the log from the context when called within a task function added with the `AddTask` method.
func (*BasicFlowContext) PersistState ¶
func (c *BasicFlowContext) PersistState(ctx context.Context, force bool) error
PersistState persists the internal state to the provider status if it has changed and force is true or it has not been persisted during the `PersistInterval`.
type FlowStatePersistor ¶
FlowStatePersistor persists the flat map to the provider status
type StateExporter ¶
type StateExporter interface { // CurrentGeneration is a counter which increments on changes of the internal state. CurrentGeneration() int64 // Exports all or parts of the internal state to a flat string map. ExportAsFlatMap() FlatMap }
StateExporter knows how to export the internal state to a flat string map.
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 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 TaskOption ¶
TaskOption contains options for created flow tasks
func Dependencies ¶
func Dependencies(dependencies ...flow.TaskIDer) TaskOption
Dependencies creates a TaskOption for dependencies
func Timeout ¶
func Timeout(timeout time.Duration) TaskOption
Timeout creates a TaskOption for Timeout
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 the raw state.
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.
type Whiteboard ¶
type Whiteboard interface { IsEmpty() bool // GetChild returns a sub-whiteboard for the given key. If no child exists with this name, it is created automatically. // Each child has its own lock. GetChild(key string) Whiteboard // HasChild returns true if there is a non-empty child for that key HasChild(key string) bool // GetChildrenKeys returns all children keys GetChildrenKeys() []string // Get returns a valid value or nil (never "" or special deleted value) Get(key string) *string Set(key, id string) SetPtr(key string, id *string) IsAlreadyDeleted(key string) bool SetAsDeleted(key string) // Keys returns all stored keys, even for deleted ones Keys() []string // AsMap returns a map with all valid key/values AsMap() map[string]string GetObject(key string) any SetObject(key string, obj any) // ImportFromFlatMap reconstructs the hierarchical structure from a flat map containing path-like keys ImportFromFlatMap(data FlatMap) // ExportAsFlatMap exports the hierarchical structure to a flat map with path-like keys. Objects are ignored. ExportAsFlatMap() FlatMap // CurrentGeneration returns current generation, which increments with any change CurrentGeneration() int64 }
Whiteboard is a hierarchical key/value store for the internal state. It is safe to be used concurrently. Additionally, it can cache objects for use in subsequent flow task.