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
- type ArchivePlan
- func (a *ArchivePlan) Attr(name string) (starlark.Value, error)
- func (a *ArchivePlan) AttrNames() []string
- func (a *ArchivePlan) Freeze()
- func (a *ArchivePlan) Hash() (uint32, error)
- func (a *ArchivePlan) String() string
- func (a *ArchivePlan) Truth() starlark.Bool
- func (a *ArchivePlan) Type() string
- type Bindings
- type DockerBindings
- type FilePlan
- type Gather
- type GitBindings
- type GitPlan
- type NpmBindings
- 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
- func (p *PackagePlan) Attr(name string) (starlark.Value, error)
- func (p *PackagePlan) AttrNames() []string
- func (p *PackagePlan) Freeze()
- func (p *PackagePlan) Hash() (uint32, error)
- func (p *PackagePlan) String() string
- func (p *PackagePlan) Truth() starlark.Bool
- func (p *PackagePlan) Type() string
- type PackageQueries
- type PlanBindings
- type PlanRoot
- type ServiceAction
- type ServiceQueries
- type StarlarkPlanBindings
- type SystemBindings
- type SystemFile
- type SystemGit
- type SystemPackage
- func (p *SystemPackage) Attr(name string) (starlark.Value, error)
- func (p *SystemPackage) AttrNames() []string
- func (p *SystemPackage) Freeze()
- func (p *SystemPackage) Hash() (uint32, error)
- func (p *SystemPackage) String() string
- func (p *SystemPackage) Truth() starlark.Bool
- func (p *SystemPackage) Type() string
- type SystemRoot
- type SystemService
- func (s *SystemService) Attr(name string) (starlark.Value, error)
- func (s *SystemService) AttrNames() []string
- func (s *SystemService) Freeze()
- func (s *SystemService) Hash() (uint32, error)
- func (s *SystemService) String() string
- func (s *SystemService) Truth() starlark.Bool
- func (s *SystemService) Type() string
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
Types ¶
type ArchivePlan ¶
type ArchivePlan struct {
// contains filtered or unexported fields
}
ArchivePlan implements plan.archive.* bindings using the slot-based model.
func NewArchivePlan ¶
NewArchivePlan creates a new ArchivePlan for the given graph and host.
func (*ArchivePlan) Attr ¶
func (a *ArchivePlan) Attr(name string) (starlark.Value, error)
Starlark HasAttrs interface
func (*ArchivePlan) AttrNames ¶
func (a *ArchivePlan) AttrNames() []string
func (*ArchivePlan) Freeze ¶
func (a *ArchivePlan) Freeze()
func (*ArchivePlan) Hash ¶
func (a *ArchivePlan) Hash() (uint32, error)
func (*ArchivePlan) Truth ¶
func (a *ArchivePlan) Truth() starlark.Bool
func (*ArchivePlan) Type ¶
func (a *ArchivePlan) Type() 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.
func (*Bindings) UpdateFeatures ¶
UpdateFeatures allows changing features after creation.
func (*Bindings) UpdateSettings ¶
UpdateSettings allows changing settings after creation.
type DockerBindings ¶
type DockerBindings struct {
// contains filtered or unexported fields
}
DockerBindings provides the docker.* API to Starlark scripts.
Uses kwargs pass-through: any keyword argument is converted to a CLI flag. This means all docker flags work automatically without explicit binding code.
Example:
docker.run("nginx", detach=True, name="web", publish=["80:80"])
# Executes: docker run --detach --name web --publish 80:80 nginx
func NewDockerBindings ¶
func NewDockerBindings(b *Bindings) *DockerBindings
NewDockerBindings creates docker bindings attached to the parent bindings.
func (*DockerBindings) Struct ¶
func (d *DockerBindings) Struct() *starlarkstruct.Struct
Struct returns the docker.* namespace for Starlark.
type FilePlan ¶
type FilePlan struct {
// contains filtered or unexported fields
}
FilePlan implements plan.file.* bindings using the slot-based model. Each method adds a node to the execution graph.
Slots can be filled with either: - Immediate values (strings known at analysis time) - Promises (Output handles that create edges)
func NewFilePlan ¶
NewFilePlan creates a new FilePlan for the given graph and host.
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 GitBindings ¶
type GitBindings struct {
// contains filtered or unexported fields
}
GitBindings provides the git.* API to Starlark scripts.
Uses kwargs pass-through: any keyword argument is converted to a CLI flag. This means all git flags work automatically without explicit binding code.
Example:
git.clone("https://github.com/user/repo", depth=1, branch="main")
# Executes: git clone --depth 1 --branch main https://github.com/user/repo
func NewGitBindings ¶
func NewGitBindings(b *Bindings) *GitBindings
NewGitBindings creates git bindings attached to the parent bindings.
func (*GitBindings) Struct ¶
func (g *GitBindings) Struct() *starlarkstruct.Struct
Struct returns the git.* namespace for Starlark.
type GitPlan ¶
type GitPlan struct {
// contains filtered or unexported fields
}
GitPlan implements plan.git.* bindings using the slot-based model.
func NewGitPlan ¶
NewGitPlan creates a new GitPlan for the given graph and host.
type NpmBindings ¶
type NpmBindings struct {
// contains filtered or unexported fields
}
NpmBindings provides the npm.* API to Starlark scripts.
Uses kwargs pass-through: any keyword argument is converted to a CLI flag. This means all npm flags work automatically without explicit binding code.
Example:
npm.install("astro", "tailwind", global=True, save_dev=True)
# Executes: npm install --global --save-dev astro tailwind
func NewNpmBindings ¶
func NewNpmBindings(b *Bindings) *NpmBindings
NewNpmBindings creates npm bindings attached to the parent bindings.
func (*NpmBindings) Struct ¶
func (n *NpmBindings) Struct() *starlarkstruct.Struct
Struct returns the npm.* namespace for Starlark.
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 second 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 struct. Exposed to phase scripts as the second argument.
Starlark API:
package.name # string: package name package.version # string: package version package.features # list[string]: enabled features package.settings # dict[string, string]: key-value settings package.dry_run # bool: true if this is a preview package.source_root # string: package source directory package.target_root # string: deployment target directory package.has_feature(name) # bool: check if feature is enabled package.setting(key, default="") # string: get setting value
type PackagePlan ¶
type PackagePlan struct {
// contains filtered or unexported fields
}
PackagePlan implements plan.package.* bindings using the slot-based model. Each method adds a node to the execution graph.
func NewPackagePlan ¶
NewPackagePlan creates a new PackagePlan for the given graph and host.
func (*PackagePlan) Attr ¶
func (p *PackagePlan) Attr(name string) (starlark.Value, error)
Starlark HasAttrs interface
func (*PackagePlan) AttrNames ¶
func (p *PackagePlan) AttrNames() []string
func (*PackagePlan) Freeze ¶
func (p *PackagePlan) Freeze()
func (*PackagePlan) Hash ¶
func (p *PackagePlan) Hash() (uint32, error)
func (*PackagePlan) Truth ¶
func (p *PackagePlan) Truth() starlark.Bool
func (*PackagePlan) Type ¶
func (p *PackagePlan) Type() string
type PackageQueries ¶
type PackageQueries interface {
// Installed checks if a package is installed.
Installed(name string) bool
// Version returns the installed version of a package, or empty string if not installed.
Version(name string) string
}
PackageQueries provides read-only package manager queries.
type PlanBindings ¶
type PlanBindings interface {
// Graph returns the underlying execution graph being built.
Graph() *execution.Graph
// Host returns the host abstraction for path expansion, etc.
Host() host.Host
// Project returns the project name for grouping nodes.
Project() string
// PackageInstall adds a package installation node.
PackageInstall(packages ...string) *execution.Node
// PackageUpgrade adds a package upgrade node.
PackageUpgrade(packages ...string) *execution.Node
// PackageRemove adds a package removal node.
PackageRemove(packages ...string) *execution.Node
// PackageUpdate adds a package index update node.
PackageUpdate() *execution.Node
// Configure adds a configuration file node (template expansion + copy).
Configure(source, target string) *execution.Node
// Link adds a symlink creation node.
Link(source, target string) *execution.Node
// Copy adds a file copy node.
Copy(source, target string) *execution.Node
// Write adds a file write node (write content directly to target).
Write(target, content string) *execution.Node
// Remove adds a file/directory removal node.
Remove(target string) *execution.Node
// Download adds a file download node.
Download(url, target string) *execution.Node
// ArchiveExtract adds an archive extraction node.
ArchiveExtract(archive, target string) *execution.Node
// GitClone adds a git clone node.
GitClone(url, target string) *execution.Node
// GitCheckout adds a git checkout node.
GitCheckout(ref string) *execution.Node
// GitPull adds a git pull node.
GitPull() *execution.Node
// Service adds a service management node.
Service(name string, action ServiceAction) *execution.Node
// Shell adds a shell command execution node.
Shell(command string) *execution.Node
// DependsOn creates a dependency edge between nodes.
// The 'from' node will execute after the 'to' node completes.
DependsOn(from, to *execution.Node)
}
PlanBindings provides operations that add nodes to the execution graph. Each method returns the created node for chaining or dependency specification.
Note: Go method names are simple (Install, Remove, etc.) while Starlark uses nested structs (plan.package.install, plan.file.copy) and engine operations use namespaced names (package-install, package-remove).
func NewPlanBindings ¶
NewPlanBindings creates a new PlanBindings for the given graph and host.
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, archive, git) and top-level bindings (source, literal, download, service, shell, depends_on).
func NewPlanRoot ¶
NewPlanRoot creates a new PlanRoot for the given graph and host.
type ServiceAction ¶
type ServiceAction int
ServiceAction represents a service management action.
const ( // ServiceStart starts a service. ServiceStart ServiceAction = iota // ServiceStop stops a service. ServiceStop // ServiceRestart restarts a service. ServiceRestart // ServiceEnable enables a service at boot. ServiceEnable // ServiceDisable disables a service at boot. ServiceDisable )
func (ServiceAction) String ¶
func (a ServiceAction) String() string
String returns the action name.
type ServiceQueries ¶
type ServiceQueries interface {
// Exists checks if a service exists.
Exists(name string) bool
// Running checks if a service is currently running.
Running(name string) bool
// Enabled checks if a service is enabled at boot.
Enabled(name string) bool
}
ServiceQueries provides read-only service manager queries.
type StarlarkPlanBindings ¶
type StarlarkPlanBindings struct {
PlanBindings
}
StarlarkPlanBindings wraps PlanBindings for Starlark conversion.
func (*StarlarkPlanBindings) ToStarlark ¶
func (s *StarlarkPlanBindings) ToStarlark() starlark.Value
ToStarlark converts the plan bindings to a Starlark value. Exposed to phase scripts as the third argument.
All namespaces use the Attr receiver pattern for consistency and static analysis support. Starlark API:
plan.package.install("pkg1", "pkg2", ...) # Install packages
plan.package.upgrade("pkg1", ...) # Upgrade packages
plan.package.remove("pkg1", ...) # Remove packages
plan.package.update() # Update package index
plan.file.configure(source, target) # Configure file (template + copy)
plan.file.link(source, target) # Create symlink
plan.file.copy(source, target) # Copy file
plan.file.write(target, content) # Write content to file
plan.file.remove(target) # Remove file/directory
plan.archive.extract(archive, prefix) # Extract archive
plan.git.clone(url, path) # Clone repository
plan.git.checkout(repo, ref) # Checkout ref
plan.git.pull(repo) # Pull changes
plan.source(path) # Declare source file
plan.literal(content) # Inline content
plan.download(url) # Download file
plan.service(name, action) # Manage service
plan.shell(command) # Run shell command
plan.depends_on(consumer, producer) # Create dependency
type SystemBindings ¶
type SystemBindings interface {
// Platform returns information about the current system.
Platform() host.Platform
// Package provides package manager queries.
Package() PackageQueries
// Service provides service manager queries.
Service() ServiceQueries
// ToStarlark converts the system bindings to a Starlark value.
ToStarlark() starlark.Value
}
SystemBindings provides read-only queries about the current platform state. Wraps host.Host to expose platform information to phase scripts.
func NewSystemBindings ¶
func NewSystemBindings(h host.Host) SystemBindings
NewSystemBindings creates a new SystemBindings from a host.Host.
type SystemFile ¶
type SystemFile struct {
// contains filtered or unexported fields
}
SystemFile implements system.file.* bindings for filesystem queries. These are immediate queries - they execute during analysis, not deferred.
func NewSystemFile ¶
func NewSystemFile(h host.Host) *SystemFile
NewSystemFile creates a new SystemFile for the given host.
func (*SystemFile) Attr ¶
func (f *SystemFile) Attr(name string) (starlark.Value, error)
Starlark HasAttrs interface
func (*SystemFile) AttrNames ¶
func (f *SystemFile) AttrNames() []string
func (*SystemFile) Freeze ¶
func (f *SystemFile) Freeze()
func (*SystemFile) Hash ¶
func (f *SystemFile) Hash() (uint32, error)
func (*SystemFile) Truth ¶
func (f *SystemFile) Truth() starlark.Bool
func (*SystemFile) Type ¶
func (f *SystemFile) Type() string
type SystemGit ¶
type SystemGit struct{}
SystemGit implements system.git.* bindings for git queries. These are immediate queries - they execute during analysis, not deferred.
type SystemPackage ¶
type SystemPackage struct {
// contains filtered or unexported fields
}
SystemPackage implements system.package.* bindings for package manager queries. These are immediate queries - they execute during analysis, not deferred.
func NewSystemPackage ¶
func NewSystemPackage(pm host.PackageManager) *SystemPackage
NewSystemPackage creates a new SystemPackage for the given package manager.
func (*SystemPackage) Attr ¶
func (p *SystemPackage) Attr(name string) (starlark.Value, error)
Starlark HasAttrs interface
func (*SystemPackage) AttrNames ¶
func (p *SystemPackage) AttrNames() []string
func (*SystemPackage) Freeze ¶
func (p *SystemPackage) Freeze()
func (*SystemPackage) Hash ¶
func (p *SystemPackage) Hash() (uint32, error)
func (*SystemPackage) Truth ¶
func (p *SystemPackage) Truth() starlark.Bool
func (*SystemPackage) Type ¶
func (p *SystemPackage) Type() string
type SystemRoot ¶
type SystemRoot struct {
// contains filtered or unexported fields
}
SystemRoot implements the top-level system namespace using the Attr receiver pattern. It provides access to sub-namespaces (package, service, git, file) and the platform struct.
Unlike plan.*, system.* bindings query current system state immediately rather than building an execution graph.
func NewSystemRoot ¶
func NewSystemRoot(h host.Host) *SystemRoot
NewSystemRoot creates a new SystemRoot for the given host.
func (*SystemRoot) Attr ¶
func (s *SystemRoot) Attr(name string) (starlark.Value, error)
Starlark HasAttrs interface
func (*SystemRoot) AttrNames ¶
func (s *SystemRoot) AttrNames() []string
func (*SystemRoot) Freeze ¶
func (s *SystemRoot) Freeze()
func (*SystemRoot) Hash ¶
func (s *SystemRoot) Hash() (uint32, error)
func (*SystemRoot) Truth ¶
func (s *SystemRoot) Truth() starlark.Bool
func (*SystemRoot) Type ¶
func (s *SystemRoot) Type() string
type SystemService ¶
type SystemService struct {
// contains filtered or unexported fields
}
SystemService implements system.service.* bindings for service manager queries. These are immediate queries - they execute during analysis, not deferred.
func NewSystemService ¶
func NewSystemService(sm host.ServiceManager) *SystemService
NewSystemService creates a new SystemService for the given service manager.
func (*SystemService) Attr ¶
func (s *SystemService) Attr(name string) (starlark.Value, error)
Starlark HasAttrs interface
func (*SystemService) AttrNames ¶
func (s *SystemService) AttrNames() []string
func (*SystemService) Freeze ¶
func (s *SystemService) Freeze()
func (*SystemService) Hash ¶
func (s *SystemService) Hash() (uint32, error)
func (*SystemService) Truth ¶
func (s *SystemService) Truth() starlark.Bool
func (*SystemService) Type ¶
func (s *SystemService) Type() string