Documentation
¶
Overview ¶
Package registry provides the client interface for accessing the devlore registry. It abstracts the underlying transport (git for demo, OCI for scale) and provides a sync-based API where the registry is cloned/pulled locally and accessed from cache.
Index ¶
- Variables
- func PhaseOrder(op Operation) []string
- func PlatformResolutionOrder(platform string) []string
- func RequiredPhase(op Operation) string
- type Client
- func (c *Client) AIExamples(name string) ([]byte, error)
- func (c *Client) AIPrompt(name string) (string, error)
- func (c *Client) AISchema(name string) ([]byte, error)
- func (c *Client) CacheDir() string
- func (c *Client) Exists() bool
- func (c *Client) FileExists(relPath string) bool
- func (c *Client) FilePath(relPath string) string
- func (c *Client) MigrationGuide(system string) ([]byte, error)
- func (c *Client) Open(relPath string) (io.ReadCloser, error)
- func (c *Client) ReadDir(relPath string) ([]os.DirEntry, error)
- func (c *Client) ReadFile(relPath string) ([]byte, error)
- func (c *Client) Resolve(name string, platform string) (*LorePackage, error)
- func (c *Client) Sync(ctx context.Context, opts SyncOptions) (*SyncResult, error)
- func (c *Client) SyncInfo() (*SyncInfo, error)
- type Feature
- type GitProvider
- type HardwareProvision
- type Lifecycle
- func (l *Lifecycle) DiscoverAllPhases(packageDir, platform string, op Operation) map[string][]string
- func (l *Lifecycle) DiscoverPhaseScripts(packageDir, platform string, op Operation, phase string) []string
- func (l *Lifecycle) EnabledFeatures(explicit []string) []string
- func (l *Lifecycle) GetPhaseScript(packageDir, platform string, op Operation, phase string) string
- func (l *Lifecycle) HasPhase(packageDir, platform string, op Operation, phase string) bool
- func (l *Lifecycle) IsSynthetic() bool
- func (l *Lifecycle) ResolvedSettings(explicit map[string]string) map[string]string
- func (l *Lifecycle) SupportsPlatform(platform string) bool
- type LorePackage
- func (p *LorePackage) DiscoverPhaseScripts(platform string, op Operation, phase string) []string
- func (p *LorePackage) HasPhase(platform string, op Operation, phase string) bool
- func (p *LorePackage) IsNative() bool
- func (p *LorePackage) IsSynthetic() bool
- func (p *LorePackage) Lifecycle() *Lifecycle
- func (p *LorePackage) PhaseActions(platform string, op Operation, phase string) []PhaseAction
- type NativePMAction
- type Operation
- type PMOperation
- type PackageSource
- type PhaseAction
- type PhaseActionType
- type Provider
- type ScriptAction
- type Setting
- type SyncInfo
- type SyncOptions
- type SyncResult
Constants ¶
This section is empty.
Variables ¶
var DecommissionPhaseOrder = []string{"unprovision", "uninstall", "cleanup"}
DecommissionPhaseOrder is the order for decommission operations.
var DeployPhaseOrder = []string{"prepare", "install", "provision", "verify"}
DeployPhaseOrder is the standard order of deploy pipeline phases.
var LifecycleSchema []byte
LifecycleSchema is the JSON schema for lifecycle.yaml files. These files define lore package metadata. Phase scripts are discovered from the directory structure (see RFC Section 9.3).
var UpgradePhaseOrder = []string{"prepare", "upgrade", "migrate", "verify"}
UpgradePhaseOrder is the order for upgrade operations. The "migrate" phase handles version-specific migrations (config format changes, data migrations, etc.) that may be needed between versions.
Functions ¶
func PhaseOrder ¶
PhaseOrder returns the phase order for an operation.
func PlatformResolutionOrder ¶
PlatformResolutionOrder returns the order of platform directories for phase script chaining, from most general to most specific.
Scripts are executed in this order, allowing specific platforms to build upon general setup. Each script that exists is executed.
Examples:
- "Linux.Debian" → ["Common", "Unix", "Linux", "Linux.Debian"]
- "Darwin" → ["Common", "Unix", "Darwin"]
- "Windows" → ["Common", "Windows"]
func RequiredPhase ¶
RequiredPhase returns the required phase for an operation. Each operation has exactly one required phase that must be implemented. Native PM packages implement only this phase; lore packages may add others.
- Deploy requires "install"
- Upgrade requires "upgrade"
- Decommission requires "uninstall"
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides access to a devlore registry.
func NewDefault ¶
NewDefault creates a registry client with default settings for the central registry. Uses the develop branch during demo phase (AI assets and latest packages).
func (*Client) AIExamples ¶
AIExamples reads an AI examples file from the cache.
func (*Client) FileExists ¶
FileExists returns true if the file exists in the cache.
func (*Client) MigrationGuide ¶
MigrationGuide reads a migration guide from the cache.
func (*Client) Open ¶
func (c *Client) Open(relPath string) (io.ReadCloser, error)
Open opens a file from the cache for reading.
func (*Client) Resolve ¶
func (c *Client) Resolve(name string, platform string) (*LorePackage, error)
Resolve looks up a package by name in the registry. It checks the lore registry first, then falls back to native package managers.
func (*Client) Sync ¶
func (c *Client) Sync(ctx context.Context, opts SyncOptions) (*SyncResult, error)
Sync updates the local cache from the remote registry.
type Feature ¶
type Feature struct {
Description string `yaml:"description"`
Default bool `yaml:"default"`
Platforms []string `yaml:"platforms,omitempty"`
}
Feature represents a package feature definition.
type GitProvider ¶
type GitProvider struct {
// contains filtered or unexported fields
}
GitProvider implements the Provider interface using git. This is the demo-phase provider per ADR-014.
func NewGitProvider ¶
func NewGitProvider(repoURL, branch string) *GitProvider
NewGitProvider creates a new git-based registry provider.
func (*GitProvider) Sync ¶
func (g *GitProvider) Sync(ctx context.Context, cacheDir string, opts SyncOptions) (*SyncResult, error)
Sync clones or updates the registry cache. Per ADR-014, uses shallow clone and hard reset (cache semantics, not workspace).
type HardwareProvision ¶
type HardwareProvision struct {
Description string `yaml:"description"`
Reference string `yaml:"reference,omitempty"`
BootArg string `yaml:"boot_arg,omitempty"`
}
HardwareProvision defines hardware-specific configuration.
type Lifecycle ¶
type Lifecycle struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Description string `yaml:"description"`
Homepage string `yaml:"homepage,omitempty"`
Repository string `yaml:"repository,omitempty"`
License string `yaml:"license,omitempty"`
Maintainer string `yaml:"maintainer,omitempty"`
Aliases []string `yaml:"aliases,omitempty"`
Platforms []string `yaml:"platforms"`
Provides []string `yaml:"provides,omitempty"`
Conflicts []string `yaml:"conflicts,omitempty"`
Features map[string]Feature `yaml:"features,omitempty"`
Settings map[string]Setting `yaml:"settings,omitempty"`
Tags []string `yaml:"tags,omitempty"`
Notes string `yaml:"notes,omitempty"`
// Verification defines how to verify the installation.
Verification struct {
Command string `yaml:"command,omitempty"`
Pattern string `yaml:"pattern,omitempty"`
} `yaml:"verification,omitempty"`
// HardwareProvisions defines hardware-specific configuration requirements.
HardwareProvisions map[string]HardwareProvision `yaml:"hardware_provisions,omitempty"`
// contains filtered or unexported fields
}
Lifecycle represents a lore package's lifecycle manifest. This is loaded from lifecycle.yaml in the package directory. Phase scripts are discovered from the directory structure, not from YAML.
func LoadLifecycle ¶
LoadLifecycle loads a lifecycle manifest from a package directory.
func (*Lifecycle) DiscoverAllPhases ¶
func (l *Lifecycle) DiscoverAllPhases(packageDir, platform string, op Operation) map[string][]string
DiscoverAllPhases returns a map of phase name to script paths for all phases in an operation on the given platform.
func (*Lifecycle) DiscoverPhaseScripts ¶
func (l *Lifecycle) DiscoverPhaseScripts(packageDir, platform string, op Operation, phase string) []string
DiscoverPhaseScripts returns all phase scripts for a phase, ordered from most general to most specific for chained execution.
Example for platform="Linux.Debian", op=OpDeploy, phase="install":
["Common/Deploy/install.star", "Unix/Deploy/install.star", "Linux/Deploy/install.star", "Linux.Debian/Deploy/install.star"]
Only scripts that exist are included.
func (*Lifecycle) EnabledFeatures ¶
EnabledFeatures returns the list of enabled features given explicit enables and the default settings.
func (*Lifecycle) GetPhaseScript ¶
GetPhaseScript returns the path to a single phase script for the given platform and operation. This finds the MOST SPECIFIC script only. For chained execution, use DiscoverPhaseScripts instead.
Returns empty string if no script exists for this phase.
func (*Lifecycle) HasPhase ¶
HasPhase returns true if at least one phase script exists for this phase on the given platform and operation.
func (*Lifecycle) IsSynthetic ¶
IsSynthetic returns true if this lifecycle was synthesized for a native PM package.
func (*Lifecycle) ResolvedSettings ¶
ResolvedSettings returns settings with defaults filled in.
func (*Lifecycle) SupportsPlatform ¶
SupportsPlatform returns true if the lifecycle supports the given platform.
type LorePackage ¶
type LorePackage struct {
Name string // Package name
Version string // Version (may be "latest" for native PMs)
Description string // One-line description
Source PackageSource // Where this package was resolved from
Dir string // Package directory (lore packages only)
// Native package manager name (for non-lore packages)
// e.g., "docker.io" for apt, "docker" for brew
NativeName string
// contains filtered or unexported fields
}
LorePackage provides a uniform view over any package, whether from the lore registry or a native package manager. Use Lifecycle() to get phase and feature metadata.
func (*LorePackage) DiscoverPhaseScripts ¶
func (p *LorePackage) DiscoverPhaseScripts(platform string, op Operation, phase string) []string
DiscoverPhaseScripts returns all phase scripts for a phase, ordered from most general to most specific for chained execution.
For native PM packages, returns empty (the engine handles install directly).
func (*LorePackage) HasPhase ¶
func (p *LorePackage) HasPhase(platform string, op Operation, phase string) bool
HasPhase returns true if at least one phase script exists for this phase.
func (*LorePackage) IsNative ¶
func (p *LorePackage) IsNative() bool
IsNative returns true if this package comes from a native package manager.
func (*LorePackage) IsSynthetic ¶
func (p *LorePackage) IsSynthetic() bool
IsSynthetic returns true if the lifecycle is synthetic (not from lifecycle.yaml).
func (*LorePackage) Lifecycle ¶
func (p *LorePackage) Lifecycle() *Lifecycle
Lifecycle returns the package's lifecycle metadata. For lore packages, this loads from lifecycle.yaml. For native PM packages, this returns a synthetic lifecycle.
func (*LorePackage) PhaseActions ¶
func (p *LorePackage) PhaseActions(platform string, op Operation, phase string) []PhaseAction
PhaseActions returns the executable actions for a phase. This provides a uniform interface for both lore and native PM packages.
For lore packages: returns ScriptAction items for each discovered script. For native PM packages: returns a NativePMAction for install/uninstall phases.
type NativePMAction ¶
type NativePMAction struct {
// Manager identifies which package manager to use.
Manager PackageSource
// Operation is the PM operation (install, remove, update).
Operation PMOperation
// Packages is the list of package names to operate on.
Packages []string
// PhaseName is the phase this action belongs to.
PhaseName string
}
NativePMAction executes a native package manager operation.
func (*NativePMAction) Batchable ¶
func (a *NativePMAction) Batchable() bool
Batchable returns true if this action can be batched with others. Native PM install/upgrade/remove operations are batchable; update (index refresh) is not.
func (*NativePMAction) CanBatchWith ¶
func (a *NativePMAction) CanBatchWith(other *NativePMAction) bool
CanBatchWith returns true if this action can be batched with another. Actions can be batched if they have the same manager, operation, and phase.
func (*NativePMAction) Merge ¶
func (a *NativePMAction) Merge(other *NativePMAction) *NativePMAction
Merge combines this action with another, returning a new batched action. Returns nil if the actions cannot be batched.
func (*NativePMAction) Phase ¶
func (a *NativePMAction) Phase() string
Phase returns the phase name.
func (*NativePMAction) Type ¶
func (a *NativePMAction) Type() PhaseActionType
Type returns ActionNativePM.
type PMOperation ¶
type PMOperation int
PMOperation represents a native package manager operation.
const ( // PMInstall installs packages. PMInstall PMOperation = iota // PMRemove removes packages. PMRemove // PMUpdate refreshes the package index. PMUpdate // PMUpgrade upgrades installed packages. PMUpgrade )
func (PMOperation) String ¶
func (op PMOperation) String() string
String returns the operation name.
type PackageSource ¶
type PackageSource string
PackageSource indicates where a package was resolved from.
const ( SourceLore PackageSource = "lore" // Lore registry (full lifecycle) SourceApt PackageSource = "apt" // Debian/Ubuntu apt SourceDnf PackageSource = "dnf" // Fedora/RHEL dnf SourceBrew PackageSource = "brew" // macOS Homebrew SourcePort PackageSource = "port" // macOS MacPorts SourceWinget PackageSource = "winget" // Windows winget SourceChoco PackageSource = "choco" // Windows Chocolatey )
type PhaseAction ¶
type PhaseAction interface {
// Type returns the action type (script or native PM).
Type() PhaseActionType
// Phase returns the phase name this action belongs to.
Phase() string
}
PhaseAction represents an executable phase action. This provides a uniform interface for both Starlark scripts and native PM operations.
type PhaseActionType ¶
type PhaseActionType int
PhaseActionType distinguishes between script and native PM actions.
const ( // ActionScript is a Starlark phase script. ActionScript PhaseActionType = iota // ActionNativePM is a native package manager operation. ActionNativePM )
type Provider ¶
type Provider interface {
// Sync updates the local cache from the remote registry.
// Returns information about what changed.
Sync(ctx context.Context, cacheDir string, opts SyncOptions) (*SyncResult, error)
// Name returns the provider type ("git", "oci", etc.)
Name() string
}
Provider abstracts the transport mechanism for registry access.
type ScriptAction ¶
type ScriptAction struct {
// Path is the absolute path to the .star file.
Path string
// PhaseName is the phase name (function to call in the script).
PhaseName string
// Platform is the platform directory this script came from.
Platform string
}
ScriptAction executes a Starlark phase script.
func (*ScriptAction) Type ¶
func (a *ScriptAction) Type() PhaseActionType
Type returns ActionScript.
type Setting ¶
type Setting struct {
Description string `yaml:"description"`
Type string `yaml:"type"`
Default string `yaml:"default"`
Values []string `yaml:"values,omitempty"`
Platforms []string `yaml:"platforms,omitempty"`
}
Setting represents a package setting definition.
type SyncInfo ¶
type SyncInfo struct {
LastSync time.Time `yaml:"last_sync"`
Ref string `yaml:"ref"`
Provider string `yaml:"provider"`
Endpoint string `yaml:"endpoint"`
}
SyncInfo tracks the last sync state.
type SyncOptions ¶
type SyncOptions struct {
Force bool // Force sync even if cache is fresh
}
SyncOptions controls sync behavior.
type SyncResult ¶
type SyncResult struct {
Updated bool // Whether the cache was updated
FromRef string // Previous reference (commit SHA, digest, etc.)
ToRef string // New reference
SyncedAt time.Time // When sync completed
FromClone bool // True if this was a fresh clone
}
SyncResult contains information about a sync operation.