diff --git a/README.md b/README.md index 1b5442395f..729ccb9313 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,15 @@ There are a number of packages for reading/writing these interfaces from/to vari The main focus has been registry interactions (hence the name) via the [`remote`](pkg/v1/remote) package, but we have implemented other formats as we needed them to interoperate with various tools. +### Experiments + +Over time, we will add new functionality under experimental environment variables listed here. + +| Env Var | Value(s) | What is does | +--------------------------------------- +| `GGCR_EXPERIMENT_ESTARGZ` | `"1"` | When enabled this experiment will direct `tarball.LayerFromOpener` to emit [estargz](https://github.com/opencontainers/image-spec/issues/815) compatible layers, which enable them to be lazily loaded by an appropriately configured containerd. | + + ### `v1.Image` #### Sources diff --git a/pkg/v1/internal/estargz/constants.go b/pkg/v1/internal/estargz/constants.go deleted file mode 100644 index d5973d2ca4..0000000000 --- a/pkg/v1/internal/estargz/constants.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020 Google LLC All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package estargz - -// TOCDigestKey holds the key of the layer annotation used to associate -// table-of-contents verification information to the layer. -const TOCDigestKey = "containerd.io/snapshot/stargz/toc.digest" diff --git a/pkg/v1/tarball/layer.go b/pkg/v1/tarball/layer.go index ff4ac6d6be..312bb16cbe 100644 --- a/pkg/v1/tarball/layer.go +++ b/pkg/v1/tarball/layer.go @@ -188,7 +188,7 @@ func LayerFromOpener(opener Opener, opts ...LayerOption) (v1.Layer, error) { if err != nil { return nil, err } - layer.annotations[gestargz.TOCDigestKey] = h.String() + layer.annotations[estargz.TOCJSONDigestAnnotation] = h.String() return &and.ReadCloser{ Reader: rc, CloseFunc: func() error { diff --git a/pkg/v1/tarball/layer_test.go b/pkg/v1/tarball/layer_test.go index 5b4f682a1e..114eb30d1e 100644 --- a/pkg/v1/tarball/layer_test.go +++ b/pkg/v1/tarball/layer_test.go @@ -24,7 +24,6 @@ import ( "github.com/containerd/stargz-snapshotter/estargz" "github.com/google/go-containerregistry/pkg/internal/compare" - gestargz "github.com/google/go-containerregistry/pkg/v1/internal/estargz" "github.com/google/go-containerregistry/pkg/v1/validate" ) @@ -130,10 +129,10 @@ func TestLayerFromFileEstargz(t *testing.T) { t.Errorf("expected digests to differ: %s", defaultDigest.String()) } - if descriptorDefaultCompression.Annotations[gestargz.TOCDigestKey] == descriptorSpeedCompression.Annotations[gestargz.TOCDigestKey] { + if descriptorDefaultCompression.Annotations[estargz.TOCJSONDigestAnnotation] == descriptorSpeedCompression.Annotations[estargz.TOCJSONDigestAnnotation] { t.Errorf("wanted different toc digests got default: %s, speed: %s", - descriptorDefaultCompression.Annotations[gestargz.TOCDigestKey], - descriptorSpeedCompression.Annotations[gestargz.TOCDigestKey]) + descriptorDefaultCompression.Annotations[estargz.TOCJSONDigestAnnotation], + descriptorSpeedCompression.Annotations[estargz.TOCJSONDigestAnnotation]) } tarLayerPrioritizedFiles, err := LayerFromFile("testdata/content.tar", @@ -162,10 +161,10 @@ func TestLayerFromFileEstargz(t *testing.T) { t.Errorf("expected digests to differ: %s", defaultDigest.String()) } - if descriptorDefaultCompression.Annotations[gestargz.TOCDigestKey] == descriptorPrioritizedFiles.Annotations[gestargz.TOCDigestKey] { + if descriptorDefaultCompression.Annotations[estargz.TOCJSONDigestAnnotation] == descriptorPrioritizedFiles.Annotations[estargz.TOCJSONDigestAnnotation] { t.Errorf("wanted different toc digests got default: %s, prioritized: %s", - descriptorDefaultCompression.Annotations[gestargz.TOCDigestKey], - descriptorPrioritizedFiles.Annotations[gestargz.TOCDigestKey]) + descriptorDefaultCompression.Annotations[estargz.TOCJSONDigestAnnotation], + descriptorPrioritizedFiles.Annotations[estargz.TOCJSONDigestAnnotation]) } }