traverser

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// FieldPathWildcard is the wildcard expression in fieldpath indices.
	FieldPathWildcard = "*"
)

Variables

This section is empty.

Functions

func FieldPath

func FieldPath(parts []string) string

FieldPath joins the given segment strings into a field path eliminating the wildcard index segments.

func FieldPathWithWildcard

func FieldPathWithWildcard(parts []string) string

FieldPathWithWildcard joins the given segment strings into a field path.

func Traverse

func Traverse(tfName string, tfResource *schema.Resource, visitors ...SchemaTraverser) error

Traverse traverses the Terraform schema of the given Terraform resource with the given Terraform resource name and visits each of the specified visitors on the traversed schema's nodes. If any of the visitors in the chain reports an error, it stops the traversal.

Types

type Element

type Element interface {
	Accept(v SchemaTraverser) error
}

Element represents a schema element being visited and should Accept a visitor.

type Node

type Node struct {
	// TFName is the Terraform resource name
	TFName string
	// Schema is the Terraform schema associated with the visited node during a
	// traversal.
	Schema *schema.Schema
	// CRDPath is the canonical CRD field path for the node being visited.
	CRDPath []string
	// TFPath is the canonical Terraform field path for the node being visited.
	TFPath []string
}

Node represents a schema node that's being traversed.

type NoopTraverser

type NoopTraverser struct{}

NoopTraverser is a traverser that doesn't do anything when visiting a node. Meant to make the implementation of visitors easy for the cases they are not interested in a specific node type.

func (NoopTraverser) VisitResource

func (n NoopTraverser) VisitResource(*ResourceNode) error

func (NoopTraverser) VisitSchema

func (n NoopTraverser) VisitSchema(*SchemaNode) error

type ResourceNode

type ResourceNode struct {
	Node
	// ElemResource is the resource schema for the Terraform element
	// of the node being visited.
	ElemResource *schema.Resource
}

ResourceNode represents a Terraform schema.Resource node.

func (*ResourceNode) Accept

func (r *ResourceNode) Accept(v SchemaTraverser) error

type SchemaNode

type SchemaNode struct {
	Node
	// ElemSchema is the schema for the Terraform element of the node being
	// visited.
	ElemSchema *schema.Schema
}

SchemaNode represents a Terraform schema.Schema node.

func (*SchemaNode) Accept

func (s *SchemaNode) Accept(v SchemaTraverser) error

type SchemaTraverser

type SchemaTraverser interface {
	// VisitSchema is called on a Terraform schema.Schema node.
	VisitSchema(s *SchemaNode) error
	// VisitResource is called on a Terraform schema.Resource node.
	VisitResource(r *ResourceNode) error
}

SchemaTraverser represents a visitor on the schema.Schema and schema.Resource nodes of a Terraform resource schema.

Jump to

Keyboard shortcuts

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