### List Tags for a Repository with Authentication Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote/transport This example demonstrates how to list tags for a repository by constructing an authenticated http.Client. It fetches credentials from the default keychain, creates a transport with appropriate scopes, and makes an authenticated GET request. It also includes error checking using `transport.CheckError` and writes the response to standard output. ```go package main import ( "io" "net/http" "os" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/remote/transport" ) func main() { repo, err := name.NewRepository("gcr.io/google-containers/pause") if err != nil { panic(err) } // Fetch credentials based on your docker config file, which is $HOME/.docker/config.json or $DOCKER_CONFIG. auth, err := authn.DefaultKeychain.Resolve(repo.Registry) if err != nil { panic(err) } // Construct an http.Client that is authorized to pull from gcr.io/google-containers/pause. scopes := []string{repo.Scope(transport.PullScope)} t, err := transport.New(repo.Registry, auth, http.DefaultTransport, scopes) if err != nil { panic(err) } client := &http.Client{Transport: t} // Make the actual request. resp, err := client.Get("https://gcr.io/v2/google-containers/pause/tags/list") if err != nil { panic(err) } // Assert that we get a 200, otherwise attempt to parse body as a structured error. if err := transport.CheckError(resp, http.StatusOK); err != nil { panic(err) } // Write the response to stdout. if _, err := io.Copy(os.Stdout, resp.Body); err != nil { panic(err) } } ``` -------------------------------- ### Docker Config JSON Example Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn Example of a Docker config.json file storing credentials in plaintext. ```json { "auths": { "registry.example.com": { "auth": "QXp1cmVEaWFtb25kOmh1bnRlcjI=" } } } ``` -------------------------------- ### Install Crane via Go Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane Installs the crane command-line tool using the Go toolchain. ```go go install github.com/google/go-containerregistry/cmd/crane@latest ``` -------------------------------- ### Example Progress Output Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball This example shows the expected output format for progress updates when writing a tarball. ```text 4096/4096 ``` -------------------------------- ### Install gcrane Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/gcrane Installs the latest version of gcrane using go install. ```bash go install github.com/google/go-containerregistry/cmd/gcrane@latest ``` -------------------------------- ### Setup Crane on GitHub Actions Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane Configures a GitHub Actions workflow to install crane and set up authentication for GitHub Container Registry. ```yaml steps: - uses: imjasonh/setup-crane@v0.1 ``` -------------------------------- ### Example Output Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane This is an example output from the crane package, showing a SHA256 digest. ```text sha256:09fb0c6289cefaad8c74c7e5fd6758ad6906ab8f57f1350d9f4eb5a7df45ff8b ``` -------------------------------- ### Docker Credential Helper Protocol - Get Credentials for Different Registry Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn Example of invoking the same credential helper for a different registry, demonstrating the need to pass the domain via STDIN. ```bash $ echo "eu.gcr.io" | docker-credential-gcr get {"Username":"_token","Secret":""} ``` -------------------------------- ### Get Image Catalog Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Returns a list of repositories available in a container registry catalog. ```go func Catalog(src string, opt ...Option) (res []string, err error) ``` -------------------------------- ### Get Manifest Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the manifest. ```go func Manifest(i WithRawManifest) (*v1.Manifest, error) ``` -------------------------------- ### Upload Stdin as a Layer to a Local Registry Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/stream This example demonstrates how to upload the contents of standard input as a layer to a local registry using the stream package. It requires setting up a repository name and creating a stream layer from os.Stdin. ```go package main import ( "os" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/stream" ) // upload the contents of stdin as a layer to a local registry func main() { repo, err := name.NewRepository("localhost:5000/stream") if err != nil { panic(err) } layer := stream.NewLayer(os.Stdin) if err := remote.WriteLayer(repo, layer); err != nil { panic(err) } } ``` -------------------------------- ### Docker Credential Helper Protocol - Get Credentials Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn Example of invoking a credential helper binary (docker-credential-gcr) to get credentials for a registry. ```bash $ echo "gcr.io" | docker-credential-gcr get {"Username":"_token","Secret":""} ``` -------------------------------- ### Get Config File Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the configuration file. ```go func ConfigFile(i WithRawConfigFile) (*v1.ConfigFile, error) ``` -------------------------------- ### Options Struct Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/kubernetes Configuration options for guiding credential resolution. ```APIDOC ## type Options ### Description Options holds configuration data for guiding credential resolution. ### Fields * `Namespace` (string) - The namespace for resolving service account and pull secret references. Defaults to "default" if empty. * `ServiceAccountName` (string) - The service account name within the namespace. Defaults to "default" if empty. Use `NoServiceAccount` to avoid lookup. * `ImagePullSecrets` ([]string) - A slice of names of Kubernetes secrets containing credential data. * `UseMountSecrets` (bool) - Determines whether to consider mount secrets in the ServiceAccount. Ignored if `ServiceAccountName` is `NoServiceAccount`. ``` -------------------------------- ### Install Crane via Pacman Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane Installs crane on Arch Linux using the pacman package manager. ```bash $ pacman -S crane ``` -------------------------------- ### Get Manifests from Image Index Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Retrieves a list of Describable items from an image index. ```go func Manifests(idx v1.ImageIndex) ([]Describable, error) ``` -------------------------------- ### Get Image Manifest Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Retrieves the manifest for a remote image reference. ```go func Manifest(ref string, opt ...Option) ([]byte, error) ``` -------------------------------- ### Install Crane via Homebrew Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane Installs crane on macOS using the Homebrew package manager. ```bash $ brew install crane ``` -------------------------------- ### Get Image Config Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Retrieves the configuration file for a specified remote image reference. ```go func Config(ref string, opt ...Option) ([]byte, error) ``` -------------------------------- ### Get Image Index from Path Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/layout Constructs a Path and returns its v1.ImageIndex. Use this to load an existing OCI image layout. ```go func ImageIndexFromPath(path string) (v1.ImageIndex, error) ``` -------------------------------- ### Configure Credential Helpers in Docker Config Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn Modify the Docker configuration file to use custom credential helpers. This example shows how to map registry hosts to specific helper executables. ```json { "credHelpers": { "gcr.io": "tee", "eu.gcr.io": "hardcoded" } } ``` -------------------------------- ### Get Raw Config File Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the raw configuration file bytes. ```go func RawConfigFile(i WithConfigFile) ([]byte, error) ``` -------------------------------- ### Ping Registry for Challenge Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote/transport Performs a GET /v2/ request to a registry to obtain authentication challenges. ```go func Ping(ctx context.Context, reg name.Registry, t http.RoundTripper) (*Challenge, error) ``` -------------------------------- ### Get Raw Manifest Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the raw manifest bytes. ```go func RawManifest(i WithManifest) ([]byte, error) ``` -------------------------------- ### Get Manifest Size Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the manifest's size. ```go func Size(i WithRawManifest) (int64, error) ``` -------------------------------- ### New Gcloud SDK Authenticator Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/google Creates an authenticator by executing the gcloud SDK. Ensure gcloud is installed and configured. ```go func NewGcloudAuthenticator(ctx context.Context) (authn.Authenticator, error) ``` -------------------------------- ### Creating a keychain Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/k8schain Demonstrates how to create a k8schain keychain using different methods. ```APIDOC ## Creating a keychain A `k8schain` keychain can be built via one of: ```go // client is a kubernetes.Interface kc, err := k8schain.New(ctx, client, k8schain.Options{}) // ... // This method is suitable for use by controllers or other in-cluster processes. kc, err := k8schain.NewInCluster(ctx, k8schain.Options{}) // ... ``` ``` -------------------------------- ### List Image Tags using Docker Run Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/gcrane Lists tags and manifests for a specified image using gcrane as a Docker container. This command is useful for inspecting image contents without installing gcrane locally. ```bash $ docker run --rm gcr.io/go-containerregistry/gcrane ls gcr.io/google-containers/busybox ``` -------------------------------- ### List Repositories in a Registry Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote Lists repositories in a registry, handling pagination to return the full list. ```go func (p *Puller) Catalog(ctx context.Context, reg name.Registry) ([]string, error) ``` -------------------------------- ### Using the keychain Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/k8schain Shows how to use the k8schain keychain to resolve image references. ```APIDOC ## Using the keychain The `k8schain` keychain can be used directly as an `authn.Keychain`, e.g. ```go auth, err := kc.Resolve(registry) if err != nil { // ... } ``` Or, with the `remote.WithAuthFromKeychain` option: ```go img, err := remote.Image(ref, remote.WithAuthFromKeychain(kc)) if err != nil { // ... } ``` ``` -------------------------------- ### List Ubuntu Image Tags using Docker Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane Demonstrates using crane as a Docker image to list tags for the 'ubuntu' image in a registry. ```bash $ docker run --rm gcr.io/go-containerregistry/crane ls ubuntu ``` -------------------------------- ### Create Auth Get Cobra Command Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane/cmd Creates a new `crane auth get` command. ```go func NewCmdAuthGet(options []crane.Option, argv ...string) *cobra.Command ``` -------------------------------- ### WithManifestAndConfigFile Interface Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Combines access to both the manifest and configuration file of an image. ```APIDOC ## Interface: WithManifestAndConfigFile ### Description Defines the subset of v1.Image used by these helper methods. ### Methods - `WithConfigFile`: Embeds the WithConfigFile interface. - `Manifest() (*v1.Manifest, error)`: Returns this image's Manifest object. ``` -------------------------------- ### Singleton Empty Index - pkg/v1 Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/empty Index is a singleton empty index, equivalent to `FROM scratch`. It represents an empty image index. ```go var Index = emptyIndex{} ``` -------------------------------- ### Fetch Image from Registry Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote Fetches an image from a remote registry using its reference. It utilizes the default keychain for authentication. This is a common starting point for interacting with images in a registry. ```go package main import ( "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/remote" ) func main() { ref, err := name.ParseReference("gcr.io/google-containers/pause") if err != nil { panic(err) } img, err := remote.Image(ref, remote.WithAuthFromKeychain(authn.DefaultKeychain)) if err != nil { panic(err) } // do stuff with img } ``` -------------------------------- ### Kubernetes Keychain Options Struct Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/kubernetes Defines configuration options for guiding Kubernetes credential resolution, including namespace, service account, and image pull secrets. ```go type Options struct { // Namespace holds the namespace inside of which we are resolving service // account and pull secret references to access the image. // If empty, "default" is assumed. Namespace string // ServiceAccountName holds the serviceaccount (within Namespace) as which a // Pod might access the image. Service accounts may have image pull secrets // attached, so we lookup the service account to complete the keychain. // If empty, "default" is assumed. To avoid a service account lookup, pass // NoServiceAccount explicitly. ServiceAccountName string // ImagePullSecrets holds the names of the Kubernetes secrets (scoped to // Namespace) containing credential data to use for the image pull. ImagePullSecrets []string // UseMountSecrets determines whether or not mount secrets in the ServiceAccount // should be considered. Mount secrets are those listed under the `.secrets` // attribute of the ServiceAccount resource. Ignored if ServiceAccountName is set // to NoServiceAccount. UseMountSecrets bool } ``` -------------------------------- ### StdlibPackages Source: https://pkg.go.dev/github.com/google/go-containerregistry/internal/depcheck StdlibPackages returns the list of all standard library packages, including some golang.org/x/ dependencies. ```APIDOC ## func StdlibPackages ### Description StdlibPackages returns the list of all standard library packages, including some golang.org/x/ dependencies. ### Signature ```go func StdlibPackages() []string ``` ### Returns * **[]string** - A slice of strings, where each string is a standard library package import path. ``` -------------------------------- ### Get Uncompressed Layer Size Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Returns the uncompressed size of a layer. ```go func UncompressedSize(l v1.Layer) (int64, error) ``` -------------------------------- ### Create Layer from Opener Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball Returns a v1.Layer given an Opener function. The Opener may return either an uncompressed or compressed tarball. Use WithCompressedCaching to memoize compression. ```go func LayerFromOpener(opener Opener, opts ...LayerOption) (v1.Layer, error) ``` -------------------------------- ### Get Redaction Reason from Context Source: https://pkg.go.dev/github.com/google/go-containerregistry/internal/redact Retrieves the redaction reason, if any, from a context. ```go func FromContext(ctx context.Context) (bool, string) ``` -------------------------------- ### Supported Compression Algorithms Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/compression Enumerates the supported compression algorithms: None, GZip, and ZStd. Use these constants to specify the desired compression method. ```go const ( None Compression = "none" GZip Compression = "gzip" ZStd Compression = "zstd" ) ``` -------------------------------- ### ConfigFile Platform Method Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1 Generates a Platform from the ConfigFile fields. ```APIDOC ## func (*ConfigFile) Platform ### Description Platform attempts to generates a Platform from the ConfigFile fields. ### Added in v0.14.0 ### Signature ```go func (cf *ConfigFile) Platform() *Platform ``` ``` -------------------------------- ### type Options Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/k8schain Options holds configuration data for guiding credential resolution. ```APIDOC ## type Options ```go type Options = kauth.Options ``` Options holds configuration data for guiding credential resolution. ``` -------------------------------- ### Get Descriptor for Mountable Layer Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote Retrieves the original descriptor from an image manifest for a MountableLayer. ```go func (ml *MountableLayer) Descriptor() (*v1.Descriptor, error) ``` -------------------------------- ### Create a New Layer Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/static Use NewLayer to create a v1.Layer from a byte slice and a media type. The contents will not be compressed. ```go func NewLayer(b []byte, mt types.MediaType) v1.Layer ``` -------------------------------- ### Create a Multi-Keychain Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn Use NewMultiKeychain to combine multiple Keychain implementations. They are checked in order until credentials are found. ```go kc := authn.NewMultiKeychain( authn.DefaultKeychain, google.Keychain, authn.NewKeychainFromHelper(ecr.ECRHelper{ClientFactory: api.DefaultClientFactory{}}), authn.NewKeychainFromHelper(acr.ACRCredHelper{}), ) ``` -------------------------------- ### Get FSLayers Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the filesystem layers. ```go func FSLayers(i WithManifest) ([]v1.Hash, error) ``` -------------------------------- ### Create Config Layer from Raw Config Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Implements v1.Layer from raw config bytes, allowing the config to be accessed as a blob. Images can implement WithConfigLayer to provide a specific layer implementation. ```go func ConfigLayer(i WithRawConfigFile) (v1.Layer, error) ``` -------------------------------- ### Get DiffIDs Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the diff IDs. ```go func DiffIDs(i WithConfigFile) ([]v1.Hash, error) ``` -------------------------------- ### Ping Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote/transport Ping does a GET /v2/ against the registry and returns the response, including authentication challenges. ```APIDOC ## Ping ### Description Ping does a GET /v2/ against the registry and returns the response. ### Signature ```go func Ping(ctx context.Context, reg name.Registry, t http.RoundTripper) (*Challenge, error) ``` ``` -------------------------------- ### Singleton Empty Image - pkg/v1 Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/empty Image is a singleton empty image, equivalent to `FROM scratch`. It is created by converting an empty struct to an image. ```go var Image, _ = partial.UncompressedToImage(emptyImage{}) ``` -------------------------------- ### Get Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Calls remote.Get to retrieve an uninterpreted response for a given reference. Added in v0.16.0. ```APIDOC ## Get ### Description Calls remote.Get to retrieve an uninterpreted response for a given reference. Added in v0.16.0. ### Signature ```go func Get(r string, opt ...Option) (*remote.Descriptor, error) ``` ``` -------------------------------- ### Configure Global Credential Helper Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn JSON configuration to set a global credential helper for Docker. ```json { "credsStore": "osxkeychain" } ``` -------------------------------- ### Get Image Digest Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Returns the SHA256 digest of a remote image at the specified reference. ```go func Digest(ref string, opt ...Option) (string, error) ``` -------------------------------- ### Option WithPlatform Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Option to specify the target platform for image operations. ```go func WithPlatform(platform *v1.Platform) Option ``` -------------------------------- ### ConfigFile Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial ConfigFile is a helper for implementing v1.Image. ```APIDOC ## ConfigFile ### Description ConfigFile is a helper for implementing v1.Image. ### Signature ```go func ConfigFile(i WithRawConfigFile) (*v1.ConfigFile, error) ``` ``` -------------------------------- ### Get Config Name Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the configuration name. ```go func ConfigName(i WithRawConfigFile) (v1.Hash, error) ``` -------------------------------- ### Load Image with Tag Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Loads an image from a specified path and assigns it a given tag. ```go func LoadTag(path, tag string, opt ...Option) (v1.Image, error) ``` -------------------------------- ### Platform String Representation Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1 Returns a string representation of the Platform. Useful for logging or display purposes. ```go func (p Platform) String() string ``` -------------------------------- ### Get Options Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Retrieves the default Options struct, potentially modified by provided Option functions. ```go func GetOptions(opts ...Option) Options ``` -------------------------------- ### Configure Per-Registry Credential Helper Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn JSON configuration to set a specific credential helper for a particular registry. ```json { "credHelpers": { "gcr.io": "gcr" } } ``` -------------------------------- ### Declare ErrNotFound Variable - pkg/v1/cache Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/cache ErrNotFound is returned by Get when no layer with the given Hash is found. ```go var ErrNotFound = errors.New("layer was not found") ``` -------------------------------- ### Get Catalogger for Paginated Repository Listing Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote Lists repositories in a registry and returns a Catalogger for paginating through the results. ```go func (p *Puller) Catalogger(ctx context.Context, reg name.Registry) (*Catalogger, error) ``` -------------------------------- ### ConfigFile Platform Method Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1 Generates a Platform struct from the ConfigFile fields. Added in v0.14.0. ```go func (cf *ConfigFile) Platform() *Platform ``` -------------------------------- ### NewFilesystemCache Function - pkg/v1/cache Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/cache NewFilesystemCache returns a Cache implementation that is backed by files on the filesystem. ```go func NewFilesystemCache(path string) Cache ``` -------------------------------- ### Get Raw Manifest from Descriptor Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote Retrieves the raw manifest bytes from a remote.Descriptor, satisfying the Taggable interface. ```go func (d *Descriptor) RawManifest() ([]byte, error) ``` -------------------------------- ### WithManifestAndConfigFile Interface Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Defines the subset of v1.Image used by helper methods, combining access to both the Manifest and ConfigFile. ```go type WithManifestAndConfigFile interface { WithConfigFile // Manifest returns this image's Manifest object. Manifest() (*v1.Manifest, error) } ``` -------------------------------- ### Compare Images - pkg/v1/compare Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/compare Use this function to compare two v1.Image objects. It returns an error if the images differ. ```go func Images(a, b v1.Image) error ``` -------------------------------- ### NewTLSServer - httptest Source: https://pkg.go.dev/github.com/google/go-containerregistry/internal/httptest Creates a new httptest server configured for TLS with generated certificates for the specified domain. The returned http client is pre-configured to direct all requests to this server. Use this when you need to test TLS server functionality. ```go func NewTLSServer(domain string, handler http.Handler) (*httptest.Server, error) ``` -------------------------------- ### Get Manifest Digest Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve the manifest's digest. ```go func Digest(i WithRawManifest) (v1.Hash, error) ``` -------------------------------- ### Get Blob Size Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve a blob's size. ```go func BlobSize(i WithManifest, h v1.Hash) (int64, error) ``` -------------------------------- ### FakeImage ConfigFile Method Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/fake The ConfigFile method on FakeImage returns a ConfigFile and an error. This is a stub for testing. ```go func (fake *FakeImage) ConfigFile() (*v1.ConfigFile, error) ``` -------------------------------- ### Get Blob Descriptor Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial A helper function for implementing the v1.Image interface to retrieve a blob's descriptor. ```go func BlobDescriptor(i WithManifest, h v1.Hash) (*v1.Descriptor, error) ``` -------------------------------- ### Create a TLS-Enabled httptest Server Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/registry TLS returns an httptest server with an http client configured for the server. The TLS certificates are generated for the specified domain. ```go func TLS(domain string) (*httptest.Server, error) ``` -------------------------------- ### Get Latest Release Version Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane Fetches the latest release tag name for crane from the GitHub API. ```bash $ VERSION=$(curl -s "https://api.github.com/repos/google/go-containerregistry/releases/latest" | jq -r '.tag_name') ``` -------------------------------- ### List Tags Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Lists all tags associated with a given source repository. ```go func ListTags(src string, opt ...Option) ([]string, error) ``` -------------------------------- ### OCI and Docker Media Type Constants Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/types Provides a comprehensive list of constants for OCI and Docker media types. Use these constants to represent and compare different content types within container images. ```go const ( OCIContentDescriptor MediaType = "application/vnd.oci.descriptor.v1+json" OCIImageIndex MediaType = "application/vnd.oci.image.index.v1+json" OCIManifestSchema1 MediaType = "application/vnd.oci.image.manifest.v1+json" OCIConfigJSON MediaType = "application/vnd.oci.image.config.v1+json" OCILayer MediaType = "application/vnd.oci.image.layer.v1.tar+gzip" OCILayerZStd MediaType = "application/vnd.oci.image.layer.v1.tar+zstd" OCIRestrictedLayer MediaType = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip" OCIUncompressedLayer MediaType = "application/vnd.oci.image.layer.v1.tar" OCIUncompressedRestrictedLayer MediaType = "application/vnd.oci.image.layer.nondistributable.v1.tar" DockerManifestSchema1 MediaType = "application/vnd.docker.distribution.manifest.v1+json" DockerManifestSchema1Signed MediaType = "application/vnd.docker.distribution.manifest.v1+prettyjws" DockerManifestSchema2 MediaType = "application/vnd.docker.distribution.manifest.v2+json" DockerManifestList MediaType = "application/vnd.docker.distribution.manifest.list.v2+json" DockerLayer MediaType = "application/vnd.docker.image.rootfs.diff.tar.gzip" DockerConfigJSON MediaType = "application/vnd.docker.container.image.v1+json" DockerPluginConfig MediaType = "application/vnd.docker.plugin.v1+json" DockerForeignLayer MediaType = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip" DockerUncompressedLayer MediaType = "application/vnd.docker.image.rootfs.diff.tar" OCIVendorPrefix = "vnd.oci" DockerVendorPrefix = "vnd.docker" ) ``` -------------------------------- ### Head Remote Reference Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Performs a HEAD request on a remote reference to get its descriptor without downloading the image. ```go func Head(r string, opt ...Option) (*v1.Descriptor, error) ``` -------------------------------- ### Create Layer from File Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball Creates a v1.Layer from a tarball file. Layer options can be provided to customize the layer creation process, such as compression settings. ```go func LayerFromFile(path string, opts ...LayerOption) (v1.Layer, error) ``` -------------------------------- ### Get Remote Descriptor Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Calls remote.Get to retrieve an uninterpreted response descriptor for a remote reference. Added in v0.16.0. ```go func Get(r string, opt ...Option) (*remote.Descriptor, error) ``` -------------------------------- ### Config Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Fetches the configuration file for a given remote image reference. ```APIDOC ## Config ### Description Fetches the configuration file for a given remote image reference. ### Signature ```go func Config(ref string, opt ...Option) ([]byte, error) ``` ``` -------------------------------- ### Get Challenges from HTTP Response Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote/internal/authchallenge ResponseChallenges extracts authorization challenges from an HTTP response, but only if the status code is 401. ```go func ResponseChallenges(resp *http.Response) []Challenge ``` -------------------------------- ### FakeImage RawConfigFile Methods Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/fake Methods for controlling and observing calls to the RawConfigFile function on a FakeImage. Use RawConfigFileReturns to set a default return value for all calls, or RawConfigFileReturnsOnCall to set a specific return value for a particular call. ```go func (fake *FakeImage) RawConfigFile() ([]byte, error) ``` ```go func (fake *FakeImage) RawConfigFileCallCount() int ``` ```go func (fake *FakeImage) RawConfigFileCalls(stub func() ([]byte, error)) ``` ```go func (fake *FakeImage) RawConfigFileReturns(result1 []byte, result2 error) ``` ```go func (fake *FakeImage) RawConfigFileReturnsOnCall(i int, result1 []byte, result2 error) ``` -------------------------------- ### Cache Interface Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/cache Cache encapsulates methods to interact with cached layers, including putting, getting, and deleting layers. ```APIDOC ## Cache Interface ### Description Cache encapsulates methods to interact with cached layers. ### Methods #### Put ``` Put(v1.Layer) (v1.Layer, error) ``` Writes the Layer to the Cache. The returned Layer should be used for future operations, since lazy cachers might only populate the cache when the layer is actually consumed. The returned layer can be consumed, and the cache entry populated, by calling either Compressed or Uncompressed and consuming the returned io.ReadCloser. #### Get ``` Get(v1.Hash) (v1.Layer, error) ``` Returns the Layer cached by the given Hash, or ErrNotFound if no such layer was found. #### Delete ``` Delete(v1.Hash) error ``` Removes the Layer with the given Hash from the Cache. ``` -------------------------------- ### Run Crane Debug Shell in Docker Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane Starts an interactive shell within the crane debug Docker image. ```bash docker run --rm -it --entrypoint "/busybox/sh" gcr.io/go-containerregistry/crane:debug ``` -------------------------------- ### Load Image Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/crane Loads an image from a specified path. ```go func Load(path string, opt ...Option) (v1.Image, error) ``` -------------------------------- ### NewCmdGc Function - go-containerregistry Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/gcrane/cmd Creates a new cobra.Command for the gc subcommand. This is used to start the garbage collection process. ```go func NewCmdGc() *cobra.Command ``` -------------------------------- ### Emulate ECR Credential Helper with Keychain Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn Emulate the Amazon ECR credential helper using NewKeychainFromHelper to adapt a Go implementation of the credentials.Helper interface. This allows using ECR credentials without requiring the helper executable. ```go import ( ecr "github.com/awslabs/amazon-ecr-credential-helper/ecr-login" "github.com/awslabs/amazon-ecr-credential-helper/ecr-login/api" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/v1/remote" ) func main() { // ... ecHelper := ecr.ECRHelper{ClientFactory: api.DefaultClientFactory{}} img, err := remote.Get(ref, remote.WithAuthFromKeychain(authn.NewKeychainFromHelper(ecrHelper))) if err != nil { panic(err) } // ... } ``` -------------------------------- ### Get Descriptor Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote Retrieves a remote.Descriptor for the given reference. The registry response is largely un-interpreted, useful for querying artifact types. ```APIDOC ## Get Descriptor ### Description Returns a remote.Descriptor for the given reference. The response from the registry is left un-interpreted, for the most part. This is useful for querying what kind of artifact a reference represents. See Head if you don't need the response body. ### Method GET ### Endpoint /v2//manifests/ ### Parameters #### Path Parameters - **ref** (name.Reference) - Required - The reference to get the descriptor for. #### Query Parameters None #### Request Body None ### Request Example ```go // Assuming 'ref' is a name.Reference descriptor, err := remote.Get(ref) ``` ### Response #### Success Response (200) - **Descriptor** (*remote.Descriptor) - The descriptor for the remote artifact. #### Response Example ```json { "mediaType": "application/vnd.oci.image.manifest.v1+json", "size": 1234, "digest": "sha256:..." } ``` ``` -------------------------------- ### ImageCore Interface Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial ImageCore defines the essential properties required to construct a v1.Image, including the raw configuration file and media type. ```go type ImageCore interface { // RawConfigFile returns the serialized bytes of this image's config file. RawConfigFile() ([]byte, error) // MediaType of this image's manifest. MediaType() (types.MediaType, error) } ``` -------------------------------- ### Resource Interface Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn Resource represents a registry or repository that can be authenticated against, providing methods to get its string representation and registry string. ```APIDOC ## type Resource ``` type Resource interface { // String returns the full string representation of the target, e.g. // gcr.io/my-project or just gcr.io. String() string // RegistryStr returns just the registry portion of the target, e.g. for // gcr.io/my-project, this should just return gcr.io. This is needed to // pull out an appropriate hostname. RegistryStr() string } ``` Resource represents a registry or repository that can be authenticated against. ``` -------------------------------- ### New Environment Authenticator Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/google Creates an authenticator that uses environment variables for credentials. Useful when running in Google Cloud environments. ```go func NewEnvAuthenticator(ctx context.Context) (authn.Authenticator, error) ``` -------------------------------- ### Get Image from Docker Daemon Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/daemon Retrieves an image reference from the Docker daemon. Functional options can be applied to the underlying imageOpener. ```go func Image(ref name.Reference, options ...Option) (v1.Image, error) ``` -------------------------------- ### Compare Image Indexes - pkg/v1/compare Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/compare Use this function to compare two v1.ImageIndex objects. It returns an error if the indexes differ. ```go func Indexes(a, b v1.ImageIndex) error ``` -------------------------------- ### NewTLSServer Source: https://pkg.go.dev/github.com/google/go-containerregistry/internal/httptest Creates and returns an httptest server configured with an HTTP client that directs all requests to this server. It also generates TLS certificates for the provided domain. The Client().Transport is correctly configured for use with this server. ```APIDOC ## func NewTLSServer ### Description NewTLSServer returns an httptest server, with an http client that has been configured to send all requests to the returned server. The TLS certs are generated for the given domain. If you need a transport, Client().Transport is correctly configured. ### Signature ```go func NewTLSServer(domain string, handler http.Handler) (*httptest.Server, error) ``` ### Parameters #### Path Parameters - **domain** (string) - Required - The domain for which to generate TLS certificates. - **handler** (http.Handler) - Required - The HTTP handler to serve requests. ### Returns - **(*httptest.Server, error)** - A pointer to the httptest.Server and an error if one occurred during server creation. ``` -------------------------------- ### Detect Gzip Magic Header Source: https://pkg.go.dev/github.com/google/go-containerregistry/internal/gzip MagicHeader is the start of gzip files. Use this to identify if a stream begins with gzip data. ```go var MagicHeader = []byte{'\x1f', '\x8b'} ``` -------------------------------- ### Get Remote Descriptor Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/remote Retrieves a remote.Descriptor for a given reference, leaving the registry response un-interpreted. Useful for querying artifact types. ```go func Get(ref name.Reference, options ...Option) (*Descriptor, error) ``` -------------------------------- ### StdlibPackages Returns Standard Library Packages Source: https://pkg.go.dev/github.com/google/go-containerregistry/internal/depcheck StdlibPackages returns a slice containing the import paths of all standard library packages, including some golang.org/x/ dependencies. ```go func StdlibPackages() []string ``` -------------------------------- ### Get Descriptor from Describable Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Returns a v1.Descriptor given a Describable. It handles unwrapping of types wrapped by CompressedToLayer, UncompressedToLayer, CompressedToImage, or UncompressedToImage. ```go func Descriptor(d Describable) (*v1.Descriptor, error) ``` -------------------------------- ### RawConfigFile Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial RawConfigFile is a helper for implementing v1.Image. ```APIDOC ## RawConfigFile ### Description RawConfigFile is a helper for implementing v1.Image. ### Signature ```go func RawConfigFile(i WithConfigFile) ([]byte, error) ``` ``` -------------------------------- ### UncompressedLayer Interface Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Defines the minimum interface for a natively uncompressed layer. It provides methods to get the DiffID, an io.ReadCloser for the uncompressed contents, and the media type. ```go type UncompressedLayer interface { // DiffID returns the Hash of the uncompressed layer. DiffID() (v1.Hash, error) // Uncompressed returns an io.ReadCloser for the uncompressed layer contents. Uncompressed() (io.ReadCloser, error) // Returns the mediaType for the compressed Layer MediaType() (types.MediaType, error) } ``` -------------------------------- ### Cache Interface Definition - pkg/v1/cache Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/cache The Cache interface defines methods for interacting with cached layers, including putting, getting, and deleting layers by their hash. ```go type Cache interface { // Put writes the Layer to the Cache. // // The returned Layer should be used for future operations, since lazy // cachers might only populate the cache when the layer is actually // consumed. // // The returned layer can be consumed, and the cache entry populated, // by calling either Compressed or Uncompressed and consuming the // returned io.ReadCloser. Put(v1.Layer) (v1.Layer, error) // Get returns the Layer cached by the given Hash, or ErrNotFound if no // such layer was found. Get(v1.Hash) (v1.Layer, error) // Delete removes the Layer with the given Hash from the Cache. Delete(v1.Hash) error } ``` -------------------------------- ### FakeImage ConfigFileReturns Method Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/fake ConfigFileReturns sets the return values for the ConfigFile method. This is used to mock behavior in tests. ```go func (fake *FakeImage) ConfigFileReturns(result1 *v1.ConfigFile, result2 error) ``` -------------------------------- ### Google Keychain Instance Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/google Exports a global instance of the google Keychain for authentication. ```go var Keychain authn.Keychain = &googleKeychain{} ``` -------------------------------- ### Create a New Registry Handler Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/registry Use New to create a handler that implements the Docker registry protocol. This handler should be registered at the site root. ```go func New(opts ...Option) http.Handler ``` -------------------------------- ### HealthConfig Type Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1 The HealthConfig type holds configuration settings for the HEALTHCHECK feature in containers. It includes parameters for the test command, interval, timeout, start period, and retries. ```APIDOC #### type HealthConfig ``` type HealthConfig struct { // Test is the test to perform to check that the container is healthy. // An empty slice means to inherit the default. // The options are: // {} : inherit healthcheck // {"NONE"} : disable healthcheck // {"CMD", args...} : exec arguments directly // {"CMD-SHELL", command} : run command with system's default shell Test []string `json:",omitempty"` // Zero means to inherit. Durations are expressed as integer nanoseconds. Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks. Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung. StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down. // Retries is the number of consecutive failures needed to consider a container as unhealthy. // Zero means inherit. Retries int `json:",omitempty"` } ``` HealthConfig holds configuration settings for the HEALTHCHECK feature. ``` -------------------------------- ### FakeImage ConfigFileReturnsOnCall Method Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/fake ConfigFileReturnsOnCall sets the return values for the ConfigFile method on a specific call. This allows for more granular control in tests. ```go func (fake *FakeImage) ConfigFileReturnsOnCall(i int, result1 *v1.ConfigFile, result2 error) ``` -------------------------------- ### Run gcrane with a Shell Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/gcrane Starts an interactive shell session within the gcrane Docker container. This allows for running multiple gcrane commands or exploring the container's environment. ```bash docker run --rm -it --entrypoint "/busybox/sh" gcr.io/go-containerregistry/gcrane:debug ``` -------------------------------- ### WithConfigFile Interface Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Defines the subset of v1.Image used by helper methods for accessing the image's config file. ```go type WithConfigFile interface { // ConfigFile returns this image's config file. ConfigFile() (*v1.ConfigFile, error) } ``` -------------------------------- ### Manifest Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Manifest is a helper for implementing v1.Image. ```APIDOC ## Manifest ### Description Manifest is a helper for implementing v1.Image. ### Signature ```go func Manifest(i WithRawManifest) (*v1.Manifest, error) ``` ``` -------------------------------- ### Get Artifact Type Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Returns the artifact type for a given manifest. It first checks if the manifest reports its own artifact type, otherwise it parses the manifest and returns its config's mediaType. ```go func ArtifactType(w WithManifest) (string, error) ``` -------------------------------- ### LoadManifest Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball Loads the manifest from a tarball using an Opener. ```APIDOC ## func LoadManifest(opener Opener) (Manifest, error) ### Description LoadManifest load manifest from a tarball. ### Parameters * `opener` (Opener) - An Opener function that provides a reader for the tarball. ### Returns * `Manifest` - The loaded manifest. * `error` - An error if the manifest loading fails. ``` -------------------------------- ### New Keychain Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/kubernetes Creates a new authn.Keychain using a provided Kubernetes client and options. ```APIDOC ## func New ### Description New returns a new authn.Keychain suitable for resolving image references as scoped by the provided Options. It speaks to Kubernetes through the provided client interface. ### Signature ```go func New(ctx context.Context, client kubernetes.Interface, opt Options) (authn.Keychain, error) ``` ### Parameters * `ctx` (context.Context) - The context for the operation. * `client` (kubernetes.Interface) - The Kubernetes client interface. * `opt` (Options) - Configuration options for the keychain. ### Returns * `authn.Keychain` - The created keychain. * `error` - An error if the keychain creation fails. ``` -------------------------------- ### Use k8schain with remote.Image Option Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/k8schain Integrate the keychain with the remote.Image function using the WithAuthFromKeychain option. ```go img, err := remote.Image(ref, remote.WithAuthFromKeychain(kc)) if err != nil { ... } ``` -------------------------------- ### New JSON Key Authenticator Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/google Creates an authenticator using a service account JSON key file. This is suitable for programmatic authentication. ```go func NewJSONKeyAuthenticator(serviceAccountJSON string) authn.Authenticator ``` -------------------------------- ### Create Canonical Image Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/mutate Combines Time and configFile to remove randomness during a docker build, producing a canonical image. ```go func Canonical(img v1.Image) (v1.Image, error) ``` -------------------------------- ### Platform.String Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1 Returns a string representation of the Platform. This is useful for logging or displaying platform information. ```APIDOC ## Platform.String ### Description Returns a string representation of the Platform. ### Signature ```go func (p Platform) String() string ``` ### Returns * (string) - A string representation of the Platform. ``` -------------------------------- ### CompressedImageCore Interface - pkg/v1/partial Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Defines the interface for accessing compressed image data, primarily used when blobs are fetched from a registry. Implementations should provide methods for raw configuration, media type, manifest, and layer retrieval by digest. ```go type CompressedImageCore interface { RawConfigFile() ([]byte, error) MediaType() (types.MediaType, error) RawManifest() ([]byte, error) LayerByDigest(v1.Hash) (CompressedLayer, error) } ``` -------------------------------- ### Generate Crane Documentation Source: https://pkg.go.dev/github.com/google/go-containerregistry/cmd/crane/help Use this command to generate documentation for the crane tool. Specify the output directory using the --dir flag. ```bash go run cmd/crane/help/main.go --dir=cmd/crane/doc/ ``` -------------------------------- ### NewFilesystemCache Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/cache NewFilesystemCache returns a Cache implementation backed by files. ```APIDOC ## NewFilesystemCache ### Description NewFilesystemCache returns a Cache implementation backed by files. ### Signature ``` func NewFilesystemCache(path string) Cache ``` ``` -------------------------------- ### WithProgress WriteOption Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball WithProgress creates a WriteOption that enables a channel to receive download and write progress updates. ```go func WithProgress(updates chan<- v1.Update) WriteOption ``` -------------------------------- ### Create k8schain Keychain with Kubernetes Client Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/k8schain Use this to create a keychain when you have an existing Kubernetes client interface. ```go kc, err := k8schain.New(ctx, client, k8schain.Options{}) ... ``` -------------------------------- ### Inject Custom Docker Client Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/daemon WithClient allows injecting a custom Docker client. If not provided, github.com/docker/docker/client.FromEnv is used by default. ```go func WithClient(client Client) Option ``` -------------------------------- ### Compare Platform Equality Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1 Checks if two Platform objects are semantically equivalent. Ignores the order of OSFeatures and Features. ```go func (p Platform) Equals(o Platform) bool ``` -------------------------------- ### Convert Uncompressed Image to v1.Image Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Fills in the missing methods from an UncompressedImageCore so that it implements the v1.Image interface. ```go func UncompressedToImage(uic UncompressedImageCore) (v1.Image, error) ``` -------------------------------- ### Parse manifest.json with jq Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball Use 'jq' to parse the manifest.json file and view the image's configuration, repository tags, and layer information. Note the special handling for 'RepoTags' when pulling by digest. ```bash $ jq < nanoserver/manifest.json [ { "Config": "sha256:bc5d255ea81f83c8c38a982a6d29a6f2198427d258aea5f166e49856896b2da6", "RepoTags": [ "index.docker.io/library/hello-world:i-was-a-digest" ], "Layers": [ "a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053.tar.gz", "be21f08f670160cbae227e3053205b91d6bfa3de750b90c7e00bd2c511ccb63a.tar.gz", "10d1439be4eb8819987ec2e9c140d44d74d6b42a823d57fe1953bd99948e1bc0.tar.gz" ], "LayerSources": { "sha256:26fd2d9d4c64a4f965bbc77939a454a31b607470f430b5d69fc21ded301fa55e": { "mediaType": "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip", "size": 101145811, "digest": "sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053", "urls": [ "https://mcr.microsoft.com/v2/windows/nanoserver/blobs/sha256:a35da61c356213336e646756218539950461ff2bf096badf307a23add6e70053" ] } } } ] ``` -------------------------------- ### Compute Manifests from Image Index Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Computes a list of Describable items from an image index. ```go func ComputeManifests(idx v1.ImageIndex) ([]Describable, error) ``` -------------------------------- ### func New Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn/k8schain New returns a new authn.Keychain suitable for resolving image references as scoped by the provided Options. It speaks to Kubernetes through the provided client interface. ```APIDOC ## func New ```go func New(ctx context.Context, client kubernetes.Interface, opt Options) (authn.Keychain, error) ``` New returns a new authn.Keychain suitable for resolving image references as scoped by the provided Options. It speaks to Kubernetes through the provided client interface. ``` -------------------------------- ### Convert Compressed Image to v1.Image Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/partial Fills in the missing methods from a CompressedImageCore so that it implements the v1.Image interface. ```go func CompressedToImage(cic CompressedImageCore) (v1.Image, error) ``` -------------------------------- ### Load Manifest Function Source: https://pkg.go.dev/github.com/google/go-containerregistry/pkg/v1/tarball LoadManifest loads the manifest.json from a tarball using an Opener. ```go func LoadManifest(opener Opener) (Manifest, error) ```