ocirequest

package
v0.0.0-...-2c00c10 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// end-1	GET	/v2/	200	404/401
	ReqPing = Kind(iota)

	// end-2	GET	/v2/<name>/blobs/<digest>	200	404
	ReqBlobGet

	// end-2	HEAD	/v2/<name>/blobs/<digest>	200	404
	ReqBlobHead

	// end-10	DELETE	/v2/<name>/blobs/<digest>	202	404/405
	ReqBlobDelete

	// end-4a	POST	/v2/<name>/blobs/uploads/	202	404
	ReqBlobStartUpload

	// end-4b	POST	/v2/<name>/blobs/uploads/?digest=<digest>	201/202	404/400
	ReqBlobUploadBlob

	// end-11	POST	/v2/<name>/blobs/uploads/?mount=<digest>&from=<other_name>	201	404
	ReqBlobMount

	// end-13	GET	/v2/<name>/blobs/uploads/<reference>	204	404
	// NOTE: despite being described in the distribution spec, this
	// isn't really part of the OCI spec.
	ReqBlobUploadInfo

	// end-5	PATCH	/v2/<name>/blobs/uploads/<reference>	202	404/416
	// NOTE: despite being described in the distribution spec, this
	// isn't really part of the OCI spec.
	ReqBlobUploadChunk

	// end-6	PUT	/v2/<name>/blobs/uploads/<reference>?digest=<digest>	201	404/400
	// NOTE: despite being described in the distribution spec, this
	// isn't really part of the OCI spec.
	ReqBlobCompleteUpload

	// end-3	GET	/v2/<name>/manifests/<tagOrDigest>	200	404
	ReqManifestGet

	// end-3	HEAD	/v2/<name>/manifests/<tagOrDigest>	200	404
	ReqManifestHead

	// end-7	PUT	/v2/<name>/manifests/<tagOrDigest>	201	404
	ReqManifestPut

	// end-9	DELETE	/v2/<name>/manifests/<tagOrDigest>	202	404/400/405
	ReqManifestDelete

	// end-8a	GET	/v2/<name>/tags/list	200	404
	// end-8b	GET	/v2/<name>/tags/list?n=<integer>&last=<integer>	200	404
	ReqTagsList

	// end-12a	GET	/v2/<name>/referrers/<digest>	200	404/400
	ReqReferrersList

	// Catalog endpoints (out-of-spec)
	// 	GET	/v2/_catalog
	ReqCatalogList
)

Variables

View Source
var (
	ErrNotFound          = errors.New("page not found")
	ErrBadlyFormedDigest = errors.New("badly formed digest")
	ErrMethodNotAllowed  = errors.New("method not allowed")
	ErrBadRequest        = errors.New("bad request")
)

Functions

func ParseRange

func ParseRange(s string) (start, end int64, ok bool)

ParseRange extracts the start and end offsets from a Content-Range string. The resulting start is inclusive and the end exclusive, to match Go convention, whereas Content-Range is inclusive on both ends.

func RangeString

func RangeString(start, end int64) string

RangeString formats a pair of start and end offsets in the Content-Range form. The input start is inclusive and the end exclusive, to match Go convention, whereas Content-Range is inclusive on both ends.

Types

type Kind

type Kind int

type ParseError

type ParseError struct {
	Err error
}

ParseError represents an error that can happen when parsing. The Err field holds one of the possible error values below.

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type Request

type Request struct {
	Kind Kind

	// Repo holds the repository name. Valid for all request kinds
	// except ReqCatalogList and ReqPing.
	Repo string

	// Digest holds the digest being used in the request.
	// Valid for:
	//	ReqBlobMount
	//	ReqBlobUploadBlob
	//	ReqBlobGet
	//	ReqBlobHead
	//	ReqBlobDelete
	//	ReqBlobCompleteUpload
	//	ReqReferrersList
	//
	// Valid for these manifest requests when they're referring to a digest
	// rather than a tag:
	//	ReqManifestGet
	//	ReqManifestHead
	//	ReqManifestPut
	//	ReqManifestDelete
	Digest string

	// Tag holds the tag being used in the request. Valid for
	// these manifest requests when they're referring to a tag:
	//	ReqManifestGet
	//	ReqManifestHead
	//	ReqManifestPut
	//	ReqManifestDelete
	Tag string

	// FromRepo holds the repository name to mount from
	// for ReqBlobMount.
	FromRepo string

	// UploadID holds the upload identifier as used for
	// chunked uploads.
	// Valid for:
	//	ReqBlobUploadInfo
	//	ReqBlobUploadChunk
	UploadID string

	// ListN holds the maximum count for listing.
	// It's -1 to specify that all items should be returned.
	//
	// Valid for:
	//	ReqTagsList
	//	ReqCatalog
	//	ReqReferrers
	ListN int

	// listLast holds the item to start just after
	// when listing.
	//
	// Valid for:
	//	ReqTagsList
	//	ReqCatalog
	//	ReqReferrers
	ListLast string
}

func Parse

func Parse(method string, u *url.URL) (*Request, error)

Parse parses the given HTTP method and URL as an OCI registry request. It understands the endpoints described in the distribution spec.

If it returns an error, it will be of type *ParseError.

func (*Request) Construct

func (req *Request) Construct() (method string, ustr string, err error)

func (*Request) MustConstruct

func (req *Request) MustConstruct() (method string, ustr string)

Jump to

Keyboard shortcuts

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