Documentation
¶
Overview ¶
Package starlark provides the Starlark runtime and host bindings for lore.
Index ¶
- func FillSlot(node *execution.Node, graph *execution.Graph, slotName string, ...) error
- func MakeAttr(name string, fn BuiltinFunc) starlark.Value
- func NoSuchAttrError(receiver, attr string) error
- type ArchivePlan
- type ArchiveReceiver
- type Bindings
- type BuiltinFunc
- type ContentPlan
- type DockerReceiver
- type EncryptionPlan
- type EnvReceiver
- type FilePlan
- type FileReceiver
- type Gather
- type GitPlan
- type GitReceiver
- type LogReceiver
- type NetPlan
- type NetReceiver
- type NpmReceiver
- type Output
- func (o *Output) Attr(name string) (starlark.Value, error)
- func (o *Output) AttrNames() []string
- func (o *Output) DependOn(consumer *execution.Node)
- func (o *Output) FillSlot(consumer *execution.Node, slotName string)
- func (o *Output) Freeze()
- func (o *Output) Graph() *execution.Graph
- func (o *Output) Hash() (uint32, error)
- func (o *Output) Node() *execution.Node
- func (o *Output) Path() string
- func (o *Output) Slot() string
- func (o *Output) String() string
- func (o *Output) Truth() starlark.Bool
- func (o *Output) Type() string
- type PackageContext
- type PackagePlan
- type PackageReceiver
- type PhaseContext
- type PlanRoot
- type Receiver
- type RuntimePredicate
- type ServicePlan
- type ServiceReceiver
- type ShellPlan
- type ShellReceiver
- type TemplatePlan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FillSlot ¶
func FillSlot(node *execution.Node, graph *execution.Graph, slotName string, value starlark.Value) error
FillSlot fills a slot in a node from a Starlark value.
Any slot accepts:
- A promise (Output): creates an edge, value flows at runtime
- A gather (Gather): creates edges from all members (parallel execution)
- An immediate value: stored directly, known at analysis time
func MakeAttr ¶
func MakeAttr(name string, fn BuiltinFunc) starlark.Value
MakeAttr creates a starlark.Builtin from a receiver method.
func NoSuchAttrError ¶
NoSuchAttrError returns an error for an unknown attribute.
Types ¶
type ArchivePlan ¶
type ArchivePlan struct {
Receiver
// contains filtered or unexported fields
}
ArchivePlan implements plan.archive.* bindings using the slot-based model.
func NewArchivePlan ¶
func NewArchivePlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *ArchivePlan
NewArchivePlan creates a new ArchivePlan for the given graph and host.
func (*ArchivePlan) Attr ¶
func (a *ArchivePlan) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*ArchivePlan) AttrNames ¶
func (a *ArchivePlan) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type ArchiveReceiver ¶
type ArchiveReceiver struct {
Receiver
// contains filtered or unexported fields
}
func NewArchiveReceiver ¶
func NewArchiveReceiver(provider *archive.Provider, output io.Writer) *ArchiveReceiver
func (*ArchiveReceiver) AttrNames ¶
func (r *ArchiveReceiver) AttrNames() []string
type Bindings ¶
type Bindings struct {
// contains filtered or unexported fields
}
Bindings provides lore's host API to Starlark scripts.
func NewBindings ¶
NewBindings creates a new Bindings instance.
func (*Bindings) Globals ¶
func (b *Bindings) Globals() starlark.StringDict
Globals returns the predeclared globals for Starlark scripts.
type BuiltinFunc ¶
type BuiltinFunc func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
BuiltinFunc is the signature for builtin function implementations.
type ContentPlan ¶
type ContentPlan struct {
Receiver
// contains filtered or unexported fields
}
ContentPlan implements plan.content.* bindings using the slot-based model.
func NewContentPlan ¶
func NewContentPlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *ContentPlan
NewContentPlan creates a new ContentPlan for the given graph and host.
func (*ContentPlan) Attr ¶
func (c *ContentPlan) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*ContentPlan) AttrNames ¶
func (c *ContentPlan) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type DockerReceiver ¶
type DockerReceiver struct {
Receiver
// contains filtered or unexported fields
}
DockerReceiver provides the docker.* Starlark namespace.
Backing implementation: os/exec (exec.Command("docker", ...)). Uses kwargs pass-through: any keyword argument is converted to a CLI flag.
Example:
docker.run("nginx", detach=True, name="web", publish=["80:80"])
# Executes: docker run --detach --name web --publish 80:80 nginx
func NewDockerReceiver ¶
func NewDockerReceiver(output io.Writer) *DockerReceiver
NewDockerReceiver creates a new docker receiver.
func (*DockerReceiver) Attr ¶
func (d *DockerReceiver) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*DockerReceiver) AttrNames ¶
func (d *DockerReceiver) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type EncryptionPlan ¶
type EncryptionPlan struct {
Receiver
// contains filtered or unexported fields
}
EncryptionPlan implements plan.encryption.* bindings using the slot-based model.
func NewEncryptionPlan ¶
func NewEncryptionPlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *EncryptionPlan
NewEncryptionPlan creates a new EncryptionPlan for the given graph and host.
func (*EncryptionPlan) Attr ¶
func (e *EncryptionPlan) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*EncryptionPlan) AttrNames ¶
func (e *EncryptionPlan) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type EnvReceiver ¶
type EnvReceiver struct {
Receiver
}
EnvReceiver provides the env.* Starlark namespace.
Backing implementation: os package (Getenv, Setenv, ExpandEnv). No backing struct — delegates directly to the standard library.
func (*EnvReceiver) Attr ¶
func (r *EnvReceiver) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*EnvReceiver) AttrNames ¶
func (r *EnvReceiver) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type FilePlan ¶
type FilePlan struct {
Receiver
// contains filtered or unexported fields
}
FilePlan implements plan.file.* bindings using the slot-based model. Each method adds a node to the execution graph.
func NewFilePlan ¶
func NewFilePlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *FilePlan
NewFilePlan creates a new FilePlan for the given graph and host.
type FileReceiver ¶
type FileReceiver struct {
Receiver
// contains filtered or unexported fields
}
func NewFileReceiver ¶
func NewFileReceiver(provider *file.Provider, output io.Writer) *FileReceiver
func (*FileReceiver) AttrNames ¶
func (r *FileReceiver) AttrNames() []string
type Gather ¶
type Gather struct {
// contains filtered or unexported fields
}
Gather represents a collection of outputs that can run in parallel. When used as a slot input, it creates edges from ALL members to the consumer, enabling parallel execution of the gathered nodes.
Usage in Starlark:
a = plan.file.copy(src1, dst1) b = plan.file.copy(src2, dst2) c = plan.file.copy(src3, dst3) group = plan.gather(a, b, c) d = plan.whatever(group) # d waits for a, b, c (which run in parallel)
type GitPlan ¶
type GitPlan struct {
Receiver
// contains filtered or unexported fields
}
GitPlan implements plan.git.* bindings using the slot-based model.
func NewGitPlan ¶
func NewGitPlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *GitPlan
NewGitPlan creates a new GitPlan for the given graph and host.
type GitReceiver ¶
type GitReceiver struct {
Receiver
// contains filtered or unexported fields
}
GitReceiver provides the git.* Starlark namespace. Forward operations (clone, checkout, pull) delegate to git.Provider. All other operations use kwargs pass-through via exec.Command("git", ...).
func NewGitReceiver ¶
func NewGitReceiver(provider *git.Provider, output io.Writer) *GitReceiver
NewGitReceiver creates a new git receiver.
func (*GitReceiver) AttrNames ¶
func (r *GitReceiver) AttrNames() []string
type LogReceiver ¶
type LogReceiver struct {
Receiver
// contains filtered or unexported fields
}
LogReceiver provides the log.* Starlark namespace and root-level output functions (note, warn, error, success, fail).
Backing implementation: io.Writer. Bound to root as both the "log" namespace and as individual builtins.
func NewLogReceiver ¶
func NewLogReceiver(output io.Writer) *LogReceiver
NewLogReceiver creates a new log receiver.
func (*LogReceiver) Attr ¶
func (r *LogReceiver) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*LogReceiver) AttrNames ¶
func (r *LogReceiver) AttrNames() []string
AttrNames implements starlark.HasAttrs.
func (*LogReceiver) OutputGlobals ¶
func (r *LogReceiver) OutputGlobals() starlark.StringDict
OutputGlobals returns a StringDict containing the log receiver and all root-level output function builtins. Used by the lore builder to inject output functions into the script environment.
type NetPlan ¶
type NetPlan struct {
Receiver
// contains filtered or unexported fields
}
NetPlan implements plan.net.* bindings using the slot-based model.
func NewNetPlan ¶
func NewNetPlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *NetPlan
NewNetPlan creates a new NetPlan for the given graph and host.
type NetReceiver ¶
type NetReceiver struct {
Receiver
// contains filtered or unexported fields
}
NetReceiver provides the net.* Starlark namespace. Forward operations (download) delegate to net.Provider. Query operations (get) perform read-only HTTP requests directly.
func NewNetReceiver ¶
func NewNetReceiver(provider *net.Provider, output io.Writer) *NetReceiver
NewNetReceiver creates a new net receiver.
func (*NetReceiver) AttrNames ¶
func (r *NetReceiver) AttrNames() []string
type NpmReceiver ¶
type NpmReceiver struct {
Receiver
// contains filtered or unexported fields
}
NpmReceiver provides the npm.* Starlark namespace.
Backing implementation: os/exec (exec.Command("npm", ...), exec.Command("npx", ...)). Uses kwargs pass-through: any keyword argument is converted to a CLI flag.
Example:
npm.install("astro", "tailwind", global=True, save_dev=True)
# Executes: npm install --global --save-dev astro tailwind
func NewNpmReceiver ¶
func NewNpmReceiver(output io.Writer) *NpmReceiver
NewNpmReceiver creates a new npm receiver.
func (*NpmReceiver) Attr ¶
func (n *NpmReceiver) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*NpmReceiver) AttrNames ¶
func (n *NpmReceiver) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
Output represents a promise - a handle to a node's output that can flow through the graph to fill slots in other nodes.
When passed to a plan function's slot, it creates an edge in the graph. The same promise can flow to multiple slots (fan-out).
func ResolveInput ¶
ResolveInput extracts an *Output from a Starlark value. Returns an error if the value is not an Output.
func (*Output) DependOn ¶
DependOn creates an edge making the given node depend on this output's node.
func (*Output) FillSlot ¶
FillSlot fills a slot in the consumer node with this promise, creating an edge. This is called when a promise is passed to a plan function.
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 PackagePlan ¶
type PackagePlan struct {
Receiver
// contains filtered or unexported fields
}
PackagePlan implements plan.package.* bindings using the slot-based model. Each method adds a node to the execution graph.
Package names may include manager prefixes (brew:pkg, cask:pkg, port:pkg) for platform-specific package manager overrides.
func NewPackagePlan ¶
func NewPackagePlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *PackagePlan
NewPackagePlan creates a new PackagePlan for the given graph and host.
func (*PackagePlan) Attr ¶
func (p *PackagePlan) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*PackagePlan) AttrNames ¶
func (p *PackagePlan) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type PackageReceiver ¶
type PackageReceiver struct {
Receiver
// contains filtered or unexported fields
}
PackageReceiver provides the package.* Starlark namespace. Forward operations (install, upgrade, remove, update) delegate to pkg.Provider. Query operations (manager, installed, version, feature, setting) use the platform's PackageManager and manifest data directly.
func NewPackageReceiver ¶
func NewPackageReceiver(pm host.PackageManager, features []string, settings map[string]string, output io.Writer) *PackageReceiver
NewPackageReceiver creates a new package receiver.
func (*PackageReceiver) AttrNames ¶
func (r *PackageReceiver) AttrNames() []string
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 *execution.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")
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. It provides access to sub-namespaces (package, file, template, encryption, archive, git, service, shell, net, content) and top-level bindings (source, gather).
func NewPlanRoot ¶
func NewPlanRoot(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *PlanRoot
NewPlanRoot creates a new PlanRoot for the given graph and host.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver provides common implementations for Starlark binding namespaces. Embed this in concrete types to satisfy starlark.Value. Concrete types must implement starlark.HasAttrs (Attr and AttrNames) themselves.
func NewReceiver ¶
NewReceiver creates a new Receiver with the given namespace name.
type RuntimePredicate ¶
type RuntimePredicate struct {
// contains filtered or unexported fields
}
RuntimePredicate is a predicate that evaluates at execution time. It implements both execution.Predicate (for Choose) and starlark.Value (for passing through Starlark scripts).
func (*RuntimePredicate) Eval ¶
func (p *RuntimePredicate) Eval(value any) (bool, error)
execution.Predicate interface
func (*RuntimePredicate) Freeze ¶
func (p *RuntimePredicate) Freeze()
func (*RuntimePredicate) Hash ¶
func (p *RuntimePredicate) Hash() (uint32, error)
func (*RuntimePredicate) String ¶
func (p *RuntimePredicate) String() string
Starlark Value interface
func (*RuntimePredicate) Truth ¶
func (p *RuntimePredicate) Truth() starlark.Bool
func (*RuntimePredicate) Type ¶
func (p *RuntimePredicate) Type() string
type ServicePlan ¶
type ServicePlan struct {
Receiver
// contains filtered or unexported fields
}
ServicePlan implements plan.service.* bindings using the slot-based model. Each method adds a service management node to the execution graph.
func NewServicePlan ¶
func NewServicePlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *ServicePlan
NewServicePlan creates a new ServicePlan for the given graph and host.
func (*ServicePlan) Attr ¶
func (s *ServicePlan) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*ServicePlan) AttrNames ¶
func (s *ServicePlan) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type ServiceReceiver ¶
type ServiceReceiver struct {
Receiver
// contains filtered or unexported fields
}
ServiceReceiver provides the service.* Starlark namespace. Forward operations (start, stop, restart, enable, disable) delegate to service.Provider. Query operations (exists, status) use the platform's ServiceManager directly.
func NewServiceReceiver ¶
func NewServiceReceiver(sm host.ServiceManager, output io.Writer) *ServiceReceiver
NewServiceReceiver creates a new service receiver.
func (*ServiceReceiver) AttrNames ¶
func (r *ServiceReceiver) AttrNames() []string
type ShellPlan ¶
type ShellPlan struct {
Receiver
// contains filtered or unexported fields
}
ShellPlan implements plan.shell.* bindings using the slot-based model.
func NewShellPlan ¶
func NewShellPlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *ShellPlan
NewShellPlan creates a new ShellPlan for the given graph and host.
type ShellReceiver ¶
type ShellReceiver struct {
Receiver
// contains filtered or unexported fields
}
ShellReceiver provides the shell.* Starlark namespace. Forward operations (exec, run) delegate to shell.Provider. Query operations (which) use os/exec directly.
func NewShellReceiver ¶
func NewShellReceiver(provider *shell.Provider, output io.Writer) *ShellReceiver
NewShellReceiver creates a new shell receiver.
func (*ShellReceiver) Attr ¶
func (r *ShellReceiver) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*ShellReceiver) AttrNames ¶
func (r *ShellReceiver) AttrNames() []string
AttrNames implements starlark.HasAttrs.
type TemplatePlan ¶
type TemplatePlan struct {
Receiver
// contains filtered or unexported fields
}
TemplatePlan implements plan.template.* bindings using the slot-based model.
func NewTemplatePlan ¶
func NewTemplatePlan(graph *execution.Graph, h host.Host, project string, reg *execution.ActionRegistry) *TemplatePlan
NewTemplatePlan creates a new TemplatePlan for the given graph and host.
func (*TemplatePlan) Attr ¶
func (t *TemplatePlan) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*TemplatePlan) AttrNames ¶
func (t *TemplatePlan) AttrNames() []string
AttrNames implements starlark.HasAttrs.
Source Files
¶
- bindings.go
- interfaces.go
- output.go
- package.go
- phase_context.go
- plan.go
- plan_archive_gen.go
- plan_content_gen.go
- plan_encryption_gen.go
- plan_file_gen.go
- plan_git_gen.go
- plan_net_gen.go
- plan_package_gen.go
- plan_root.go
- plan_service_gen.go
- plan_shell_gen.go
- plan_template_gen.go
- predicate_runtime.go
- receiver.go
- receiver_archive_gen.go
- receiver_docker.go
- receiver_env.go
- receiver_file_gen.go
- receiver_git_gen.go
- receiver_git_queries.go
- receiver_log.go
- receiver_net_gen.go
- receiver_net_queries.go
- receiver_npm.go
- receiver_package_gen.go
- receiver_package_queries.go
- receiver_service_gen.go
- receiver_service_queries.go
- receiver_shell.go