ociutil

package
v0.0.0-...-18cb69e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PublicVisibility = []string{"//visibility:public"}
)

Functions

func ContentTypesFilterHandler

func ContentTypesFilterHandler(handler images.HandlerFunc, contentTypes ...string) images.HandlerFunc

ContentTypesFilterHandler filters the children of the handler to only include the listed content types

func CopyAndCreateDescriptor

func CopyAndCreateDescriptor(reader io.Reader, writer io.Writer) (ocispec.Descriptor, error)

CopyAndCreateDescriptor copys a reader to a writer and returns a descriptor, note that this desciptor will only have the Digest and Size fields populated.

func CopyChildrenFromHandler

func CopyChildrenFromHandler(ctx context.Context, handler images.HandlerFunc, from content.Provider, to content.Ingester, parent ocispec.Descriptor) error

CopyChildrenFromHandler performs a recursive depth-first copy of the parent descriptors children (as returned by calling handler on the parent) from the provider to the ingester

func CopyContent

func CopyContent(ctx context.Context, from content.Provider, to content.Ingester, desc ocispec.Descriptor) error

CopyContent copies a descriptor from a provider to an ingestor interfaces provider by "containerd/content". Useful when you want to copy between layouts or when pulling an image via oras.ProviderWrapper

func CopyContentHandler

func CopyContentHandler(handler images.HandlerFunc, from content.Provider, to content.Ingester) images.HandlerFunc

CopyContentHandler copies the parent descriptor from the provider to the ingestor

func CopyJSONToFileAndCreateDescriptor

func CopyJSONToFileAndCreateDescriptor(inf interface{}, outFile string) (ocispec.Descriptor, error)

CopyJSONToFileAndCreateDescriptor encodes inf to json and then writes it to a file, returning the descriptor.

func CopyReaderToFileAndCreateDescriptor

func CopyReaderToFileAndCreateDescriptor(reader io.Reader, outFile string) (ocispec.Descriptor, error)

CopyReaderToFileAndCreateDescriptor copys a reader to a file and then returns a descriptor.

func DescriptorToURL

func DescriptorToURL(reg string, desc ocispec.Descriptor) (string, error)

DescriptortoURL converts a combination of a registry and a descriptor to a URL that the blob can be downloaded from.

func ExtendedResolver

func ExtendedResolver(resolver remotes.Resolver, hosts docker.RegistryHosts) remotes.Resolver

func FetchAndJSONDecode

func FetchAndJSONDecode(ctx context.Context, fetch remotes.FetcherFunc, desc ocispec.Descriptor, inf interface{}) error

FetchAndJSONDecodefetches a the content from a descriptor and unmarshalls it into a struct

func FetchertoProvider

func FetchertoProvider(fetcher remotes.Fetcher) content.Provider

func GenerateBuildFilesHandler

func GenerateBuildFilesHandler(handler images.HandlerFunc, layoutRoot string, provider content.Provider) images.HandlerFunc

GenerateBuildFilesHandler generates build files while walking a tree. TODO Ideally, this should actually be a content.WalkFunc, but ocilayout doesn't implement this interface yet

func GetLayerDiffID

func GetLayerDiffID(ctx context.Context, store content.Store, desc ocispec.Descriptor) (digest.Digest, error)

GetLayerDiffID will return the diff ID of a given layer descriptor to be used within an image config. If a layer is uncompressed, the diff ID is simply the digest but if the layer is compressed, we must uncompress the file and acquire the digest.

func ImageConfigFromProvider

func ImageConfigFromProvider(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) (ocispec.Image, error)

ImageConfigFromProvider fetches an image config from a provider and decodes it. The descriptor must point directly at the image config.

XXX: This function assumes that the data is json encoded.

func ImageConfigToPlatform

func ImageConfigToPlatform(cfg ocispec.Image) ocispec.Platform

imageConfigToPlatform creates a Platform from an Image Config type

func ImageIndexFromProvider

func ImageIndexFromProvider(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) (ocispec.Index, error)

ImageIndexFromProvider fetches an image index from a provider and decodes it.

XXX: This function assumes that the data is json encoded.

func ImageManifestFromProvider

func ImageManifestFromProvider(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) (ocispec.Manifest, error)

ImageManifestFromProvider fetches an image manifest from a provider and decodes it.

XXX: This function assumes that the data is json encoded.

func IngestorJSONEncode

func IngestorJSONEncode(ctx context.Context, ing content.Ingester, mediaType string, inf interface{}) (ocispec.Descriptor, error)

