Documentation
¶
Overview ¶
Package inspect provides business logic for inspecting and explaining solutions. This package is the shared domain layer used by CLI, MCP, and future API consumers.
Index ¶
- func AppendResolverHints(suggestions *[]string, cause error, resolverName string, ...)
- func LoadSolution(ctx context.Context, path string) (*solution.Solution, error)
- func LookupProvider(ctx context.Context, name string, reg *provider.Registry) (*provider.Descriptor, error)
- type ActionInfo
- type CatalogInfo
- type ExecutionDiagnostic
- type FileDependencyInfo
- type LinkInfo
- type MaintainerInfo
- type ParamInfo
- type ResolverInfo
- type RunCommandInfo
- type SolutionExplanation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendResolverHints ¶ added in v0.6.0
func AppendResolverHints(suggestions *[]string, cause error, resolverName string, sol *solution.Solution)
AppendResolverHints inspects an error cause and adds provider-specific hints to the suggestions slice. This is exported so callers can build custom diagnostic flows while reusing the hint logic.
func LoadSolution ¶
LoadSolution loads a solution from a path using the standard loader with catalog resolution. This function is reusable by CLI, MCP, and future API.
func LookupProvider ¶
func LookupProvider(ctx context.Context, name string, reg *provider.Registry) (*provider.Descriptor, error)
LookupProvider looks up a provider by name and returns its descriptor. This is a standalone function reusable by CLI, MCP, and future API.
Types ¶
type ActionInfo ¶
type ActionInfo struct {
Name string `json:"name" yaml:"name" doc:"Action name" maxLength:"256" example:"deploy"`
Provider string `json:"provider" yaml:"provider" doc:"Provider used by this action" maxLength:"128" example:"shell"`
DependsOn []string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty" doc:"Action dependencies" maxItems:"100"`
Conditional bool `json:"conditional,omitempty" yaml:"conditional,omitempty" doc:"Whether action has a when condition"`
HasRetry bool `json:"hasRetry,omitempty" yaml:"hasRetry,omitempty" doc:"Whether retry is configured"`
HasForEach bool `json:"hasForEach,omitempty" yaml:"hasForEach,omitempty" doc:"Whether forEach is configured"`
SourcePos *sourcepos.Position `json:"sourcePos,omitempty" yaml:"sourcePos,omitempty" doc:"Source file location"`
}
ActionInfo holds structured information about an action.
type CatalogInfo ¶
type CatalogInfo struct {
Visibility string `json:"visibility,omitempty" yaml:"visibility,omitempty" doc:"Catalog visibility level" maxLength:"32" example:"public"`
Beta bool `json:"beta,omitempty" yaml:"beta,omitempty" doc:"Whether the solution is in beta"`
Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty" doc:"Whether the solution is disabled"`
}
CatalogInfo holds catalog metadata.
type ExecutionDiagnostic ¶ added in v0.6.0
type ExecutionDiagnostic struct {
// Details is the human-readable description of the error.
Details string `json:"details" yaml:"details" doc:"Detailed error description" maxLength:"4096" example:"2 resolver(s) failed, 1 succeeded"`
// Suggestions are actionable steps to fix the error.
Suggestions []string `json:"suggestions" yaml:"suggestions" doc:"Actionable fix suggestions" maxItems:"20"`
}
ExecutionDiagnostic holds a structured diagnosis of a resolver execution error. This is the domain-level representation that can be used by CLI, MCP, and future API consumers to build user-facing error messages.
func DiagnoseExecutionError ¶ added in v0.6.0
func DiagnoseExecutionError(err error, sol *solution.Solution) *ExecutionDiagnostic
DiagnoseExecutionError converts a resolver execution error into a structured diagnostic with typed analysis and actionable suggestions. The solution is used to inspect resolver configurations for provider-specific hints.
type FileDependencyInfo ¶ added in v0.6.0
type FileDependencyInfo struct {
Path string `json:"path" yaml:"path" doc:"Relative file path" maxLength:"512" example:"templates/main.tf"`
Source string `` /* 158-byte string literal not displayed */
}
FileDependencyInfo describes a file dependency discovered via static analysis.
type LinkInfo ¶
type LinkInfo struct {
Name string `json:"name" yaml:"name" doc:"Link display name" maxLength:"128" example:"Documentation"`
URL string `json:"url" yaml:"url" doc:"Link URL" maxLength:"1024" example:"https://example.com/docs"`
}
LinkInfo holds a named link.
type MaintainerInfo ¶
type MaintainerInfo struct {
Name string `json:"name" yaml:"name" doc:"Maintainer name" maxLength:"128" example:"Jane Doe"`
Email string `json:"email,omitempty" yaml:"email,omitempty" doc:"Maintainer email" maxLength:"256" example:"jane@example.com"`
}
MaintainerInfo holds maintainer contact info.
type ParamInfo ¶ added in v0.6.0
type ParamInfo struct {
Name string `json:"name" yaml:"name" doc:"Parameter name" maxLength:"256" example:"projectName"`
Type string `json:"type,omitempty" yaml:"type,omitempty" doc:"Parameter type" maxLength:"64" example:"string"`
Description string `` /* 141-byte string literal not displayed */
Example any `json:"example,omitempty" yaml:"example,omitempty" doc:"Example value"`
}
ParamInfo describes a parameter-type resolver that requires a user-provided value.
type ResolverInfo ¶
type ResolverInfo struct {
Name string `json:"name" yaml:"name" doc:"Resolver name" maxLength:"256" example:"api-data"`
Providers []string `json:"providers,omitempty" yaml:"providers,omitempty" doc:"Provider names used" maxItems:"20"`
DependsOn []string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty" doc:"Resolver dependencies" maxItems:"100"`
Conditional bool `json:"conditional,omitempty" yaml:"conditional,omitempty" doc:"Whether resolver has a when condition"`
Phases []string `json:"phases,omitempty" yaml:"phases,omitempty" doc:"Configured phases (resolve, transform, validate)" maxItems:"3"`
SourcePos *sourcepos.Position `json:"sourcePos,omitempty" yaml:"sourcePos,omitempty" doc:"Source file location"`
}
ResolverInfo holds structured information about a resolver.
type RunCommandInfo ¶ added in v0.6.0
type RunCommandInfo struct {
// Command is the full CLI command string with all flags.
Command string `` /* 156-byte string literal not displayed */
// Subcommand is the base command (e.g., "scafctl run solution").
Subcommand string `json:"subcommand" yaml:"subcommand" doc:"Base CLI subcommand" maxLength:"128" example:"scafctl run solution"`
// Explanation describes why this command variant was chosen.
Explanation string `` /* 142-byte string literal not displayed */
// Parameters lists the parameter-type resolvers that need values.
Parameters []ParamInfo `json:"parameters" yaml:"parameters" doc:"Parameter-type resolvers requiring values" maxItems:"100"`
// HasWorkflow indicates whether the solution has a workflow.
HasWorkflow bool `json:"hasWorkflow" yaml:"hasWorkflow" doc:"Whether the solution has a workflow"`
// HasResolvers indicates whether the solution has resolvers.
HasResolvers bool `json:"hasResolvers" yaml:"hasResolvers" doc:"Whether the solution has resolvers"`
}
RunCommandInfo holds the structured result of analyzing a solution to determine how to run it. This is the domain representation used by CLI, MCP, and future API consumers.
func BuildRunCommand ¶ added in v0.6.0
func BuildRunCommand(sol *solution.Solution, path, binaryName string) (*RunCommandInfo, error)
BuildRunCommand analyzes a solution and returns the exact CLI command to run it, including any parameter-type resolvers that need values passed via -r flags. The binaryName parameter is used in the generated command (e.g., "scafctl" or a custom name when scafctl is embedded as a library). Returns nil and an error message if the solution has nothing to run.
type SolutionExplanation ¶
type SolutionExplanation struct {
Name string `json:"name" yaml:"name" doc:"Solution name" maxLength:"256" example:"my-solution"`
DisplayName string `` /* 129-byte string literal not displayed */
Version string `json:"version" yaml:"version" doc:"Solution version" maxLength:"64" example:"1.0.0"`
Description string `` /* 134-byte string literal not displayed */
Category string `json:"category,omitempty" yaml:"category,omitempty" doc:"Solution category" maxLength:"128" example:"infrastructure"`
Path string `json:"path,omitempty" yaml:"path,omitempty" doc:"Source file path" maxLength:"512" example:"./solution.yaml"`
Catalog *CatalogInfo `json:"catalog,omitempty" yaml:"catalog,omitempty" doc:"Catalog visibility info"`
Resolvers []ResolverInfo `json:"resolvers,omitempty" yaml:"resolvers,omitempty" doc:"Resolver configurations" maxItems:"1000"`
Actions []ActionInfo `json:"actions,omitempty" yaml:"actions,omitempty" doc:"Action configurations" maxItems:"1000"`
Finally []ActionInfo `json:"finally,omitempty" yaml:"finally,omitempty" doc:"Finally/cleanup actions" maxItems:"100"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty" doc:"Solution tags" maxItems:"50"`
Links []LinkInfo `json:"links,omitempty" yaml:"links,omitempty" doc:"Related links" maxItems:"50"`
Maintainers []MaintainerInfo `json:"maintainers,omitempty" yaml:"maintainers,omitempty" doc:"Solution maintainers" maxItems:"20"`
// FileDependencies lists files discovered through static analysis of provider inputs.
FileDependencies []FileDependencyInfo `` /* 137-byte string literal not displayed */
}
SolutionExplanation holds structured explanation data for a solution. This can be serialized to JSON/YAML or formatted for terminal output.
func BuildSolutionExplanation ¶
func BuildSolutionExplanation(sol *solution.Solution) *SolutionExplanation
BuildSolutionExplanation builds a structured explanation from a loaded solution. This returns data that can be serialized (JSON/YAML) or formatted for display.