pfutils

package
v0.0.0-...-626180e Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(opts JoinOptions, path *tftypes.AttributePath, x, y *tftypes.Value) (*tftypes.Value, error)

Joins two values. The missing combinator from tftypes, which provides Diff and Walk but no ability to join.

func ProposedNew

func ProposedNew(ctx context.Context, schema Schema, priorState, config tftypes.Value) (tftypes.Value, error)

Computes the ProposedNewState from priorState and config.

Likely the canonical implementaiton is ProposedNew objchange.go:

https://github.com/hashicorp/terraform/blob/v1.3.6/internal/plans/objchange/objchange.go#L27-#L27

Terraform core does this as a utility to providers to make their code easier; therefore the bridge has to do it also, as it imitates Terraform core.

Quote from TF docs serves as a spec:

The ProposedNewState merges any non-null values in the configuration with any computed attributes in PriorState
as a utility to help providers avoid needing to implement such merging functionality themselves.

The state is represented as a tftypes.Object, with each attribute and nested block getting its own key and
value.

The ProposedNewState will be null when planning a delete operation.

When Pulumi programs retract attributes, config (checkedInputs) will have no entry for these, while priorState might have an entry. ProposedNewState must have a Null entry in this case for Diff to work properly and recognize an attribute deletion.

Types

type Attr

type Attr interface {
	AttrLike
	IsNested() bool
	Nested() map[string]Attr
	NestingMode() NestingMode
	HasNestedObject() bool
}

Attr type works around not being able to link to fwschema.Attribute from "github.com/hashicorp/terraform-plugin-framework/internal/fwschema"

Most methods from fwschema.Attribute have simple signatures and are copied into attrLike interface. Casting to attrLike exposes these methods.

GetAttributes method is special since it returns a NestedAttributes interface that is also internal and cannot be linked to. Instead, NestedAttriutes information is recorded in a dedicated new field.

func FromAttrLike

func FromAttrLike(attrLike AttrLike) Attr

func FromDataSourceAttribute

func FromDataSourceAttribute(x dschema.Attribute) Attr

func FromProviderAttribute

func FromProviderAttribute(x pschema.Attribute) Attr

func FromResourceAttribute

func FromResourceAttribute(x rschema.Attribute) Attr

type AttrLike

type AttrLike interface {
	IsComputed() bool
	IsOptional() bool
	IsRequired() bool
	IsSensitive() bool
	GetDeprecationMessage() string
	GetDescription() string
	GetMarkdownDescription() string
	GetType() attr.Type
}

type Block

type Block interface {
	BlockLike
	NestedAttrs() map[string]Attr
	NestedBlocks() map[string]Block
	GetMaxItems() int64
	GetMinItems() int64
	HasNestedObject() bool
}

Block type works around not being able to link to fwschema.Block from "github.com/hashicorp/terraform-plugin-framework/internal/fwschema".

func FromBlockLike

func FromBlockLike(x BlockLike) Block

func FromDataSourceBlock

func FromDataSourceBlock(x dschema.Block) Block

func FromProviderBlock

func FromProviderBlock(x pschema.Block) Block

func FromResourceBlock

func FromResourceBlock(x rschema.Block) Block

type BlockLike

type BlockLike interface {
	GetDeprecationMessage() string
	GetDescription() string
	GetMarkdownDescription() string

	Type() attr.Type
}

type BlockNestingMode

type BlockNestingMode uint8
const (
	BlockNestingModeUnknown BlockNestingMode = 0
	BlockNestingModeList    BlockNestingMode = 1
	BlockNestingModeSet     BlockNestingMode = 2
	BlockNestingModeSingle  BlockNestingMode = 3
)

type DataSources

type DataSources interface {
	All() []TypeName
	Has(TypeName) bool
	Schema(TypeName) Schema
	Diagnostics(TypeName) diag.Diagnostics
	AllDiagnostics() diag.Diagnostics
	DataSource(TypeName) datasource.DataSource
}

Represents all provider's datasources pre-indexed by TypeName.

func GatherDatasources

func GatherDatasources(ctx context.Context, prov provider.Provider) (DataSources, error)

type Diff

type Diff struct {
	tftypes.ValueDiff
	Type tftypes.Type
}

func (Diff) Null

func (d Diff) Null() *tftypes.Value

func (Diff) Unknown

func (d Diff) Unknown() *tftypes.Value

type Eq

type Eq interface {
	Equal(path *tftypes.AttributePath, a, b tftypes.Value) (bool, error)
}
var DefaultEq Eq = defaultEq(0)

Default equality for tftype.Value.

func NonComputedEq

func NonComputedEq(schema Schema) Eq

Considers two tftype.Value values equal if all their non-computed attributes are equal.

type JoinOptions

type JoinOptions struct {
	// Reconciles two values that are not both present or else present but not Equal. At least one of the values is
	// immediate. Immediate values are nulls, unknowns, and scalar values (not List, Set, Map, Object).
	Reconcile func(Diff) (*tftypes.Value, error)

	// Optional. Allows overriding how set elements are compared for equality.
	SetElementEqual Eq
}

Configures how to join two values.

type LookupResult

type LookupResult struct {
	IsAttr         bool
	IsBlock        bool
	IsNestedObject bool
	Attr           Attr
	Block          Block
}

func LookupTerraformPath

func LookupTerraformPath(schema Schema, path *tftypes.AttributePath) (LookupResult, error)

type NestingMode

type NestingMode uint8
const (
	NestingModeUnknown NestingMode = 0
	NestingModeSingle  NestingMode = 1
	NestingModeList    NestingMode = 2
	NestingModeSet     NestingMode = 3
	NestingModeMap     NestingMode = 4
)

type Resources

type Resources interface {
	All() []TypeName
	Has(TypeName) bool
	Schema(TypeName) Schema
	Diagnostics(TypeName) diag.Diagnostics
	AllDiagnostics() diag.Diagnostics
	Resource(TypeName) resource.Resource
}

Represents all provider's resources pre-indexed by TypeName.

func GatherResources

func GatherResources(ctx context.Context, prov provider.Provider) (Resources, error)

Collects all resources from prov and indexes them by TypeName.

type Schema

type Schema interface {
	tftypes.AttributePathStepper

	Type() attr.Type

	Attrs() map[string]Attr
	Blocks() map[string]Block

	DeprecationMessage() string
	AttributeAtPath(context.Context, path.Path) (Attr, diag.Diagnostics)
}

Attr type works around not being able to link to fwschema.Schema from "github.com/hashicorp/terraform-plugin-framework/internal/fwschema"

func FromDataSourceSchema

func FromDataSourceSchema(x dschema.Schema) Schema

func FromProviderSchema

func FromProviderSchema(x pschema.Schema) Schema

func FromResourceSchema

func FromResourceSchema(x rschema.Schema) Schema

type TypeName

type TypeName string

Full resource type, including the provider type prefix and an underscore. For example, examplecloud_thing.

Jump to

Keyboard shortcuts

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