convert

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: 8 Imported by: 0

Documentation

Overview

Converts between Pulumi and Terraform value representations. Conversions are type-driven and require to know Terraform types since Terraform values must be tagged with their corresponding types. Pulumi type metadata is also required to make finer grained distinctions such as int vs float, and to correctly handle object properties that have Pulumi names that differ from their Terraform names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePropertyMap

func DecodePropertyMap(dec Decoder, v tftypes.Value) (resource.PropertyMap, error)

func DecodePropertyMapFromDynamic

func DecodePropertyMapFromDynamic(dec Decoder, objectType tftypes.Object,
	dv *tfprotov6.DynamicValue) (resource.PropertyMap, error)

func EncodePropertyMap

func EncodePropertyMap(enc Encoder, pmap resource.PropertyMap) (tftypes.Value, error)

func EncodePropertyMapToDynamic

func EncodePropertyMapToDynamic(enc Encoder, objectType tftypes.Object,
	pmap resource.PropertyMap) (*tfprotov6.DynamicValue, error)

Types

type Decoder

type Decoder interface {
	ToPropertyValue(tftypes.Value) (resource.PropertyValue, error)
}

type Encoder

type Encoder interface {
	FromPropertyValue(resource.PropertyValue) (tftypes.Value, error)
}

type Encoding

type Encoding interface {
	NewConfigEncoder(tftypes.Object) (Encoder, error)
	NewResourceDecoder(tokens.Type, tftypes.Object) (Decoder, error)
	NewResourceEncoder(tokens.Type, tftypes.Object) (Encoder, error)
	NewDataSourceDecoder(tokens.ModuleMember, tftypes.Object) (Decoder, error)
	NewDataSourceEncoder(tokens.ModuleMember, tftypes.Object) (Encoder, error)
}

func NewEncoding

func NewEncoding(spec PackageSpec, propertyNames PropertyNames) Encoding

type LocalPropertyNames

type LocalPropertyNames interface {
	PropertyKey(property TerraformPropertyName, t tftypes.Type) resource.PropertyKey
}

Like PropertyNames but specialized to either a type by token or config property.

func NewConfigPropertyNames

func NewConfigPropertyNames(pn PropertyNames) LocalPropertyNames

func NewTypeLocalPropertyNames

func NewTypeLocalPropertyNames(pn PropertyNames, tok tokens.Token) LocalPropertyNames

type PackageSpec

type PackageSpec interface {
	Config() *pschema.ConfigSpec
	Function(tok tokens.ModuleMember) *pschema.FunctionSpec
	Resource(tok tokens.Type) *pschema.ResourceSpec
	Type(tok tokens.Type) *pschema.ComplexTypeSpec
}

Subset of pschema.PackageSpec required for conversion.

type PropertyNames

type PropertyNames interface {
	// Translates a Terraform property name for a given type to a Pulumi PropertyKey.
	//
	// typeToken identifies the resource, data source, or named object type.
	PropertyKey(typeToken tokens.Token, property TerraformPropertyName, t tftypes.Type) resource.PropertyKey

	// Same as PropertyKey but for provider-level configuration properties.
	ConfigPropertyKey(property TerraformPropertyName, t tftypes.Type) resource.PropertyKey
}

type TerraformPropertyName

type TerraformPropertyName = string

An alias to assist marking Terraform-level property names (see for example AttributeTypes in tftypes.Object). Pulumi may rename properties and it is important to keep track of which name is being used during conversion.

Jump to

Keyboard shortcuts

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