Documentation
¶
Index ¶
- Constants
- Variables
- func AddKnownMediaTypesToCtx(ctx context.Context, mediaTypes []string) context.Context
- func ConvertV1ManifestToV2(ctx context.Context, client Client, cache cache.Cache, ref string, ...) (ocispecv1.Descriptor, error)
- func Copy(ctx context.Context, client Client, srcRef, tgtRef string) error
- func CreateDescriptorFromManifest(manifest *ocispecv1.Manifest) (ocispecv1.Descriptor, error)
- func CreateV2Config(v1Manifest *V1Manifest, diffIDs []digest.Digest, history []ocispecv1.History) (ocispecv1.Descriptor, []byte, error)
- func CreateV2Manifest(configDesc ocispecv1.Descriptor, layers []ocispecv1.Descriptor) (ocispecv1.Descriptor, []byte, error)
- func GetLayerByDigest(layers []ocispecv1.Descriptor, digest string) []ocispecv1.Descriptor
- func GetLayerByMediaType(layers []ocispecv1.Descriptor, mediaType string) []ocispecv1.Descriptor
- func GetLayerByName(layers []ocispecv1.Descriptor, name string) *ocispecv1.Descriptor
- func IsMultiArchImage(mediaType string) bool
- func IsSingleArchImage(mediaType string) bool
- func NewClient(log logr.Logger, opts ...Option) (*client, error)
- func ParseImageRef(ref string) (repository, version string, err error)
- func ParseV1Manifest(ctx context.Context, client Client, ref string, v1Manifest *V1Manifest) (layers []ocispecv1.Descriptor, diffIDs []digest.Digest, ...)
- func TagIsDigest(tag string) bool
- type AllowPlainHttp
- type Client
- type ExtendedClient
- type FSLayer
- type GenericStore
- type History
- type Option
- type Options
- type PushOption
- type PushOptions
- type Resolver
- type Store
- type V1History
- type V1Manifest
- type WithCacheOption
- type WithHTTPClient
- type WithKeyringOption
- type WithKnownMediaType
- type WithStoreOption
Constants ¶
const ( MediaTypeDockerV2Schema1Manifest = "application/vnd.docker.distribution.manifest.v1+json" MediaTypeDockerV2Schema1SignedManifest = images.MediaTypeDockerSchema1Manifest MediaTypeImageLayerZstd = "application/vnd.oci.image.layer.v1.tar+zstd" )
const MediaTypeTar = "application/tar"
MediaTypeTar is the media type for a tar
const MediaTypeTarGzip = "application/tar+gzip"
MediaTypeTarGzip is the media type for a gzipped tar
Variables ¶
var DefaultKnownMediaTypes = sets.NewString( MediaTypeTarGzip, MediaTypeTar, )
DefaultKnownMediaTypes contain also known media types of the oci client
Functions ¶
func AddKnownMediaTypesToCtx ¶
AddKnownMediaTypesToCtx adds a list of known media types to the context
func ConvertV1ManifestToV2 ¶
func ConvertV1ManifestToV2(ctx context.Context, client Client, cache cache.Cache, ref string, v1ManifestDesc ocispecv1.Descriptor) (ocispecv1.Descriptor, error)
ConvertV1ManifestToV2 converts a Docker v2 Schema 1 manifest to Docker v2 Schema 2. The converted manifest is stored in the cache. The descriptor of the cached manifest is returned.
func Copy ¶
Copy copies a oci artifact from one location to a target ref. The artifact is copied without any modification. This function does directly stream the blobs from the upstream it does not use any cache.
func CreateDescriptorFromManifest ¶
func CreateDescriptorFromManifest(manifest *ocispecv1.Manifest) (ocispecv1.Descriptor, error)
func CreateV2Config ¶
func CreateV2Config(v1Manifest *V1Manifest, diffIDs []digest.Digest, history []ocispecv1.History) (ocispecv1.Descriptor, []byte, error)
CreateV2Config creates a v2 config
func CreateV2Manifest ¶
func CreateV2Manifest(configDesc ocispecv1.Descriptor, layers []ocispecv1.Descriptor) (ocispecv1.Descriptor, []byte, error)
CreateV2Manifest creates a v2 manifest
func GetLayerByDigest ¶
func GetLayerByDigest(layers []ocispecv1.Descriptor, digest string) []ocispecv1.Descriptor
GetLayerByDigest returns the layers with a given digest.
func GetLayerByMediaType ¶
func GetLayerByMediaType(layers []ocispecv1.Descriptor, mediaType string) []ocispecv1.Descriptor
GetLayerByMediaType returns the layers with a given mediatype.
func GetLayerByName ¶
func GetLayerByName(layers []ocispecv1.Descriptor, name string) *ocispecv1.Descriptor
GetLayerByName returns the layer with a given name. The name should be specified by the annotation title.
func IsMultiArchImage ¶
func IsSingleArchImage ¶
func ParseImageRef ¶
ParseImageRef parses a valid image ref into its repository and version
func ParseV1Manifest ¶
func ParseV1Manifest(ctx context.Context, client Client, ref string, v1Manifest *V1Manifest) (layers []ocispecv1.Descriptor, diffIDs []digest.Digest, history []ocispecv1.History, err error)
ParseV1Manifest returns the data necessary to build a v2 manifest from a v1 manifest
Types ¶
type AllowPlainHttp ¶
type AllowPlainHttp bool
AllowPlainHttp sets the allow plain http flag.
func (AllowPlainHttp) ApplyOption ¶
func (c AllowPlainHttp) ApplyOption(options *Options)
type Client ¶
type Client interface {
Resolver
// Fetch fetches the blob for the given ocispec Descriptor.
Fetch(ctx context.Context, ref string, desc ocispecv1.Descriptor, writer io.Writer) error
// PushBlob uploads the blob for the given ocispec Descriptor to the given ref
PushBlob(ctx context.Context, ref string, desc ocispecv1.Descriptor, opts ...PushOption) error
// GetRawManifest returns the raw manifest for a reference.
// The returned manifest can either be single arch or multi arch (image index/manifest list)
GetRawManifest(ctx context.Context, ref string) (ocispecv1.Descriptor, []byte, error)
// PushRawManifest uploads the given raw manifest to the given reference.
// If the manifest is multi arch (image index/manifest list), only the multi arch manifest is pushed.
// The referenced single arch manifests must be pushed individiually before.
PushRawManifest(ctx context.Context, ref string, desc ocispecv1.Descriptor, rawManifest []byte, opts ...PushOption) error
// GetManifest returns the ocispec Manifest for a reference
// Deprecated: Please prefer GetRawManifest instead
GetManifest(ctx context.Context, ref string) (*ocispecv1.Manifest, error)
// PushManifest uploads the given Manifest to the given reference.
// Deprecated: Please prefer PushRawManifest instead
PushManifest(ctx context.Context, ref string, manifest *ocispecv1.Manifest, opts ...PushOption) error
// GetOCIArtifact returns an OCIArtifact for a reference.
// Deprecated: Please prefer GetRawManifest instead
GetOCIArtifact(ctx context.Context, ref string) (*oci.Artifact, error)
// PushOCIArtifact uploads the given OCIArtifact to the given ref.
// Deprecated: Please prefer PushRawManifest instead
PushOCIArtifact(ctx context.Context, ref string, artifact *oci.Artifact, opts ...PushOption) error
}
type ExtendedClient ¶
type ExtendedClient interface {
Client
// ListTags returns a list of all tags of the given ref.
ListTags(ctx context.Context, ref string) ([]string, error)
// ListRepositories lists all repositories for the given registry host.
ListRepositories(ctx context.Context, registryHost string) ([]string, error)
}
ExtendedClient defines an oci client with extended functionality that may not work with all registries.
type FSLayer ¶
type FSLayer struct {
BlobSum digest.Digest `json:"blobSum"`
}
FSLayer represents 1 item in a schema 1 "fsLayers" list
type GenericStore ¶
GenericStore is a helper struct to implement a custom oci blob store.
func (GenericStore) Get ¶
func (s GenericStore) Get(desc ocispecv1.Descriptor) (io.ReadCloser, error)
type History ¶
type History struct {
V1Compatibility string `json:"v1Compatibility"`
}
History represents 1 item in a schema 1 "history" list
type Option ¶
type Option interface {
ApplyOption(options *Options)
}
Option is the interface to specify different cache options
func WithKeyring ¶
func WithKeyring(ring credentials.OCIKeyring) Option
WithKeyring return a option that configures the resolver to use the given oci keyring
type Options ¶
type Options struct {
// Paths configures local paths to search for docker configuration files
Paths []string
// AllowPlainHttp allows the fallback to http if https is not supported by the registry.
AllowPlainHttp bool
// Keyring sets the used keyring.
// A default keyring will be created if not given.
Keyring credentials.OCIKeyring
// CacheConfig contains the cache configuration.
// Tis configuration will automatically create a new cache based on that configuration.
// This cache can be overwritten with the Cache property.
CacheConfig *cache.Options
// Cache is the oci cache to be used by the client
Cache cache.Cache
// CustomMediaTypes defines the custom known media types
CustomMediaTypes sets.String //nolint:all
HTTPClient *http.Client
}
Options contains all client options to configure the oci client.
func (*Options) ApplyOptions ¶
ApplyOptions applies the given list options on these options, and then returns itself (for convenient chaining).
type PushOption ¶
type PushOption interface {
ApplyPushOption(options *PushOptions)
}
PushOption is the interface to specify different cache options
type PushOptions ¶
type PushOptions struct {
// Store is the oci cache to be used by the client
Store Store
}
PushOptions contains all oci push options.
func (*PushOptions) ApplyOptions ¶
func (o *PushOptions) ApplyOptions(opts []PushOption) *PushOptions
ApplyOptions applies the given list options on these options, and then returns itself (for convenient chaining).
type Resolver ¶
type Resolver interface {
// Resolve attempts to resolve the reference into a name and descriptor.
//
// The argument `ref` should be a scheme-less URI representing the remote.
// Structurally, it has a host and path. The "host" can be used to directly
// reference a specific host or be matched against a specific handler.
//
// The returned name should be used to identify the referenced entity.
// Depending on the remote namespace, this may be immutable or mutable.
// While the name may differ from ref, it should itself be a valid ref.
//
// If the resolution fails, an error will be returned.
Resolve(ctx context.Context, ref string) (name string, desc ocispecv1.Descriptor, err error)
}
Resolver provides remotes based on a locator.
type Store ¶
type Store interface {
Get(desc ocispecv1.Descriptor) (io.ReadCloser, error)
}
Store describes a store that returns a io reader for a descriptor
type V1History ¶
type V1History struct {
Author string `json:"author,omitempty"`
Created time.Time `json:"created"`
Comment string `json:"comment,omitempty"`
ThrowAway *bool `json:"throwaway,omitempty"`
Size *int `json:"Size,omitempty"`
ContainerConfig struct {
Cmd []string `json:"Cmd,omitempty"`
} `json:"container_config,omitempty"`
}
V1History is the unmarshalled v1Compatibility property of a history item
type V1Manifest ¶
V1Manifest describes a Docker v2 Schema 1 manifest
type WithCacheOption ¶
WithCacheOption configures a cache for the oci client
func WithCache ¶
func WithCache(c cache.Cache) WithCacheOption
WithCache configures a cache for the oci client
func (WithCacheOption) ApplyOption ¶
func (c WithCacheOption) ApplyOption(options *Options)
func (WithCacheOption) ApplyPushOption ¶
func (c WithCacheOption) ApplyPushOption(options *PushOptions)
type WithHTTPClient ¶
WithHTTPClient configures the http client.
func (WithHTTPClient) ApplyOption ¶
func (c WithHTTPClient) ApplyOption(options *Options)
type WithKeyringOption ¶
type WithKeyringOption struct {
credentials.OCIKeyring
}
WithKeyringOption configures the resolver to use the given oci keyring
func (WithKeyringOption) ApplyOption ¶
func (c WithKeyringOption) ApplyOption(options *Options)
type WithKnownMediaType ¶
type WithKnownMediaType string
WithKnownMediaType adds a known media types to the client
func (WithKnownMediaType) ApplyOption ¶
func (c WithKnownMediaType) ApplyOption(options *Options)
type WithStoreOption ¶
type WithStoreOption struct {
Store
}
WithStoreOption configures a cache for the oci client
func WithStore ¶
func WithStore(store Store) WithStoreOption
WithStore configures a store for the oci push.
func (WithStoreOption) ApplyPushOption ¶
func (c WithStoreOption) ApplyPushOption(options *PushOptions)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_ociclient is a generated GoMock package.
|
Package mock_ociclient is a generated GoMock package. |
|
test
|
|
|
utils
|
|