crane

package
Version: v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0 Imports: 23 Imported by: 36

Documentation

Overview

Package crane holds libraries used to implement the crane CLI.

Example
package main

import (
	"fmt"

	"github.com/google/go-containerregistry/pkg/crane"
)

func main() {
	c := map[string][]byte{
		"/binary": []byte("binary contents"),
	}
	i, _ := crane.Image(c)
	d, _ := i.Digest()
	fmt.Println(d)
}
Output:

sha256:09fb0c6289cefaad8c74c7e5fd6758ad6906ab8f57f1350d9f4eb5a7df45ff8b

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(base v1.Image, paths ...string) (v1.Image, error)

Append reads a layer from path and appends it the the v1.Image base.

func Catalog

func Catalog(src string, opt ...Option) (res []string, err error)

Catalog returns the repositories in a registry's catalog.

func Config

func Config(ref string, opt ...Option) ([]byte, error)

Config returns the config file for the remote image ref.

func Copy

func Copy(src, dst string, opt ...Option) error

Copy copies a remote image or index from src to dst.

func Delete

func Delete(src string, opt ...Option) error

Delete deletes the remote reference at src.

func Digest

func Digest(ref string, opt ...Option) (string, error)

Digest returns the sha256 hash of the remote image at ref.

func Export

func Export(img v1.Image, w io.Writer) error

Export writes the filesystem contents (as a tarball) of img to w.

func Head(r string, opt ...Option) (*v1.Descriptor, error)

Head performs a HEAD request for a manifest and returns a content descriptor based on the registry's response.

func Image

func Image(filemap map[string][]byte) (v1.Image, error)

Image creates a image with the given filemaps as its contents. These images are reproducible and consistent. A filemap is a path -> file content map representing a file system.

func Insecure

func Insecure(o *options)

Insecure is an Option that allows image references to be fetched without TLS.

func Layer

func Layer(filemap map[string][]byte) (v1.Layer, error)

Layer creates a layer from a single file map. These layers are reproducible and consistent. A filemap is a path -> file content map representing a file system.

func ListTags

func ListTags(src string, opt ...Option) ([]string, error)

ListTags returns the tags in repository src.

func Load

func Load(path string, opt ...Option) (v1.Image, error)

Load reads the tarball at path as a v1.Image.

func LoadTag added in v0.5.0

func LoadTag(path, tag string, opt ...Option) (v1.Image, error)

LoadTag reads a tag from the tarball at path as a v1.Image. If tag is "", will attempt to read the tarball as a single image.

func Manifest

func Manifest(ref string, opt ...Option) ([]byte, error)

Manifest returns the manifest for the remote image or index ref.

func MultiSave added in v0.5.0

func MultiSave(imgMap map[string]v1.Image, path string) error

MultiSave writes collection of v1.Image img with tag as a tarball.

func MultiSaveLegacy added in v0.5.0

func MultiSaveLegacy(imgMap map[string]v1.Image, path string) error

MultiSaveLegacy writes collection of v1.Image img with tag as a legacy tarball.

func MultiSaveOCI added in v0.5.0

func MultiSaveOCI(imgMap map[string]v1.Image, path string) error

MultiSaveOCI writes collection of v1.Image img as an OCI Image Layout at path. If a layout already exists at that path, it will add the image to the index.

func Optimize added in v0.3.0

func Optimize(src, dst string, prioritize []string, opt ...Option) error

Optimize optimizes a remote image or index from src to dst. THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE WITHOUT WARNING.

func Pull

func Pull(src string, opt ...Option) (v1.Image, error)

Pull returns a v1.Image of the remote image src.

func PullLayer

func PullLayer(ref string, opt ...Option) (v1.Layer, error)

PullLayer returns the given layer from a registry.

func Push

func Push(img v1.Image, dst string, opt ...Option) error

Push pushes the v1.Image img to a registry as dst.

func Save

func Save(img v1.Image, src, path string) error

Save writes the v1.Image img as a tarball at path with tag src.

func SaveLegacy

func SaveLegacy(img v1.Image, src, path string) error

SaveLegacy writes the v1.Image img as a legacy tarball at path with tag src.

func SaveOCI

func SaveOCI(img v1.Image, path string) error

SaveOCI writes the v1.Image img as an OCI Image Layout at path. If a layout already exists at that path, it will add the image to the index.

func Tag

func Tag(img, tag string, opt ...Option) error

Tag adds tag to the remote img.

Types

type Option

type Option func(*options)

Option is a functional option for crane.

func WithAuth added in v0.2.0

func WithAuth(auth authn.Authenticator) Option

WithAuth is a functional option for overriding the default authenticator for remote operations.

By default, crane will use authn.DefaultKeychain.

func WithAuthFromKeychain added in v0.2.0

func WithAuthFromKeychain(keys authn.Keychain) Option

WithAuthFromKeychain is a functional option for overriding the default authenticator for remote operations, using an authn.Keychain to find credentials.

By default, crane will use authn.DefaultKeychain.

func WithContext added in v0.6.0

func WithContext(ctx context.Context) Option

WithContext is a functional option for setting the context.

func WithPlatform added in v0.1.4

func WithPlatform(platform *v1.Platform) Option

WithPlatform is an Option to specify the platform.

func WithTransport

func WithTransport(t http.RoundTripper) Option

WithTransport is a functional option for overriding the default transport for remote operations.

func WithUserAgent added in v0.2.0

func WithUserAgent(ua string) Option

WithUserAgent adds the given string to the User-Agent header for any HTTP requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL