pfutils

package
v0.44.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GatherDatasources

func GatherDatasources[F func(Schema) shim.SchemaMap](
	ctx context.Context, prov provider.Provider, f F,
) (runtypes.DataSources, error)

func GatherResources

func GatherResources[F func(Schema) shim.SchemaMap](
	ctx context.Context, prov provider.Provider, f F,
) (runtypes.Resources, error)

Collects all resources from prov and indexes them by TypeName.

func NewRawState added in v0.2.0

func NewRawState(t tftypes.Type, v tftypes.Value) (*tfprotov6.RawState, error)

func ProposedNew

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

Computes the ProposedNewState from priorState and config.

func ValueToJSON added in v0.2.0

func ValueToJSON(typ tftypes.Type, v tftypes.Value) ([]byte, error)

Inverse of tftypes.ValueFromJson.

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 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 tftypes.AttributePathStepper) Eq

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

type LookupResult

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

Classifies the results of LookupTerraformPath. The only valid cases are:

1. IsAttr=true, and Attr is set; this means an Attribute was found 2. IsBlock=true, and Block is set; this means a Block was found 3. IsNestedObject=true; this means the path is a nested object one level down from Attr or Block 4. IsMisc=true; this groups all other cases, such as resolving to a simple atomic type as String

All other combinations should not be valid.

func LookupTerraformPath

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

Drills down a Schema with a given AttributePath to classify what is found at that path, see LookupResult.

type NestingMode

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

type Schema

type Schema interface {
	SchemaType

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

	DeprecationMessage() string
	ResourceProtoSchema(ctx context.Context) (*tfprotov6.Schema, error)
}

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 SchemaType added in v0.38.0

type SchemaType interface {
	tftypes.AttributePathStepper

	Type(context.Context) tftypes.Type

	// Resource schemas are versioned for [State Upgrade].
	//
	// [State Upgrade]: https://developer.hashicorp.com/terraform/plugin/framework/resources/state-upgrade
	ResourceSchemaVersion() int64
}

Jump to

Keyboard shortcuts

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