Documentation
¶
Index ¶
- func BackupFromContext(ctx context.Context) (bool, bool)
- func ConflictStrategyFromContext(ctx context.Context) (string, bool)
- func DryRunFromContext(ctx context.Context) bool
- func OutputDirectoryFromContext(ctx context.Context) (string, bool)
- func ParametersFromContext(ctx context.Context) (map[string]any, bool)
- func ResolverContextFromContext(ctx context.Context) (map[string]any, bool)
- func ValidateDescriptor(desc *Descriptor) error
- func WithBackup(ctx context.Context, backup bool) context.Context
- func WithConflictStrategy(ctx context.Context, strategy string) context.Context
- func WithDryRun(ctx context.Context, dryRun bool) context.Context
- func WithExecutionMode(ctx context.Context, mode Capability) context.Context
- func WithIOStreams(ctx context.Context, streams *IOStreams) context.Context
- func WithIterationContext(ctx context.Context, iterCtx *IterationContext) context.Context
- func WithOutputDirectory(ctx context.Context, dir string) context.Context
- func WithParameters(ctx context.Context, parameters map[string]any) context.Context
- func WithResolverContext(ctx context.Context, resolverContext map[string]any) context.Context
- func WithSolutionMetadata(ctx context.Context, meta *SolutionMeta) context.Context
- func WithWorkingDirectory(ctx context.Context, dir string) context.Context
- func WorkingDirectoryFromContext(ctx context.Context) (string, bool)
- type Capability
- type Contact
- type Descriptor
- type Example
- type IOStreams
- type IterationContext
- type Link
- type Output
- type Provider
- type SchemaValidator
- type SolutionMeta
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackupFromContext ¶
BackupFromContext retrieves the backup flag from the context. Returns the backup flag and true if found, false and false otherwise.
func ConflictStrategyFromContext ¶
ConflictStrategyFromContext retrieves the conflict strategy from the context. Returns the strategy string and true if found, empty string and false otherwise.
func DryRunFromContext ¶
DryRunFromContext retrieves the dry-run flag from the context. Defaults to false if not set.
func OutputDirectoryFromContext ¶
OutputDirectoryFromContext retrieves the output directory from the context. Returns the directory path and true if found, empty string and false otherwise.
func ParametersFromContext ¶
ParametersFromContext retrieves the CLI parameters map from the context. Returns the parameters map and true if found, nil and false otherwise.
func ResolverContextFromContext ¶
ResolverContextFromContext retrieves the resolver context map from the context.
func ValidateDescriptor ¶
func ValidateDescriptor(desc *Descriptor) error
ValidateDescriptor validates that a Descriptor meets all requirements. Returns an error if:
- OutputSchemas is missing for any declared capability
- Required fields are missing for capabilities that mandate them
- Field types don't match the expected JSON Schema types
func WithBackup ¶
WithBackup returns a new context with the backup flag attached.
func WithConflictStrategy ¶
WithConflictStrategy returns a new context with the conflict strategy attached.
func WithDryRun ¶
WithDryRun returns a new context with the dry-run flag set.
func WithExecutionMode ¶
func WithExecutionMode(ctx context.Context, mode Capability) context.Context
WithExecutionMode returns a new context with the specified execution mode (capability).
func WithIOStreams ¶
WithIOStreams returns a new context with IO streams for provider terminal output.
func WithIterationContext ¶
func WithIterationContext(ctx context.Context, iterCtx *IterationContext) context.Context
WithIterationContext returns a new context with the iteration context.
func WithOutputDirectory ¶
WithOutputDirectory returns a new context with the output directory path attached. When set, providers executing in action mode resolve relative paths against this directory instead of the current working directory.
func WithParameters ¶
WithParameters returns a new context with the CLI parameters map. Parameters are parsed from -r/--resolver flags and stored for retrieval by the parameter provider.
func WithResolverContext ¶
WithResolverContext returns a new context with the resolver context map.
func WithSolutionMetadata ¶
func WithSolutionMetadata(ctx context.Context, meta *SolutionMeta) context.Context
WithSolutionMetadata returns a new context with the solution metadata attached.
func WithWorkingDirectory ¶
WithWorkingDirectory returns a new context with the logical working directory attached. When set, path resolution helpers use this directory instead of the process CWD (os.Getwd). This allows callers—such as the MCP server or a --cwd CLI flag—to control path resolution without mutating global process state.
func WorkingDirectoryFromContext ¶
WorkingDirectoryFromContext retrieves the logical working directory from the context. Returns the directory path and true if found, empty string and false otherwise. When not set, callers should fall back to os.Getwd().
Types ¶
type Capability ¶
type Capability string
Capability represents the types of operations a provider can perform.
const ( CapabilityFrom Capability = "from" CapabilityTransform Capability = "transform" CapabilityValidation Capability = "validation" CapabilityAuthentication Capability = "authentication" CapabilityAction Capability = "action" )
func ExecutionModeFromContext ¶
func ExecutionModeFromContext(ctx context.Context) (Capability, bool)
ExecutionModeFromContext retrieves the execution mode from the context.
func (Capability) IsValid ¶
func (c Capability) IsValid() bool
IsValid checks if the capability is valid.
func (Capability) String ¶
func (c Capability) String() string
String returns the string representation.
type Contact ¶
type Contact struct {
Name string `json:"name,omitempty" yaml:"name,omitempty" doc:"Maintainer name" maxLength:"60" example:"Jane Doe"`
Email string `json:"email,omitempty" yaml:"email,omitempty" doc:"Maintainer email" format:"email" maxLength:"100"`
}
Contact represents maintainer contact information.
type Descriptor ¶
type Descriptor struct {
// Name is the unique identifier for this provider. Must be lowercase with hyphens only.
// Used to reference the provider in configurations and the registry.
Name string `` /* 145-byte string literal not displayed */
// DisplayName is the human-readable name shown in UIs and documentation.
// Optional - defaults to Name if not specified.
DisplayName string `` /* 129-byte string literal not displayed */
// APIVersion indicates the provider API contract version (e.g., "v1").
// Used for compatibility checking and migration support.
APIVersion string `` /* 126-byte string literal not displayed */
// Version is the semantic version of this provider implementation.
// Follows semver conventions for versioning provider releases.
Version *semver.Version `json:"version" yaml:"version" doc:"Semantic version" required:"true"`
// Description provides a concise explanation of what the provider does.
// Displayed in catalogs, help text, and documentation.
Description string `` /* 144-byte string literal not displayed */
// Schema defines the structure and validation rules for provider inputs using JSON Schema.
// Used for input validation, documentation generation, and UI form building.
Schema *jsonschema.Schema `json:"schema" yaml:"schema" doc:"Input schema (JSON Schema)" required:"true"`
// OutputSchemas defines the output structure for each supported capability using JSON Schema.
// Each capability can produce different output shapes. Required for all declared capabilities.
// Certain capabilities have required minimum fields:
// - validation: must include "valid" (boolean) and "errors" (array)
// - authentication: must include "authenticated" (boolean) and "token" (string)
// - action: must include "success" (boolean)
// - from: no required fields
// - transform: no required fields
OutputSchemas map[Capability]*jsonschema.Schema `json:"outputSchemas" yaml:"outputSchemas" doc:"Output schemas per capability (JSON Schema)" required:"true"`
// SensitiveFields lists property names that contain sensitive data and should be redacted
// in logs, errors, and snapshot output. Replaces the old per-property IsSecret flag.
SensitiveFields []string `` /* 126-byte string literal not displayed */
// Decode converts validated map[string]any inputs into strongly-typed structs for internal use.
// Called after schema validation but before Execute(). Optional - providers can work with map[string]any directly.
// When Decode is set, the Executor calls it and passes the result directly to Execute().
Decode func(map[string]any) (any, error) `json:"-" yaml:"-"`
// ExtractDependencies extracts resolver dependencies from the provider's inputs.
// Called during dependency graph building to determine execution order.
// Optional - if nil, the generic extraction logic is used (which handles common patterns like
// CEL expressions with _.resolverName and Go templates with {{.resolverName}}).
// Providers should implement this when they have custom input formats or need special handling
// (e.g., go-template provider with custom delimiters).
// The function receives the raw inputs map and returns a slice of resolver names that are referenced.
ExtractDependencies func(inputs map[string]any) []string `json:"-" yaml:"-"`
// WhatIf generates a human-readable description of what the provider would do
// with the given inputs, without executing. Optional — if nil, falls back to
// a generic message. In solution dry-run, receives the materialized inputs
// map (map[string]any), not the decoded struct that Execute may receive.
WhatIf func(ctx context.Context, input any) (string, error) `json:"-" yaml:"-"`
// Capabilities declares the execution contexts this provider supports.
// Determines where the provider can be used (from, transform, validation, etc.).
Capabilities []Capability `json:"capabilities" yaml:"capabilities" doc:"Supported execution contexts" minItems:"1" maxItems:"10" required:"true"`
// WriteOperations lists operation names that mutate external state.
// When set, the executor rejects these operations in resolver (CapabilityFrom)
// context to prevent unsafe side effects during DAG resolution, where retries
// and parallelism can cause duplicate writes.
//
// Semantics:
// - nil: provider cannot classify operations (no enforcement occurs).
// Use this for providers like exec or http where the command/request
// determines read vs write behavior.
// - empty ([]string{}): all operations are reads (everything allowed in resolvers).
// - populated: listed operations are blocked in resolver context.
WriteOperations []string `json:"writeOperations" yaml:"writeOperations" doc:"Operation names that mutate state" maxItems:"200"`
// Category classifies the provider for organization in catalogs and documentation.
// Examples: "network", "storage", "security", "utility".
Category string `json:"category,omitempty" yaml:"category,omitempty" doc:"Classification category" maxLength:"50" example:"network"`
// Tags are searchable keywords for discovery and filtering.
// Used in catalog searches and provider listings.
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty" doc:"Searchable keywords" maxItems:"20"`
// Icon is a URL to an image representing the provider.
// Displayed in UIs and documentation alongside the provider name.
Icon string `` /* 126-byte string literal not displayed */
// Links provides related resources such as documentation, source code, or tutorials.
Links []Link `json:"links,omitempty" yaml:"links,omitempty" doc:"Related links" maxItems:"10"`
// Examples contains sample configurations demonstrating provider usage.
// Shown in documentation and can be used for testing.
Examples []Example `json:"examples,omitempty" yaml:"examples,omitempty" doc:"Usage examples" maxItems:"10"`
// IsDeprecated indicates the provider should no longer be used.
// Deprecated providers may be removed in future versions.
IsDeprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty" doc:"Deprecation status"`
// Beta indicates the provider is experimental and may have breaking changes.
// Beta providers are not recommended for production use.
Beta bool `json:"beta,omitempty" yaml:"beta,omitempty" doc:"Beta status"`
// Maintainers lists the people or teams responsible for this provider.
// Used for contact and support information.
Maintainers []Contact `json:"maintainers,omitempty" yaml:"maintainers,omitempty" doc:"Maintainer contacts" maxItems:"10"`
}
Descriptor contains provider identity, versioning, schemas, capabilities, and catalog metadata.
func (*Descriptor) DescribeWhatIf ¶
func (d *Descriptor) DescribeWhatIf(ctx context.Context, input any) string
DescribeWhatIf returns a human-readable description of what the provider would do. Calls WhatIf if set, falls back to a generic message.
func (*Descriptor) IsSensitiveField ¶
func (d *Descriptor) IsSensitiveField(name string) bool
IsSensitiveField checks whether a field name is marked as sensitive in the descriptor.
func (*Descriptor) IsWriteOperation ¶ added in v0.2.0
func (d *Descriptor) IsWriteOperation(name string) bool
IsWriteOperation reports whether the named operation is listed in WriteOperations. Returns false when WriteOperations is nil (provider cannot classify operations).
type Example ¶
type Example struct {
Name string `json:"name,omitempty" yaml:"name,omitempty" doc:"Example name" maxLength:"50" example:"Basic usage"`
Description string `` /* 132-byte string literal not displayed */
YAML string `json:"yaml" yaml:"yaml" doc:"YAML example" minLength:"10" maxLength:"2000" required:"true"`
}
Example represents a usage example for a provider.
type IOStreams ¶
type IOStreams struct {
// Out is the writer for standard output (typically os.Stdout).
Out io.Writer `json:"-" yaml:"-" doc:"Writer for standard output"`
// ErrOut is the writer for standard error output (typically os.Stderr).
ErrOut io.Writer `json:"-" yaml:"-" doc:"Writer for standard error output"`
}
IOStreams holds terminal IO writers for providers that support streaming output. Providers can use these to write output directly to the terminal during execution, while still capturing data for inter-action dependencies.
func IOStreamsFromContext ¶
IOStreamsFromContext retrieves the IO streams from the context. Returns the IO streams and true if found, nil and false otherwise. Providers should check this to determine if they can stream output to the terminal.
type IterationContext ¶
type IterationContext struct {
// Item is the current element being iterated over.
Item any `json:"item" yaml:"item" doc:"Current element in the iteration."`
// Index is the current index in the iteration.
Index int `json:"index" yaml:"index" doc:"Current zero-based index in the iteration." maximum:"10000" example:"0"`
// ItemAlias is the custom variable name for the current item (empty if using default __item).
ItemAlias string `` /* 131-byte string literal not displayed */
// IndexAlias is the custom variable name for the current index (empty if using default __index).
IndexAlias string `` /* 129-byte string literal not displayed */
}
IterationContext holds information about the current forEach iteration. This is passed to providers to enable them to access iteration variables as top-level CEL variables.
func IterationContextFromContext ¶
func IterationContextFromContext(ctx context.Context) (*IterationContext, bool)
IterationContextFromContext retrieves the iteration context from the context. Returns the iteration context and true if found, nil and false otherwise.
type Link ¶
type Link struct {
Name string `json:"name,omitempty" yaml:"name,omitempty" doc:"Link name" maxLength:"30" example:"Documentation"`
URL string `json:"url,omitempty" yaml:"url,omitempty" doc:"Link URL" format:"uri" maxLength:"500"`
}
Link represents a named hyperlink.
type Output ¶
type Output struct {
Data any `json:"data" yaml:"data" doc:"Provider output data" required:"true"`
Warnings []string `json:"warnings,omitempty" yaml:"warnings,omitempty" doc:"Non-fatal warning messages" maxItems:"50"`
Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" doc:"Execution metadata"`
// Streamed indicates that the provider already wrote its primary output
// (e.g., stdout/stderr) directly to the terminal via IOStreams from context.
// When true, the CLI output layer should not re-print the streamed content.
Streamed bool `json:"streamed,omitempty" yaml:"streamed,omitempty" doc:"Whether output was already streamed to terminal"`
}
Output is the standardized return structure for all provider executions.
type Provider ¶
type Provider interface {
// Descriptor returns the provider's metadata, schema, and capabilities.
Descriptor() *Descriptor
// Execute runs the provider logic with resolved inputs.
// The input parameter is either:
// - map[string]any if Descriptor().Decode is nil
// - The decoded type if Descriptor().Decode is set and returns a typed struct
// Resolver values can be accessed via ResolverContextFromContext(ctx).
// Execution mode and dry-run flag are available via ExecutionModeFromContext(ctx) and DryRunFromContext(ctx).
Execute(ctx context.Context, input any) (*Output, error)
}
Provider is the core interface that all providers must implement. Providers are stateless execution primitives that perform single, well-defined operations.
type SchemaValidator ¶
type SchemaValidator struct{}
SchemaValidator provides validation for provider inputs and outputs against JSON Schema definitions.
func NewSchemaValidator ¶
func NewSchemaValidator() *SchemaValidator
NewSchemaValidator creates a new schema validator.
func (*SchemaValidator) ValidateInputs ¶
func (sv *SchemaValidator) ValidateInputs(inputs map[string]any, schema *jsonschema.Schema) error
ValidateInputs validates provider inputs against the JSON Schema definition.
func (*SchemaValidator) ValidateOutput ¶
func (sv *SchemaValidator) ValidateOutput(output any, schema *jsonschema.Schema) error
ValidateOutput validates provider output data against the JSON Schema definition.
type SolutionMeta ¶
type SolutionMeta struct {
// Name is the unique identifier for the solution.
Name string `json:"name" yaml:"name" doc:"The unique name of the solution" maxLength:"256" example:"my-solution"`
// Version is the semantic version string of the solution.
Version string `json:"version" yaml:"version" doc:"The version of the solution" maxLength:"64" example:"1.0.0"`
// DisplayName is the human-readable name of the solution.
DisplayName string `` /* 134-byte string literal not displayed */
// Description provides details about the solution's purpose.
Description string `` /* 154-byte string literal not displayed */
// Category classifies the solution.
Category string `` /* 127-byte string literal not displayed */
// Tags are searchable keywords associated with the solution.
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty" doc:"A list of tags for the solution" maxItems:"50"`
}
SolutionMeta holds solution metadata fields made available to providers via context. This is a provider-package type to avoid circular imports with pkg/solution.
func SolutionMetadataFromContext ¶
func SolutionMetadataFromContext(ctx context.Context) (*SolutionMeta, bool)
SolutionMetadataFromContext retrieves the solution metadata from the context. Returns the solution metadata and true if found, nil and false otherwise.
type ValidationError ¶
type ValidationError struct {
Field string
Value any
Constraint string
Message string
Actual string
Expected string
}
ValidationError represents a single field validation error with contextual information.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.
type ValidationErrors ¶
type ValidationErrors []*ValidationError
ValidationErrors is a collection of validation errors.
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string
Error implements the error interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package schemahelper provides ergonomic builder functions for constructing jsonschema.Schema objects used in provider descriptors.
|
Package schemahelper provides ergonomic builder functions for constructing jsonschema.Schema objects used in provider descriptors. |