schema

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindResource     = "resource"
	KindDataSource   = "data_source"
	KindEphemeral    = "ephemeral"
	KindListResource = "list_resource"
	KindAction       = "action"
	KindFunction     = "function"
	KindNone         = "none" // content-only categories (guides, index)
)

Schema-kind identifiers used to select the right target map on ProviderSchema. They match the schema_kind values declared in internal/config/defaults.hcl.

Variables

BlockKinds are the schema kinds whose targets carry a SchemaBlock and can therefore be represented as *ResourceSchema. KindFunction is intentionally excluded — functions have signatures, not blocks.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name       string
	Required   bool
	Optional   bool
	Computed   bool
	Deprecated bool
	Sensitive  bool
	Children   []Attribute // nested object attributes (from cty type or nested_type)
}

Attribute represents a single schema attribute with its properties.

type Block

type Block struct {
	Path        string
	Attributes  []Attribute
	ChildBlocks []string // names of immediate child blocks
}

Block represents a flattened schema block with its attributes and child block names.

type FunctionSchema

type FunctionSchema struct {
	Name              string
	Description       string
	ParameterNames    []string
	VariadicParameter string // empty when none
}

FunctionSchema holds the minimal representation of a provider function. Full signature data (return type, variadic parameters) is captured on demand; we record only what rules consume today — the function's positional parameter names and descriptions. Expand when a function-aware rule needs more.

type IdentityAttribute

type IdentityAttribute struct {
	Name     string
	Type     string
	Required bool // required_for_import
}

IdentityAttribute describes a single attribute in a resource identity schema.

type IdentitySchema

type IdentitySchema struct {
	Attributes []IdentityAttribute
}

IdentitySchema holds the identity attributes for a resource that supports import-by-identity (Terraform v1.12+).

type ProviderSchema

type ProviderSchema struct {
	Resources       map[string]*ResourceSchema
	DataSources     map[string]*ResourceSchema
	Ephemerals      map[string]*ResourceSchema
	ListResources   map[string]*ResourceSchema
	Actions         map[string]*ResourceSchema
	Functions       map[string]*FunctionSchema
	IdentitySchemas map[string]*IdentitySchema
}

ProviderSchema holds every target the provider exposes, grouped by schema kind. Kinds with no entries in the provider have empty (but non-nil) maps so callers can iterate safely.

func LoadFile

func LoadFile(path string, providerSource string) (*ProviderSchema, error)

LoadFile reads a `terraform providers schema -json` file and returns the parsed schemas for every target category Terraform currently exposes.

func (*ProviderSchema) Function

func (ps *ProviderSchema) Function(name string) *FunctionSchema

Function returns the function with the given name, or nil when absent.

func (*ProviderSchema) ResourceSchemaFor

func (ps *ProviderSchema) ResourceSchemaFor(kind, name string) *ResourceSchema

ResourceSchemaFor returns the flattened block schema for a named target of a block-kind category, or nil when: the kind is unknown, the kind is KindFunction or KindNone (no block schema to return), or the target name does not exist in that kind.

func (*ProviderSchema) TargetNames

func (ps *ProviderSchema) TargetNames(kind string) []string

TargetNames returns the sorted set of target names for the given schema kind. Unknown kinds (including KindNone) yield an empty slice. Output is sorted so test assertions and log output are stable.

type ResourceSchema

type ResourceSchema struct {
	Name   string
	Blocks map[string]*Block // keyed by dot-path (e.g., "", "rule", "rule.action")
}

ResourceSchema holds the flattened block map for a single block-based target (resource, data source, ephemeral, list resource, or action).

Jump to

Keyboard shortcuts

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