Documentation
¶
Overview ¶
Package imagepush manages outbound image pushes: exporting images from hypeman's OCI cache to remote container registries.
A push job resolves a hypeman image to its cached manifest digest, then streams the cached blobs to the target reference through lib/registrypush. Jobs run on a bounded queue, persist their status to disk, and expose in-flight digests so the OCI cache GC keeps the required blobs alive.
Index ¶
Constants ¶
const ( StatusQueued = "queued" StatusPushing = "pushing" StatusPushed = "pushed" StatusFailed = "failed" // DefaultPushTimeout bounds a single registry export so a wedged registry // cannot pin a queue slot forever. DefaultPushTimeout = 30 * time.Minute )
Variables ¶
var ( ErrNotFound = errors.New("push not found") ErrImageNotReady = errors.New("image not ready for push") ErrInvalidTarget = errors.New("invalid push target") // ErrCredentialConflict is returned when a push request matches an // in-flight job but its credential intent differs from that job's. The // manager never stores credential values, so it can only detect a // presence mismatch; two requests that both borrow different credentials // for the same target are indistinguishable and merge. ErrCredentialConflict = errors.New("push already in flight with different credentials") )
Functions ¶
This section is empty.
Types ¶
type ImageResolver ¶
ImageResolver resolves a hypeman image name to its stored state.
type Manager ¶
type Manager interface {
// CreatePush validates the request, persists a queued job, and enqueues it.
// A request that matches an in-flight job (same digest and target) returns
// the existing job instead of creating a duplicate; the in-flight job's
// credentials remain in effect. A request whose credential presence
// differs from the in-flight job's (one borrowed, one not) returns
// ErrCredentialConflict instead of silently merging under the wrong auth.
CreatePush(ctx context.Context, req PushRequest) (*Push, error)
GetPush(ctx context.Context, id string) (*Push, error)
// ListPushes returns all pushes, newest first.
ListPushes(ctx context.Context) ([]Push, error)
// WaitForPush blocks until the push reaches a terminal state (pushed or
// failed) or the context is cancelled. The HTTP API currently polls the
// persisted job instead; this remains available to in-process callers.
WaitForPush(ctx context.Context, id string) error
// LiveCacheManifestDigests implements ocicachegc.RootsProvider: the
// manifest digests of queued and pushing jobs, so the OCI cache GC keeps
// their blobs alive mid-push.
LiveCacheManifestDigests() []string
}
Manager orchestrates push jobs.
func NewManager ¶
func NewManager(p *paths.Paths, resolver ImageResolver, provider registrypush.Provider, maxConcurrent int) (Manager, error)
NewManager creates a push manager using DefaultPushTimeout. provider may be nil, in which case credentials resolve from the default Docker keychain. Interrupted pushes from a previous run are re-enqueued FIFO.
func NewManagerWithTimeout ¶
func NewManagerWithTimeout(p *paths.Paths, resolver ImageResolver, provider registrypush.Provider, maxConcurrent int, timeout time.Duration) (Manager, error)
NewManagerWithTimeout creates a push manager with a per-push timeout.
type Push ¶
type Push struct {
ID string
Image string
Digest string
Target string
Status string
QueuePosition *int
Error *string
Layers int
Bytes int64
CreatedAt time.Time
CompletedAt *time.Time
}
Push is the state of one push job.
type PushRequest ¶
type PushRequest struct {
// Image is the hypeman image name (tag or digest form).
Image string
// Target is the full remote reference, e.g. "registry.example.com/app:v1".
Target string
// Insecure allows pushing to plain-HTTP registries.
Insecure bool
// Credentials are borrowed for this push only, docker-style: the caller's
// registry login (e.g. resolved from the client's ~/.docker/config.json)
// rides along with the request instead of living on the server. They are
// never persisted or logged; a push interrupted across a restart cannot be
// recovered and fails instead. When nil, the manager's default provider
// resolves credentials.
Credentials *authn.AuthConfig
}
PushRequest describes a request to push a hypeman image to a remote registry.
type StatusEvent ¶
StatusEvent represents a terminal status change for push notifications.