IngestorJSONEncode encodes json and saves it to a ingester.

func IsEmptyPlatform

func IsEmptyPlatform(plat *ocispec.Platform) bool

func ManifestFromIndex

func ManifestFromIndex(manifest ocispec.Index, platform platforms.MatchComparer) (ocispec.Descriptor, error)

ManifestFromIndex gets an OCI Manifest from an image index that matches the desired platform.

func MultiProvider

func MultiProvider(providers ...content.Provider) content.Provider

MultiProvider will read from the first provider that can read the requrested descriptor.

func NamedRef

func NamedRef(ref string) (dref.Named, error)

NamedRef will parse the ref and return a Named instance of it.

func NewTarIngestor

func NewTarIngestor(path string) content.Ingester

func ProviderJSONDecode

func ProviderJSONDecode(ctx context.Context, provider content.Provider, desc ocispec.Descriptor, inf interface{}) error

ProviderJSONDecode fetches content content from a provider and decodes the json content.

func ReadDescriptorFromFile

func ReadDescriptorFromFile(path string) (ocispec.Descriptor, error)

DescriptorFromFile reads an OCI descriptor from a file path.

XXX Descriptor must be json encoded

func RefToPath

func RefToPath(ref string) (string, error)

RefToPath will parse the ref and just its path

func RefToRegistryName

func RefToRegistryName(ref string) (string, error)

RefToRegistryName will return a hostname of a registry given a reference string.

func ResolvePlatformFromDescriptor

func ResolvePlatformFromDescriptor(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) (ocispec.Platform, error)

ResolvePlatformFromDescriptor resolves a platform from an image manifest, by looking at the OS and Arch variables in the image config

func SplitStore

func SplitStore(ing content.Ingester, prov content.Provider) content.Store

SplitStore implementents content.Store, where reads are from a different store than writes.

func WriteDescriptorToFile

func WriteDescriptorToFile(path string, desc ocispec.Descriptor) error

WriteDescriptorToFile writes an OCI descriptor to a file.

Types

type ProviderWrapper

type ProviderWrapper struct {
	Fetcher remotes.Fetcher
}

ProviderWrapper wraps a remote.Fetcher to make a content.Provider, which is useful for things

func (*ProviderWrapper) ReaderAt

type RepositoryIngester

type RepositoryIngester interface {
	Contains(ctx context.Context, dgst digest.Digest) error
	Mount(ctx context.Context, from string, dgst digest.Digest) error
}

type Resolver

type Resolver struct {
	remotes.Resolver
}

func DefaultResolver

func DefaultResolver() Resolver

DefaultResolver returns a resolver with credential helper auth and ocitool extensions.

func ResolverWithHeaders

func ResolverWithHeaders(headers map[string]string) Resolver

ResolverWithHeaders returns a resolver with credential helper auth and ocitool extensions.

func (Resolver) MarshalAndPushContent

func (resolver Resolver) MarshalAndPushContent(ctx context.Context, ref string, content interface{}, mediaType string) (ocispec.Descriptor, error)

func (Resolver) PushBlob

func (resolver Resolver) PushBlob(ctx context.Context, path, ref, mediaType string) (ocispec.Descriptor, error)

PushBlob pushes a singluar blob to a registry.

func (Resolver) PushImageIndexShallow

func (resolver Resolver) PushImageIndexShallow(ctx context.Context, idx ocispec.Index, ref string) (ocispec.Descriptor, error)

PushImageIndexShallow pushes a new image index to a repository without pulling all of the dependent descriptors, aka it doesn't need to pull any of the dependent images.

XXX Currently there is a major limitation that you can only push an index who's dependencies all coexist within the same repository. To support cross-repository shallow pushes we would need to mount blobs to this repository. `containerd` has some nice facilities to walk descriptors. https://github.com/opencontainers/distribution-spec/blob/main/spec.md#mounting-a-blob-from-another-repository

type WriterCounter

type WriterCounter struct {
	io.Writer
	// contains filtered or unexported fields
}

WriterCounter is counter for io.Writer, doesn't prevent concurrent writes.

func NewWriterCounter

func NewWriterCounter(w io.Writer) *WriterCounter

NewWriterCounter function create new WriterCounter

func (*WriterCounter) Count

func (counter *WriterCounter) Count() uint64

Count function return counted bytes

func (*WriterCounter) Write

func (counter *WriterCounter) Write(buf []byte) (int, error)

Jump to

Keyboard shortcuts

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