From d3a8cc4713ddeb5f3b6e698e6e3d295e26d1eb84 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 11 Jan 2020 20:43:35 -0500 Subject: [PATCH] feat(chore): Remove unused code Signed-off-by: Marc Khouzam --- pkg/repo/index.go | 47 ------------------- pkg/repo/index_test.go | 20 -------- pkg/repo/testdata/unversioned-index.yaml | 60 ------------------------ 3 files changed, 127 deletions(-) delete mode 100644 pkg/repo/testdata/unversioned-index.yaml diff --git a/pkg/repo/index.go b/pkg/repo/index.go index a7fea673b..36386665e 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -17,8 +17,6 @@ limitations under the License. package repo import ( - "encoding/json" - "fmt" "io/ioutil" "os" "path" @@ -290,48 +288,3 @@ func loadIndex(data []byte) (*IndexFile, error) { } return i, nil } - -// unversionedEntry represents a deprecated pre-Alpha.5 format. -// -// This will be removed prior to v2.0.0 -type unversionedEntry struct { - Checksum string `json:"checksum"` - URL string `json:"url"` - Chartfile *chart.Metadata `json:"chartfile"` -} - -// loadUnversionedIndex loads a pre-Alpha.5 index.yaml file. -// -// This format is deprecated. This function will be removed prior to v2.0.0. -func loadUnversionedIndex(data []byte) (*IndexFile, error) { - fmt.Fprintln(os.Stderr, "WARNING: Deprecated index file format. Try 'helm repo update'") - i := map[string]unversionedEntry{} - - // This gets around an error in the YAML parser. Instead of parsing as YAML, - // we convert to JSON, and then decode again. - var err error - data, err = yaml.YAMLToJSON(data) - if err != nil { - return nil, err - } - if err := json.Unmarshal(data, &i); err != nil { - return nil, err - } - - if len(i) == 0 { - return nil, ErrNoAPIVersion - } - ni := NewIndexFile() - for n, item := range i { - if item.Chartfile == nil || item.Chartfile.Name == "" { - parts := strings.Split(n, "-") - ver := "" - if len(parts) > 1 { - ver = strings.TrimSuffix(parts[1], ".tgz") - } - item.Chartfile = &chart.Metadata{Name: parts[0], Version: ver} - } - ni.Add(item.Chartfile, item.URL, "", item.Checksum) - } - return ni, nil -} diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index c830a339e..b5119166a 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -361,26 +361,6 @@ func TestIndexDirectory(t *testing.T) { } } -func TestLoadUnversionedIndex(t *testing.T) { - data, err := ioutil.ReadFile("testdata/unversioned-index.yaml") - if err != nil { - t.Fatal(err) - } - - ind, err := loadUnversionedIndex(data) - if err != nil { - t.Fatal(err) - } - - if l := len(ind.Entries); l != 2 { - t.Fatalf("Expected 2 entries, got %d", l) - } - - if l := len(ind.Entries["mysql"]); l != 3 { - t.Fatalf("Expected 3 mysql versions, got %d", l) - } -} - func TestIndexAdd(t *testing.T) { i := NewIndexFile() i.Add(&chart.Metadata{Name: "clipper", Version: "0.1.0"}, "clipper-0.1.0.tgz", "http://example.com/charts", "sha256:1234567890") diff --git a/pkg/repo/testdata/unversioned-index.yaml b/pkg/repo/testdata/unversioned-index.yaml deleted file mode 100644 index 1d814c7ae..000000000 --- a/pkg/repo/testdata/unversioned-index.yaml +++ /dev/null @@ -1,60 +0,0 @@ -memcached-0.1.0: - name: memcached - url: https://mumoshu.github.io/charts/memcached-0.1.0.tgz - created: 2016-08-04 02:05:02.259205055 +0000 UTC - checksum: ce9b76576c4b4eb74286fa30a978c56d69e7a522 - chartfile: - name: memcached - home: http://https://hub.docker.com/_/memcached/ - sources: [] - version: 0.1.0 - description: A simple Memcached cluster - keywords: [] - maintainers: - - name: Matt Butcher - email: mbutcher@deis.com -mysql-0.2.0: - name: mysql - url: https://mumoshu.github.io/charts/mysql-0.2.0.tgz - created: 2016-08-04 00:42:47.517342022 +0000 UTC - checksum: aa5edd2904d639b0b6295f1c7cf4c0a8e4f77dd3 - chartfile: - name: mysql - home: https://www.mysql.com/ - sources: [] - version: 0.2.0 - description: Chart running MySQL. - keywords: [] - maintainers: - - name: Matt Fisher - email: mfisher@deis.com -mysql-0.2.1: - name: mysql - url: https://mumoshu.github.io/charts/mysql-0.2.1.tgz - created: 2016-08-04 02:40:29.717829534 +0000 UTC - checksum: 9d9f056171beefaaa04db75680319ca4edb6336a - chartfile: - name: mysql - home: https://www.mysql.com/ - sources: [] - version: 0.2.1 - description: Chart running MySQL. - keywords: [] - maintainers: - - name: Matt Fisher - email: mfisher@deis.com -mysql-0.2.2: - name: mysql - url: https://mumoshu.github.io/charts/mysql-0.2.2.tgz - created: 2016-08-04 02:40:29.71841952 +0000 UTC - checksum: 6d6810e76a5987943faf0040ec22990d9fb141c7 - chartfile: - name: mysql - home: https://www.mysql.com/ - sources: [] - version: 0.2.2 - description: Chart running MySQL. - keywords: [] - maintainers: - - name: Matt Fisher - email: mfisher@deis.com