From 240dd53e78a5c1f8243891e1c4956254da6d4f09 Mon Sep 17 00:00:00 2001 From: Josh Dolitsky Date: Wed, 3 Jul 2019 15:00:16 -0500 Subject: [PATCH] Helm 3: set custom manifest config media type on chart push (#5719) * set custom manifest config media type Signed-off-by: Josh Dolitsky * use v1 for manifest schema Signed-off-by: Josh Dolitsky * remove unneeded debug flag Signed-off-by: Josh Dolitsky * update to new config media type Signed-off-by: Josh Dolitsky --- Gopkg.lock | 14 +++++++------- Gopkg.toml | 2 +- pkg/registry/cache.go | 12 ++++++------ pkg/registry/client.go | 3 ++- pkg/registry/client_test.go | 1 - pkg/registry/constants.go | 15 +++++++++------ pkg/registry/constants_test.go | 4 ++-- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 55a44557b..2a1e3a5af 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -229,7 +229,7 @@ version = "v1.1.1" [[projects]] - digest = "1:32b33e550e9fba29158153b1881dd46b86593e045564746dcb56557b9061668f" + digest = "1:5bed34759ca1dd43ff92383caedd16f006d3b6c4b73c7690a24ae0a5627294fa" name = "github.com/deislabs/oras" packages = [ "pkg/auth", @@ -239,8 +239,8 @@ "pkg/oras", ] pruneopts = "UT" - revision = "9f7669048990b0d0c186985737e6a6c3bb3f7ecc" - version = "v0.4.0" + revision = "b3b6ce7eeb31a5c0d891d33f585c84ae3dcc9046" + version = "v0.5.0" [[projects]] digest = "1:76dc72490af7174349349838f2fe118996381b31ea83243812a97e5a0fd5ed55" @@ -251,17 +251,17 @@ version = "v3.2.0" [[projects]] - digest = "1:f65090e4f60dcd4d2de69e8ebca022d59a8c6463a3a4c122e64cec91a83749ff" + digest = "1:238ba9f81f5f913de38bd4c5dab90c4b5eea90a5ee32a986e5416267adec4f67" name = "github.com/docker/cli" packages = [ "cli/config", "cli/config/configfile", "cli/config/credentials", - "opts", + "cli/config/types", ] pruneopts = "UT" - revision = "c89750f836c57ce10386e71669e1b08a54c3caeb" - version = "v18.09.5" + revision = "f28d9cc92972044feb72ab6833699102992d40a2" + version = "v19.03.0-beta3" [[projects]] digest = "1:feaf11ab67fe48ec2712bf9d44e2fb2d4ebdc5da8e5a47bd3ce05bae9f82825b" diff --git a/Gopkg.toml b/Gopkg.toml index 52ade6e71..0c22ca389 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -44,7 +44,7 @@ [[constraint]] name = "github.com/deislabs/oras" - version = "0.4.0" + version = "0.5.0" [[constraint]] name = "github.com/sirupsen/logrus" diff --git a/pkg/registry/cache.go b/pkg/registry/cache.go index ccedd1e54..151b13811 100644 --- a/pkg/registry/cache.go +++ b/pkg/registry/cache.go @@ -110,7 +110,7 @@ func (cache *filesystemCache) ChartToLayers(ch *chart.Chart) ([]ocispec.Descript if err != nil { return nil, err } - metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaMediaType, metaJSONRaw) + metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaLayerMediaType, metaJSONRaw) // Create content layer // TODO: something better than this hack. Currently needed for chartutil.Save() @@ -131,7 +131,7 @@ func (cache *filesystemCache) ChartToLayers(ch *chart.Chart) ([]ocispec.Descript if err != nil { return nil, err } - contentLayer := cache.store.Add(HelmChartContentFileName, HelmChartContentMediaType, contentRaw) + contentLayer := cache.store.Add(HelmChartContentFileName, HelmChartContentLayerMediaType, contentRaw) // Set annotations contentLayer.Annotations[HelmChartNameAnnotation] = name @@ -149,14 +149,14 @@ func (cache *filesystemCache) LoadReference(ref *Reference) ([]ocispec.Descripto if err != nil { return nil, err } - metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaMediaType, metaJSONRaw) + metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaLayerMediaType, metaJSONRaw) // add content layer contentRaw, err := getSymlinkDestContent(filepath.Join(tagDir, "content")) if err != nil { return nil, err } - contentLayer := cache.store.Add(HelmChartContentFileName, HelmChartContentMediaType, contentRaw) + contentLayer := cache.store.Add(HelmChartContentFileName, HelmChartContentLayerMediaType, contentRaw) // set annotations on content layer (chart name and version) err = setLayerAnnotationsFromChartLink(contentLayer, filepath.Join(tagDir, "chart")) @@ -329,9 +329,9 @@ func extractLayers(layers []ocispec.Descriptor) (ocispec.Descriptor, ocispec.Des for _, layer := range layers { switch layer.MediaType { - case HelmChartMetaMediaType: + case HelmChartMetaLayerMediaType: metaLayer = layer - case HelmChartContentMediaType: + case HelmChartContentLayerMediaType: contentLayer = layer } } diff --git a/pkg/registry/client.go b/pkg/registry/client.go index 7bde355e9..93ef04023 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -97,7 +97,8 @@ func (c *Client) PushChart(ref *Reference) error { if err != nil { return err } - _, err = oras.Push(c.newContext(), c.resolver, ref.String(), c.cache.store, layers) + _, err = oras.Push(c.newContext(), c.resolver, ref.String(), c.cache.store, layers, + oras.WithConfigMediaType(HelmChartConfigMediaType)) if err != nil { return err } diff --git a/pkg/registry/client_test.go b/pkg/registry/client_test.go index d9f22361f..9882afa62 100644 --- a/pkg/registry/client_test.go +++ b/pkg/registry/client_test.go @@ -71,7 +71,6 @@ func (suite *RegistryClientTestSuite) SetupSuite() { // Init test client suite.RegistryClient = NewClient(&ClientOptions{ - Debug: false, Out: suite.Out, Authorizer: Authorizer{ Client: client, diff --git a/pkg/registry/constants.go b/pkg/registry/constants.go index 2883815e7..76458b38d 100644 --- a/pkg/registry/constants.go +++ b/pkg/registry/constants.go @@ -20,11 +20,14 @@ const ( // HelmChartDefaultTag is the default tag used when storing a chart reference with no tag HelmChartDefaultTag = "latest" - // HelmChartMetaMediaType is the reserved media type for Helm chart metadata - HelmChartMetaMediaType = "application/vnd.cncf.helm.chart.meta.v1+json" + // HelmChartConfigMediaType is the reserved media type for the Helm chart manifest config + HelmChartConfigMediaType = "application/vnd.cncf.helm.config.v1+json" - // HelmChartContentMediaType is the reserved media type for Helm chart package content - HelmChartContentMediaType = "application/vnd.cncf.helm.chart.content.v1+tar" + // HelmChartMetaLayerMediaType is the reserved media type for Helm chart metadata + HelmChartMetaLayerMediaType = "application/vnd.cncf.helm.chart.meta.layer.v1+json" + + // HelmChartContentLayerMediaType is the reserved media type for Helm chart package content + HelmChartContentLayerMediaType = "application/vnd.cncf.helm.chart.content.layer.v1+tar" // HelmChartMetaFileName is the reserved file name for Helm chart metadata HelmChartMetaFileName = "chart-meta.json" @@ -42,7 +45,7 @@ const ( // KnownMediaTypes returns a list of layer mediaTypes that the Helm client knows about func KnownMediaTypes() []string { return []string{ - HelmChartMetaMediaType, - HelmChartContentMediaType, + HelmChartMetaLayerMediaType, + HelmChartContentLayerMediaType, } } diff --git a/pkg/registry/constants_test.go b/pkg/registry/constants_test.go index 046f7b730..d58554619 100644 --- a/pkg/registry/constants_test.go +++ b/pkg/registry/constants_test.go @@ -24,6 +24,6 @@ import ( func TestConstants(t *testing.T) { knownMediaTypes := KnownMediaTypes() - assert.Contains(t, knownMediaTypes, HelmChartMetaMediaType) - assert.Contains(t, knownMediaTypes, HelmChartContentMediaType) + assert.Contains(t, knownMediaTypes, HelmChartMetaLayerMediaType) + assert.Contains(t, knownMediaTypes, HelmChartContentLayerMediaType) }