Documentation
¶
Overview ¶
Package oci implements oci specific functionality, primarily related to interpreting and serializing manifests and manifest lists. Bottles are stored as oci objects with standard manifest formats, but have special handling for the purposes of working with configuration blobs.
Index ¶
- Constants
- func HasPlatformContext(ctx context.Context) bool
- func MakeManifest(config ocispec.Descriptor, layers []ocispec.Descriptor, artifactType string, ...) ([]byte, error)
- type BottleManifest
- func (b *BottleManifest) AddAnnotation(key string, value string)
- func (b *BottleManifest) Copy() ManifestHandler
- func (b *BottleManifest) GetAnnotation(key string) string
- func (b *BottleManifest) GetConfigDescriptor() ocispec.Descriptor
- func (b *BottleManifest) GetContentDescriptors() []ocispec.Descriptor
- func (b *BottleManifest) GetLayerDescriptors() []ocispec.Descriptor
- func (b *BottleManifest) GetManifestData() ocispec.Manifest
- func (b *BottleManifest) GetManifestDescriptor() ocispec.Descriptor
- func (b *BottleManifest) GetManifestRaw() ([]byte, error)
- func (b *BottleManifest) GetStatus() ManifestStatusInfo
- type CtxPlatformKey
- type ManifestHandler
- type ManifestListHandler
- func (mlh *ManifestListHandler) AddAnnotation(key string, value string)
- func (mlh *ManifestListHandler) Copy() ManifestHandler
- func (mlh *ManifestListHandler) GetAnnotation(key string) string
- func (mlh *ManifestListHandler) GetConfigDescriptor() ocispec.Descriptor
- func (mlh *ManifestListHandler) GetContentDescriptors() []ocispec.Descriptor
- func (mlh *ManifestListHandler) GetLayerDescriptors() []ocispec.Descriptor
- func (mlh *ManifestListHandler) GetManifestData() ocispec.Manifest
- func (mlh *ManifestListHandler) GetManifestDescriptor() ocispec.Descriptor
- func (mlh *ManifestListHandler) GetManifestRaw() ([]byte, error)
- func (mlh *ManifestListHandler) GetPlatformSourceRef(ctx context.Context, parentRef ref.SourceRef) (ref.SourceRef, error)
- func (mlh *ManifestListHandler) GetSourceRefs(ctx context.Context, parentRef ref.SourceRef) []ref.SourceRef
- func (mlh *ManifestListHandler) GetStatus() ManifestStatusInfo
- type ManifestStatusInfo
- type Manifests
- type ManifestsOption
Constants ¶
const ( // ManifestUnsupportedType indicates that the server returned an unsupported media type for a manifest. ManifestUnsupportedType = 1 // ManifestBadFormat indicates a badly formatted manifest was returned from the server. ManifestBadFormat = 2 // ManifestUnsupportedArchitecture indicates a failure to identify a valid architecture for an image. ManifestUnsupportedArchitecture = 3 // ManifestOK indicates that a manifest pull occurred successfully. ManifestOK = 200 // ManifestBadRequest is a manifest pull status indicating a malformed repository Name. ManifestBadRequest = 400 // ManifestAuthRequired is a manifest pull status indicating authentication needs to be performed. ManifestAuthRequired = 401 // ManifestAccessDenied is a manifest pull status indicating user doesn't have access to repository. ManifestAccessDenied = 403 // ManifestNotFound is a manifest pull status indicating that the requested manifest is not found. ManifestNotFound = 404 )
const ( // MediaTypeImageManifestDocker represents the media type for docker's v2 manifest, which matches the oci manifest // spec, but must be added as an acceptable media type. MediaTypeImageManifestDocker string = "application/vnd.docker.distribution.manifest.v2+json" // MediaTypeImageManifestDockerList represents the media type for manifest list content, which is not supported by // oci, but provides a redirection to alternate platform versions (or sub-manifests?) MediaTypeImageManifestDockerList string = "application/vnd.docker.distribution.manifest.list.v2+json" )
Variables ¶
This section is empty.
Functions ¶
func HasPlatformContext ¶
HasPlatformContext is a function to determine if a the context has any of the platform values set TODO I think this function is a bad idea.
func MakeManifest ¶
func MakeManifest(config ocispec.Descriptor, layers []ocispec.Descriptor, artifactType string, annos map[string]string) ([]byte, error)
MakeManifest creates a manifest object and encodes it to json, including config descriptor, layers, artifactType and annotations. If an artifact type is not known, an empty string can be used to avoid adding it to the manifest.
Types ¶
type BottleManifest ¶
type BottleManifest struct {
Descriptor ocispec.Descriptor
Manifest ocispec.Manifest
ManifestStatusInfo
// contains filtered or unexported fields
}
BottleManifest is an alias for ocispec.Manifest which implements the manifest handler interface. It also contains information about the manifest descriptor itself (notably, size, Digest, etc), and a status structure used during transfer. This structure implements the ManifestHandler interface.
func (*BottleManifest) AddAnnotation ¶
func (b *BottleManifest) AddAnnotation(key string, value string)
AddAnnotation adds the provided key/value annotation to the manifest descriptor, allowing custom information to be assigned to individual manifests, and implementing the ManifestHandler interface.
func (*BottleManifest) Copy ¶
func (b *BottleManifest) Copy() ManifestHandler
Copy creates a fresh manifest handler based on the data contained in the current BottleManifest. This allows a duplicate handler to be modified (such as adding annotations) without updating the originating handler.
func (*BottleManifest) GetAnnotation ¶
func (b *BottleManifest) GetAnnotation(key string) string
GetAnnotation returns the annotation for the manifest denoted by key, or an empty string.
func (*BottleManifest) GetConfigDescriptor ¶
func (b *BottleManifest) GetConfigDescriptor() ocispec.Descriptor
GetConfigDescriptor returns the configuration descriptor contained within the manifest. Note this does not include any config data apart from annotations, a separate transfer is necessary to retrieve the required data.
func (*BottleManifest) GetContentDescriptors ¶
func (b *BottleManifest) GetContentDescriptors() []ocispec.Descriptor
GetContentDescriptors returns a collection of content descriptors, with the config blob first, implementing the ManifestHandler interface.
func (*BottleManifest) GetLayerDescriptors ¶
func (b *BottleManifest) GetLayerDescriptors() []ocispec.Descriptor
GetLayerDescriptors implements the ManifestHandler interface.
func (*BottleManifest) GetManifestData ¶
func (b *BottleManifest) GetManifestData() ocispec.Manifest
GetManifestData returns the full manifest data object.
func (*BottleManifest) GetManifestDescriptor ¶
func (b *BottleManifest) GetManifestDescriptor() ocispec.Descriptor
GetManifestDescriptor returns the oci descriptor for the manifest itself, implementing the ManifestHandler interface.
func (*BottleManifest) GetManifestRaw ¶
func (b *BottleManifest) GetManifestRaw() ([]byte, error)
GetManifestRaw returns the original raw data for the manifest, useful to avoid errors that occur when roundtripping decode/encode for non-bottle manifests.
func (*BottleManifest) GetStatus ¶
func (b *BottleManifest) GetStatus() ManifestStatusInfo
GetStatus returns the status information after a transfer for a manifest, implementing the ManifestHandler interface.
type CtxPlatformKey ¶
type CtxPlatformKey string
CtxPlatformKey is a context key type for specifying context platform values for image selection.
const ( // CtxPlatform specifies a combined os/arch platform selector. CtxPlatform CtxPlatformKey = "platform" // CtxPlatformOs specifies an os platform selector. CtxPlatformOs CtxPlatformKey = "platform_os" // CtxPlatformArch specifies an architecture platform selector. CtxPlatformArch CtxPlatformKey = "platform_arch" // CtxPlatformVariant specifies an architecture variant platform selector. CtxPlatformVariant CtxPlatformKey = "platform_variant" )
type ManifestHandler ¶
type ManifestHandler interface {
// GetManifestDescriptor returns the OCI descriptor for the manifest data
GetManifestDescriptor() ocispec.Descriptor
// GetConfigDescriptor returns the OCI descriptor for the config record within the manifest data
GetConfigDescriptor() ocispec.Descriptor
// GetLayerDescriptors returns a list of OCI descriptors for each layer specified in a manifest
GetLayerDescriptors() []ocispec.Descriptor
// GetContentDescriptors returns a list of OCI descriptors for each layer and config specified in a manifest
GetContentDescriptors() []ocispec.Descriptor
// GetManifestData returns an OCI manifest structure filled with manifest data
GetManifestData() ocispec.Manifest
// GetManifestRaw returns a json formatted slice of bytes representing the manifest data
GetManifestRaw() ([]byte, error)
// GetStatus returns information about the transfer of a manifest, including http and internal error information
GetStatus() ManifestStatusInfo
// AddAnnotation adds a key value annotation to the manifest
AddAnnotation(key string, value string)
// GetAnnotation returns a annotation value based on a given key, or empty if the key is not found
GetAnnotation(key string) string
// Copy duplicates a manifest handler, changes to be made without affecting the original. Notably, this facilitates
// tracking the transfer of a manifest to multiple destinations asynchronously (due to transfer status information
// for GetStatus needing to be tracked separately)
Copy() ManifestHandler
}
ManifestHandler defines an interface for unifying layer descriptor extraction from manifests, different manifest formats store layer descriptors differently.
func ManifestFromData ¶
func ManifestFromData(contentType string, data []byte) ManifestHandler
ManifestFromData generates a ManifestHandler from json formatted data bytes and a content type hint.
type ManifestListHandler ¶
type ManifestListHandler struct {
Descriptor ocispec.Descriptor
ManifestList ocispec.Index
ManifestStatusInfo
// contains filtered or unexported fields
}
ManifestListHandler is a manifest handler representing a list of manifests as provided by the MediaTypeManifestDockerList.
func (*ManifestListHandler) AddAnnotation ¶
func (mlh *ManifestListHandler) AddAnnotation(key string, value string)
AddAnnotation adds the provided key/value annotation to the manifest descriptor, allowing custom information to be assigned to individual manifests, and implementing the ManifestHandler interface.
func (*ManifestListHandler) Copy ¶
func (mlh *ManifestListHandler) Copy() ManifestHandler
Copy creates a fresh manifest handler based on the data contained in the current BottleManifest. This allows a duplicate handler to be modified (such as adding annotations) without updating the originating handler.
func (*ManifestListHandler) GetAnnotation ¶
func (mlh *ManifestListHandler) GetAnnotation(key string) string
GetAnnotation returns the annotation for the manifest denoted by key, or an empty string.
func (*ManifestListHandler) GetConfigDescriptor ¶
func (mlh *ManifestListHandler) GetConfigDescriptor() ocispec.Descriptor
GetConfigDescriptor returns an empty descriptor, as manifest lists do not include config information.
func (*ManifestListHandler) GetContentDescriptors ¶
func (mlh *ManifestListHandler) GetContentDescriptors() []ocispec.Descriptor
GetContentDescriptors returns a collection of manifest descriptors from the manifest list.
func (*ManifestListHandler) GetLayerDescriptors ¶
func (mlh *ManifestListHandler) GetLayerDescriptors() []ocispec.Descriptor
GetLayerDescriptors implements ManifestHandler.
func (*ManifestListHandler) GetManifestData ¶
func (mlh *ManifestListHandler) GetManifestData() ocispec.Manifest
GetManifestData for ManifestListHandler returns an empty Manifest object.
func (*ManifestListHandler) GetManifestDescriptor ¶
func (mlh *ManifestListHandler) GetManifestDescriptor() ocispec.Descriptor
GetManifestDescriptor for ManifestListHandler returns the oci descriptor for the manifest itself, implementing the ManifestHandler interface.
func (*ManifestListHandler) GetManifestRaw ¶
func (mlh *ManifestListHandler) GetManifestRaw() ([]byte, error)
GetManifestRaw returns the original raw data for the manifest list.
func (*ManifestListHandler) GetPlatformSourceRef ¶
func (mlh *ManifestListHandler) GetPlatformSourceRef(ctx context.Context, parentRef ref.SourceRef) (ref.SourceRef, error)
GetPlatformSourceRef creates a new source ref from a parent source ref, redirecting the source from the original to a platform-appropriate manifest, based on platform values in the supplied context.
func (*ManifestListHandler) GetSourceRefs ¶
func (mlh *ManifestListHandler) GetSourceRefs(ctx context.Context, parentRef ref.SourceRef) []ref.SourceRef
GetSourceRefs returns a slice containing all child source references in a manifest list. To get a single architecture ref, use GetPlatformSourceRef.
func (*ManifestListHandler) GetStatus ¶
func (mlh *ManifestListHandler) GetStatus() ManifestStatusInfo
GetStatus returns the status information after a transfer for a manifest list, implementing the ManifestHandler interface.
type ManifestStatusInfo ¶
ManifestStatusInfo is a structure for recording status information encountered while pulling a manifest.
type Manifests ¶
type Manifests struct {
SourceSet ref.Set
Client *http.Client
InsecureAllowed bool
Concurrency int
// contains filtered or unexported fields
}
Manifests is an object that implements retrieval of manifests specified in source set. A destination store provides a location where manifest blobs can be saved, and prior existence of objects can be checked with an Exist set.
func (Manifests) GetNumSources ¶
GetNumSources returns the number of manifests in the cache if there are any, or the number of source refs defined in the internal SourceSet.
type ManifestsOption ¶
type ManifestsOption func(ocim *Manifests)
ManifestsOption allows configuration of an oci manifests structure on creation, such as assigning a transferworker.