tfxsdk

package
v0.0.0-...-54aa85e Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindSubTraversal

func FindSubTraversal(t1 hcl.Traversal, t2str string) (int, error)

FindSubTraversal finds the last step's traversal index in "t1", for the sub-address "t2".

Any index/splat steps in "t1" will be ignored, except the current step in "t2" being tested is also a index/slat step.

If "t2" is not found in the "t1", -1 is returned. E.g. Given "a[0].b.c", and as "a.b", 2 is returned.

func FormatTraversal

func FormatTraversal(ts hcl.Traversal) string

func FormatTraverse

func FormatTraverse(t hcl.Traverser) (str string, isAttr bool)

func IndexKeyString

func IndexKeyString(key cty.Value) string

func NewFixConfigDefinitionFunction

func NewFixConfigDefinitionFunction(fixers DefinitionFixers) function.Function

NewFixConfigDefinitionFunction returns the provider function for fixing the config definition.

func NewFixConfigReferenceFunction

func NewFixConfigReferenceFunction(fixers ReferenceFixers) function.Function

NewFixConfigReferenceFunction returns the provider function for fixing the config reference.

func ParseTraversal

func ParseTraversal(t string) (hcl.Traversal, error)

func SchemaVersioIndex

func SchemaVersioIndex(regVersions []int, version int) (int, error)

SchemaVersionIndex checks if the schema version is supported by the registered schema versions. The regVersions is supposed to be ordered from the least version. If supported, the index of the version in the regVersions is returned. Otherwise, -1 is returned.

func TraversalMatches

func TraversalMatches(t1 hcl.Traversal, t2str string) (bool, error)

TraversalMatches tells whether the traversal "t1" matches the sub-traversal t2.

Any index/splat steps in "t1" will be ignored, except the current step in "t2str" being tested is also a index/slat step.

current step in "t2" being tested is also a index/slat step. E.g. "a[0].b.c" matches "a.b.c", but not "a.b"

func TraversalReplace

func TraversalReplace(t hcl.Traversal, tpfx hcl.Traversal, nt hcl.Traversal) (hcl.Traversal, error)

TraversalReplace finds the traveral prefix "tpfx" in the "t", replace the last traverse of "tpfx" in the "t" with the "nt".

Any index/splat steps in "t" will be ignored, except the current step in "tpfx" being tested is also a index/slat step.

If the "tpfx" is not found, "t" will be returned.

Types

type BlockType

type BlockType string
const (
	BlockTypeProvider   BlockType = "provider"
	BlockTypeResource   BlockType = "resource"
	BlockTypeDataSource BlockType = "datasource"
)

type DefinitionConfigUpgrader

type DefinitionConfigUpgrader struct {
	DefinitionConfigUpgrader func(context.Context, UpgradeDefinitionConfigRequest, *UpgradeDefinitionConfigResponse)
}

DefinitionConfigUpgrader upgrades the definition config from the current schema version to the next version

type DefinitionConfigUpgraders

type DefinitionConfigUpgraders map[int]DefinitionConfigUpgrader

DefinitionConfigUpgraders is a collection of DefinitionConfigUpgrader, from the schema version 0 to the latest supported version. Each DefinitionConfigUpgraders upgrades the definition config one version forward.

The schema version expects to be continuouse within the major version of the provider.

type DefinitionFixers

type DefinitionFixers map[BlockType]map[string]DefinitionConfigUpgraders

type FixConfigDefinitionFunction

type FixConfigDefinitionFunction struct {
	Fixers DefinitionFixers
}

func (FixConfigDefinitionFunction) Definition

func (FixConfigDefinitionFunction) Metadata

func (FixConfigDefinitionFunction) Run

type FixConfigReferenceFunction

type FixConfigReferenceFunction struct {
	Fixers ReferenceFixers
}

func (FixConfigReferenceFunction) Definition

func (FixConfigReferenceFunction) Metadata

func (FixConfigReferenceFunction) Run

type ReferenceConfigUpgrader

type ReferenceConfigUpgrader struct {
	ReferenceConfigUpgrader func(context.Context, UpgradeReferenceConfigRequest, *UpgradeReferenceConfigResponse)
}

ReferenceConfigUpgrader upgrades the reference config from the current schema version to the next version

type ReferenceConfigUpgraders

type ReferenceConfigUpgraders map[int]ReferenceConfigUpgrader

ReferenceConfigUpgraders is a collection of ReferenceConfigUpgrader, from the schema version 0 to the latest supported version. Each ReferenceConfigUpgraders upgrades the reference config one version forward.

The schema version expects to be continuouse within the major version of the provider.

type ReferenceFixers

type ReferenceFixers map[BlockType]map[string]ReferenceConfigUpgraders

type UpgradeDefinitionConfigRequest

type UpgradeDefinitionConfigRequest struct {
	// The syntax body that descirbes this definition
	SyntaxBody *hclsyntax.Body
	// The hclwrite.Body that the user is supposed to make change to
	WriteBody *hclwrite.Body
	// State can be nil for modules without state, or resource whose address contains the index
	State map[string]interface{}
}

type UpgradeDefinitionConfigResponse

type UpgradeDefinitionConfigResponse struct {
	// State represents the upgraded states to the next schema version.
	// The provider is expected to invoke its StateUpgrader to retrieve the result.
	State map[string]interface{}
	Error error
}

type UpgradeReferenceConfigRequest

type UpgradeReferenceConfigRequest struct {
	Traversals []hcl.Traversal
}

type UpgradeReferenceConfigResponse

type UpgradeReferenceConfigResponse struct {
	Traversals []hcl.Traversal
	Error      error
}

Jump to

Keyboard shortcuts

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