registry

package
v0.1.0-dev.20260129014927 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var DecommissionPhaseOrder = []string{"unprovision", "uninstall", "cleanup"}

DecommissionPhaseOrder is the order for decommission operations.

View Source
var DeployPhaseOrder = []string{"prepare", "install", "provision", "verify"}

DeployPhaseOrder is the standard order of deploy pipeline phases.

View Source
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).

View Source
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

func PhaseOrder(op Operation) []string

PhaseOrder returns the phase order for an operation.

func PlatformResolutionOrder

func PlatformResolutionOrder(platform string) []string

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

func RequiredPhase(op Operation) string

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 New

func New(name string, provider Provider, cacheDir string) *Client

New creates a new registry client.

func NewDefault

func NewDefault() (*Client, error)

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

func (c *Client) AIExamples(name string) ([]byte, error)

AIExamples reads an AI examples file from the cache.

func (*Client) AIPrompt

func (c *Client) AIPrompt(name string) (string, error)

AIPrompt reads an AI prompt file from the cache.

func (*Client) AISchema

func (c *Client) AISchema(name string) ([]byte, error)

AISchema reads an AI JSON schema file from the cache.

func (*Client) CacheDir

func (c *Client) CacheDir() string

CacheDir returns the local cache directory path.

func (*Client) Exists

func (c *Client) Exists() bool

Exists returns true if the cache exists.

func (*Client) FileExists

func (c *Client) FileExists(relPath string) bool

FileExists returns true if the file exists in the cache.

func (*Client) FilePath

func (c *Client) FilePath(relPath string) string

FilePath returns the absolute path to a file in the cache.

func (*Client) MigrationGuide

func (c *Client) MigrationGuide(system string) ([]byte, error)

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) ReadDir

func (c *Client) ReadDir(relPath string) ([]os.DirEntry, error)

ReadDir reads a directory from the cache.

func (*Client) ReadFile

func (c *Client) ReadFile(relPath string) ([]byte, error)

ReadFile reads a file from the cache.

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.

func (*Client) SyncInfo

func (c *Client) SyncInfo() (*SyncInfo, error)

SyncInfo returns information about the last sync, if available.

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) Name

func (g *GitProvider) Name() string

Name returns "git".

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

func LoadLifecycle(packageDir string) (*Lifecycle, error)

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

func (l *Lifecycle) EnabledFeatures(explicit []string) []string

EnabledFeatures returns the list of enabled features given explicit enables and the default settings.

func (*Lifecycle) GetPhaseScript

func (l *Lifecycle) GetPhaseScript(packageDir, platform string, op Operation, phase string) string

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

func (l *Lifecycle) HasPhase(packageDir, platform string, op Operation, phase string) bool

HasPhase returns true if at least one phase script exists for this phase on the given platform and operation.

func (*Lifecycle) IsSynthetic

func (l *Lifecycle) IsSynthetic() bool

IsSynthetic returns true if this lifecycle was synthesized for a native PM package.

func (*Lifecycle) ResolvedSettings

func (l *Lifecycle) ResolvedSettings(explicit map[string]string) map[string]string

ResolvedSettings returns settings with defaults filled in.

func (*Lifecycle) SupportsPlatform

func (l *Lifecycle) SupportsPlatform(platform string) bool

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 Operation

type Operation string

Operation represents a pipeline operation type.

const (
	OpDeploy       Operation = "Deploy"
	OpUpgrade      Operation = "Upgrade"
	OpDecommission Operation = "Decommission"
)

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) Phase

func (a *ScriptAction) Phase() string

Phase returns the phase name.

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.

Jump to

Keyboard shortcuts

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