schema

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NestingModeList = "list"
	NestingModeSet  = "set"
)

Variables

This section is empty.

Functions

func ToTerraformAttribute added in v0.1.3

func ToTerraformAttribute[A any](a Attribute, types *AttributeTypes[A]) (*A, error)

ToTerraformAttribute converts our representation of an Attribute into a Terraform SDK attribute so it can be passed back to Terraform Core in a resource or data source schema.

func ToTerraformBlock added in v0.1.3

func ToTerraformBlock[B, A any](b Block, toListBlock ToListBlock[B, A], toSetBlock ToSetBlock[B, A], attributeTypes *AttributeTypes[A]) (*B, error)

ToTerraformBlock converts our representation of a Block into a Terraform SDK block so it can be passed back to Terraform Core in a resource or data source schema.

Types

type Attribute

type Attribute struct {
	Description         string `json:"-"` // Dynamic resources don't need descriptions so hide them from the exposed JSON schema.
	MarkdownDescription string `json:"-"` // Dynamic resources don't need descriptions so hide them from the exposed JSON schema.

	Type     Type `json:"type"`
	Optional bool `json:"optional"`
	Required bool `json:"required"`
	Computed bool `json:"computed"`

	Value *data.Value `json:"value,omitempty"`

	List   *Attribute           `json:"list,omitempty"`
	Map    *Attribute           `json:"map,omitempty"`
	Object map[string]Attribute `json:"object,omitempty"`
	Set    *Attribute           `json:"set,omitempty"`

	Sensitive bool `json:"sensitive"` // True if values for this attribute should be hidden in the plan.
	Replace   bool `json:"replace"`   // True if the resource should be replaced when this attribute changes.

	// SkipNestedMetadata instructs the dynamic resource to not use the nested
	// attribute field when building element and attribute types of complex
	// attributes (list, map, object, and set).
	SkipNestedMetadata bool `json:"skip_nested_metadata"`
}

Attribute defines an internal representation of a Terraform attribute in a schema.

It is designed to be read dynamically from a JSON object, allowing schemas, blocks and attributes to be defined dynamically by the user of the provider.

For data sources, the values provided in the optional, required and computed field are ignored. All data source attributes are computed, with optional and required being set to false regardless of the actual values for those fields. The generated ID attribute is unique and marked as required and not computed as it is used to identify the data source and retrieve it during the Terraform operations.

type AttributeTypes added in v0.1.3

type AttributeTypes[A any] struct {
	// contains filtered or unexported fields
}

AttributeTypes contains functions that map provider attributes into Terraform resource or datasource attributes.

type Block

type Block struct {
	Description         string `json:"-"` // Dynamic resources don't need descriptions so hide them from the exposed JSON schema.
	MarkdownDescription string `json:"-"` // Dynamic resources don't need descriptions so hide them from the exposed JSON schema.

	Attributes map[string]Attribute `json:"attributes"`
	Blocks     map[string]Block     `json:"blocks"`
	Mode       string               `json:"mode"`
}

Block defines an internal representation of a Terraform block in a schema.

It is designed to be read dynamically from a JSON object, allowing schemas, blocks and attributes to be defined dynamically by the user of the provider.

type Schema

type Schema struct {
	Description         string               `json:"-"` // Dynamic resources don't need descriptions so hide them from the exposed JSON schema.
	MarkdownDescription string               `json:"-"` // Dynamic resources don't need descriptions so hide them from the exposed JSON schema.
	Attributes          map[string]Attribute `json:"attributes"`
	Blocks              map[string]Block     `json:"blocks"`
}

Schema defines an internal representation of a Terraform schema.

It is designed to be read dynamically from a JSON object, allowing schemas, blocks and attributes to be defined dynamically by the user of the provider.

func (Schema) AllAttributes

func (schema Schema) AllAttributes() map[string]Attribute

AllAttributes returns the attributes for the dynamic schema, plus the required ID attribute that is attached to tfsdk.Schema objects automatically.

func (Schema) ToTerraformDataSourceSchema

func (schema Schema) ToTerraformDataSourceSchema() (datasource_schema.Schema, error)

ToTerraformDataSourceSchema converts our representation of a Schema into a Terraform SDK tfsdk.Schema. It automatically creates and attaches a required attribute called `id` that is required by every resource and data source in this provider.

func (Schema) ToTerraformResourceSchema

func (schema Schema) ToTerraformResourceSchema() (resource_schema.Schema, error)

ToTerraformResourceSchema converts out representation of a Schema into a Terraform SDK tfsdk.Schema. It automatically creates and attaches a computed type called `id` that is required by every resource and data source in this provider.

type ToListBlock added in v0.1.3

type ToListBlock[B any, A any] func(block Block, blocks map[string]B, attributes map[string]A) *B

type ToSetBlock added in v0.1.3

type ToSetBlock[B any, A any] func(block Block, blocks map[string]B, attributes map[string]A) *B

type Type

type Type string
const (
	Boolean Type = "boolean"
	Float   Type = "float"
	Integer Type = "integer"
	Number  Type = "number"
	String  Type = "string"

	List   Type = "list"
	Map    Type = "map"
	Object Type = "object"
	Set    Type = "set"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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