provider

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretMask is the string used to redact secret values in logs and errors
	SecretMask = "***REDACTED***"
)

Variables

View Source
var GlobalMetrics = &Metrics{enabled: false}

GlobalMetrics is the default metrics collector. Metrics collection is disabled by default; call Enable() to turn it on.

Functions

func AbsFromContext added in v0.6.0

func AbsFromContext(ctx context.Context, path string) (string, error)

AbsFromContext resolves a relative path to an absolute path using the context working directory. If no working directory is set in the context, it falls back to filepath.Abs (which uses os.Getwd()).

Note: this function does NOT perform path containment/traversal validation. If the caller needs to restrict resolved paths within a specific directory, use ResolvePath (which validates containment for output directories) or perform additional checks after calling this function.

func BackupFromContext added in v0.6.0

func BackupFromContext(ctx context.Context) (bool, bool)

BackupFromContext retrieves the backup flag from the context. Returns the backup flag and true if found, false and false otherwise.

func ConflictStrategyFromContext added in v0.6.0

func ConflictStrategyFromContext(ctx context.Context) (string, bool)

ConflictStrategyFromContext retrieves the conflict strategy from the context. Returns the strategy string and true if found, empty string and false otherwise.

func Count

func Count() int

Count returns the number of providers in the global registry.

func DryRunFromContext

func DryRunFromContext(ctx context.Context) bool

DryRunFromContext retrieves the dry-run flag from the context. Defaults to false if not set.

func GetWorkingDirectory added in v0.6.0

func GetWorkingDirectory(ctx context.Context) (string, error)

GetWorkingDirectory returns the effective working directory from the context. It checks the context for a logical working directory first (set via WithWorkingDirectory), then falls back to the process CWD via os.Getwd().

func Has

func Has(name string) bool

Has checks if a provider is registered in the global registry.

func List

func List() []string

List returns all provider names from the global registry.

func MaskValue

func MaskValue(value any, isSecret bool) string

MaskValue redacts a value if it should be kept secret. This is useful for logging and error messages.

func OutputDirectoryFromContext added in v0.6.0

func OutputDirectoryFromContext(ctx context.Context) (string, bool)

OutputDirectoryFromContext retrieves the output directory from the context. Returns the directory path and true if found, empty string and false otherwise.

func ParametersFromContext

func ParametersFromContext(ctx context.Context) (map[string]any, bool)

ParametersFromContext retrieves the CLI parameters map from the context. Returns the parameters map and true if found, nil and false otherwise.

func Register

func Register(p Provider) error

Register registers a provider in the global registry.

func ResetGlobalExecutor

func ResetGlobalExecutor()

ResetGlobalExecutor resets the global executor to a new instance. This is primarily for testing purposes.

func ResetGlobalRegistry

func ResetGlobalRegistry()

ResetGlobalRegistry clears the global registry. This is primarily for testing purposes.

func ResolvePath added in v0.6.0

func ResolvePath(ctx context.Context, path string) (string, error)

ResolvePath resolves a filesystem path based on the current execution context.

When all of the following are true, the path is resolved against the output directory:

  • The path is relative
  • The execution mode is CapabilityAction
  • An output directory is set in the context

Otherwise, the path is resolved against the context working directory (set via WithWorkingDirectory), falling back to the process CWD when no context directory is set.

When resolving against an output directory, the result is validated to ensure it does not escape the output directory via parent traversal (e.g., "../../../etc/passwd").

func ResolverContextFromContext

func ResolverContextFromContext(ctx context.Context) (map[string]any, bool)

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 ValidateDirectory added in v0.6.0

func ValidateDirectory(dir string) (string, error)

ValidateDirectory resolves a directory path to an absolute path and validates that it exists and is a directory. Returns the resolved absolute path or an error.

func WithBackup added in v0.6.0

func WithBackup(ctx context.Context, backup bool) context.Context

WithBackup returns a new context with the backup flag attached.

