Documentation
¶
Overview ¶
Package adapters wires pkg/taskgraph's generic dependency runner to specific integrations -- mirroring pkg/scheduler/adapters' role for the scheduler. CobraCommand in this file is the custom-command-depends-on-command integration: it resolves and invokes an already-registered *cobra.Command in-process, in the same fashion internal/exec's workflow dependency adapter resolves and invokes workflows.
Index ¶
- func CustomCommandDependencyOptions(atmosConfig *schema.AtmosConfiguration, root *cobra.Command, ...) []taskgraph.Option
- func CustomCommandRunner(root *cobra.Command, isCustom IsCustomCommand) taskgraph.Runner
- func DependenciesAlreadyResolved(cmd *cobra.Command) bool
- func FindRegisteredCommand(root *cobra.Command, name string, isCustom IsCustomCommand) (*cobra.Command, bool)
- func RecordDependencyError(cmd *cobra.Command, err error)
- func WithDependenciesResolved(ctx context.Context) context.Context
- func WithDependencyErrorSink(ctx context.Context) (context.Context, *errorSink)
- type IsCustomCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CustomCommandDependencyOptions ¶
func CustomCommandDependencyOptions(atmosConfig *schema.AtmosConfiguration, root *cobra.Command, isCustom IsCustomCommand) []taskgraph.Option
CustomCommandDependencyOptions returns the taskgraph.Options wiring shared by every custom command's dependencies.commands/dependencies.workflows resolution: commands run in-process against root's registered cobra tree; workflows require an explicit `file:` (a custom command has no "current workflow file" to default same-name lookups against).
func CustomCommandRunner ¶
func CustomCommandRunner(root *cobra.Command, isCustom IsCustomCommand) taskgraph.Runner
CustomCommandRunner executes a taskgraph.Ref{Kind: KindCommand} dependency in-process by locating its already-registered *cobra.Command under root and invoking it directly with the given flag/arg overrides. In-process, not a subprocess, since command-depends-on-command is entirely resolvable within the cobra tree -- unlike workflow-depends-on-command (see internal/exec's WorkflowRunner-via-subprocess), which cannot reach this cobra tree without an import cycle.
Two Refs sharing a Name -- e.g. the same command depended on twice with different flags: dependencies.commands: [{name: build, flags: {env: dev}}, {name: build, flags: {env: prod}}] -- resolve to the SAME already-registered *cobra.Command (FindRegisteredCommand is keyed by name, not by Ref), and taskgraph runs independent graph nodes concurrently by default. Without commandLocks, concurrent dispatches would race on that one shared, mutable Cobra object's PersistentFlags/context/annotations. Same-name dependencies serialize; differently-named ones still run fully concurrently.
func DependenciesAlreadyResolved ¶
DependenciesAlreadyResolved reports whether cmd was invoked as a dependency of another command whose taskgraph run already satisfied cmd's own dependencies.
func FindRegisteredCommand ¶
func FindRegisteredCommand(root *cobra.Command, name string, isCustom IsCustomCommand) (*cobra.Command, bool)
FindRegisteredCommand searches root's custom subcommands (and their own nested custom subcommands, recursively) for a *cobra.Command whose own Name() matches name, mirroring schema.FindCommandByName's by-name-regardless-of-nesting semantics for the already-registered cobra tree. Deliberately restricted to isCustom(cmd) matches -- without this guard, a depth-first walk of the FULL command tree (including built-ins) can shadow the intended custom command with an unrelated built-in subcommand that happens to share a leaf name deep in the tree (e.g. `atmos mcp client test <name>` matching a dependencies.commands: [test] entry meant for a top-level custom command named "test").
func RecordDependencyError ¶
RecordDependencyError reports err into cmd's error sink, if one is present in its context (i.e. cmd is running as someone else's already-resolved dependency -- see DependenciesAlreadyResolved). A no-op when no sink is present, so call sites outside a dependency invocation (a command's own top-level, non-dependency run) are unaffected.
func WithDependenciesResolved ¶
WithDependenciesResolved marks ctx so a command invoked as someone else's dependency skips re-resolving its own dependencies.commands/dependencies.workflows -- without it, invoking a command via its full Run (which unconditionally resolves dependencies at the top of executeCustomCommand) would resolve and run that command's dependencies a second, redundant time on top of the graph that already ran them.
func WithDependencyErrorSink ¶
WithDependencyErrorSink returns ctx carrying a fresh error sink a dependency invocation can report its failure into, plus the sink itself so the caller can read it back after Run() returns (Cobra's Run has no return value, so this is the channel back to the dispatcher).
Types ¶
type IsCustomCommand ¶
IsCustomCommand reports whether cmd was constructed from Atmos command configuration. Injected rather than reaching into cmd package internals directly, so this package stays decoupled from cmd's own annotation implementation detail.