ociclient

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package ociclient provides an implementation of oci.Interface that uses HTTP to talk to the remote registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse added in v0.0.14

func CheckResponse(resp *http.Response, okStatuses ...int) error

CheckResponse checks that resp has an acceptable status.

If okStatuses is empty, any 2xx response is accepted. Otherwise, only the supplied statuses are accepted. Non-2xx responses are returned as OCI errors. CheckResponse reads but does not close resp.Body when constructing an error.

func ErrorFromResponse added in v0.0.14

func ErrorFromResponse(resp *http.Response) error

ErrorFromResponse forms an OCI error from an HTTP response.

It reads but does not close resp.Body.

Types

type Client added in v0.0.14

type Client struct {
	*oci.Funcs
	// contains filtered or unexported fields
}

Client is an OCI registry client that uses HTTP to talk to the remote registry.

func New

func New(host string, opts0 *Options) (*Client, error)

New returns a client implementation that uses the OCI HTTP API. A nil opts parameter is equivalent to a pointer to zero Options.

The host specifies the host name to talk to; it may optionally be a host:port pair.

func (*Client) DeleteBlob added in v0.0.14

func (c *Client) DeleteBlob(ctx context.Context, repoName string, digest oci.Digest) error

DeleteBlob deletes the blob with the given digest from the repository.

func (*Client) DeleteManifest added in v0.0.14

func (c *Client) DeleteManifest(ctx context.Context, repoName string, digest oci.Digest) error

DeleteManifest deletes the manifest with the given digest from the repository.

func (*Client) DeleteTag added in v0.0.14

func (c *Client) DeleteTag(ctx context.Context, repoName string, tagName string) error

DeleteTag deletes the manifest with the given tag from the repository.

func (*Client) Do added in v0.0.14

func (c *Client) Do(req *http.Request, opts *RequestOptions) (*http.Response, error)

Do performs an HTTP request against the registry.

If req.URL has no scheme or host, Do fills them in from the client's configured registry. It also sets the User-Agent header and, when the request has a body, sets Expect: 100-continue.

Do does not interpret HTTP response statuses. Callers that want OCI error handling can use CheckResponse or ErrorFromResponse. On a nil error, the caller is responsible for closing resp.Body.

func (*Client) GetBlob added in v0.0.14

func (c *Client) GetBlob(ctx context.Context, repo string, digest oci.Digest) (oci.BlobReader, error)

GetBlob returns the content of the blob with the given digest.

func (*Client) GetBlobRange added in v0.0.14

func (c *Client) GetBlobRange(ctx context.Context, repo string, digest oci.Digest, o0, o1 int64) (_ oci.BlobReader, _err error)

GetBlobRange is like GetBlob but asks for only the given byte range.

func (*Client) GetManifest added in v0.0.14

func (c *Client) GetManifest(ctx context.Context, repo string, digest oci.Digest) (oci.BlobReader, error)

GetManifest returns the content of the manifest with the given digest.

func (*Client) GetTag added in v0.0.14

func (c *Client) GetTag(ctx context.Context, repo string, tagName string) (oci.BlobReader, error)

GetTag returns the content of the manifest with the given tag.

func (*Client) MountBlob added in v0.0.14

func (c *Client) MountBlob(ctx context.Context, fromRepo, toRepo string, dig oci.Digest) (oci.Descriptor, error)

MountBlob makes a blob from fromRepo available in toRepo without uploading it again.

func (*Client) PushBlob added in v0.0.14

func (c *Client) PushBlob(ctx context.Context, repo string, desc oci.Descriptor, r io.Reader) (_ oci.Descriptor, _err error)

PushBlob pushes a blob described by desc to the given repository.

func (*Client) PushBlobChunked added in v0.0.14

func (c *Client) PushBlobChunked(ctx context.Context, repo string, chunkSize int) (oci.BlobWriter, error)

PushBlobChunked starts a chunked blob upload to the given repository.

func (*Client) PushBlobChunkedResume added in v0.0.14

func (c *Client) PushBlobChunkedResume(ctx context.Context, repo string, id string, offset int64, chunkSize int) (oci.BlobWriter, error)

PushBlobChunkedResume resumes a previous chunked blob upload.

func (*Client) PushManifest added in v0.0.14

func (c *Client) PushManifest(ctx context.Context, repo string, contents []byte, mediaType string, params *oci.PushManifestParameters) (oci.Descriptor, error)

PushManifest pushes a manifest with the given media type and contents.

func (*Client) Referrers added in v0.0.14

func (c *Client) Referrers(ctx context.Context, repoName string, digest oci.Digest, params *oci.ReferrersParameters) iter.Seq2[oci.Descriptor, error]

Referrers returns an iterator over manifests that refer to the given digest.

func (*Client) Repositories added in v0.0.14

func (c *Client) Repositories(ctx context.Context, startAfter string) iter.Seq2[string, error]

Repositories returns an iterator over repositories in the registry.

func (*Client) ResolveBlob added in v0.0.14

func (c *Client) ResolveBlob(ctx context.Context, repo string, digest oci.Digest) (oci.Descriptor, error)

ResolveBlob returns the descriptor for the blob with the given digest.

func (*Client) ResolveManifest added in v0.0.14

func (c *Client) ResolveManifest(ctx context.Context, repo string, digest oci.Digest) (oci.Descriptor, error)

ResolveManifest returns the descriptor for the manifest with the given digest.

func (*Client) ResolveTag added in v0.0.14

func (c *Client) ResolveTag(ctx context.Context, repo string, tag string) (oci.Descriptor, error)

ResolveTag returns the descriptor for the manifest with the given tag.

func (*Client) Tags added in v0.0.14

func (c *Client) Tags(ctx context.Context, repoName string, params *oci.TagsParameters) iter.Seq2[string, error]

Tags returns an iterator over tags in the given repository.

type Options

type Options struct {
	// DebugID is used to prefix any log messages printed by the client.
	DebugID string

	// Transport is used to make HTTP requests. The context passed
	// to its RoundTrip method will have an appropriate
	// [ociauth.RequestInfo] value added, suitable for consumption
	// by the transport created by [ociauth.NewStdTransport]. If
	// Transport is nil, [http.DefaultTransport] will be used.
	Transport http.RoundTripper

	// Insecure specifies whether an http scheme will be used to
	// address the host instead of https.
	Insecure bool

	// Specifies a user agent string to use when making requests. Defaults to "docker/oci"
	UserAgent string
}

Options holds configuration for creating a new OCI registry client.

type RequestOptions added in v0.0.14

type RequestOptions struct {
	// Scope is the authorization scope required by the request. It is attached
	// to the request context for use by transports created by
	// [ociauth.NewStdTransport].
	Scope ociauth.Scope
}

RequestOptions holds options for Client.Do.

Jump to

Keyboard shortcuts

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