registry

package
v6.16.10 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package registry centralizes all registry lifecycle helpers that KSail-Go needs for local development clusters.

The package includes:

  • mirror registry utilities used by cluster provisioners (Kind, K3d) to handle pull-through caching containers consistently, and
  • the developer-facing registry service abstraction that provisions the localhost-only OCI registry leveraged by the CLI.

Index

Constants

View Source
const (
	// LocalRegistryBaseName is the base name for the local registry container.
	// The actual container name includes the cluster name prefix: <cluster>-local-registry.
	LocalRegistryBaseName = "local-registry"
	// DefaultLocalArtifactTag is used when no explicit tag is provided for a workload
	// artifact. The "dev" tag is intended only for local development and will
	// typically point to the most recently built image, which is convenient but
	// not suitable for reproducible or production deployments where explicit
	// immutable version tags (for example, semantic versions or digests) should
	// be used instead.
	DefaultLocalArtifactTag = "dev"
	// DefaultRepoName is used when no repository name can be derived.
	DefaultRepoName = "ksail-workloads"
)

Shared registry constants used across services and CLI layers.

View Source
const (
	// DefaultEndpointHost exposes the registry on the developer workstation only.
	DefaultEndpointHost = "localhost"
)

Variables

View Source
var (
	// ErrNameRequired indicates that an operation was attempted without providing a registry name.
	ErrNameRequired = errors.New("registry name is required")
	// ErrHostRequired indicates that no host or bind address was provided for the registry endpoint.
	ErrHostRequired = errors.New("registry host is required")
	// ErrInvalidPort indicates that a provided registry port is outside the valid TCP port range.
	ErrInvalidPort = errors.New("registry port must be between 1 and 65535")
)
View Source
var (
	// ErrEmptyBaseDir is returned when the base directory is empty.
	ErrEmptyBaseDir = errors.New("baseDir cannot be empty")
)

Static errors for the registry package.

View Source
var ErrExecFailed = errors.New("exec failed")

ErrExecFailed is returned when a docker exec command exits with a non-zero status.

Functions

func AllocatePort

func AllocatePort(nextPort *int, usedPorts map[int]struct{}) int

AllocatePort returns the next available port and updates the tracking map.

func BuildHostEndpointMap

func BuildHostEndpointMap(
	specs []MirrorSpec,
	containerPrefix string,
	existing map[string][]string,
) (map[string][]string, bool)

BuildHostEndpointMap merges parsed mirror specifications with existing host endpoint mappings. Generated mirror endpoints are tracked internally while upstream remotes are appended to preserve fallbacks. Returns the updated map and a boolean indicating whether any changes were applied.

func BuildLocalRegistryName

func BuildLocalRegistryName(clusterName string) string

BuildLocalRegistryName constructs the local registry container name with cluster prefix. The container name follows the pattern: <cluster>-local-registry For example: kind-default-local-registry, talos-default-local-registry.

func BuildRegistryName

func BuildRegistryName(prefix, host string) string

BuildRegistryName constructs a registry container name from prefix and host.

func BuildUpstreamLookup

func BuildUpstreamLookup(specs []MirrorSpec) map[string]string

BuildUpstreamLookup returns a map of registry host to user-specified upstream URL.

func CleanupMirrorSpecRegistries

func CleanupMirrorSpecRegistries(
	ctx context.Context,
	mirrorSpecs []MirrorSpec,
	clusterName string,
	dockerClient client.APIClient,
	deleteVolumes bool,
	networkName string,
) error

CleanupMirrorSpecRegistries prepares a registry manager from mirror specifications and removes the matching registry containers. This is a convenience function that combines PrepareRegistryManagerFromSpecs with CleanupRegistries.

func CleanupRegistries

func CleanupRegistries(
	ctx context.Context,
	registryMgr Backend,
	registries []Info,
	clusterName string,
	deleteVolumes bool,
	networkName string,
	warningWriter io.Writer,
) error

CleanupRegistries removes the provided registry. Errors are logged as warnings.

func CollectExistingRegistryPorts

func CollectExistingRegistryPorts(
	ctx context.Context,
	registryMgr Backend,
) (map[int]struct{}, error)

CollectExistingRegistryPorts returns a set of host ports that are already bound by existing registry containers. This allows callers to avoid host port collisions when provisioning new registry mirrors for additional clusters.

func CollectRegistryNames

func CollectRegistryNames(infos []Info) []string

CollectRegistryNames extracts registry names from a slice of registry Info structs. Empty names are filtered out. This is useful for collecting names before cleanup operations.

func ConnectMirrorSpecsToNetwork

func ConnectMirrorSpecsToNetwork(
	ctx context.Context,
	mirrorSpecs []MirrorSpec,
	clusterName string,
	networkName string,
	dockerClient client.APIClient,
	writer io.Writer,
) error

ConnectMirrorSpecsToNetwork builds registry infos from mirror specifications and connects them to the specified Docker network. This is a convenience function that combines BuildRegistryInfosFromSpecs with ConnectRegistriesToNetwork.

func ConnectRegistriesToNetwork

func ConnectRegistriesToNetwork(
	ctx context.Context,
	dockerClient client.APIClient,
	registries []Info,
	networkName string,
	writer io.Writer,
) error

ConnectRegistriesToNetwork attaches each registry container to the provided network. Any connection failures are logged as warnings but do not abort the operation.

func ConnectRegistriesToNetworkWithStaticIPs

func ConnectRegistriesToNetworkWithStaticIPs(
	ctx context.Context,
	dockerClient client.APIClient,
	registries []Info,
	networkName string,
	networkCIDR string,
	writer io.Writer,
) (map[string]string, error)

ConnectRegistriesToNetworkWithStaticIPs attaches registry containers to a network using static IPs from the high end of the subnet to avoid conflicts with Talos node IPs that start from .2. For a /24 network, registries are assigned starting from .250 down (.250, .249, .248, etc.). Returns a map of registry names to their assigned static IPs.

func EscapeShellArg

func EscapeShellArg(arg string) string

EscapeShellArg escapes a string for safe use in POSIX shell commands. It wraps the string in single quotes and escapes any single quotes within.

func ExtractNameFromEndpoint

func ExtractNameFromEndpoint(endpoint string) string

ExtractNameFromEndpoint extracts the hostname portion from an endpoint URL.

func ExtractPortFromEndpoint

func ExtractPortFromEndpoint(endpoint string) int

ExtractPortFromEndpoint extracts the port from an endpoint URL. Returns 0 if not found.

func ExtractRegistryPort

func ExtractRegistryPort(endpoints []string, usedPorts map[int]struct{}, nextPort *int) int

ExtractRegistryPort determines a unique host port to expose for the given endpoints.

func GenerateHostsToml

func GenerateHostsToml(entry MirrorEntry) string

GenerateHostsToml generates a hosts.toml file content for containerd registry configuration. This uses the modern hosts directory pattern as documented at: https://gardener.cloud/docs/gardener/advanced/containerd-registry-configuration/#hosts-directory-pattern

The generated content includes:

  • server: The upstream registry URL (fallback when mirrors are unavailable)
  • host: Local mirror endpoint with pull and resolve capabilities

Example output for docker.io with a local mirror:

server = "https://registry-1.docker.io"

[host."http://docker.io:5000"]
  capabilities = ["pull", "resolve"]

func GenerateRandomDelimiter

func GenerateRandomDelimiter() (string, error)

GenerateRandomDelimiter creates a random heredoc delimiter to prevent injection attacks. The delimiter is prefixed with "EOF_" and followed by 16 random hex characters.

func GenerateScaffoldedHostsToml

func GenerateScaffoldedHostsToml(spec MirrorSpec) string

GenerateScaffoldedHostsToml generates a hosts.toml file content for scaffolded registry mirrors. This generates configuration that redirects requests through a local registry container that acts as a pull-through cache for the upstream registry.

Parameters:

Example output for docker.io:

server = "https://registry-1.docker.io"

[host."http://docker.io:5000"]
  capabilities = ["pull", "resolve"]

The local registry container (e.g., docker.io:5000) will be configured with REGISTRY_PROXY_REMOTEURL to proxy requests to the upstream.

func GenerateUpstreamURL

func GenerateUpstreamURL(host string) string

GenerateUpstreamURL attempts to derive the upstream registry URL from the host name.

func GenerateVolumeName

func GenerateVolumeName(host string) string

GenerateVolumeName returns a deterministic Docker volume name for the registry.

func InitPortAllocation

func InitPortAllocation(baseUsedPorts map[int]struct{}) (map[int]struct{}, int)

InitPortAllocation prepares the used ports set and the next available port based on provided base mapping.

func InjectHostsToml

func InjectHostsToml(
	ctx context.Context,
	dockerClient client.APIClient,
	nodeName string,
	registryHost string,
	hostsTomlContent string,
) error

InjectHostsToml creates the hosts directory and writes the hosts.toml file inside a cluster node using docker exec. It generates a random heredoc delimiter to prevent injection attacks.

func InjectHostsTomlIntoNodes

func InjectHostsTomlIntoNodes(
	ctx context.Context,
	dockerClient client.APIClient,
	nodes []string,
	entries []MirrorEntry,
) error

InjectHostsTomlIntoNodes injects hosts.toml files into all cluster nodes for the given entries. This is the shared implementation used by Kind and VCluster provisioners.

func PrepareRegistryManager

func PrepareRegistryManager(
	ctx context.Context,
	dockerClient client.APIClient,
	extractor func(baseUsedPorts map[int]struct{}) []Info,
) (Backend, []Info, error)

PrepareRegistryManager builds a registry manager and extracts registry info via the provided extractor. The extractor receives the set of already used ports (if any) and should return the registries that need work. This function collects ports from ALL running containers (not just ksail-managed registries) to avoid port conflicts with registries created by other cluster distributions (e.g., K3d's native registries).

func PrepareRegistryManagerFromSpecs

func PrepareRegistryManagerFromSpecs(
	ctx context.Context,
	mirrorSpecs []MirrorSpec,
	clusterName string,
	dockerClient client.APIClient,
) (Backend, []Info, error)

PrepareRegistryManagerFromSpecs creates a registry manager and builds registry infos from mirror specifications. Returns nil manager if mirrorSpecs is empty. The clusterName is used as prefix for container names to ensure uniqueness.

func RenderK3dMirrorConfig

func RenderK3dMirrorConfig(hostEndpoints map[string][]string) string

RenderK3dMirrorConfig renders a K3d-compatible mirrors configuration from the provided host endpoints mapping. Hosts are sorted deterministically to ensure stable output.

func ResolveRegistryName

func ResolveRegistryName(host string, endpoints []string, prefix string) string

ResolveRegistryName determines the registry container name from endpoints or falls back to prefix + host. Only HTTP endpoints represent local mirror containers; HTTPS endpoints are remote upstreams and should be skipped.

func SanitizeHostIdentifier

func SanitizeHostIdentifier(host string) string

SanitizeHostIdentifier converts a registry host string into a Docker-safe identifier while keeping dots intact so hosts such as docker.io remain reachable via container name resolution.

func SanitizeRepoName

func SanitizeRepoName(value string) string

SanitizeRepoName converts a source directory path into a DNS-compliant repository name. This function is used by both the OCI push command and Flux installer to ensure the artifact repository name matches what Flux expects.

The function:

  • Converts to lowercase
  • Replaces non-alphanumeric characters with hyphens
  • Collapses consecutive hyphens
  • Trims leading/trailing hyphens
  • Truncates to DNS1123LabelMaxLength (63 chars)
  • Falls back to DefaultRepoName if result is invalid

func SetBackendFactoryForTests

func SetBackendFactoryForTests(factory BackendFactory) func()

SetBackendFactoryForTests sets an override backend factory for testing. Returns a cleanup function that restores the previous factory.

func SetupMirrorSpecRegistries

func SetupMirrorSpecRegistries(
	ctx context.Context,
	mirrorSpecs []MirrorSpec,
	clusterName string,
	dockerClient client.APIClient,
	networkName string,
	writer io.Writer,
) error

SetupMirrorSpecRegistries prepares a registry manager from mirror specifications and ensures that the matching registry containers exist. This is a convenience function that combines PrepareRegistryManagerFromSpecs with SetupRegistries.

func SetupRegistries

func SetupRegistries(
	ctx context.Context,
	registryMgr Backend,
	registries []Info,
	clusterName string,
	networkName string,
	writer io.Writer,
) error

SetupRegistries ensures that the provided registries exist. Any newly created registries are cleaned up if a later creation fails.

func SortHosts

func SortHosts(hosts []string)

SortHosts deterministically sorts registry hostnames.

func TrimNonEmpty

func TrimNonEmpty(s string) (string, bool)

TrimNonEmpty returns the trimmed string and whether it's non-empty. This consolidates the common pattern of trimming and checking for emptiness.

Types

type Backend

type Backend interface {
	CreateRegistry(ctx context.Context, config dockerclient.RegistryConfig) error
	DeleteRegistry(
		ctx context.Context,
		name, clusterName string,
		deleteVolume bool,
		networkName string,
		volumeName string,
	) error
	ListRegistries(ctx context.Context) ([]string, error)
	GetRegistryPort(ctx context.Context, name string) (int, error)
	WaitForRegistriesReady(ctx context.Context, registryIPs map[string]string) error
}

Backend defines the minimal registry operations required by both mirror and local registry flows.

func DefaultBackendFactory

func DefaultBackendFactory(dockerClient client.APIClient) (Backend, error)

DefaultBackendFactory creates a real RegistryManager that interacts with Docker.

type BackendFactory

type BackendFactory func(client.APIClient) (Backend, error)

BackendFactory creates a Backend from a Docker API client. This abstraction allows tests to inject mock backends without creating real Docker containers.

func GetBackendFactory

func GetBackendFactory() BackendFactory

GetBackendFactory returns the current backend factory, using the override if set.

type Config

type Config struct {
	DockerClient    client.APIClient
	RegistryManager Backend
}

Config controls how the registry service interacts with the container engine.

type CreateOptions

type CreateOptions struct {
	Name        string
	Host        string
	Port        int
	VolumeName  string
	ClusterName string
}

CreateOptions capture the desired shape of a managed OCI registry container.

func (CreateOptions) Endpoint

func (o CreateOptions) Endpoint() string

Endpoint returns the host-facing endpoint string (host:port) for the registry.

func (CreateOptions) Validate

func (o CreateOptions) Validate() error

Validate asserts that the option set is well formed before interacting with the container engine.

func (CreateOptions) WithDefaults

func (o CreateOptions) WithDefaults() CreateOptions

WithDefaults applies standard defaults for host bindings and storage metadata.

type HostsDirectoryManager

type HostsDirectoryManager struct {
	// contains filtered or unexported fields
}

HostsDirectoryManager manages the containerd hosts directory structure for registry mirrors. It creates temporary directories with hosts.toml files that can be mounted into Kind nodes.

func NewHostsDirectoryManager

func NewHostsDirectoryManager(baseDir string) (*HostsDirectoryManager, error)

NewHostsDirectoryManager creates a new manager for containerd hosts directory. The baseDir will be created if it doesn't exist.

func (*HostsDirectoryManager) Cleanup

func (m *HostsDirectoryManager) Cleanup() error

Cleanup removes all created directories and files.

func (*HostsDirectoryManager) GetBaseDir

func (m *HostsDirectoryManager) GetBaseDir() string

GetBaseDir returns the base directory path.

func (*HostsDirectoryManager) WriteAllHostsToml

func (m *HostsDirectoryManager) WriteAllHostsToml(
	entries []MirrorEntry,
) (map[string]string, error)

WriteAllHostsToml creates hosts.toml files for all provided mirror entries. Returns a map of registry host to directory path.

func (*HostsDirectoryManager) WriteHostsToml

func (m *HostsDirectoryManager) WriteHostsToml(entry MirrorEntry) (string, error)

WriteHostsToml creates a hosts.toml file for the specified registry mirror. Returns the path to the created directory (parent of hosts.toml).

type Info

type Info struct {
	Host     string
	Name     string
	Upstream string
	Port     int
	Volume   string
	Username string // Optional: username for registry authentication (supports ${ENV_VAR} placeholders)

	Password string
}

Info describes a registry mirror that should be managed for a cluster.

func BuildRegistryInfo

func BuildRegistryInfo(
	host string,
	endpoints []string,
	port int,
	prefix string,
	upstreamOverride string,
	username string,
	password string,
) Info

BuildRegistryInfo creates an Info populated with derived fields using the supplied prefix for container names.

func BuildRegistryInfosFromSpecs

func BuildRegistryInfosFromSpecs(
	mirrorSpecs []MirrorSpec,
	upstreams map[string]string,
	_ map[int]struct{},
	prefix string,
) []Info

BuildRegistryInfosFromSpecs builds registry Info structs from mirror specs directly. This is used when provisioners need Info structs for SetupRegistries/CleanupRegistries. The prefix is prepended to container names to avoid Docker DNS collisions. The upstreams map provides optional overrides for upstream URLs per host. Mirror registries do not need host port allocation since they are accessed via Docker network by cluster nodes, not from the host.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager orchestrates registry lifecycle operations shared between mirror and local registries.

func NewManager

func NewManager(backend Backend) (*Manager, error)

NewManager creates a manager backed by the provided registry backend.

func (*Manager) Cleanup

func (c *Manager) Cleanup(
	ctx context.Context,
	registries []Info,
	clusterName string,
	deleteVolumes bool,
	networkName string,
	writer io.Writer,
) error

Cleanup removes the provided registries via the backend.

func (*Manager) CleanupOne

func (c *Manager) CleanupOne(
	ctx context.Context,
	registry Info,
	clusterName string,
	deleteVolume bool,
	networkName string,
) error

CleanupOne removes a single registry spec.

func (*Manager) EnsureBatch

func (c *Manager) EnsureBatch(
	ctx context.Context,
	registries []Info,
	clusterName string,
	networkName string,
	writer io.Writer,
) error

EnsureBatch creates all requested registries as an atomic batch. Any failure rolls back prior creations.

func (*Manager) EnsureOne

func (c *Manager) EnsureOne(
	ctx context.Context,
	spec Info,
	clusterName string,
	writer io.Writer,
) (bool, error)

EnsureOne provisions a single registry and reports whether a new container was created.

type MirrorEntry

type MirrorEntry struct {
	Host          string
	SanitizedName string
	ContainerName string
	Endpoint      string
	Port          int
	Remote        string
}

MirrorEntry contains the normalized data required to create a registry mirror.

func BuildMirrorEntries

func BuildMirrorEntries(
	specs []MirrorSpec,
	containerPrefix string,
	existingHosts map[string]struct{},
	usedPorts map[int]struct{},
	nextPort *int,
) []MirrorEntry

BuildMirrorEntries converts mirror specs into registry entries using the provided prefix. Prefix should exclude the trailing hyphen (e.g., "kind", "k3d"). An empty prefix results in container names that match the sanitized host directly, which is useful when sharing mirrors across distributions. Existing hosts are skipped, and the allocations update the provided maps.

type MirrorSpec

type MirrorSpec struct {
	Host     string
	Remote   string
	Username string // Optional: username for registry authentication (supports ${ENV_VAR} placeholders)

	Password string
}

MirrorSpec represents a parsed mirror registry specification entry.

func MergeSpecs

func MergeSpecs(existingSpecs, flagSpecs []MirrorSpec) []MirrorSpec

MergeSpecs merges two sets of mirror specs, with flagSpecs taking precedence. If the same host appears in both, the version from flagSpecs is used. The result is sorted by host to ensure deterministic output.

func ParseMirrorSpecs

func ParseMirrorSpecs(specs []string) []MirrorSpec

ParseMirrorSpecs converts raw mirror specification strings into structured specs. Invalid entries (missing host or remote) are ignored. Format: [user:pass@]host[=endpoint] Credentials can use ${ENV_VAR} placeholders for environment variable expansion.

func ReadExistingHostsToml

func ReadExistingHostsToml(baseDir string) ([]MirrorSpec, error)

ReadExistingHostsToml reads existing hosts.toml files from the Kind mirrors directory (typically kind/mirrors) and returns MirrorSpec entries. This allows inferring mirror registry configuration from previously scaffolded hosts files.

func (MirrorSpec) HasCredentials

func (m MirrorSpec) HasCredentials() bool

HasCredentials returns true if the spec has non-empty username or password.

func (MirrorSpec) ResolveCredentials

func (m MirrorSpec) ResolveCredentials() (username, password string)

ResolveCredentials returns the username and password with environment variable placeholders expanded. Placeholders use the format ${VAR_NAME}. If a referenced environment variable is not set, the placeholder is replaced with an empty string.

type MockBackend

type MockBackend struct {
	mock.Mock
}

MockBackend is an autogenerated mock type for the Backend type

func NewMockBackend

func NewMockBackend(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockBackend

NewMockBackend creates a new instance of MockBackend. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockBackend) CreateRegistry

func (_mock *MockBackend) CreateRegistry(ctx context.Context, config docker.RegistryConfig) error

CreateRegistry provides a mock function for the type MockBackend

func (*MockBackend) DeleteRegistry

func (_mock *MockBackend) DeleteRegistry(ctx context.Context, name string, clusterName string, deleteVolume bool, networkName string, volumeName string) error

DeleteRegistry provides a mock function for the type MockBackend

func (*MockBackend) EXPECT

func (_m *MockBackend) EXPECT() *MockBackend_Expecter

func (*MockBackend) GetRegistryPort

func (_mock *MockBackend) GetRegistryPort(ctx context.Context, name string) (int, error)

GetRegistryPort provides a mock function for the type MockBackend

func (*MockBackend) ListRegistries

func (_mock *MockBackend) ListRegistries(ctx context.Context) ([]string, error)

ListRegistries provides a mock function for the type MockBackend

func (*MockBackend) WaitForRegistriesReady

func (_mock *MockBackend) WaitForRegistriesReady(ctx context.Context, registryIPs map[string]string) error

WaitForRegistriesReady provides a mock function for the type MockBackend

type MockBackend_CreateRegistry_Call

type MockBackend_CreateRegistry_Call struct {
	*mock.Call
}

MockBackend_CreateRegistry_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRegistry'

func (*MockBackend_CreateRegistry_Call) Return

func (*MockBackend_CreateRegistry_Call) Run

func (*MockBackend_CreateRegistry_Call) RunAndReturn

type MockBackend_DeleteRegistry_Call

type MockBackend_DeleteRegistry_Call struct {
	*mock.Call
}

MockBackend_DeleteRegistry_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRegistry'

func (*MockBackend_DeleteRegistry_Call) Return

func (*MockBackend_DeleteRegistry_Call) Run

func (_c *MockBackend_DeleteRegistry_Call) Run(run func(ctx context.Context, name string, clusterName string, deleteVolume bool, networkName string, volumeName string)) *MockBackend_DeleteRegistry_Call

func (*MockBackend_DeleteRegistry_Call) RunAndReturn

func (_c *MockBackend_DeleteRegistry_Call) RunAndReturn(run func(ctx context.Context, name string, clusterName string, deleteVolume bool, networkName string, volumeName string) error) *MockBackend_DeleteRegistry_Call

type MockBackend_Expecter

type MockBackend_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockBackend_Expecter) CreateRegistry

func (_e *MockBackend_Expecter) CreateRegistry(ctx interface{}, config interface{}) *MockBackend_CreateRegistry_Call

CreateRegistry is a helper method to define mock.On call

  • ctx context.Context
  • config docker.RegistryConfig

func (*MockBackend_Expecter) DeleteRegistry

func (_e *MockBackend_Expecter) DeleteRegistry(ctx interface{}, name interface{}, clusterName interface{}, deleteVolume interface{}, networkName interface{}, volumeName interface{}) *MockBackend_DeleteRegistry_Call

DeleteRegistry is a helper method to define mock.On call

  • ctx context.Context
  • name string
  • clusterName string
  • deleteVolume bool
  • networkName string
  • volumeName string

func (*MockBackend_Expecter) GetRegistryPort

func (_e *MockBackend_Expecter) GetRegistryPort(ctx interface{}, name interface{}) *MockBackend_GetRegistryPort_Call

GetRegistryPort is a helper method to define mock.On call

  • ctx context.Context
  • name string

func (*MockBackend_Expecter) ListRegistries

func (_e *MockBackend_Expecter) ListRegistries(ctx interface{}) *MockBackend_ListRegistries_Call

ListRegistries is a helper method to define mock.On call

  • ctx context.Context

func (*MockBackend_Expecter) WaitForRegistriesReady

func (_e *MockBackend_Expecter) WaitForRegistriesReady(ctx interface{}, registryIPs interface{}) *MockBackend_WaitForRegistriesReady_Call

WaitForRegistriesReady is a helper method to define mock.On call

  • ctx context.Context
  • registryIPs map[string]string

type MockBackend_GetRegistryPort_Call

type MockBackend_GetRegistryPort_Call struct {
	*mock.Call
}

MockBackend_GetRegistryPort_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRegistryPort'

func (*MockBackend_GetRegistryPort_Call) Return

func (*MockBackend_GetRegistryPort_Call) Run

func (*MockBackend_GetRegistryPort_Call) RunAndReturn

type MockBackend_ListRegistries_Call

type MockBackend_ListRegistries_Call struct {
	*mock.Call
}

MockBackend_ListRegistries_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRegistries'

func (*MockBackend_ListRegistries_Call) Return

func (*MockBackend_ListRegistries_Call) Run

func (*MockBackend_ListRegistries_Call) RunAndReturn

type MockBackend_WaitForRegistriesReady_Call

type MockBackend_WaitForRegistriesReady_Call struct {
	*mock.Call
}

MockBackend_WaitForRegistriesReady_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForRegistriesReady'

func (*MockBackend_WaitForRegistriesReady_Call) Return