func WithConflictStrategy added in v0.6.0

func WithConflictStrategy(ctx context.Context, strategy string) context.Context

WithConflictStrategy returns a new context with the conflict strategy attached.

func WithDryRun

func WithDryRun(ctx context.Context, dryRun bool) context.Context

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 added in v0.4.0

func WithIOStreams(ctx context.Context, streams *IOStreams) context.Context

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 added in v0.6.0

func WithOutputDirectory(ctx context.Context, dir string) context.Context

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

func WithParameters(ctx context.Context, parameters map[string]any) context.Context

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

func WithResolverContext(ctx context.Context, resolverContext map[string]any) context.Context

WithResolverContext returns a new context with the resolver context map.

func WithSolutionMetadata added in v0.6.0

func WithSolutionMetadata(ctx context.Context, meta *SolutionMeta) context.Context

WithSolutionMetadata returns a new context with the solution metadata attached.

func WithWorkingDirectory added in v0.6.0

func WithWorkingDirectory(ctx context.Context, dir string) context.Context

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 added in v0.6.0

func WorkingDirectoryFromContext(ctx context.Context) (string, bool)

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"`

	// 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 added in v0.6.0

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.

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 ExecutionMetrics

type ExecutionMetrics struct {
	ExecutionCount  uint64 `json:"executionCount" yaml:"executionCount" doc:"Total number of executions"`
	SuccessCount    uint64 `json:"successCount" yaml:"successCount" doc:"Number of successful executions"`
	FailureCount    uint64 `json:"failureCount" yaml:"failureCount" doc:"Number of failed executions"`
	TotalDurationNs uint64 `json:"totalDurationNs" yaml:"totalDurationNs" doc:"Total execution duration in nanoseconds"`
	LastExecutionNs uint64 `json:"lastExecutionNs" yaml:"lastExecutionNs" doc:"Timestamp of last execution in nanoseconds since epoch"`
}

ExecutionMetrics tracks execution statistics for a provider.

func (*ExecutionMetrics) AverageDuration

func (m *ExecutionMetrics) AverageDuration() time.Duration

AverageDuration returns the average execution duration.

func (*ExecutionMetrics) SuccessRate

func (m *ExecutionMetrics) SuccessRate() float64

SuccessRate returns the success rate as a percentage (0-100).

type ExecutionResult

type ExecutionResult struct {
	// Provider is the provider that was executed
	Provider Provider `json:"provider" yaml:"provider" doc:"The provider that was executed"`

	// Output is the validated output from the provider
	Output Output `json:"output" yaml:"output" doc:"The validated output from the provider"`

	// DryRun indicates whether this was a dry-run execution
	DryRun bool `json:"dryRun" yaml:"dryRun" doc:"Whether this was a dry-run execution"`

	// ExecutionDuration is the total time taken to execute the provider
	ExecutionDuration time.Duration `json:"executionDuration" yaml:"executionDuration" doc:"The total time taken to execute the provider" example:"1000000000"`

	// ResolvedInputs are the inputs after resolution (for debugging)
	ResolvedInputs map[string]any `json:"resolvedInputs,omitempty" yaml:"resolvedInputs,omitempty" doc:"The resolved inputs (for debugging)"`
}

ExecutionResult contains the result of a provider execution.

func Execute

func Execute(ctx context.Context, provider Provider, inputs map[string]any) (*ExecutionResult, error)

Execute executes a provider using the global executor.

func ExecuteByName

func ExecuteByName(ctx context.Context, providerName string, inputs map[string]any) (*ExecutionResult, error)

ExecuteByName executes a provider by name using the global executor.

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor orchestrates provider execution with input resolution and validation.

func GetGlobalExecutor

func GetGlobalExecutor() *Executor

GetGlobalExecutor returns the global executor instance.

func NewExecutor

func NewExecutor(opts ...ExecutorOption) *Executor

NewExecutor creates a new provider executor with the given options.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, provider Provider, inputs map[string]any) (*ExecutionResult, error)

Execute executes a provider with the given inputs and context. It performs: 1. Execution mode validation against provider capabilities 2. Input resolution (literal, resolver bindings, CEL, templates) 3. Input validation against provider schema 4. Optional decode (if Descriptor.Decode is set) 5. Provider execution (provider checks context for dry-run mode) 6. Output validation against output schema

The context should contain: - Execution mode (via WithExecutionMode) - REQUIRED - Dry-run flag (via WithDryRun) - providers check this to modify behavior - Resolver context (via WithResolverContext) for input resolution

Note: Providers are responsible for handling dry-run mode by checking DryRunFromContext(ctx) and returning appropriate outputs without performing side effects.

func (*Executor) ExecuteByName

func (e *Executor) ExecuteByName(ctx context.Context, providerName string, inputs map[string]any) (*ExecutionResult, error)

ExecuteByName executes a provider by name from the global registry. This is a convenience method that looks up the provider and calls Execute.

type ExecutorOption

type ExecutorOption func(*Executor)

ExecutorOption is a functional option for configuring an Executor.

func WithSchemaValidator

func WithSchemaValidator(validator *SchemaValidator) ExecutorOption

WithSchemaValidator sets a custom schema validator.

type IOStreams added in v0.4.0

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 added in v0.4.0

func IOStreamsFromContext(ctx context.Context) (*IOStreams, bool)

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 InputResolver

type InputResolver struct {
	// contains filtered or unexported fields
}

InputResolver resolves provider inputs from various forms into concrete values.

func NewInputResolver

func NewInputResolver(ctx context.Context, schema *jsonschema.Schema, sensitiveFields []string) *InputResolver

NewInputResolver creates a new input resolver for the given schema and context. The sensitiveFields parameter lists field names that should be redacted in errors.

func (*InputResolver) ResolveInputs

func (r *InputResolver) ResolveInputs(rawInputs any) (map[string]any, error)

ResolveInputs resolves all provider inputs from their declared forms into concrete values. It validates exclusivity (only one form per property), resolves each input based on its form, applies type coercion, and validates the final values against the schema.

rawInputs is expected to be map[string]InputValue or map[string]any (for backwards compatibility). Returns a map[string]any with resolved concrete values, ready for provider execution.

type InputValue

type InputValue struct {
	Literal any                        `json:"literal,omitempty" yaml:"literal,omitempty" doc:"Direct static value"`
	Rslvr   string                     `json:"rslvr,omitempty" yaml:"rslvr,omitempty" doc:"Resolver binding (e.g., 'environment')"`
	Expr    celexp.Expression          `json:"expr,omitempty" yaml:"expr,omitempty" doc:"CEL expression to evaluate"`
	Tmpl    gotmpl.GoTemplatingContent `json:"tmpl,omitempty" yaml:"tmpl,omitempty" doc:"Go template to render"`
}

InputValue represents a single input value with exactly one form specified. Only one of Literal, Rslvr, Expr, or Tmpl should be set.

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 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 Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

Metrics provides global provider metrics collection. It is safe for concurrent use.

func (*Metrics) Disable

func (m *Metrics) Disable()

Disable turns off metrics collection.

func (*Metrics) Enable

func (m *Metrics) Enable()

Enable turns on metrics collection.

func (*Metrics) GetAllMetrics

func (m *Metrics) GetAllMetrics() map[string]*ExecutionMetrics

GetAllMetrics returns a map of all provider metrics. The returned map is a copy and safe to modify.

func (*Metrics) GetMetrics

func (m *Metrics) GetMetrics(providerName string) *ExecutionMetrics

GetMetrics returns metrics for a specific provider. Returns nil if no metrics have been recorded for the provider.

func (*Metrics) IsEnabled

func (m *Metrics) IsEnabled() bool

IsEnabled returns whether metrics collection is enabled.

