From b3ebfd69d3cf4f1e90277aef96e66cc1d9f456b5 Mon Sep 17 00:00:00 2001 From: youyongsong Date: Sat, 8 Aug 2020 16:59:37 +0800 Subject: [PATCH 1/2] enable oci by default --- pkg/gates/gates.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/gates/gates.go b/pkg/gates/gates.go index 69559219e7f..c766d20a8e3 100644 --- a/pkg/gates/gates.go +++ b/pkg/gates/gates.go @@ -17,7 +17,6 @@ package gates import ( "fmt" - "os" ) // Gate is the name of the feature gate. @@ -30,7 +29,7 @@ func (g Gate) String() string { // IsEnabled determines whether a certain feature gate is enabled. func (g Gate) IsEnabled() bool { - return os.Getenv(string(g)) != "" + return true } func (g Gate) Error() error { From 7d50efe385093734377e227248150949279bded1 Mon Sep 17 00:00:00 2001 From: youyongsong Date: Fri, 13 Aug 2021 14:51:05 +0800 Subject: [PATCH 2/2] retry http registry if insecure specified like docker --- internal/experimental/registry/client.go | 36 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/internal/experimental/registry/client.go b/internal/experimental/registry/client.go index 3978b694bf0..46dc0a28769 100644 --- a/internal/experimental/registry/client.go +++ b/internal/experimental/registry/client.go @@ -140,11 +140,27 @@ func (c *Client) PushChart(ref *Reference, insecure bool, plainHTTP bool) error fmt.Fprintf(c.out, "The push refers to repository [%s]\n", r.Repo) c.printCacheRefSummary(r) layers := []ocispec.Descriptor{*r.ContentLayer} + _, err = oras.Push(ctx(c.out, c.debug), c.resolver, r.Name, c.cache.Provider(), layers, oras.WithConfig(*r.Config), oras.WithNameValidation(nil)) - if err != nil { + if err != nil && insecure { + resolver, err := c.newResolver(insecure, true) + if err != nil { + return err + } + c.resolver = &Resolver{ + Resolver: resolver, + } + + _, err = oras.Push(ctx(c.out, c.debug), c.resolver, r.Name, c.cache.Provider(), layers, + oras.WithConfig(*r.Config), oras.WithNameValidation(nil)) + if err != nil { + return err + } + } else if err != nil { return err } + s := "" numLayers := len(layers) if 1 < numLayers { @@ -179,7 +195,23 @@ func (c *Client) PullChart(ref *Reference, insecure bool, plainHTTP bool) error oras.WithPullEmptyNameAllowed(), oras.WithAllowedMediaTypes(KnownMediaTypes()), oras.WithContentProvideIngester(c.cache.ProvideIngester())) - if err != nil { + if err != nil && insecure { + resolver, err := c.newResolver(insecure, true) + if err != nil { + return err + } + c.resolver = &Resolver{ + Resolver: resolver, + } + + manifest, _, err = oras.Pull(ctx(c.out, c.debug), c.resolver, ref.FullName(), c.cache.Ingester(), + oras.WithPullEmptyNameAllowed(), + oras.WithAllowedMediaTypes(KnownMediaTypes()), + oras.WithContentProvideIngester(c.cache.ProvideIngester())) + if err != nil { + return err + } + } else if err != nil { return err } err = c.cache.AddManifest(ref, &manifest)