Documentation
¶
Overview ¶
Package starlark provides the Starlark runtime and host bindings for lore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 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 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 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() *engine.Graph
// PackageInstall adds a package installation node.
PackageInstall(packages ...string) *engine.Node
// PackageUpgrade adds a package upgrade node.
PackageUpgrade(packages ...string) *engine.Node
// PackageRemove adds a package removal node.
PackageRemove(packages ...string) *engine.Node
// PackageUpdate adds a package index update node.
PackageUpdate() *engine.Node
// Configure adds a configuration file node (template expansion + copy).
Configure(source, target string) *engine.Node
// Link adds a symlink creation node.
Link(source, target string) *engine.Node
// Copy adds a file copy node.
Copy(source, target string) *engine.Node
// Mkdir adds a directory creation node.
Mkdir(target string) *engine.Node
// Service adds a service management node.
Service(name string, action ServiceAction) *engine.Node
// Shell adds a shell command execution node.
Shell(command string) *engine.Node
// DependsOn creates a dependency edge between nodes.
// The 'from' node will execute after the 'to' node completes.
DependsOn(from, to *engine.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 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 struct. Exposed to phase scripts as the third argument.
Starlark API uses nested structs:
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.mkdir(target) # Create directory
plan.service(name, action) # Manage service
plan.shell(command) # Run shell command
plan.depends_on(from, to) # 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.