Documentation
¶
Overview ¶
Package transfer moves model artifacts between OCI registries and the local store. It is a thin, registry-agnostic layer over oras-go v2 (ADR-0005): oras.Copy does graph traversal and tagging, while large leaf blobs take a custom download path that survives interruption via HTTP Range resume.
Index ¶
- Constants
- func Load(ctx context.Context, st *store.Store, r io.Reader, opts ...LoadOption) ([]string, error)
- func Logout(ctx context.Context, host string) error
- func RehashPartial(partial string, expectedSize int64) (int64, hash.Hash, error)
- func Save(ctx context.Context, st *store.Store, refs []string, w io.Writer) (int, error)
- type Client
- func (c *Client) Copy(ctx context.Context, src, dst registry.Reference, ev Events) (ocispec.Descriptor, error)
- func (c *Client) Login(ctx context.Context, host, username, password string) error
- func (c *Client) Pull(ctx context.Context, st *store.Store, ref registry.Reference, ev Events) (ocispec.Descriptor, error)
- func (c *Client) Push(ctx context.Context, st *store.Store, ref registry.Reference, ev Events) (ocispec.Descriptor, error)
- func (c *Client) Registry(host string) (*remote.Registry, error)
- func (c *Client) Repository(ref registry.Reference) (*remote.Repository, error)
- type Events
- type LoadOption
- type Options
Constants ¶
const DefaultConcurrency = 4
DefaultConcurrency is the default number of parallel blob streams.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load imports every tagged reference from a tar'd OCI image layout into the local store and returns the imported refs.
func RehashPartial ¶ added in v0.3.0
RehashPartial replays an existing partial file through SHA-256 so the digest check covers resumed bytes too. A corrupt or oversized partial is discarded.
Exported because resuming a download is not registry-specific: internal/hf resumes a Hugging Face fetch the same way, and this is the tested version.
func Save ¶
Save exports refs from the local store into a tar stream containing a standard OCI image layout, readable by any OCI tool (see docs/architecture.md, "Client and local store": offline transfer bundles).
A model's signature travels with it when the store holds one, so the bundle can be verified on a machine that never reaches a registry. Save reports how many signatures it included, since that is not something the caller's list of references reveals.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client performs pulls, pushes, and copies against remote repositories.
func (*Client) Copy ¶
func (c *Client) Copy(ctx context.Context, src, dst registry.Reference, ev Events) (ocispec.Descriptor, error)
Copy transfers an artifact between two registries without touching the local store: the air-gap and mirroring workhorse.
func (*Client) Login ¶
Login validates credentials against host (ping) and saves them in the Docker credentials store: a configured credential helper when present, plaintext config.json otherwise.
func (*Client) Pull ¶
func (c *Client) Pull(ctx context.Context, st *store.Store, ref registry.Reference, ev Events) (ocispec.Descriptor, error)
Pull fetches ref from its registry into the local store and tags it with the fully-qualified reference. Large leaf blobs download concurrently with cross-restart resume; manifests, config, and tagging go through oras.Copy, which skips everything already present.
func (*Client) Push ¶
func (c *Client) Push(ctx context.Context, st *store.Store, ref registry.Reference, ev Events) (ocispec.Descriptor, error)
Push uploads the locally-stored ref to its registry. Blobs the registry already has are skipped; where the registry supports cross-repository blob mounting, blobs known from sibling repositories mount server-side instead of re-uploading.
func (*Client) Repository ¶
Repository opens a handle on the repository containing ref.
type Events ¶
type Events struct {
// OnBlobStart announces a starting blob transfer. resumeOffset > 0 means
// a partial download is being continued from that byte offset. The
// returned function (may be nil) receives byte-count deltas as the blob
// streams.
OnBlobStart func(desc ocispec.Descriptor, resumeOffset int64) func(delta int64)
// OnBlobSkip reports content skipped because the destination has it.
OnBlobSkip func(desc ocispec.Descriptor)
// OnSignature reports whether a cosign signature travelled with the
// artifact. False with a nil problem means the registry held none, which
// is not an error; a non-nil problem means the lookup itself failed and
// the model was kept anyway.
OnSignature func(stored bool, problem error)
}
Events carries optional progress callbacks. All fields may be nil. Callbacks must be safe for concurrent use: blobs transfer in parallel.
type LoadOption ¶ added in v0.3.0
type LoadOption func(*loadConfig)
LoadOption configures Load.
func WithBeforeImport ¶ added in v0.3.0
func WithBeforeImport(fn func(ctx context.Context, bundle oras.ReadOnlyTarget, refs []string) error) LoadOption
WithBeforeImport runs fn against the bundle's own layout before any content reaches the store, so a policy check can reject a bundle without the store ever holding what it rejected. A non-nil error aborts the whole import.
The callback takes a plain read-only target rather than anything from the signing package, which keeps verification policy out of the transfer layer.
type Options ¶
type Options struct {
// PlainHTTP uses HTTP instead of HTTPS (lab bring-up only).
PlainHTTP bool
// InsecureSkipTLSVerify disables TLS certificate verification. The CLI
// warns loudly when this is set; it is never the default.
InsecureSkipTLSVerify bool
// CAFile adds a PEM CA bundle (e.g. the internal CA) to the trust pool.
CAFile string
// Credential overrides credential resolution; nil uses the Docker
// credentials store (~/.docker/config.json and credential helpers).
Credential auth.CredentialFunc
// UserAgent identifies palan to registries.
UserAgent string
// Concurrency bounds parallel blob streams; <=0 means DefaultConcurrency.
Concurrency int
}
Options configures a transfer Client.