Documentation
¶
Overview ¶
Package starlark provides the Starlark scripting runtime for devlore.
Index ¶
- type PackageContext
- type PhaseContext
- type PlanRoot
- type Runtime
- func (rt *Runtime) BuildGlobals(graph *op.Graph, project string, reg *op.ActionRegistry) starlark.StringDict
- func (rt *Runtime) ConfigureThread(thread *starlark.Thread, graph *op.Graph, project string, ...)
- func (rt *Runtime) NewPopulatedRegistry(ctx op.Context) *op.ActionRegistry
- func (rt *Runtime) RegisterActions(reg *op.ActionRegistry, ctx op.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PackageContext ¶
type PackageContext struct {
// Name is the package name being deployed.
Name string
// Version is the version being deployed.
Version string
// Features are the enabled feature flags for this deployment.
Features []string
// Settings are key-value configuration settings.
Settings map[string]string
// DryRun indicates this is a preview (no actual changes).
DryRun bool
// SourceRoot is the package source directory in the registry cache.
SourceRoot string
// TargetRoot is the deployment target directory (usually $HOME).
TargetRoot string
}
PackageContext provides information about the package being deployed. Passed to phase scripts as the first argument.
func (*PackageContext) HasFeature ¶
func (p *PackageContext) HasFeature(name string) bool
HasFeature checks if a feature is enabled.
func (*PackageContext) Setting ¶
func (p *PackageContext) Setting(key string) string
Setting returns a setting value, or empty string if not set.
func (*PackageContext) ToStarlark ¶
func (p *PackageContext) ToStarlark() starlark.Value
ToStarlark converts the PackageContext to a Starlark receiver.
type PhaseContext ¶
type PhaseContext struct {
// PhaseName is the lifecycle phase (e.g., "install", "provision").
PhaseName string
// Action is the lifecycle action (e.g., "deploy", "remove").
Action string
// Retry holds the retry policy configured by the script.
Retry *op.RetryPolicy
}
PhaseContext provides phase metadata to lifecycle scripts.
Passed as the second call argument: def install(package, phase):
Starlark API:
phase.name # Phase name (e.g., "install", "provision") phase.action # Lifecycle action (e.g., "deploy", "remove") phase.retry(max_attempts=3, backoff="exponential") # Configures retry policy
func (*PhaseContext) ToStarlark ¶
func (c *PhaseContext) ToStarlark() starlark.Value
ToStarlark returns a Starlark value exposing phase.name, phase.action, phase.retry().
type PlanRoot ¶
type PlanRoot struct {
// contains filtered or unexported fields
}
PlanRoot implements the top-level plan namespace using the slot-based model. Sub-namespaces are populated from PlanningReceiverFactory implementations selected by Runtime. Flow actions (choose, source, gather) are built-in.
func NewPlanRootFromProviders ¶
func NewPlanRootFromProviders(graph *op.Graph, project string, reg *op.ActionRegistry, providers map[string]op.PlanningReceiverFactory) *PlanRoot
NewPlanRootFromProviders creates a PlanRoot from announced PlanningReceiverFactory implementations. Consumers select providers via Runtime, which passes the filtered provider map here.
type Runtime ¶
type Runtime struct {
*op.StarlarkRuntime
// contains filtered or unexported fields
}
Runtime is the devlore Starlark runtime. It embeds op.StarlarkRuntime for immediate receiver management and adds the plan namespace and @devlore// module loader used by the CLI tools.
func NewRuntime ¶
func NewRuntime(cfg *op.BindingConfig) *Runtime
NewRuntime creates a Runtime with the given configuration. Receivers listed in cfg.Receivers are included as pre-injected globals.
Parameters:
- cfg: configuration specifying providers, writer, and program name.
Returns:
- *Runtime: the initialized runtime.
func (*Runtime) BuildGlobals ¶
func (rt *Runtime) BuildGlobals(graph *op.Graph, project string, reg *op.ActionRegistry) starlark.StringDict
BuildGlobals constructs the Starlark globals dict for a consumer. Only receivers listed in cfg.Receivers appear as globals. If GraphBuilder is enabled, a PlanRoot is built from all announced PlanningReceiverFactory implementations.
Parameters:
- graph: the execution graph for plan namespace construction.
- project: the project name passed to planned providers.
- reg: the action registry for plan namespace construction.
Returns:
- starlark.StringDict: the complete globals dict for Starlark execution.
func (*Runtime) ConfigureThread ¶
func (rt *Runtime) ConfigureThread(thread *starlark.Thread, graph *op.Graph, project string, reg *op.ActionRegistry)
ConfigureThread sets thread.Load to the @devlore// module loader. The loader resolves provider names from the runtime and caches instances. Must be called before starlark.ExecFileOptions.
Parameters:
- thread: the Starlark thread to configure.
- graph: the execution graph for module resolution.
- project: the project name for module resolution.
- reg: the action registry for module resolution.
func (*Runtime) NewPopulatedRegistry ¶
func (rt *Runtime) NewPopulatedRegistry(ctx op.Context) *op.ActionRegistry
NewPopulatedRegistry creates an ActionRegistry with all provider actions registered. Shorthand for NewActionRegistry() + RegisterActions().
Parameters:
- ctx: the execution context for provider initialization.
Returns:
- *op.ActionRegistry: the populated registry.
func (*Runtime) RegisterActions ¶
func (rt *Runtime) RegisterActions(reg *op.ActionRegistry, ctx op.Context)
RegisterActions registers all providers' actions with the registry. All providers' actions are always registered regardless of Providers selections — the action registry is for the executor, not the script environment.
Parameters:
- reg: the action registry to populate.
- ctx: the execution context for provider initialization.