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 ¶
- func Append(base v1.Image, paths ...string) (v1.Image, error)
- func Catalog(src string, opt ...Option) (res []string, err error)
- func Config(ref string, opt ...Option) ([]byte, error)
- func Copy(src, dst string, opt ...Option) error
- func CopyRepository(src, dst string, opt ...Option) error
- func Delete(src string, opt ...Option) error
- func Digest(ref string, opt ...Option) (string, error)
- func Export(img v1.Image, w io.Writer) error
- func Get(r string, opt ...Option) (*remote.Descriptor, error)
- func Head(r string, opt ...Option) (*v1.Descriptor, error)
- func Image(filemap map[string][]byte) (v1.Image, error)
- func Insecure(o *Options)
- func Layer(filemap map[string][]byte) (v1.Layer, error)
- func ListTags(src string, opt ...Option) ([]string, error)
- func Load(path string, opt ...Option) (v1.Image, error)
- func LoadTag(path, tag string, opt ...Option) (v1.Image, error)
- func Manifest(ref string, opt ...Option) ([]byte, error)
- func MultiSave(imgMap map[string]v1.Image, path string, opt ...Option) error
- func MultiSaveLegacy(imgMap map[string]v1.Image, path string) error
- func MultiSaveOCI(imgMap map[string]v1.Image, path string) error
- func Pull(src string, opt ...Option) (v1.Image, error)
- func PullLayer(ref string, opt ...Option) (v1.Layer, error)
- func Push(img v1.Image, dst string, opt ...Option) error
- func Save(img v1.Image, src, path string) error
- func SaveLegacy(img v1.Image, src, path string) error
- func SaveOCI(img v1.Image, path string) error
- func Tag(img, tag string, opt ...Option) error
- func Upload(layer v1.Layer, repo string, opt ...Option) error
- type Option
- func WithAuth(auth authn.Authenticator) Option
- func WithAuthFromKeychain(keys authn.Keychain) Option
- func WithContext(ctx context.Context) Option
- func WithJobs(jobs int) Option
- func WithNoClobber(noclobber bool) Option
- func WithNondistributable() Option
- func WithPlatform(platform *v1.Platform) Option
- func WithTransport(t http.RoundTripper) Option
- func WithUserAgent(ua string) Option
- type Options
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
Append reads a layer from path and appends it the the v1.Image base.
If the base image is a Windows base image (i.e., its config.OS is "windows"), the contents of the tarballs will be modified to be suitable for a Windows container image.`,
func CopyRepository ¶ added in v0.15.0
CopyRepository copies every tag from src to dst.
func Export ¶
Export writes the filesystem contents (as a tarball) of img to w. If img has a single layer, just write the (uncompressed) contents to w so that this "just works" for images that just wrap a single blob.
func Get ¶ added in v0.16.0
func Get(r string, opt ...Option) (*remote.Descriptor, error)
Get calls remote.Get and returns an uninterpreted response.
func Head ¶ added in v0.6.0
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 ¶
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. This will also allow for untrusted (e.g. self-signed) certificates in cases where the default transport is used (i.e. when WithTransport is not used).
func Layer ¶
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 LoadTag ¶ added in v0.5.0
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 MultiSaveLegacy ¶ added in v0.5.0
MultiSaveLegacy writes collection of v1.Image img with tag as a legacy tarball.
func MultiSaveOCI ¶ added in v0.5.0
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 SaveLegacy ¶
SaveLegacy writes the v1.Image img as a legacy tarball at path with tag src.
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
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
WithContext is a functional option for setting the context.
func WithJobs ¶ added in v0.15.0
WithJobs sets the number of concurrent jobs to run.
The default number of jobs is GOMAXPROCS.
func WithNoClobber ¶ added in v0.15.0
WithNoClobber modifies behavior to avoid overwriting existing tags, if possible.
func WithNondistributable ¶ added in v0.10.0
func WithNondistributable() Option
WithNondistributable is an option that allows pushing non-distributable layers.
func WithPlatform ¶ added in v0.1.4
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. Setting a transport will override the Insecure option's configuration allowing for image registries to use untrusted certificates.
func WithUserAgent ¶ added in v0.2.0
WithUserAgent adds the given string to the User-Agent header for any HTTP requests.
type Options ¶ added in v0.7.0
type Options struct { Name []name.Option Remote []remote.Option Platform *v1.Platform Keychain authn.Keychain Transport http.RoundTripper // contains filtered or unexported fields }
Options hold the options that crane uses when calling other packages.
func GetOptions ¶ added in v0.7.0
GetOptions exposes the underlying []remote.Option, []name.Option, and platform, based on the passed Option. Generally, you shouldn't need to use this unless you've painted yourself into a dependency corner as we have with the crane and gcrane cli packages.