mirror

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mirror implements the reloader manager for mirror reloaders.

Index

Constants

View Source
const (
	// ScaleUpReplicaCount is the number of replicas the original deployment
	// will be scaled up to. This is intentionally hard-coded to avoid
	// storing state in the old deployments or within Caproni.
	//
	// See https://gitlab.com/gitlab-org/gitlab/-/issues/590495#note_3118758329
	ScaleUpReplicaCount = 1
)

Variables

View Source
var (
	// ErrInvalidResourceType is returned when a resource type is not "deployment" or "statefulset".
	ErrInvalidResourceType = errors.New("resource type must be 'deployment' or 'statefulset'")

	// ErrInvalidDeploymentStructure is returned when deployment JSON structure is invalid.
	ErrInvalidDeploymentStructure = errors.New("invalid deployment structure")

	// ErrContainerNotFound is returned when the specified container is not found in the deployment.
	ErrContainerNotFound = errors.New("container not found in deployment")
)
View Source
var (
	// ErrInvalidReloaderType is returned when the reloader type is not 'mirror'.
	ErrInvalidReloaderType = errors.New("reloader type is not 'mirror'")

	// ErrMirrorConfigMissing is returned when the mirror configuration is missing.
	ErrMirrorConfigMissing = errors.New("mirror configuration is missing")

	// ErrTargetConfigMissing is returned when the target configuration is missing.
	ErrTargetConfigMissing = errors.New("target configuration is missing")

	// ErrEmptyCommand is returned when a process has an empty command.
	ErrEmptyCommand = errors.New("empty command for process")

	// ErrRepositoryNotFound is returned when the referenced repository doesn't exist.
	ErrRepositoryNotFound = errors.New("repository not found")
)

Functions

This section is empty.

Types

type CopyInfo

type CopyInfo struct {
	ResourceType string
	Name         string
	Namespace    string
}

CopyInfo holds information about a prepared deployment copy.

type Manager

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

Manager implements reloader.Manager for mirror reloaders.

func NewManager

func NewManager(kubectlBackend kubectl.Backend, executor executor.CommandRunner) *Manager

NewManager creates a new mirror reloader manager.

func (*Manager) CleanupCopy

func (m *Manager) CleanupCopy(ctx context.Context, deployment CopyInfo) error

CleanupCopy deletes a -caproni deployment copy and scales the original back up.

func (*Manager) PrepareCopies

func (m *Manager) PrepareCopies(ctx context.Context, targets []Target, copyImage string) ([]CopyInfo, error)

PrepareCopies scales down original deployments and creates -caproni copies for the given targets. It deduplicates targets and skips unsupported resource types. Returns a slice of CopyInfo for cleanup operations.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) error

Run starts the mirror reloader, blocking until the context is cancelled. This method:

  • Generates a mirrord configuration file
  • Starts caproni edit-mode-process-supervisor wrapped in mirrord
  • Auto-restarts processes that exit unexpectedly
  • Cleans up on shutdown

func (*Manager) Status

func (m *Manager) Status(ctx context.Context, reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) (*reloader.Status, error)

Status returns the current status of the reloader.

func (*Manager) Type

func (m *Manager) Type() string

Type returns the reloader type identifier.

func (*Manager) Validate

func (m *Manager) Validate(reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) error

Validate validates the mirror reloader configuration. Mirror reloaders don't have file path dependencies, so this primarily validates the configuration structure.

type Target

type Target struct {
	Namespace      string
	KubernetesType string
	Name           string
	// Container is optional. When set, only this container is replaced in the deployment copy.
	Container string
}

Target represents a Kubernetes resource to be mirrored.

Jump to

Keyboard shortcuts

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