Helm 3: set custom manifest config media type on chart push (#5719)

* set custom manifest config media type

Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>

* use v1 for manifest schema

Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>

* remove unneeded debug flag

Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>

* update to new config media type

Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>
pull/5980/head
Josh Dolitsky 5 years ago committed by GitHub
parent e55a25bfeb
commit 240dd53e78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

14
Gopkg.lock generated

@ -229,7 +229,7 @@
version = "v1.1.1" version = "v1.1.1"
[[projects]] [[projects]]
digest = "1:32b33e550e9fba29158153b1881dd46b86593e045564746dcb56557b9061668f" digest = "1:5bed34759ca1dd43ff92383caedd16f006d3b6c4b73c7690a24ae0a5627294fa"
name = "github.com/deislabs/oras" name = "github.com/deislabs/oras"
packages = [ packages = [
"pkg/auth", "pkg/auth",
@ -239,8 +239,8 @@
"pkg/oras", "pkg/oras",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "9f7669048990b0d0c186985737e6a6c3bb3f7ecc" revision = "b3b6ce7eeb31a5c0d891d33f585c84ae3dcc9046"
version = "v0.4.0" version = "v0.5.0"
[[projects]] [[projects]]
digest = "1:76dc72490af7174349349838f2fe118996381b31ea83243812a97e5a0fd5ed55" digest = "1:76dc72490af7174349349838f2fe118996381b31ea83243812a97e5a0fd5ed55"
@ -251,17 +251,17 @@
version = "v3.2.0" version = "v3.2.0"
[[projects]] [[projects]]
digest = "1:f65090e4f60dcd4d2de69e8ebca022d59a8c6463a3a4c122e64cec91a83749ff" digest = "1:238ba9f81f5f913de38bd4c5dab90c4b5eea90a5ee32a986e5416267adec4f67"
name = "github.com/docker/cli" name = "github.com/docker/cli"
packages = [ packages = [
"cli/config", "cli/config",
"cli/config/configfile", "cli/config/configfile",
"cli/config/credentials", "cli/config/credentials",
"opts", "cli/config/types",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "c89750f836c57ce10386e71669e1b08a54c3caeb" revision = "f28d9cc92972044feb72ab6833699102992d40a2"
version = "v18.09.5" version = "v19.03.0-beta3"
[[projects]] [[projects]]
digest = "1:feaf11ab67fe48ec2712bf9d44e2fb2d4ebdc5da8e5a47bd3ce05bae9f82825b" digest = "1:feaf11ab67fe48ec2712bf9d44e2fb2d4ebdc5da8e5a47bd3ce05bae9f82825b"

@ -44,7 +44,7 @@
[[constraint]] [[constraint]]
name = "github.com/deislabs/oras" name = "github.com/deislabs/oras"
version = "0.4.0" version = "0.5.0"
[[constraint]] [[constraint]]
name = "github.com/sirupsen/logrus" name = "github.com/sirupsen/logrus"

@ -110,7 +110,7 @@ func (cache *filesystemCache) ChartToLayers(ch *chart.Chart) ([]ocispec.Descript
if err != nil { if err != nil {
return nil, err return nil, err
} }
metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaMediaType, metaJSONRaw) metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaLayerMediaType, metaJSONRaw)
// Create content layer // Create content layer
// TODO: something better than this hack. Currently needed for chartutil.Save() // 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 { if err != nil {
return nil, err return nil, err
} }
contentLayer := cache.store.Add(HelmChartContentFileName, HelmChartContentMediaType, contentRaw) contentLayer := cache.store.Add(HelmChartContentFileName, HelmChartContentLayerMediaType, contentRaw)
// Set annotations // Set annotations
contentLayer.Annotations[HelmChartNameAnnotation] = name contentLayer.Annotations[HelmChartNameAnnotation] = name
@ -149,14 +149,14 @@ func (cache *filesystemCache) LoadReference(ref *Reference) ([]ocispec.Descripto
if err != nil { if err != nil {
return nil, err return nil, err
} }
metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaMediaType, metaJSONRaw) metaLayer := cache.store.Add(HelmChartMetaFileName, HelmChartMetaLayerMediaType, metaJSONRaw)
// add content layer // add content layer
contentRaw, err := getSymlinkDestContent(filepath.Join(tagDir, "content")) contentRaw, err := getSymlinkDestContent(filepath.Join(tagDir, "content"))
if err != nil { if err != nil {
return nil, err 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) // set annotations on content layer (chart name and version)
err = setLayerAnnotationsFromChartLink(contentLayer, filepath.Join(tagDir, "chart")) err = setLayerAnnotationsFromChartLink(contentLayer, filepath.Join(tagDir, "chart"))
@ -329,9 +329,9 @@ func extractLayers(layers []ocispec.Descriptor) (ocispec.Descriptor, ocispec.Des
for _, layer := range layers { for _, layer := range layers {
switch layer.MediaType { switch layer.MediaType {
case HelmChartMetaMediaType: case HelmChartMetaLayerMediaType:
metaLayer = layer metaLayer = layer
case HelmChartContentMediaType: case HelmChartContentLayerMediaType:
contentLayer = layer contentLayer = layer
} }
} }

@ -97,7 +97,8 @@ func (c *Client) PushChart(ref *Reference) error {
if err != nil { if err != nil {
return err 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 { if err != nil {
return err return err
} }

@ -71,7 +71,6 @@ func (suite *RegistryClientTestSuite) SetupSuite() {
// Init test client // Init test client
suite.RegistryClient = NewClient(&ClientOptions{ suite.RegistryClient = NewClient(&ClientOptions{
Debug: false,
Out: suite.Out, Out: suite.Out,
Authorizer: Authorizer{ Authorizer: Authorizer{
Client: client, Client: client,

@ -20,11 +20,14 @@ const (
// HelmChartDefaultTag is the default tag used when storing a chart reference with no tag // HelmChartDefaultTag is the default tag used when storing a chart reference with no tag
HelmChartDefaultTag = "latest" HelmChartDefaultTag = "latest"
// HelmChartMetaMediaType is the reserved media type for Helm chart metadata // HelmChartConfigMediaType is the reserved media type for the Helm chart manifest config
HelmChartMetaMediaType = "application/vnd.cncf.helm.chart.meta.v1+json" HelmChartConfigMediaType = "application/vnd.cncf.helm.config.v1+json"
// HelmChartContentMediaType is the reserved media type for Helm chart package content // HelmChartMetaLayerMediaType is the reserved media type for Helm chart metadata
HelmChartContentMediaType = "application/vnd.cncf.helm.chart.content.v1+tar" 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 is the reserved file name for Helm chart metadata
HelmChartMetaFileName = "chart-meta.json" HelmChartMetaFileName = "chart-meta.json"
@ -42,7 +45,7 @@ const (
// KnownMediaTypes returns a list of layer mediaTypes that the Helm client knows about // KnownMediaTypes returns a list of layer mediaTypes that the Helm client knows about
func KnownMediaTypes() []string { func KnownMediaTypes() []string {
return []string{ return []string{
HelmChartMetaMediaType, HelmChartMetaLayerMediaType,
HelmChartContentMediaType, HelmChartContentLayerMediaType,
} }
} }

@ -24,6 +24,6 @@ import (
func TestConstants(t *testing.T) { func TestConstants(t *testing.T) {
knownMediaTypes := KnownMediaTypes() knownMediaTypes := KnownMediaTypes()
assert.Contains(t, knownMediaTypes, HelmChartMetaMediaType) assert.Contains(t, knownMediaTypes, HelmChartMetaLayerMediaType)
assert.Contains(t, knownMediaTypes, HelmChartContentMediaType) assert.Contains(t, knownMediaTypes, HelmChartContentLayerMediaType)
} }

Loading…
Cancel
Save