starlark

package
v0.1.0-dev.20260301204145 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package starlark provides the Starlark scripting runtime for devlore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BindingSet

type BindingSet struct {
	// contains filtered or unexported fields
}

BindingSet selects which provider bindings a consumer uses and builds Starlark globals from them. Consumers call With() to include specific providers as pre-injected globals. All other providers remain available via load("@devlore//name", "name") in scripts.

func NewBindingSet

func NewBindingSet(cfg op.BindingConfig) *BindingSet

NewBindingSet creates a BindingSet with the given configuration. No providers are included as globals by default.

func (*BindingSet) BuildGlobals

func (bs *BindingSet) BuildGlobals(graph *op.Graph, project string, reg *op.ActionRegistry) starlark.StringDict

BuildGlobals constructs the Starlark globals dict for a consumer. Only providers named in With() appear as globals. If "plan" was included via With(), a PlanRoot is built from all registered PlannedFactory bindings.

func (*BindingSet) ConfigureThread

func (bs *BindingSet) 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 binding registry and caches instances on the BindingSet. Must be called before starlark.ExecFileOptions.

func (*BindingSet) NewPopulatedRegistry

func (bs *BindingSet) NewPopulatedRegistry() *op.ActionRegistry

NewPopulatedRegistry creates an ActionRegistry with all provider actions registered. Shorthand for NewActionRegistry() + RegisterActions().

func (*BindingSet) RegisterActions

func (bs *BindingSet) RegisterActions(reg *op.ActionRegistry)

RegisterActions registers all providers' actions with the registry. All providers' actions are always registered regardless of With() selections — the action registry is for the executor, not the script environment.

func (*BindingSet) With

func (bs *BindingSet) With(names ...string) *BindingSet

With includes one or more providers as pre-injected globals. "plan" is a special name that includes the PlanRoot aggregate. Returns the BindingSet for chaining.

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 PlannedFactory functions selected by BindingSet. Flow actions (choose, source, gather) are built-in.

func NewPlanRootFromFactories

func NewPlanRootFromFactories(graph *op.Graph, project string, reg *op.ActionRegistry, factories map[string]op.PlannedFactory) *PlanRoot

NewPlanRootFromFactories creates a PlanRoot using filtered PlannedFactory functions from the binding registry. Consumers select providers via BindingSet, which passes the filtered factory map here.

func (*PlanRoot) Attr

func (p *PlanRoot) Attr(name string) (starlark.Value, error)

Attr implements starlark.HasAttrs.

func (*PlanRoot) AttrNames

func (p *PlanRoot) AttrNames() []string

AttrNames implements starlark.HasAttrs.

func (*PlanRoot) Freeze

func (p *PlanRoot) Freeze()

Freeze implements starlark.Value.

func (*PlanRoot) Hash

func (p *PlanRoot) Hash() (uint32, error)

Hash implements starlark.Value.

func (*PlanRoot) String

func (p *PlanRoot) String() string

String implements starlark.Value.

func (*PlanRoot) Truth

func (p *PlanRoot) Truth() starlark.Bool

Truth implements starlark.Value.

func (*PlanRoot) Type

func (p *PlanRoot) Type() string

Type implements starlark.Value.

Jump to

Keyboard shortcuts

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