api

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Overview

Package api exposes the standalone updater service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistryDigestResolver added in v0.2.0

func NewRegistryDigestResolver() digest.RemoteResolver

NewRegistryDigestResolver returns a registry HTTP digest resolver.

func ResolvePullableImageRef

func ResolvePullableImageRef(summaryImage, inspectConfigImage string, repoTags []string) (ref, source string)

ResolvePullableImageRef chooses the best pullable image reference for a container.

Types

type Config

type Config struct {
	DockerClientProvider           DockerClientProvider
	ImagePuller                    ImagePuller
	PendingStore                   PendingStore
	RunRecorder                    RunRecorder
	Settings                       SettingsProvider
	RegistryDigestResolver         digest.RemoteResolver
	ProjectUpdater                 ProjectUpdater
	SelfUpdater                    SelfUpdater
	Notifier                       Notifier
	EventRecorder                  EventRecorder
	UsedImageCollector             UsedImageCollector
	LabelPolicy                    types.LabelPolicy
	AllowComposeStandaloneFallback bool
	Logger                         *slog.Logger
}

Config configures Service.

type DockerClientProvider

type DockerClientProvider interface {
	DockerClient(ctx context.Context) (*client.Client, error)
}

DockerClientProvider provides Docker clients.

func NewDockerClientProvider added in v0.2.0

func NewDockerClientProvider(options ...client.Opt) DockerClientProvider

NewDockerClientProvider returns a Docker client provider that uses the local Docker environment.

type EventRecorder

type EventRecorder interface {
	RecordEvent(ctx context.Context, event types.Event) error
}

EventRecorder receives updater lifecycle events.

type ImagePuller

type ImagePuller interface {
	PullImage(ctx context.Context, imageRef string, progress io.Writer) error
}

ImagePuller pulls images and may write progress to progress.

func NewImagePuller added in v0.2.0

func NewImagePuller(provider DockerClientProvider) ImagePuller

NewImagePuller returns an image puller backed by Docker's ImagePull API.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, notification types.Notification) error
}

Notifier receives successful update notifications.

type PendingStore

type PendingStore interface {
	PendingImageUpdates(ctx context.Context) ([]types.ImageUpdateRecord, error)
	ClearImageUpdateRecord(ctx context.Context, record types.ImageUpdateRecord) error
}

PendingStore provides pending update records and clears applied records.

func NewMemoryPendingStore added in v0.2.0

func NewMemoryPendingStore(records ...types.ImageUpdateRecord) PendingStore

NewMemoryPendingStore returns an in-memory pending update store.

type ProjectUpdater

type ProjectUpdater interface {
	ProjectByComposeName(ctx context.Context, composeName string) (types.ComposeProject, error)
	UpdateServices(ctx context.Context, projectID string, services []string) error
}

ProjectUpdater updates Docker Compose services owned by a host application.

func NewDockerComposeProjectUpdater added in v0.2.0

func NewDockerComposeProjectUpdater(provider DockerClientProvider) ProjectUpdater

NewDockerComposeProjectUpdater returns a Docker Compose CLI project updater.

type RunRecorder

type RunRecorder interface {
	RecordUpdateRun(ctx context.Context, result types.ResourceResult) error
}

RunRecorder records per-resource updater results.

type SelfUpdater

type SelfUpdater interface {
	TriggerSelfUpdate(ctx context.Context, target types.SelfUpdateTarget) error
}

SelfUpdater handles host-specific self-update targets.

type Service

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

Service coordinates Docker image updates, container recreation, and host adapters.

func NewDefaultService added in v0.2.0

func NewDefaultService() *Service

NewDefaultService constructs a service with the built-in Docker-backed defaults.

func NewService

func NewService(config Config) *Service

NewService constructs an updater service.

func (*Service) ApplyPending

func (s *Service) ApplyPending(ctx context.Context, opts types.Options) (out *types.Result, err error)

ApplyPending applies pending image updates from the configured PendingStore.

func (*Service) BeginContainerUpdate

func (s *Service) BeginContainerUpdate(containerID string) func()

BeginContainerUpdate marks a container as updating and returns a completion callback.

func (*Service) BeginProjectUpdate

func (s *Service) BeginProjectUpdate(projectID string) func()

BeginProjectUpdate marks a project as updating and returns a completion callback.

func (*Service) RestartContainersUsingOldImages

func (s *Service) RestartContainersUsingOldImages(ctx context.Context, oldIDToNewRef map[string]string, oldRefToNewRef map[string]string) ([]types.ResourceResult, error)

RestartContainersUsingOldImages restarts running containers matching old image IDs or refs.

func (*Service) Status

func (s *Service) Status() types.Status

Status returns a point-in-time updater status snapshot.

func (*Service) UpdateContainer

func (s *Service) UpdateContainer(ctx context.Context, containerID string, opts types.Options) (out *types.Result, err error)

UpdateContainer updates a single Docker container by pulling its latest image and recreating it.

func (*Service) UpdateStandaloneContainer

func (s *Service) UpdateStandaloneContainer(ctx context.Context, cnt container.Summary, inspect container.InspectResponse, newRef string) error

UpdateStandaloneContainer recreates a non-compose container with newRef.

type SettingsProvider

type SettingsProvider interface {
	ExcludedContainers(ctx context.Context) ([]string, error)
}

SettingsProvider provides updater settings owned by the host application.

type UsedImageCollector

type UsedImageCollector interface {
	UsedImages(ctx context.Context) (map[string]struct{}, error)
}

UsedImageCollector allows callers to provide their own active-image discovery.

type UsedImageCollectorFunc

type UsedImageCollectorFunc func(context.Context) (map[string]struct{}, error)

UsedImageCollectorFunc adapts a function to UsedImageCollector.

func (UsedImageCollectorFunc) UsedImages

func (f UsedImageCollectorFunc) UsedImages(ctx context.Context) (map[string]struct{}, error)

UsedImages calls f(ctx).

Jump to

Keyboard shortcuts

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