registry

package
v0.1.0-dev.20260905211448 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package registry provides the transport abstraction for devlore registry access. The Transport interface decouples registry consumers from the underlying protocol (git, OCI, HTTP). Today only git is implemented; the design accommodates future transports without changing callers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URL       string // Remote registry URL
	Branch    string // Branch to track
	ForceTags bool   // Force tag resolution even on non-main branches
}

Config holds the configuration needed to construct a Transport.

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.

type Transport

type Transport interface {
	// Sync updates the local cache from the remote registry.
	//
	// Parameters:
	//   - ctx: context for cancellation
	//   - cacheDir: local cache directory path
	//   - opts: sync behavior options
	//
	// Returns:
	//   - *SyncResult: information about what changed
	//   - error: sync failure
	Sync(ctx context.Context, cacheDir string, opts SyncOptions) (*SyncResult, error)

	// Name returns the transport type identifier ("git", "oci", etc.).
	//
	// Returns:
	//   - string: transport type name
	Name() string

	// ListVersions returns all available version tags.
	// Tags are returned in descending semver order (newest first).
	//
	// Parameters:
	//   - ctx: context for cancellation
	//   - cacheDir: local cache directory path
	//
	// Returns:
	//   - []string: version tags sorted newest-first
	//   - error: listing failure
	ListVersions(ctx context.Context, cacheDir string) ([]string, error)

	// ResolveVersion resolves a version string to a ref.
	//
	// Parameters:
	//   - ctx: context for cancellation
	//   - cacheDir: local cache directory path
	//   - version: version string ("latest", "v1.0.0", or "")
	//
	// Returns:
	//   - string: resolved ref (commit SHA or "HEAD")
	//   - error: resolution failure
	ResolveVersion(ctx context.Context, cacheDir, version string) (string, error)

	// CheckoutVersion checks out a specific version in the cache.
	//
	// Parameters:
	//   - ctx: context for cancellation
	//   - cacheDir: local cache directory path
	//   - version: version to checkout
	//
	// Returns:
	//   - error: checkout failure
	CheckoutVersion(ctx context.Context, cacheDir, version string) error

	// HasTag checks whether a specific tag exists.
	//
	// Parameters:
	//   - ctx: context for cancellation
	//   - cacheDir: local cache directory path
	//   - tag: tag name to check
	//
	// Returns:
	//   - bool: true if the tag exists
	//   - error: lookup failure
	HasTag(ctx context.Context, cacheDir, tag string) (bool, error)

	// CurrentRef returns the current HEAD ref in the cache.
	//
	// Parameters:
	//   - ctx: context for cancellation
	//   - cacheDir: local cache directory path
	//
	// Returns:
	//   - string: HEAD commit SHA
	//   - error: ref lookup failure
	CurrentRef(ctx context.Context, cacheDir string) (string, error)

	// CurrentVersion returns the version tag at HEAD, or "" if HEAD is not tagged.
	//
	// Parameters:
	//   - ctx: context for cancellation
	//   - cacheDir: local cache directory path
	//
	// Returns:
	//   - string: version tag at HEAD, or empty string
	//   - error: lookup failure
	CurrentVersion(ctx context.Context, cacheDir string) (string, error)
}

Transport abstracts the protocol used to synchronize a local registry cache with a remote registry.

func NewTransport

func NewTransport(cfg Config) Transport

NewTransport creates a Transport from configuration. Today this always returns a git transport; future transports (OCI, HTTP) will be selected by inspecting cfg.URL scheme or adding a Type field.

Parameters:

  • cfg: transport configuration

Returns:

  • Transport: configured transport implementation

Jump to

Keyboard shortcuts

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