func (*MockBackend_WaitForRegistriesReady_Call) Run

func (*MockBackend_WaitForRegistriesReady_Call) RunAndReturn

type Service

type Service interface {
	// Create provisions (or updates) an OCI registry container definition using the supplied options.
	Create(ctx context.Context, opts CreateOptions) (v1alpha1.OCIRegistry, error)
	// Start ensures the registry container is running and optionally attached to the target network.
	Start(ctx context.Context, opts StartOptions) (v1alpha1.OCIRegistry, error)
	// Stop halts the running registry container and optionally removes persistent storage resources.
	Stop(ctx context.Context, opts StopOptions) error
	// Status inspects the registry container and returns its current lifecycle state and metadata.
	Status(ctx context.Context, opts StatusOptions) (v1alpha1.OCIRegistry, error)
}

Service models the lifecycle management interface for localhost-scoped OCI registry.

func NewService

func NewService(cfg Config) (Service, error)

NewService constructs a registry lifecycle manager backed by the Docker API.

type StartOptions

type StartOptions struct {
	Name        string
	NetworkName string
}

StartOptions define how a registry instance should be started or connected.

func (StartOptions) Validate

func (o StartOptions) Validate() error

Validate ensures the start options reference a registry container.

type StatusOptions

type StatusOptions struct {
	Name string
}

StatusOptions identify the registry instance whose status should be inspected.

func (StatusOptions) Validate

func (o StatusOptions) Validate() error

Validate ensures the status query references a registry container.

type StopOptions

type StopOptions struct {
	Name         string
	ClusterName  string
	NetworkName  string
	DeleteVolume bool
	VolumeName   string
}

StopOptions describe how a registry instance should be stopped and optionally cleaned up.

func (StopOptions) Validate

func (o StopOptions) Validate() error

Validate ensures the stop options reference a registry container.

Jump to

Keyboard shortcuts

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