blob

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 6

Documentation

Overview

Package blob is the underlying type for pushing and pulling blobs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BCommon added in v0.5.2

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

BCommon is a common struct for all blobs which includes various shared methods.

func (*BCommon) Digest deprecated added in v0.5.2

func (c *BCommon) Digest() digest.Digest

Digest returns the provided or calculated digest of the blob.

Deprecated: Digest should be replaced by GetDescriptor().Digest, see [GetDescriptor].

func (*BCommon) GetDescriptor added in v0.5.2

func (c *BCommon) GetDescriptor() descriptor.Descriptor

GetDescriptor returns the descriptor associated with the blob.

func (*BCommon) Length deprecated added in v0.5.2

func (c *BCommon) Length() int64

Length returns the provided or calculated length of the blob.

Deprecated: Length should be replaced by GetDescriptor().Size, see [GetDescriptor].

func (*BCommon) MediaType deprecated added in v0.5.2

func (c *BCommon) MediaType() string

MediaType returns the Content-Type header received from the registry.

Deprecated: MediaType should be replaced by GetDescriptor().MediaType, see [GetDescriptor].

func (*BCommon) RawHeaders added in v0.5.2

func (c *BCommon) RawHeaders() http.Header

RawHeaders returns the headers received from the registry.

func (*BCommon) Response added in v0.5.2

func (c *BCommon) Response() *http.Response

Response returns the response associated with the blob.

type BOCIConfig added in v0.5.2

type BOCIConfig struct {
	BCommon
	// contains filtered or unexported fields
}

BOCIConfig includes an OCI Image Config struct that may be extracted from or pushed to a blob.

func NewOCIConfig

func NewOCIConfig(opts ...Opts) *BOCIConfig

NewOCIConfig creates a new BOCIConfig. When created from an existing blob, a BOCIConfig will be created using BReader.ToOCIConfig().

func (*BOCIConfig) GetConfig added in v0.5.2

func (oc *BOCIConfig) GetConfig() v1.Image

GetConfig returns OCI config.

func (*BOCIConfig) MarshalJSON added in v0.5.2

func (oc *BOCIConfig) MarshalJSON() ([]byte, error)

MarshalJSON passes through the marshalling to the underlying image if rawBody is not available.

func (*BOCIConfig) RawBody added in v0.5.2

func (oc *BOCIConfig) RawBody() ([]byte, error)

RawBody returns the original body from the request.

func (*BOCIConfig) SetConfig added in v0.5.2

func (oc *BOCIConfig) SetConfig(image v1.Image)

SetConfig updates the config, including raw body and descriptor.

func (*BOCIConfig) UnmarshalJSON added in v0.5.2

func (oc *BOCIConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON extracts json content and populates the content.

type BReader added in v0.5.2

type BReader struct {
	BCommon
	// contains filtered or unexported fields
}

BReader is used to read blobs.

func NewReader

func NewReader(opts ...Opts) *BReader

NewReader creates a new BReader.

func (*BReader) Close added in v0.5.2

func (r *BReader) Close() error

Close attempts to close the reader and populates/validates the digest.

func (*BReader) RawBody added in v0.5.2

func (r *BReader) RawBody() ([]byte, error)

RawBody returns the original body from the request.

func (*BReader) Read added in v0.5.2

func (r *BReader) Read(p []byte) (int, error)

Read passes through the read operation while computing the digest and tracking the size.

func (*BReader) Seek added in v0.5.2

func (r *BReader) Seek(offset int64, whence int) (int64, error)

Seek passes through the seek operation, reseting or invalidating the digest

func (*BReader) ToOCIConfig added in v0.5.2

func (r *BReader) ToOCIConfig() (*BOCIConfig, error)

ToOCIConfig converts a BReader to a BOCIConfig.

func (*BReader) ToTarReader added in v0.5.2

func (r *BReader) ToTarReader() (*BTarReader, error)

ToTarReader converts a BReader to a BTarReader

type BTarReader added in v0.5.2

type BTarReader struct {
	BCommon
	// contains filtered or unexported fields
}

BTarReader is used to read individual files from an image layer.

func NewTarReader added in v0.4.5

func NewTarReader(opts ...Opts) *BTarReader

NewTarReader creates a BTarReader. Typically a BTarReader will be created using BReader.ToTarReader().

func (*BTarReader) Close added in v0.5.2

func (tr *BTarReader) Close() error

Close attempts to close the reader and populates/validates the digest.

func (*BTarReader) GetTarReader added in v0.5.2

func (tr *BTarReader) GetTarReader() (*tar.Reader, error)

GetTarReader returns the tar.Reader for the blob.

func (*BTarReader) RawBody added in v0.5.2

func (tr *BTarReader) RawBody() ([]byte, error)

RawBody returns the original body from the request.

func (*BTarReader) ReadFile added in v0.5.2

func (tr *BTarReader) ReadFile(filename string) (*tar.Header, io.Reader, error)

ReadFile parses the tar to find a file.

type Blob

type Blob interface {
	// GetDescriptor returns the descriptor associated with the blob.
	GetDescriptor() descriptor.Descriptor
	// RawBody returns the raw content of the blob.
	RawBody() ([]byte, error)
	// RawHeaders returns the headers received from the registry.
	RawHeaders() http.Header
	// Response returns the response associated with the blob.
	Response() *http.Response

	// Digest returns the provided or calculated digest of the blob.
	//
	// Deprecated: Digest should be replaced by GetDescriptor().Digest.
	Digest() digest.Digest
	// Length returns the provided or calculated length of the blob.
	//
	// Deprecated: Length should be replaced by GetDescriptor().Size.
	Length() int64
	// MediaType returns the Content-Type header received from the registry.
	//
	// Deprecated: MediaType should be replaced by GetDescriptor().MediaType.
	MediaType() string
}

Blob interface is used for returning blobs.

type Common

type Common = *BCommon

Common was previously an interface. A type alias is provided for upgrades.

type OCIConfig

type OCIConfig = *BOCIConfig

OCIConfig was previously an interface. A type alias is provided for upgrading.

type Opts

type Opts func(*blobConfig)

Opts is used for options to create a new blob.

func WithDesc

func WithDesc(d descriptor.Descriptor) Opts

WithDesc specifies the descriptor associated with the blob.

func WithHeader

func WithHeader(header http.Header) Opts

WithHeader defines the headers received when pulling a blob.

func WithImage

func WithImage(image v1.Image) Opts

WithImage provides the OCI Image config needed for config blobs.

func WithRawBody

func WithRawBody(raw []byte) Opts

WithRawBody defines the raw blob contents for OCIConfig.

func WithReader

func WithReader(rc io.Reader) Opts

WithReader defines the reader for a new blob.

func WithRef

func WithRef(r ref.Ref) Opts

WithRef specifies the reference where the blob was pulled from.

func WithResp

func WithResp(resp *http.Response) Opts

WithResp includes the http response, which is used to extract the headers and reader.

type Reader

type Reader = *BReader

Reader was previously an interface. A type alias is provided for upgrading.

type TarReader added in v0.4.5

type TarReader = *BTarReader

TarReader was previously an interface. A type alias is provided for upgrading.

Jump to

Keyboard shortcuts

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