Repository: helm/helm
Pull request #6773 (2019-10-24 11:26:41)

chore(mod): Update containerd dependency from beta to release
containerd released [1.3.0](https://github.com/containerd/containerd/releases/tag/v1.3.0). Updating from beta to the release dependency.


Patch:
diff --git a/Makefile b/Makefile
index 5cc931af3..b52464ba9 100644
--- a/Makefile
+++ b/Makefile
@@ -100,10 +100,6 @@ test-acceptance: build build-cross
 test-acceptance-completion: ACCEPTANCE_RUN_TESTS = shells.robot
 test-acceptance-completion: test-acceptance
 
-.PHONY: verify-docs
-verify-docs: build
-	@scripts/verify-docs.sh
-
 .PHONY: coverage
 coverage:
 	@scripts/coverage.sh
@@ -154,10 +150,6 @@ checksum:
 
 # ------------------------------------------------------------------------------
 
-.PHONY: docs
-docs: build
-	@scripts/update-docs.sh
-
 .PHONY: clean
 clean:
 	@rm -rf $(BINDIR) ./_dist
diff --git a/cmd/helm/install.go b/cmd/helm/install.go
index 6c6920daa..c80f8875d 100644
--- a/cmd/helm/install.go
+++ b/cmd/helm/install.go
@@ -93,9 +93,9 @@ A chart reference is a convenient way of referencing a chart in a chart reposito
 
 When you use a chart reference with a repo prefix ('example/mariadb'), Helm will look in the local
 configuration for a chart repository named 'example', and will then look for a
-chart in that repository whose name is 'mariadb'. It will install the latest
-version of that chart unless you also supply a version number with the
-'--version' flag.
+chart in that repository whose name is 'mariadb'. It will install the latest stable version of that chart 
+until you specify '--devel' flag to also include development version (alpha, beta, and release candidate releases), or  
+supply a version number with the '--version' flag.
 
 To see the list of chart repositories, use 'helm repo list'. To search for
 charts in a repository, use 'helm search'.
diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go
index 9a448f75f..8abcd1eb7 100644
--- a/cmd/helm/search_repo.go
+++ b/cmd/helm/search_repo.go
@@ -38,6 +38,20 @@ Search reads through all of the repositories configured on the system, and
 looks for matches. Search of these repositories uses the metadata stored on
 the system.
 
+It will display the latest stable versions of that chart until you specify '--devel' flag 
+to also include development versions (alpha, beta, and release candidate releases), or  
+supply a version number with the '--version' flag.
+
+Examples: 
+	# Searches only for stable releases, prerelease versions will be skipped
+	helm repo search 
+ 
+	# Searches for releases and prereleases (alpha, beta, and release candidate releases)
+	helm repo search --devel
+
+	# searches only for release in version 1.0.0
+	helm repo search --version 1.0.0
+
 Repositories are managed with 'helm repo' commands.
 `
 
@@ -47,6 +61,7 @@ const searchMaxScore = 25
 type searchRepoOptions struct {
 	versions     bool
 	regexp       bool
+	devel        bool
 	version      string
 	maxColWidth  uint
 	repoFile     string
@@ -71,6 +86,7 @@ func newSearchRepoCmd(out io.Writer) *cobra.Command {
 	f := cmd.Flags()
 	f.BoolVarP(&o.regexp, "regexp", "r", false, "use regular expressions for searching repositories you have added")
 	f.BoolVarP(&o.versions, "versions", "l", false, "show the long listing, with each version of each chart on its own line, for repositories you have added")
+	f.BoolVar(&o.devel, "devel", false, "use development versions (alpha, beta, and release candidate releases), too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored")
 	f.StringVar(&o.version, "version", "", "search using semantic versioning constraints on repositories you have added")
 	f.UintVar(&o.maxColWidth, "max-col-width", 50, "maximum column width for output table")
 	bindOutputFlag(cmd, &o.outputFormat)
@@ -79,6 +95,8 @@ func newSearchRepoCmd(out io.Writer) *cobra.Command {
 }
 
 func (o *searchRepoOptions) run(out io.Writer, args []string) error {
+	o.setupSearchedVersion()
+
 	index, err := o.buildIndex(out)
 	if err != nil {
 		return err
@@ -104,6 +122,22 @@ func (o *searchRepoOptions) run(out io.Writer, args []string) error {
 	return o.outputFormat.Write(out, &repoSearchWriter{data, o.maxColWidth})
 }
 
+func (o *searchRepoOptions) setupSearchedVersion() {
+	debug("Original chart version: %q", o.version)
+
+	if o.version != "" {
+		return
+	}
+
+	if o.devel { // search for releases and prereleases (alpha, beta, and release candidate releases).
+		debug("setting version to >0.0.0-0")
+		o.version = ">0.0.0-0"
+	} else { // search only for stable releases, prerelease versions will be skip
+		debug("setting version to >0.0.0")
+		o.version = ">0.0.0"
+	}
+}
+
 func (o *searchRepoOptions) applyConstraint(res []*search.Result) ([]*search.Result, error) {
 	if len(o.version) == 0 {
 		return res, nil
diff --git a/cmd/helm/testdata/output/search-multiple.txt b/cmd/helm/testdata/output/search-multiple-stable-release.txt
similarity index 100%
rename from cmd/helm/testdata/output/search-multiple.txt
rename to cmd/helm/testdata/output/search-multiple-stable-release.txt
diff --git a/go.mod b/go.mod
index d986c4b77..6744a7451 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
 	github.com/Masterminds/vcs v1.13.0
 	github.com/Microsoft/go-winio v0.4.12 // indirect
 	github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a
-	github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4
+	github.com/containerd/containerd v1.3.0
 	github.com/cyphar/filepath-securejoin v0.2.2
 	github.com/deislabs/oras v0.7.0
 	github.com/docker/distribution v2.7.1+incompatible
diff --git a/go.sum b/go.sum
index de710b39a..c82eb87fe 100644
--- a/go.sum
+++ b/go.sum
@@ -71,6 +71,8 @@ github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4 h1:aMyA5J7j6D07U7pf8BFEY67BKoDcz0zWleAbQj3zVng=
 github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
+github.com/containerd/containerd v1.3.0 h1:xjvXQWABwS2uiv3TWgQt5Uth60Gu86LTGZXMJkjc7rY=
+github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
 github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 h1:4BX8f882bXEDKfWIf0wa8HRvpnBoPszJJXL+TVbBw4M=
 github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
 github.com/coreos/bbolt v1.3.1-coreos.6 h1:uTXKg9gY70s9jMAKdfljFQcuh4e/BXOM+V+d00KFj3A=
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
diff --git a/pkg/action/list.go b/pkg/action/list.go
index f72edc83b..4af0ef8e5 100644
--- a/pkg/action/list.go
+++ b/pkg/action/list.go
@@ -17,6 +17,7 @@ limitations under the License.
 package action
 
 import (
+	"path"
 	"regexp"
 
 	"helm.sh/helm/v3/pkg/release"
@@ -218,27 +219,23 @@ func (l *List) sort(rels []*release.Release) {
 }
 
 // filterList returns a list scrubbed of old releases.
-func filterList(rels []*release.Release) []*release.Release {
-	idx := map[string]int{}
-
-	for _, r := range rels {
-		name, version := r.Name, r.Version
-		if max, ok := idx[name]; ok {
-			// check if we have a greater version already
-			if max > version {
-				continue
-			}
+func filterList(releases []*release.Release) []*release.Release {
+	latestReleases := make(map[string]*release.Release)
+
+	for _, rls := range releases {
+		name, namespace := rls.Name, rls.Namespace
+		key := path.Join(namespace, name)
+		if latestRelease, exists := latestReleases[key]; exists && latestRelease.Version > rls.Version {
+			continue
 		}
-		idx[name] = version
+		latestReleases[key] = rls
 	}
 
-	uniq := make([]*release.Release, 0, len(idx))
-	for _, r := range rels {
-		if idx[r.Name] == r.Version {
-			uniq = append(uniq, r)
-		}
+	var list = make([]*release.Release, 0, len(latestReleases))
+	for _, rls := range latestReleases {
+		list = append(list, rls)
 	}
-	return uniq
+	return list
 }
 
 // setStateMask calculates the state mask based on parameters.
diff --git a/pkg/repo/index.go b/pkg/repo/index.go
index 8e8f56d47..b3703304f 100644
--- a/pkg/repo/index.go
+++ b/pkg/repo/index.go
@@ -147,7 +147,8 @@ func (i IndexFile) SortEntries() {
 
 // Get returns the ChartVersion for the given name.
 //
-// If version is empty, this will return the chart with the highest version.
+// If version is empty, this will return the chart with the latest stable version,
+// prerelease versions will be skipped.
 func (i IndexFile) Get(name, version string) (*ChartVersion, error) {
 	vs, ok := i.Entries[name]
 	if !ok {


Test patch:
diff --git a/cmd/helm/search_repo_test.go b/cmd/helm/search_repo_test.go
index 5e945e3b7..6ece55505 100644
--- a/cmd/helm/search_repo_test.go
+++ b/cmd/helm/search_repo_test.go
@@ -25,13 +25,13 @@ func TestSearchRepositoriesCmd(t *testing.T) {
 	repoCache := "testdata/helmhome/helm/repository"
 
 	tests := []cmdTestCase{{
-		name:   "search for 'alpine', expect two matches",
+		name:   "search for 'alpine', expect one match with latest stable version",
 		cmd:    "search repo alpine",
-		golden: "output/search-multiple.txt",
+		golden: "output/search-multiple-stable-release.txt",
 	}, {
-		name:   "search for 'alpine', expect two matches",
-		cmd:    "search repo alpine",
-		golden: "output/search-multiple.txt",
+		name:   "search for 'alpine', expect one match with newest development version",
+		cmd:    "search repo alpine --devel",
+		golden: "output/search-multiple-devel-release.txt",
 	}, {
 		name:   "search for 'alpine' with versions, expect three matches",
 		cmd:    "search repo alpine --versions",
diff --git a/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml b/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml
index aab74f742..429388fb8 100644
--- a/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml
+++ b/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml
@@ -25,6 +25,18 @@ entries:
       keywords: []
       maintainers: []
       icon: ""
+    - name: alpine
+      url: https://kubernetes-charts.storage.googleapis.com/alpine-0.3.0-rc.1.tgz
+      checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
+      home: https://helm.sh/helm
+      sources:
+        - https://github.com/helm/helm
+      version: 0.3.0-rc.1
+      appVersion: 3.0.0
+      description: Deploy a basic Alpine Linux pod
+      keywords: []
+      maintainers: []
+      icon: ""
   mariadb:
     - name: mariadb
       url: https://kubernetes-charts.storage.googleapis.com/mariadb-0.3.0.tgz
diff --git a/cmd/helm/testdata/output/search-multiple-devel-release.txt b/cmd/helm/testdata/output/search-multiple-devel-release.txt
new file mode 100644
index 000000000..7e29a8f7e
--- /dev/null
+++ b/cmd/helm/testdata/output/search-multiple-devel-release.txt
@@ -0,0 +1,2 @@
+NAME          	CHART VERSION	APP VERSION	DESCRIPTION                    
+testing/alpine	0.3.0-rc.1   	3.0.0      	Deploy a basic Alpine Linux pod
diff --git a/pkg/action/list_test.go b/pkg/action/list_test.go
index cab0111fd..cd86aee68 100644
--- a/pkg/action/list_test.go
+++ b/pkg/action/list_test.go
@@ -159,6 +159,7 @@ func TestList_LimitOffsetOutOfBounds(t *testing.T) {
 	is.NoError(err)
 	is.Len(list, 2)
 }
+
 func TestList_StateMask(t *testing.T) {
 	is := assert.New(t)
 	lister := newListFixture(t)
@@ -166,7 +167,8 @@ func TestList_StateMask(t *testing.T) {
 	one, err := lister.cfg.Releases.Get("one", 1)
 	is.NoError(err)
 	one.SetStatus(release.StatusUninstalled, "uninstalled")
-	lister.cfg.Releases.Update(one)
+	err = lister.cfg.Releases.Update(one)
+	is.NoError(err)
 
 	res, err := lister.Run()
 	is.NoError(err)
@@ -222,11 +224,6 @@ func makeMeSomeReleases(store *storage.Storage, t *testing.T) {
 	three.Name = "three"
 	three.Namespace = "default"
 	three.Version = 3
-	four := releaseStub()
-	four.Name = "four"
-	four.Namespace = "default"
-	four.Version = 4
-	four.Info.Status = release.StatusSuperseded
 
 	for _, rel := range []*release.Release{one, two, three} {
 		if err := store.Create(rel); err != nil {
@@ -238,3 +235,29 @@ func makeMeSomeReleases(store *storage.Storage, t *testing.T) {
 	assert.NoError(t, err)
 	assert.Len(t, all, 3, "sanity test: three items added")
 }
+
+func TestFilterList(t *testing.T) {
+	one := releaseStub()
+	one.Name = "one"
+	one.Namespace = "default"
+	one.Version = 1
+	two := releaseStub()
+	two.Name = "two"
+	two.Namespace = "default"
+	two.Version = 1
+	anotherOldOne := releaseStub()
+	anotherOldOne.Name = "one"
+	anotherOldOne.Namespace = "testing"
+	anotherOldOne.Version = 1
+	anotherOne := releaseStub()
+	anotherOne.Name = "one"
+	anotherOne.Namespace = "testing"
+	anotherOne.Version = 2
+
+	list := []*release.Release{one, two, anotherOne}
+	expectedFilteredList := []*release.Release{one, two, anotherOne}
+
+	filteredList := filterList(list)
+
+	assert.ElementsMatch(t, expectedFilteredList, filteredList)
+}
diff --git a/pkg/storage/driver/cfgmaps_test.go b/pkg/storage/driver/cfgmaps_test.go
index 6efd790ce..2aa38f284 100644
--- a/pkg/storage/driver/cfgmaps_test.go
+++ b/pkg/storage/driver/cfgmaps_test.go
@@ -51,7 +51,7 @@ func TestConfigMapGet(t *testing.T) {
 	}
 }
 
-func TestUNcompressedConfigMapGet(t *testing.T) {
+func TestUncompressedConfigMapGet(t *testing.T) {
 	vers := 1
 	name := "smug-pigeon"
 	namespace := "default"