Documentation
¶
Index ¶
Constants ¶
const ( // SchemaVarName is the variable name for accessing instance spec in CEL. SchemaVarName = "schema" // InstanceNodeID is the ID of the instance node (same as SchemaVarName since // that's how it's accessed in CEL expressions). InstanceNodeID = SchemaVarName // EachVarName is the variable name for collection item iteration in CEL. EachVarName = "each" )
Well-known node/variable identifiers used in CEL expressions.
const ( // MetadataNamePath is the path to the resource name field. MetadataNamePath = "metadata.name" // MetadataNamespacePath is the path to the resource namespace field. MetadataNamespacePath = "metadata.namespace" )
often used field paths in resource templates.
Variables ¶
var (
// ErrNamingConvention is the base error message for naming convention violations
ErrNamingConvention = "naming convention violation"
)
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is an object that is responsible for constructing and managing resourceGraphDefinitions. It is responsible for transforming the resourceGraphDefinition CRD into a runtime representation that can be used to create the resources in the cluster.
The GraphBuild performs several key functions:
- It validates the resource definitions and their naming conventions.
- It resolves the OpenAPI schema for resources and validates against schema.
- Extracts and processes the CEL expressions from the resources definitions.
- Builds the dependency graph between the resources, by inspecting the CEL expressions.
If any of the above steps fail, the Builder will return an error.
The resulting Graph object is a fully processed and validated representation of a resource graph definition, it's underlying resources, and the relationships between the resources. This object can be used to instantiate a "runtime" data structure that can be used to create the resources in the cluster.
func NewBuilder ¶
func NewBuilder(schemaResolver resolver.SchemaResolver) *Builder
NewBuilder creates a new GraphBuilder instance from a SchemaResolver.
This is the constructor for use with Crossplane functions. The resolver provides schema resolution for GVKs.
func (*Builder) NewResourceGraphDefinition ¶
func (b *Builder) NewResourceGraphDefinition(rg *v1beta1.ResourceGraph, xrSchema *spec.Schema) (*Graph, error)
NewResourceGraphDefinition creates a new Graph from a ResourceGraph input and XR schema. This is the entry point for Crossplane functions that receive schemas via required_schemas.
The xrSchema parameter should be the OpenAPI schema for the composite resource (XR), typically obtained from Crossplane's required_schemas response.
type ForEachDimension ¶
type ForEachDimension struct {
// Name is the iterator variable name (e.g., "region")
Name string
// Expression is the CEL expression that returns a list (e.g., "schema.spec.regions")
Expression string
}
ForEachDimension represents a parsed forEach dimension from an RGD resource.
type Graph ¶
type Graph struct {
// DAG is the directed acyclic graph of node dependencies.
DAG *dag.DirectedAcyclicGraph[string]
// Instance is the instance node (the generated CRD instance).
Instance *Node
// Nodes maps node ID to immutable node spec.
Nodes map[string]*Node
// Resources is an alias for Nodes kept for backward compatibility in tests and tooling.
Resources map[string]*Node
// TopologicalOrder is the sorted order of node IDs for processing.
// This excludes the instance node.
TopologicalOrder []string
// CRD is the generated CustomResourceDefinition for the instance.
CRD *extv1.CustomResourceDefinition
}
Graph represents a processed ResourceGraphDefinition. It contains the DAG and immutable node specs produced by the builder.
type Node ¶
type Node struct {
// Meta contains identification metadata (ID, Type, GVR, etc.)
Meta NodeMeta
// Template is the resource template with CEL expressions.
// This is the original object from the RGD with expressions intact.
Template *unstructured.Unstructured
// Variables holds the CEL expression fields found in the template.
Variables []*variable.ResourceField
// IncludeWhen are CEL expressions that must all evaluate to true
// for this resource to be included. Empty means always include.
IncludeWhen []string
// ReadyWhen are CEL expressions that must all evaluate to true
// for this resource to be considered ready.
ReadyWhen []string
// ForEach holds the forEach dimensions for collection resources.
// nil or empty means this is not a collection.
ForEach []ForEachDimension
}
Node is the immutable node spec produced by the builder. It contains the template, variables, and conditions for a resource. No CRD/schema references are kept here - schemas are only used during build for CEL type-checking.
type NodeMeta ¶
type NodeMeta struct {
// ID is the unique identifier of the node within the graph.
ID string
// Index is the position of this node in the original RGD resource list.
// Used to preserve user-defined ordering when building the dependency graph.
Index int
// Type identifies the kind of node (Resource, Collection, External, Instance).
Type NodeType
// Dependencies lists the IDs of nodes this node depends on.
Dependencies []string
}
NodeMeta contains immutable metadata about a node. This is grouped separately for clarity and to distinguish identification data from behavioral data.
type NodeType ¶
type NodeType int
NodeType identifies the kind of node in the resource graph. This is set by the builder based on the resource definition.
const ( // NodeTypeResource is a regular managed resource. NodeTypeResource NodeType = iota // NodeTypeCollection is a forEach collection that expands into multiple resources. NodeTypeCollection // NodeTypeExternal is an external reference (read-only, not applied). NodeTypeExternal // NodeTypeInstance is the instance node (ID: "instance"). NodeTypeInstance )