{"modulePath":"github.com/windsorcli/cli","version":"v0.10.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package evaluator\n\n## Functions\n\n```go\nfunc ContainsExpression(value any) bool\n```\nContainsExpression determines whether the provided value is a string that contains an unresolved expression. An expression is identified by the pattern \"${...}\" anywhere in the string. This function returns true if the value is a string containing at least one properly closed \"${...}\" expression pattern, and false otherwise. Used to identify values containing unresolved expressions that should be skipped when evaluateDeferred is false.\n\n```go\nfunc DeferredExpression(value any) (string, bool)\n```\nDeferredExpression returns the preserved raw expression string when value is DeferredValue.\n\n```go\nfunc ExpressionBody(value string) (string, bool)\n```\nExpressionBody returns the inner expression for ${ ... } inputs. Double-brace ${{ ... }} inputs are not matched; callers should normalize those first. When value is not wrapped as a full expression, returns the original trimmed string and false.\n\n```go\nfunc IsDeferredValue(value any) bool\n```\nIsDeferredValue reports whether value is a DeferredValue (value or pointer form).\n\n## Types\n\n```go\ntype DefaultExpressionEvaluator struct {\n\tShims *Shims\n\t// contains filtered or unexported fields\n}\n```\nDefaultExpressionEvaluator is the concrete implementation of ExpressionEvaluator.\n\n```go\nfunc (e *DefaultExpressionEvaluator) Evaluate(s string, facetPath string, scope map[string]any, evaluateDeferred bool) (any, error)\n```\nEvaluate resolves the Windsor expressions in s, both whole and interpolated ${...} expressions. It loads files as necessary. It defers unresolved expressions when evaluateDeferred is false. facetPath is the base for relative paths. When scope is nil, the environment is the enriched config. Otherwise it is scope plus the runtime keys. It returns the evaluated value, or an error when evaluation fails or the input is malformed.\n\n```go\nfunc (e *DefaultExpressionEvaluator) EvaluateMap(values map[string]any, facetPath string, scope map[string]any, evaluateDeferred bool) (map[string]any, error)\n```\nEvaluateMap evaluates a map of values using this expression evaluator. Each string value is evaluated as an expression; maps and arrays are recursively evaluated. When evaluateDeferred is false and evaluation fails with a DeferredError, the original value is preserved in the result. Environment is determined by scope the same way as Evaluate (nil = enriched config, non-nil = that scope with runtime keys). Returns a new map containing evaluated values, or an error if evaluation fails with a non-deferred error.\n\n```go\nfunc (e *DefaultExpressionEvaluator) Register(name string, helper func(params []any, deferred bool) (any, error), signatures ...any)\n```\nRegister adds a custom helper function to the evaluator for expression evaluation. The provided helper function receives the deferred flag as a closure variable. The name parameter specifies the function name used in expressions, helper is the custom function, and signatures define the helper's input/output signatures. Pass one signature per accepted argument count. This allows providers and consumers to extend evaluator capabilities with domain-specific helpers.\n\n```go\nfunc (e *DefaultExpressionEvaluator) SetConfigScope(scope map[string]any)\n```\nSetConfigScope publishes the composed scope (facet config blocks merged over context config) that a nil-scope evaluation should use as its base. The composer calls this after composition so apply-time consumers — secret resolution in particular — dereference computed config values the same way substitutions do. Passing nil clears it, reverting nil-scope evaluations to context config alone.\n\n```go\nfunc (e *DefaultExpressionEvaluator) SetEnvLookup(lookup func(name string) (string, bool))\n```\nSetEnvLookup replaces the source that env() expressions resolve against. The test runner uses this to supply a hermetic environment so composition never reads the host env.\n\n```go\nfunc (e *DefaultExpressionEvaluator) SetTemplateData(templateData map[string][]byte)\n```\nSetTemplateData sets the template data map for in-memory file resolution. This is used when loading blueprints from OCI artifacts where template files are stored in memory rather than on disk. The map keys should use paths relative to the template root, typically prefixed with \"\\_template/\".\n\n```go\ntype DeferredError = secretsRuntime.DeferredError\n```\nDeferredError signals that an expression is deferred and should be preserved for later evaluation. This is not an error condition but a signal that the expression cannot be evaluated at this time.\n\n```go\ntype DeferredValue struct {\n\tExpression string\n}\n```\nDeferredValue represents a value that could not be fully resolved because one or more deferred helpers (for example terraform\\_output) were unavailable at evaluation time. Expression stores the raw expression text preserved for later resolution.\n\n```go\ntype ExpressionEvaluator interface {\n\tHelperRegistrar\n\tSetTemplateData(templateData map[string][]byte)\n\tSetEnvLookup(lookup func(name string) (string, bool))\n\tSetConfigScope(scope map[string]any)\n\tEvaluate(expression string, facetPath string, scope map[string]any, evaluateDeferred bool) (any, error)\n\tEvaluateMap(values map[string]any, facetPath string, scope map[string]any, evaluateDeferred bool) (map[string]any, error)\n}\n```\nExpressionEvaluator provides unified expression evaluation for the Runtime system. It uses the config handler for accessing configuration values and supports dynamic value resolution through the provider system. The evaluator handles expression compilation, evaluation, and string interpolation with support for file loading functions.\n\n```go\nfunc NewExpressionEvaluator(configHandler config.ConfigHandler, projectRoot, templateRoot string) ExpressionEvaluator\n```\nNewExpressionEvaluator creates a new expression evaluator with the provided dependencies. The configHandler is used for accessing configuration values and provider resolution. The projectRoot and templateRoot paths are used for resolving relative file paths in expressions. Returns a fully initialized evaluator ready for use.\n\n```go\ntype HelperRegistrar interface {\n\tRegister(name string, helper func(params []any, deferred bool) (any, error), signatures ...any)\n}\n```\nHelperRegistrar defines the interface for registering custom helpers with the evaluator. This allows providers to extend expression evaluation capabilities without the evaluator needing to know about provider-specific functionality.\n\n```go\ntype MockExpressionEvaluator struct {\n\tSetTemplateDataFunc func(templateData map[string][]byte)\n\tSetEnvLookupFunc    func(lookup func(name string) (string, bool))\n\tSetConfigScopeFunc  func(scope map[string]any)\n\tRegisterFunc        func(name string, helper func(params []any, deferred bool) (any, error), signatures ...any)\n\tEvaluateFunc        func(expression string, facetPath string, scope map[string]any, evaluateDeferred bool) (any, error)\n\tEvaluateMapFunc     func(values map[string]any, facetPath string, scope map[string]any, evaluateDeferred bool) (map[string]any, error)\n}\n```\nMockExpressionEvaluator is a mock implementation of the ExpressionEvaluator interface for testing purposes. It provides a way to simulate expression evaluation without executing actual evaluation logic. It allows for controlled testing of evaluator-dependent functionality by providing mock implementations of all ExpressionEvaluator interface methods.\n\n```go\nfunc NewMockExpressionEvaluator() *MockExpressionEvaluator\n```\nNewMockExpressionEvaluator creates a new instance of MockExpressionEvaluator.\n\n```go\nfunc (m *MockExpressionEvaluator) Evaluate(expression string, facetPath string, scope map[string]any, evaluateDeferred bool) (any, error)\n```\nEvaluate calls the mock EvaluateFunc if set, otherwise returns nil, nil.\n\n```go\nfunc (m *MockExpressionEvaluator) EvaluateMap(values map[string]any, facetPath string, scope map[string]any, evaluateDeferred bool) (map[string]any, error)\n```\nEvaluateMap calls the mock EvaluateMapFunc if set, otherwise returns an empty map and nil error.\n\n```go\nfunc (m *MockExpressionEvaluator) Register(name string, helper func(params []any, deferred bool) (any, error), signatures ...any)\n```\nRegister calls the mock RegisterFunc if set, otherwise does nothing.\n\n```go\nfunc (m *MockExpressionEvaluator) SetConfigScope(scope map[string]any)\n```\nSetConfigScope calls the mock SetConfigScopeFunc if set, otherwise does nothing.\n\n```go\nfunc (m *MockExpressionEvaluator) SetEnvLookup(lookup func(name string) (string, bool))\n```\nSetEnvLookup calls the mock SetEnvLookupFunc if set, otherwise does nothing.\n\n```go\nfunc (m *MockExpressionEvaluator) SetTemplateData(templateData map[string][]byte)\n```\nSetTemplateData calls the mock SetTemplateDataFunc if set, otherwise does nothing.\n\n```go\ntype Shims struct {\n\tshims.Shims\n}\n```\nShims holds the shared system call primitives.\n\n```go\nfunc NewShims() *Shims\n```\nNewShims returns a Shims with every field set to its real implementation.\n\n","path":"github.com/windsorcli/cli/pkg/runtime/evaluator","name":"evaluator","synopsis":"","isRedistributable":true}
