From 5e1ad8b0258067c67374025cae00be7f02d72f32 Mon Sep 17 00:00:00 2001 From: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> Date: Thu, 24 Oct 2019 07:20:34 -0500 Subject: [PATCH] Change mediatype for chart content layer Mediatype changed to application/tar+gzip. Please see the following OCI mailing list item for more info: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/pdc1lucm_Ak Also, improved check for invalid manifests, a nil reference error was occurring when upgrading from existing cache with old mediatype. Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> --- internal/experimental/registry/cache.go | 6 +++++- internal/experimental/registry/constants.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/experimental/registry/cache.go b/internal/experimental/registry/cache.go index 19ceb86ea..fbd62562a 100644 --- a/internal/experimental/registry/cache.go +++ b/internal/experimental/registry/cache.go @@ -122,10 +122,14 @@ func (cache *Cache) FetchReference(ref *Reference) (*CacheRefSummary, error) { contentLayer = &layer } } - if contentLayer.Size == 0 { + if contentLayer == nil { return &r, errors.New( fmt.Sprintf("manifest does not contain a layer with mediatype %s", HelmChartContentLayerMediaType)) } + if contentLayer.Size == 0 { + return &r, errors.New( + fmt.Sprintf("manifest layer with mediatype %s is of size 0", HelmChartContentLayerMediaType)) + } r.ContentLayer = contentLayer info, err := cache.ociStore.Info(ctx(cache.out, cache.debug), contentLayer.Digest) if err != nil { diff --git a/internal/experimental/registry/constants.go b/internal/experimental/registry/constants.go index e0f17fe61..dafb3c9e5 100644 --- a/internal/experimental/registry/constants.go +++ b/internal/experimental/registry/constants.go @@ -21,7 +21,7 @@ const ( HelmChartConfigMediaType = "application/vnd.cncf.helm.config.v1+json" // HelmChartContentLayerMediaType is the reserved media type for Helm chart package content - HelmChartContentLayerMediaType = "application/vnd.cncf.helm.chart.content.layer.v1+tar" + HelmChartContentLayerMediaType = "application/tar+gzip" ) // KnownMediaTypes returns a list of layer mediaTypes that the Helm client knows about