func (*Metrics) Record

func (m *Metrics) Record(ctx context.Context, providerName string, duration time.Duration, success bool)

Record records an execution result for a provider. When metrics collection is enabled, results are written to both the in-memory store and the global OTel MeterProvider.

func (*Metrics) Reset

func (m *Metrics) Reset()

Reset clears all collected metrics.

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.

func Get

func Get(name string) (Provider, bool)

Get retrieves a provider from the global registry.

func ListByCapability

func ListByCapability(capability Capability) []Provider

ListByCapability returns providers with the given capability from the global registry.

func ListByCategory

func ListByCategory(category string) []Provider

ListByCategory returns providers in the given category from the global registry.

func ListProviders

func ListProviders() []Provider

ListProviders returns all providers from the global registry.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages provider registration and discovery. It ensures global name uniqueness and maintains the latest stable version of each provider.

func GetGlobalRegistry

func GetGlobalRegistry() *Registry

GetGlobalRegistry returns the global registry instance. This is useful for testing or when you need direct access to the registry.

func NewRegistry

func NewRegistry(opts ...RegistryOption) *Registry

NewRegistry creates a new provider registry with the given options.

func (*Registry) Clear

func (r *Registry) Clear()

Clear removes all providers from the registry. This is primarily for testing purposes.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered providers.

func (*Registry) DescriptorLookup

func (r *Registry) DescriptorLookup() func(name string) *Descriptor

DescriptorLookup returns a function that looks up provider descriptors by name. This is used for dependency extraction during resolver phase building. The returned function returns nil if the provider is not found.

func (*Registry) Get

func (r *Registry) Get(name string) (Provider, bool)

Get retrieves a provider by name. Returns the provider and true if found, nil and false otherwise.

func (*Registry) Has

func (r *Registry) Has(name string) bool

Has checks if a provider with the given name is registered.

func (*Registry) List

func (r *Registry) List() []string

List returns a list of all registered provider names. The list is sorted alphabetically.

func (*Registry) ListByCapability

func (r *Registry) ListByCapability(capability Capability) []Provider

ListByCapability returns providers that support the given capability. The list is sorted alphabetically by provider name.

func (*Registry) ListByCategory

func (r *Registry) ListByCategory(category string) []Provider

ListByCategory returns providers in the given category. The list is sorted alphabetically by provider name.

func (*Registry) ListProviders

func (r *Registry) ListProviders() []Provider

ListProviders returns a list of all registered providers. The list is sorted alphabetically by provider name.

func (*Registry) Register

func (r *Registry) Register(p Provider) error

Register registers a provider in the registry. Returns an error if: - Provider is nil - Provider descriptor is invalid - Provider name already exists (unless allowOverwrite is true) - Provider version is older than existing version

func (*Registry) Unregister

func (r *Registry) Unregister(name string) bool

Unregister removes a provider from the registry. Returns true if the provider was removed, false if it didn't exist. This is primarily for testing purposes.

type RegistryOption

type RegistryOption func(*registryOptions)

RegistryOption is a functional option for configuring a Registry.

func WithAllowOverwrite

func WithAllowOverwrite(allow bool) RegistryOption

WithAllowOverwrite allows overwriting existing providers in the registry. This is primarily for testing purposes and should not be used in production.

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 added in v0.6.0

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 added in v0.6.0

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
githubprovider
Package githubprovider implements a provider for GitHub API operations.
Package githubprovider implements a provider for GitHub API operations.
identityprovider
Package identityprovider provides authentication identity information from auth handlers.
Package identityprovider provides authentication identity information from auth handlers.
secretprovider
Package secretprovider implements a resolver provider for accessing encrypted secrets.
Package secretprovider implements a resolver provider for accessing encrypted secrets.
Package detail provides shared business logic for building structured provider information.
Package detail provides shared business logic for building structured provider information.
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.

Jump to

Keyboard shortcuts

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