json

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	// Name is a name of attribute.
	// Note that this key does not exist in the original data structure.
	// In order to reduce the possibility of future conflicts,
	// naming borrowed from the schema definition of the grpc provider's proto file.
	// https://github.com/hashicorp/terraform/pull/18550
	Name string `json:"name"`

	// Type is a type of the attribute's value.
	// Note that Type is not cty.Type to customize string representation.
	Type tfschema.Type `json:"type"`
	// Required is a flag whether this attribute is required.
	Required bool `json:"required"`
	// Optional is a flag whether this attribute is optional.
	// This field conflicts with Required.
	Optional bool `json:"optional"`
	// Computed is a flag whether this attribute is computed.
	// If true, the value may come from provider rather than configuration.
	// If combined with Optional, then the config may optionally provide an
	// overridden value.
	Computed bool `json:"computed"`
	// Sensitive is a flag whether this attribute may contain sensitive information.
	Sensitive bool `json:"sensitive"`
}

Attribute is wrapper for tfschema.Attribute.

func NewAttribute

func NewAttribute(a *tfschema.Attribute, name string) *Attribute

NewAttribute creates a new Attribute instance.

func NewAttributes

func NewAttributes(as map[string]*tfschema.Attribute) []*Attribute

NewAttributes creates a new slice of Attributes.

type Block

type Block struct {
	// Attributes is a slice of any attributes.
	Attributes []*Attribute `json:"attributes"`
	// BlockTypes is a slice of any nested block types.
	BlockTypes []*NestedBlock `json:"block_types"`
}

Block is wrapper for tfschema.Block. This is a layer for customization for JSON format. Although the original data structure is a map, it is hard to parse because the names of the key are not predictable. We use a slice here to format easy-to-parse JSON.

func NewBlock

func NewBlock(b *tfschema.Block) *Block

NewBlock creates a new Block instance.

func (*Block) Format

func (b *Block) Format() (string, error)

Format returns a formatted string in JSON format.

type NestedBlock

type NestedBlock struct {
	// TypeName is a name of block type.
	// Note that this key does not exist in the original data structure.
	// In order to reduce the possibility of future conflicts,
	// naming borrowed from the schema definition of the grpc provider's proto file.
	// https://github.com/hashicorp/terraform/pull/18550
	TypeName string `json:"type_name"`

	// Block is a nested child block.
	Block
	// Nesting is a nesting mode.
	Nesting configschema.NestingMode `json:"nesting"`
	// MinItems is a lower limit on number of nested child blocks.
	MinItems int `json:"min_items"`
	// MaxItems is a upper limit on number of nested child blocks.
	MaxItems int `json:"max_items"`
}

NestedBlock is wrapper for tfschema.NestedBlock

func NewBlockTypes

func NewBlockTypes(bs map[string]*tfschema.NestedBlock) []*NestedBlock

NewBlockTypes creates a new slice of NestedBlocks.

func NewNestedBlock

func NewNestedBlock(b *tfschema.NestedBlock, typeName string) *NestedBlock

NewNestedBlock creates a new NestedBlock instance.

Jump to

Keyboard shortcuts

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