Documentation
¶
Index ¶
- Constants
- Variables
- func AbsFromContext(ctx context.Context, path string) (string, error)
- func BackupFromContext(ctx context.Context) (bool, bool)
- func ConflictStrategyFromContext(ctx context.Context) (string, bool)
- func Count() int
- func DryRunFromContext(ctx context.Context) bool
- func GetWorkingDirectory(ctx context.Context) (string, error)
- func Has(name string) bool
- func List() []string
- func MaskValue(value any, isSecret bool) string
- func OutputDirectoryFromContext(ctx context.Context) (string, bool)
- func ParametersFromContext(ctx context.Context) (map[string]any, bool)
- func Register(p Provider) error
- func ResetGlobalExecutor()
- func ResetGlobalRegistry()
- func ResolvePath(ctx context.Context, path string) (string, error)
- func ResolverContextFromContext(ctx context.Context) (map[string]any, bool)
- func SolutionDirectoryFromContext(ctx context.Context) (string, bool)
- func ValidateDescriptor(desc *Descriptor) error
- func ValidateDirectory(dir string) (string, 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 WithSolutionDirectory(ctx context.Context, dir string) 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 ExecutionMetrics
- type ExecutionResult
- type Executor
- type ExecutorOption
- type IOStreams
- type InputResolver
- type InputValue
- type IterationContext
- type Link
- type Metrics
- func (m *Metrics) Disable()
- func (m *Metrics) Enable()
- func (m *Metrics) GetAllMetrics() map[string]*ExecutionMetrics
- func (m *Metrics) GetMetrics(providerName string) *ExecutionMetrics
- func (m *Metrics) IsEnabled() bool
- func (m *Metrics) Record(ctx context.Context, providerName string, duration time.Duration, success bool)
- func (m *Metrics) Reset()
- type Output
- type Provider
- type Registry
- func (r *Registry) Clear()
- func (r *Registry) Count() int
- func (r *Registry) DescriptorLookup() func(name string) *Descriptor
- func (r *Registry) Get(name string) (Provider, bool)
- func (r *Registry) Has(name string) bool
- func (r *Registry) List() []string
- func (r *Registry) ListByCapability(capability Capability) []Provider
- func (r *Registry) ListByCategory(category string) []Provider
- func (r *Registry) ListProviders() []Provider
- func (r *Registry) Register(p Provider) error
- func (r *Registry) Unregister(name string) bool
- type RegistryOption
- type SchemaValidator
- type SolutionMeta
- type ValidationError
- type ValidationErrors
Constants ¶
const ( CapabilityFrom = sdkprovider.CapabilityFrom CapabilityTransform = sdkprovider.CapabilityTransform CapabilityValidation = sdkprovider.CapabilityValidation CapabilityAuthentication = sdkprovider.CapabilityAuthentication CapabilityAction = sdkprovider.CapabilityAction )
const (
// SecretMask is the string used to redact secret values in logs and errors
SecretMask = "***REDACTED***"
)
Variables ¶
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
AbsFromContext resolves a relative path to an absolute path using the context working directory. Resolution priority:
- If the path is absolute, return it cleaned.
- If a working directory is set in context (via WithWorkingDirectory), use it.
- If a solution directory is set in context (via WithSolutionDirectory), use it. This ensures resolver-phase paths resolve relative to the solution file location.
- Fall 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
BackupFromContext retrieves the backup flag from the context.
func ConflictStrategyFromContext ¶ added in v0.6.0
ConflictStrategyFromContext retrieves the conflict strategy from the context.
func DryRunFromContext ¶
DryRunFromContext retrieves the dry-run flag from the context. Defaults to false if not set.
func GetWorkingDirectory ¶ added in v0.6.0
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 MaskValue ¶
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
OutputDirectoryFromContext retrieves the output directory from the context.
func ParametersFromContext ¶
ParametersFromContext retrieves the CLI parameters map from the context.
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
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 ¶
ResolverContextFromContext retrieves the resolver context map from the context.
func SolutionDirectoryFromContext ¶ added in v0.8.0
SolutionDirectoryFromContext retrieves the solution file's parent directory. Returns the directory path and true if found, empty string and false otherwise.
func ValidateDescriptor ¶
func ValidateDescriptor(desc *Descriptor) error
ValidateDescriptor validates that a Descriptor meets all requirements.
func ValidateDirectory ¶ added in v0.6.0
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
WithBackup returns a new context with the backup flag attached.
func WithConflictStrategy ¶ added in v0.6.0
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 ¶ added in v0.4.0
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
WithOutputDirectory returns a new context with the output directory path attached.
func WithParameters ¶
WithParameters returns a new context with the CLI parameters map.
func WithResolverContext ¶
WithResolverContext returns a new context with the resolver context map.
func WithSolutionDirectory ¶ added in v0.8.0
WithSolutionDirectory returns a new context with the solution file's parent directory. When set, resolver-phase path resolution uses this as the base for relative paths instead of the process CWD, ensuring consistent behaviour between local and bundled execution.
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
WithWorkingDirectory returns a new context with the logical working directory attached.
Types ¶
type Capability ¶
type Capability = sdkprovider.Capability
Capability represents the types of operations a provider can perform.
func ExecutionModeFromContext ¶
func ExecutionModeFromContext(ctx context.Context) (Capability, bool)
ExecutionModeFromContext retrieves the execution mode from the context.
type Contact ¶
type Contact = sdkprovider.Contact
Contact represents maintainer contact information.
type Descriptor ¶
type Descriptor = sdkprovider.Descriptor
Descriptor contains provider identity, versioning, schemas, capabilities, and catalog metadata.
type Example ¶
type Example = sdkprovider.Example
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 = sdkprovider.IOStreams
IOStreams holds terminal IO writers for providers that support streaming output.
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 = sdkprovider.IterationContext
IterationContext holds information about the current forEach iteration.
func IterationContextFromContext ¶
func IterationContextFromContext(ctx context.Context) (*IterationContext, bool)
IterationContextFromContext retrieves the iteration context from the context.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics provides global provider metrics collection. It is safe for concurrent use.
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.
type Output ¶
type Output = sdkprovider.Output
Output is the standardized return structure for all provider executions.
type Provider ¶
type Provider = sdkprovider.Provider
Provider is the core interface that all providers must implement.
func ListByCapability ¶
func ListByCapability(capability Capability) []Provider
ListByCapability returns providers with the given capability from the global registry.
func ListByCategory ¶
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) 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 ¶
Get retrieves a provider by name. Returns the provider and true if found, nil and false otherwise.
func (*Registry) List ¶
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 ¶
ListByCategory returns providers in the given category. The list is sorted alphabetically by provider name.
func (*Registry) ListProviders ¶
ListProviders returns a list of all registered providers. The list is sorted alphabetically by provider name.
func (*Registry) Register ¶
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 ¶
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 = sdkprovider.SchemaValidator
SchemaValidator provides validation for provider inputs and outputs against JSON Schema definitions.
func NewSchemaValidator ¶
func NewSchemaValidator() *SchemaValidator
NewSchemaValidator creates a new schema validator.
type SolutionMeta ¶ added in v0.6.0
type SolutionMeta = sdkprovider.SolutionMeta
SolutionMeta holds solution metadata fields made available to providers via context.
func SolutionMetadataFromContext ¶ added in v0.6.0
func SolutionMetadataFromContext(ctx context.Context) (*SolutionMeta, bool)
SolutionMetadataFromContext retrieves the solution metadata from the context.
type ValidationError ¶
type ValidationError = sdkprovider.ValidationError
ValidationError represents a single field validation error with contextual information.
type ValidationErrors ¶
type ValidationErrors = sdkprovider.ValidationErrors
ValidationErrors is a collection of validation errors.
Source Files
¶
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. |