Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpressionInspection ¶
type ExpressionInspection struct {
// ResourceDependencies lists all known resources and their access paths
// used in the expression
ResourceDependencies []ResourceDependency
// FunctionCalls lists all known function calls and their arguments found
// in the expression
FunctionCalls []FunctionCall
// UnknownResources lists any resource references that weren't declared
UnknownResources []UnknownResource
// UnknownFunctions lists any function calls that weren't declared, either
// by kro engine, standard libraries or CEL built-in functions.
UnknownFunctions []UnknownFunction
}
ExpressionInspection contains all the findings from analyzing a CEL expression. It tracks all resources accessed, functions called, and any unknown references.
type FunctionCall ¶
type FunctionCall struct {
// Name is the function identifier
// For example: "hash" "toLower"
Name string
// Arguments contains the string representation of each argument passed to the function
// For example: ["deployment.name", "'frontend'"] for a call like concat(deployment.name, "frontend")
Arguments []string
}
FunctionCall represents an invocation of a declared function within a CEL expression. This tracks both the function name and its arguments as they appear in the expression
The arguments are string representations of the AST nodes. We mainly ignore them for now, but they could be used to further analyze the expression.
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector analyzes CEL expressions to discover resource and function dependencies. It maintains the CEL environment and tracks which resources and functions are known.
func NewInspectorWithEnv ¶
NewInspectorWithEnv creates a new Inspector with the given CEL environment and resource names.
func (*Inspector) Inspect ¶
func (a *Inspector) Inspect(expression string) (ExpressionInspection, error)
Inspect analyzes the given CEL expression and returns an ExpressionInspection.
This function can be called multiple times with different expressions using the same Inspector instance (AND environment).
type ResourceDependency ¶
type ResourceDependency struct {
// ID is the root resource identifier (e.g "deployment", "service", "pod")
ID string
// Path is the full access path including nested fields
// For example: "deployment.spec.replicas" or "service.metadata.name"
Path string
}
ResourceDependency represents a resource and its accessed path within a CEL expression. For example, in the expression "deployment.spec.replicas > 0", ID would be "deployment" and Path would be "deployment.spec.replicas"
type UnknownFunction ¶
type UnknownFunction struct {
// Name is the undeclared function identifier that was called
Name string
}
UnknownFunction represents a function call in the expression that wasn't declared in the known functions list and isn't a CEL built in function.
type UnknownResource ¶
type UnknownResource struct {
// ID is the undeclared resource identifier that was referenced
ID string
// Path is the full access path that was attempted with this unknown resource
// For example: "unknown_resource.field.subfield"
Path string
}
UnknownResource represents a resource reference in the expression that wasn't declared in the known resources list. This helps identify potentially missing or misspelled resource ids.