workflow

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package workflow provides shared orchestration logic for module discovery, filtering, dependency extraction, and graph building.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFilters added in v0.10.0

func ApplyFilters(cfg config.Snapshot, ff *filter.Flags, modules []*discovery.Module) ([]*discovery.Module, error)

ApplyFilters applies config and CLI filters to a module list.

func MergedFilterOptions added in v0.10.0

func MergedFilterOptions(cfg config.Snapshot, ff *filter.Flags) filter.Options

MergedFilterOptions merges config defaults with CLI filter flags.

func ResolveTargets added in v0.10.0

func ResolveTargets(ctx context.Context, workDir string, cfg config.Snapshot, result *Result, opts TargetSelectionOptions) ([]*discovery.Module, error)

ResolveTargets applies module/path filters and optional change detection to a workflow result.

Types

type ChangeDetectionRequest added in v0.10.5

type ChangeDetectionRequest struct {
	WorkDir      string
	BaseRef      string
	ModuleIndex  *discovery.ModuleIndex
	LibraryPaths []string
}

ChangeDetectionRequest describes one VCS diff request. Implementations should derive all change dimensions from a single underlying diff.

type ChangeDetectionResult added in v0.10.5

type ChangeDetectionResult struct {
	Modules      []*discovery.Module
	Files        []string
	LibraryPaths []string
}

ChangeDetectionResult contains changed files and their TerraCi projections.

type ChangeDetector added in v0.10.0

type ChangeDetector interface {
	DetectChanges(ctx context.Context, req ChangeDetectionRequest) (*ChangeDetectionResult, error)
}

ChangeDetector detects changed modules from git or another VCS.

type ChangeDetectorResolver added in v0.10.0

type ChangeDetectorResolver func() (ChangeDetector, error)

ChangeDetectorResolver resolves the change detection provider for changed-only target selection.

type LibrarySummary added in v0.10.5

type LibrarySummary struct {
	ConfiguredPaths int
	Discovered      int
	Consumers       int
	Orphans         []string
}

LibrarySummary describes discovered library_modules diagnostics.

func SummarizeLibraries added in v0.10.5

func SummarizeLibraries(cfg config.Snapshot, result *Result) *LibrarySummary

SummarizeLibraries derives configured library_modules diagnostics.

type LibraryUsage added in v0.10.5

type LibraryUsage struct {
	Path         string
	RelativePath string
	UsedBy       int
}

LibraryUsage describes one tracked library module path and its consumers.

func LibraryUsages added in v0.10.5

func LibraryUsages(workDir string, result *Result) []LibraryUsage

LibraryUsages derives deterministic library usage diagnostics.

type ModuleSet added in v0.10.0

type ModuleSet struct {
	Modules []*discovery.Module
	Index   *discovery.ModuleIndex
}

ModuleSet keeps a module slice and its lookup index together.

func NewModuleSet added in v0.10.0

func NewModuleSet(modules []*discovery.Module) ModuleSet

NewModuleSet builds a consistent module collection and lookup index.

func (ModuleSet) All added in v0.10.0

func (s ModuleSet) All() []*discovery.Module

All returns modules in their workflow order.

func (ModuleSet) ByID added in v0.10.0

func (s ModuleSet) ByID(id string) *discovery.Module

ByID returns a module by workflow ID.

type Options

type Options struct {
	WorkDir  string
	Segments []string

	Excludes       []string
	Includes       []string
	SegmentFilters map[string][]string

	// LibraryPaths are project-relative roots whose discovered modules will be
	// flagged Module.IsLibrary=true and routed into Result.Libraries instead
	// of the executable target sets. Empty/nil disables the feature.
	LibraryPaths []string
}

Options configures module discovery, filtering, and graph building.

func OptionsFromConfig added in v0.10.0

func OptionsFromConfig(workDir string, cfg config.Snapshot, ff *filter.Flags) Options

OptionsFromConfig builds workflow options from configuration and CLI filters.

type ProjectRequest added in v0.10.5

type ProjectRequest struct {
	WorkDir   string
	Config    config.Snapshot
	Filters   filter.Flags
	Targeting TargetRequest
}

ProjectRequest describes one canonical Terraform project planning request.

type ProjectResult added in v0.10.5

type ProjectResult struct {
	Workflow       *Result
	Targets        []*discovery.Module
	LibraryUsages  []LibraryUsage
	LibrarySummary *LibrarySummary
}

ProjectResult contains workflow output plus target selection and diagnostics.

func PlanProject added in v0.10.5

func PlanProject(ctx context.Context, req ProjectRequest) (*ProjectResult, error)

PlanProject runs workflow discovery and optional target selection from one canonical request.

type Result

type Result struct {
	// All contains every discovered module (executable + library), in scan
	// order. Use Filtered for execution targets and Libraries for reporting.
	All ModuleSet
	// Filtered is the executable subset after filters; library modules are
	// always excluded regardless of filters.
	Filtered ModuleSet
	// Libraries holds modules under any configured library_modules.paths.
	// They are not included in Filtered and never become execution targets,
	// but are tracked here for diagnostics (validate/graph).
	Libraries ModuleSet

	Graph        *graph.DependencyGraph
	Dependencies map[string]*parser.ModuleDependencies
	Warnings     []error
}

Result contains everything produced by the module workflow.

func Run

func Run(ctx context.Context, opts Options) (*Result, error)

Run executes the full module workflow: scan → filter → parse → build graph.

type TargetRequest added in v0.10.5

type TargetRequest struct {
	Enabled bool

	ModulePath  string
	ChangedOnly bool
	BaseRef     string

	ChangeDetectorResolver ChangeDetectorResolver
}

TargetRequest controls optional executable target selection.

type TargetSelectionOptions added in v0.10.0

type TargetSelectionOptions struct {
	ModulePath  string
	ChangedOnly bool
	BaseRef     string
	Filters     *filter.Flags

	ChangeDetectorResolver ChangeDetectorResolver
}

TargetSelectionOptions controls how executable targets are selected from a workflow result.

Jump to

Keyboard shortcuts

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