From c50813af548f0c70e63ef9a69de781e57bd45cf6 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 25 Apr 2018 09:35:29 -0700 Subject: [PATCH] ref(*): remove local repository (dead code) --- cmd/helm/delete.go | 0 cmd/helm/helm_test.go | 19 +-- cmd/helm/home.go | 1 - cmd/helm/init.go | 43 +----- cmd/helm/init_test.go | 8 +- cmd/helm/init_unix.go | 29 ---- cmd/helm/init_windows.go | 29 ---- cmd/helm/package.go | 13 -- cmd/helm/plugin_test.go | 2 - cmd/helm/repo_update.go | 7 +- cmd/helm/repo_update_test.go | 4 +- .../helmhome/plugins/fullenv/fullenv.sh | 1 - cmd/helm/testdata/repositories.yaml | 2 - pkg/hapi/tiller.go | 13 -- pkg/helm/helmpath/helmhome.go | 11 -- pkg/helm/helmpath/helmhome_unix_test.go | 1 - pkg/helm/helmpath/helmhome_windows_test.go | 1 - pkg/plugin/installer/http_installer.go | 2 +- pkg/plugin/plugin.go | 9 +- pkg/repo/local.go | 137 ------------------ pkg/repo/local_test.go | 67 --------- pkg/repo/repo_test.go | 2 +- pkg/tiller/release_server.go | 3 - 23 files changed, 13 insertions(+), 391 deletions(-) mode change 100755 => 100644 cmd/helm/delete.go delete mode 100644 cmd/helm/init_unix.go delete mode 100644 cmd/helm/init_windows.go delete mode 100644 pkg/repo/local.go delete mode 100644 pkg/repo/local_test.go diff --git a/cmd/helm/delete.go b/cmd/helm/delete.go old mode 100755 new mode 100644 diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 40f011591..baaa22bf6 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -99,7 +99,7 @@ func tempHelmHome(t *testing.T) (helmpath.Home, error) { // // t is used only for logging. func ensureTestHome(home helmpath.Home, t *testing.T) error { - configDirectories := []string{home.String(), home.Repository(), home.Cache(), home.LocalRepository(), home.Plugins(), home.Starters()} + configDirectories := []string{home.String(), home.Repository(), home.Cache(), home.Plugins(), home.Starters()} for _, p := range configDirectories { if fi, err := os.Stat(p); err != nil { if err := os.MkdirAll(p, 0755); err != nil { @@ -117,10 +117,6 @@ func ensureTestHome(home helmpath.Home, t *testing.T) error { Name: "charts", URL: "http://example.com/foo", Cache: "charts-index.yaml", - }, &repo.Entry{ - Name: "local", - URL: "http://localhost.com:7743/foo", - Cache: "local-index.yaml", }) if err := rf.WriteFile(repoFile, 0644); err != nil { return err @@ -135,19 +131,6 @@ func ensureTestHome(home helmpath.Home, t *testing.T) error { } } - localRepoIndexFile := home.LocalRepository(localRepositoryIndexFile) - if fi, err := os.Stat(localRepoIndexFile); err != nil { - i := repo.NewIndexFile() - if err := i.WriteFile(localRepoIndexFile, 0644); err != nil { - return err - } - - //TODO: take this out and replace with helm update functionality - os.Symlink(localRepoIndexFile, home.CacheIndex("local")) - } else if fi.IsDir() { - return fmt.Errorf("%s must be a file, not a directory", localRepoIndexFile) - } - t.Logf("$HELM_HOME has been configured at %s.\n", settings.Home.String()) return nil diff --git a/cmd/helm/home.go b/cmd/helm/home.go index e96edd7a1..4ab649d74 100644 --- a/cmd/helm/home.go +++ b/cmd/helm/home.go @@ -42,7 +42,6 @@ func newHomeCmd(out io.Writer) *cobra.Command { fmt.Fprintf(out, "Cache: %s\n", h.Cache()) fmt.Fprintf(out, "Stable CacheIndex: %s\n", h.CacheIndex("stable")) fmt.Fprintf(out, "Starters: %s\n", h.Starters()) - fmt.Fprintf(out, "LocalRepository: %s\n", h.LocalRepository()) fmt.Fprintf(out, "Plugins: %s\n", h.Plugins()) } }, diff --git a/cmd/helm/init.go b/cmd/helm/init.go index 5eec5d0de..c4faed4a4 100644 --- a/cmd/helm/init.go +++ b/cmd/helm/init.go @@ -33,18 +33,9 @@ const initDesc = ` This command sets up local configuration in $HELM_HOME (default ~/.helm/). ` -const ( - stableRepository = "stable" - localRepository = "local" - localRepositoryIndexFile = "index.yaml" -) +const stableRepository = "stable" -var ( - stableRepositoryURL = "https://kubernetes-charts.storage.googleapis.com" - // This is the IPv4 loopback, not localhost, because we have to force IPv4 - // for Dockerized Helm: https://github.com/kubernetes/helm/issues/1410 - localRepositoryURL = "http://127.0.0.1:8879/charts" -) +var stableRepositoryURL = "https://kubernetes-charts.storage.googleapis.com" type initCmd struct { skipRefresh bool @@ -71,7 +62,6 @@ func newInitCmd(out io.Writer) *cobra.Command { f := cmd.Flags() f.BoolVar(&i.skipRefresh, "skip-refresh", false, "do not refresh (download) the local repository cache") f.StringVar(&stableRepositoryURL, "stable-repo-url", stableRepositoryURL, "URL for stable repository") - f.StringVar(&localRepositoryURL, "local-repo-url", localRepositoryURL, "URL for local repository") return cmd } @@ -100,7 +90,6 @@ func ensureDirectories(home helmpath.Home, out io.Writer) error { home.String(), home.Repository(), home.Cache(), - home.LocalRepository(), home.Plugins(), home.Starters(), home.Archive(), @@ -128,12 +117,7 @@ func ensureDefaultRepos(home helmpath.Home, out io.Writer, skipRefresh bool) err if err != nil { return err } - lr, err := initLocalRepo(home.LocalRepository(localRepositoryIndexFile), home.CacheIndex("local"), out, home) - if err != nil { - return err - } f.Add(sr) - f.Add(lr) if err := f.WriteFile(repoFile, 0644); err != nil { return err } @@ -168,29 +152,6 @@ func initStableRepo(cacheFile string, out io.Writer, skipRefresh bool, home helm return &c, nil } -func initLocalRepo(indexFile, cacheFile string, out io.Writer, home helmpath.Home) (*repo.Entry, error) { - if fi, err := os.Stat(indexFile); err != nil { - fmt.Fprintf(out, "Adding %s repo with URL: %s \n", localRepository, localRepositoryURL) - i := repo.NewIndexFile() - if err := i.WriteFile(indexFile, 0644); err != nil { - return nil, err - } - - //TODO: take this out and replace with helm update functionality - if err := createLink(indexFile, cacheFile, home); err != nil { - return nil, err - } - } else if fi.IsDir() { - return nil, fmt.Errorf("%s must be a file, not a directory", indexFile) - } - - return &repo.Entry{ - Name: localRepository, - URL: localRepositoryURL, - Cache: cacheFile, - }, nil -} - func ensureRepoFileFormat(file string, out io.Writer) error { r, err := repo.LoadRepositoriesFile(file) if err == repo.ErrRepoOutOfDate { diff --git a/cmd/helm/init_test.go b/cmd/helm/init_test.go index 42f0c0464..00fa3673c 100644 --- a/cmd/helm/init_test.go +++ b/cmd/helm/init_test.go @@ -48,7 +48,7 @@ func TestEnsureHome(t *testing.T) { t.Error(err) } - expectedDirs := []string{hh.String(), hh.Repository(), hh.Cache(), hh.LocalRepository()} + expectedDirs := []string{hh.String(), hh.Repository(), hh.Cache()} for _, dir := range expectedDirs { if fi, err := os.Stat(dir); err != nil { t.Errorf("%s", err) @@ -62,10 +62,4 @@ func TestEnsureHome(t *testing.T) { } else if fi.IsDir() { t.Errorf("%s should not be a directory", fi) } - - if fi, err := os.Stat(hh.LocalRepository(localRepositoryIndexFile)); err != nil { - t.Errorf("%s", err) - } else if fi.IsDir() { - t.Errorf("%s should not be a directory", fi) - } } diff --git a/cmd/helm/init_unix.go b/cmd/helm/init_unix.go deleted file mode 100644 index 1117dd487..000000000 --- a/cmd/helm/init_unix.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build !windows - -/* -Copyright 2017 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "os" - - "k8s.io/helm/pkg/helm/helmpath" -) - -func createLink(indexFile, cacheFile string, home helmpath.Home) error { - return os.Symlink(indexFile, cacheFile) -} diff --git a/cmd/helm/init_windows.go b/cmd/helm/init_windows.go deleted file mode 100644 index be17bccda..000000000 --- a/cmd/helm/init_windows.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build windows - -/* -Copyright 2017 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "os" - - "k8s.io/helm/pkg/helm/helmpath" -) - -func createLink(indexFile, cacheFile string, home helmpath.Home) error { - return os.Link(indexFile, cacheFile) -} diff --git a/cmd/helm/package.go b/cmd/helm/package.go index 6ffa90d08..f9fff79fe 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -36,7 +36,6 @@ import ( "k8s.io/helm/pkg/hapi/chart" "k8s.io/helm/pkg/helm/helmpath" "k8s.io/helm/pkg/provenance" - "k8s.io/helm/pkg/repo" ) const packageDesc = ` @@ -51,7 +50,6 @@ Versioned chart archives are used by Helm package repositories. ` type packageCmd struct { - save bool sign bool path string valueFiles valueFiles @@ -102,7 +100,6 @@ func newPackageCmd(out io.Writer) *cobra.Command { f.VarP(&pkg.valueFiles, "values", "f", "specify values in a YAML file or a URL(can specify multiple)") f.StringArrayVar(&pkg.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.StringArrayVar(&pkg.stringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") - f.BoolVar(&pkg.save, "save", true, "save packaged chart to local chart repository") f.BoolVar(&pkg.sign, "sign", false, "use a PGP private key to sign this package") f.StringVar(&pkg.key, "key", "", "name of the key to use when signing. Used if --sign is true") f.StringVar(&pkg.keyring, "keyring", defaultKeyring(), "location of a public keyring") @@ -200,16 +197,6 @@ func (p *packageCmd) run() error { return fmt.Errorf("Failed to save: %s", err) } - // Save to $HELM_HOME/local directory. This is second, because we don't want - // the case where we saved here, but didn't save to the default destination. - if p.save { - lr := p.home.LocalRepository() - if err := repo.AddChartToLocalRepo(ch, lr); err != nil { - return err - } - debug("Successfully saved %s to %s\n", name, lr) - } - if p.sign { err = p.clearsign(name) } diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index ef130fb4d..707616f5a 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -82,7 +82,6 @@ func TestLoadPlugins(t *testing.T) { hh.Repository(), hh.RepositoryFile(), hh.Cache(), - hh.LocalRepository(), os.Args[0], }, "\n") @@ -173,7 +172,6 @@ func TestSetupEnv(t *testing.T) { {"HELM_PATH_REPOSITORY", settings.Home.Repository()}, {"HELM_PATH_REPOSITORY_FILE", settings.Home.RepositoryFile()}, {"HELM_PATH_CACHE", settings.Home.Cache()}, - {"HELM_PATH_LOCAL_REPOSITORY", settings.Home.LocalRepository()}, {"HELM_PATH_STARTER", settings.Home.Starters()}, } { if got := os.Getenv(tt.name); got != tt.expect { diff --git a/cmd/helm/repo_update.go b/cmd/helm/repo_update.go index 51e5c0868..3532211ce 100644 --- a/cmd/helm/repo_update.go +++ b/cmd/helm/repo_update.go @@ -92,12 +92,7 @@ func updateCharts(repos []*repo.ChartRepository, out io.Writer, home helmpath.Ho wg.Add(1) go func(re *repo.ChartRepository) { defer wg.Done() - if re.Config.Name == localRepository { - fmt.Fprintf(out, "...Skip %s chart repository\n", re.Config.Name) - return - } - err := re.DownloadIndexFile(home.Cache()) - if err != nil { + if err := re.DownloadIndexFile(home.Cache()); err != nil { fmt.Fprintf(out, "...Unable to get an update from the %q chart repository (%s):\n\t%s\n", re.Config.Name, re.Config.URL, err) } else { fmt.Fprintf(out, "...Successfully got an update from the %q chart repository\n", re.Config.Name) diff --git a/cmd/helm/repo_update_test.go b/cmd/helm/repo_update_test.go index 68f964f32..be96f79da 100644 --- a/cmd/helm/repo_update_test.go +++ b/cmd/helm/repo_update_test.go @@ -60,8 +60,8 @@ func TestUpdateCmd(t *testing.T) { t.Fatal(err) } - if got := out.String(); !strings.Contains(got, "charts") || !strings.Contains(got, "local") { - t.Errorf("Expected 'charts' and 'local' (in any order) got %q", got) + if got := out.String(); !strings.Contains(got, "charts") { + t.Errorf("Expected 'charts' got %q", got) } } diff --git a/cmd/helm/testdata/helmhome/plugins/fullenv/fullenv.sh b/cmd/helm/testdata/helmhome/plugins/fullenv/fullenv.sh index 518f492e9..d56b94b73 100755 --- a/cmd/helm/testdata/helmhome/plugins/fullenv/fullenv.sh +++ b/cmd/helm/testdata/helmhome/plugins/fullenv/fullenv.sh @@ -6,5 +6,4 @@ echo $HELM_HOME echo $HELM_PATH_REPOSITORY echo $HELM_PATH_REPOSITORY_FILE echo $HELM_PATH_CACHE -echo $HELM_PATH_LOCAL_REPOSITORY echo $HELM_BIN diff --git a/cmd/helm/testdata/repositories.yaml b/cmd/helm/testdata/repositories.yaml index 047527ef4..ad88dcf11 100644 --- a/cmd/helm/testdata/repositories.yaml +++ b/cmd/helm/testdata/repositories.yaml @@ -2,5 +2,3 @@ apiVersion: v1 repositories: - name: charts url: "https://kubernetes-charts.storage.googleapis.com" - - name: local - url: "http://localhost:8879/charts" diff --git a/pkg/hapi/tiller.go b/pkg/hapi/tiller.go index 6c5591861..5327f9572 100644 --- a/pkg/hapi/tiller.go +++ b/pkg/hapi/tiller.go @@ -77,19 +77,6 @@ type ListReleasesRequest struct { StatusCodes []release.StatusCode `json:"status_codes,omitempty"` } -// ListReleasesResponse is a list of releases. -type ListReleasesResponse struct { - // Count is the expected total number of releases to be returned. - Count int64 `json:"count,omitempty"` - // Next is the name of the next release. If this is other than an empty - // string, it means there are more results. - Next string `json:"next,omitempty"` - // Total is the total number of queryable releases. - Total int64 `json:"total,omitempty"` - // Releases is the list of found release objects. - Releases []*release.Release `json:"releases,omitempty"` -} - // GetReleaseStatusRequest is a request to get the status of a release. type GetReleaseStatusRequest struct { // Name is the name of the release diff --git a/pkg/helm/helmpath/helmhome.go b/pkg/helm/helmpath/helmhome.go index fc6de0e0c..c8b44b9a7 100644 --- a/pkg/helm/helmpath/helmhome.go +++ b/pkg/helm/helmpath/helmhome.go @@ -66,17 +66,6 @@ func (h Home) Starters() string { return h.Path("starters") } -// LocalRepository returns the location to the local repo. -// -// The local repo is the one used by 'helm serve' -// -// If additional path elements are passed, they are appended to the returned path. -func (h Home) LocalRepository(elem ...string) string { - p := []string{"repository", "local"} - p = append(p, elem...) - return h.Path(p...) -} - // Plugins returns the path to the plugins directory. func (h Home) Plugins() string { return h.Path("plugins") diff --git a/pkg/helm/helmpath/helmhome_unix_test.go b/pkg/helm/helmpath/helmhome_unix_test.go index 153e506e0..e21a56225 100644 --- a/pkg/helm/helmpath/helmhome_unix_test.go +++ b/pkg/helm/helmpath/helmhome_unix_test.go @@ -33,7 +33,6 @@ func TestHelmHome(t *testing.T) { isEq(t, hh.String(), "/r") isEq(t, hh.Repository(), "/r/repository") isEq(t, hh.RepositoryFile(), "/r/repository/repositories.yaml") - isEq(t, hh.LocalRepository(), "/r/repository/local") isEq(t, hh.Cache(), "/r/repository/cache") isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml") isEq(t, hh.Starters(), "/r/starters") diff --git a/pkg/helm/helmpath/helmhome_windows_test.go b/pkg/helm/helmpath/helmhome_windows_test.go index d29c29b60..138095bf0 100644 --- a/pkg/helm/helmpath/helmhome_windows_test.go +++ b/pkg/helm/helmpath/helmhome_windows_test.go @@ -30,7 +30,6 @@ func TestHelmHome(t *testing.T) { isEq(t, hh.String(), "r:\\") isEq(t, hh.Repository(), "r:\\repository") isEq(t, hh.RepositoryFile(), "r:\\repository\\repositories.yaml") - isEq(t, hh.LocalRepository(), "r:\\repository\\local") isEq(t, hh.Cache(), "r:\\repository\\cache") isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml") isEq(t, hh.Starters(), "r:\\starters") diff --git a/pkg/plugin/installer/http_installer.go b/pkg/plugin/installer/http_installer.go index e06b0f776..59c5454d5 100644 --- a/pkg/plugin/installer/http_installer.go +++ b/pkg/plugin/installer/http_installer.go @@ -171,7 +171,7 @@ func (g *TarGzExtractor) Extract(buffer *bytes.Buffer, targetDir string) error { os.MkdirAll(targetDir, 0755) - for true { + for { header, err := tarReader.Next() if err == io.EOF { diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go index 38545039c..5a3c84892 100644 --- a/pkg/plugin/plugin.go +++ b/pkg/plugin/plugin.go @@ -177,11 +177,10 @@ func SetupPluginEnv(settings helm_env.EnvSettings, "HELM_HOME": settings.Home.String(), // Set vars that convey common information. - "HELM_PATH_REPOSITORY": settings.Home.Repository(), - "HELM_PATH_REPOSITORY_FILE": settings.Home.RepositoryFile(), - "HELM_PATH_CACHE": settings.Home.Cache(), - "HELM_PATH_LOCAL_REPOSITORY": settings.Home.LocalRepository(), - "HELM_PATH_STARTER": settings.Home.Starters(), + "HELM_PATH_REPOSITORY": settings.Home.Repository(), + "HELM_PATH_REPOSITORY_FILE": settings.Home.RepositoryFile(), + "HELM_PATH_CACHE": settings.Home.Cache(), + "HELM_PATH_STARTER": settings.Home.Starters(), } { os.Setenv(key, val) } diff --git a/pkg/repo/local.go b/pkg/repo/local.go deleted file mode 100644 index 3e004a6d5..000000000 --- a/pkg/repo/local.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package repo - -import ( - "fmt" - htemplate "html/template" - "io/ioutil" - "net/http" - "path/filepath" - "strings" - - "github.com/ghodss/yaml" - - "k8s.io/helm/pkg/chartutil" - "k8s.io/helm/pkg/hapi/chart" - "k8s.io/helm/pkg/provenance" -) - -const indexHTMLTemplate = ` - - - Helm Repository - -

Helm Charts Repository

- - -

Last Generated: {{.Index.Generated}}

- - -` - -// RepositoryServer is an HTTP handler for serving a chart repository. -type RepositoryServer struct { - RepoPath string -} - -// ServeHTTP implements the http.Handler interface. -func (s *RepositoryServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { - uri := r.URL.Path - switch uri { - case "/", "/charts/", "/charts/index.html", "/charts/index": - w.Header().Set("Content-Type", "text/html; charset=utf-8") - s.htmlIndex(w, r) - default: - file := strings.TrimPrefix(uri, "/charts/") - http.ServeFile(w, r, filepath.Join(s.RepoPath, file)) - } -} - -// StartLocalRepo starts a web server and serves files from the given path -func StartLocalRepo(path, address string) error { - if address == "" { - address = "127.0.0.1:8879" - } - s := &RepositoryServer{RepoPath: path} - return http.ListenAndServe(address, s) -} - -func (s *RepositoryServer) htmlIndex(w http.ResponseWriter, r *http.Request) { - t := htemplate.Must(htemplate.New("index.html").Parse(indexHTMLTemplate)) - // load index - lrp := filepath.Join(s.RepoPath, "index.yaml") - i, err := LoadIndexFile(lrp) - if err != nil { - http.Error(w, err.Error(), 500) - return - } - data := map[string]interface{}{ - "Index": i, - } - if err := t.Execute(w, data); err != nil { - fmt.Fprintf(w, "Template error: %s", err) - } -} - -// AddChartToLocalRepo saves a chart in the given path and then reindexes the index file -func AddChartToLocalRepo(ch *chart.Chart, path string) error { - _, err := chartutil.Save(ch, path) - if err != nil { - return err - } - return Reindex(ch, path+"/index.yaml") -} - -// Reindex adds an entry to the index file at the given path -func Reindex(ch *chart.Chart, path string) error { - name := ch.Metadata.Name + "-" + ch.Metadata.Version - y, err := LoadIndexFile(path) - if err != nil { - return err - } - found := false - for k := range y.Entries { - if k == name { - found = true - break - } - } - if !found { - dig, err := provenance.DigestFile(path) - if err != nil { - return err - } - - y.Add(ch.Metadata, name+".tgz", "http://127.0.0.1:8879/charts", "sha256:"+dig) - - out, err := yaml.Marshal(y) - if err != nil { - return err - } - - ioutil.WriteFile(path, out, 0644) - } - return nil -} diff --git a/pkg/repo/local_test.go b/pkg/repo/local_test.go deleted file mode 100644 index 1e5359dee..000000000 --- a/pkg/repo/local_test.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package repo - -import ( - "io/ioutil" - "net/http" - "strings" - "testing" -) - -func TestRepositoryServer(t *testing.T) { - expectedIndexYAML, err := ioutil.ReadFile("testdata/server/index.yaml") - if err != nil { - t.Fatal(err) - } - - tests := []struct { - name string - path string - expect string - }{ - {"index YAML", "/charts/index.yaml", string(expectedIndexYAML)}, - {"index HTML", "/charts/index.html", ""}, - {"charts root", "/charts/", ""}, - {"root", "/", ""}, - {"file", "/test.txt", "Hello World"}, - } - - s := &RepositoryServer{RepoPath: "testdata/server"} - srv, err := startLocalServerForTests(s) - if err != nil { - t.Fatal(err) - } - defer srv.Close() - - for _, tt := range tests { - res, err := http.Get(srv.URL + tt.path) - if err != nil { - t.Errorf("%s: error getting %s: %s", tt.name, tt.path, err) - continue - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Errorf("%s: error reading %s: %s", tt.name, tt.path, err) - } - res.Body.Close() - if !strings.Contains(string(body), tt.expect) { - t.Errorf("%s: expected to find %q in %q", tt.name, tt.expect, string(body)) - } - } - -} diff --git a/pkg/repo/repo_test.go b/pkg/repo/repo_test.go index 4b5bcdbf5..97f49775c 100644 --- a/pkg/repo/repo_test.go +++ b/pkg/repo/repo_test.go @@ -202,7 +202,7 @@ func TestWriteFile(t *testing.T) { t.Errorf("failed to create test-file (%v)", err) } defer os.Remove(repoFile.Name()) - if err := sampleRepository.WriteFile(repoFile.Name(), 744); err != nil { + if err := sampleRepository.WriteFile(repoFile.Name(), 0744); err != nil { t.Errorf("failed to write file (%v)", err) } diff --git a/pkg/tiller/release_server.go b/pkg/tiller/release_server.go index 33366d572..b48759718 100644 --- a/pkg/tiller/release_server.go +++ b/pkg/tiller/release_server.go @@ -66,9 +66,6 @@ var ( errInvalidName = errors.New("invalid release name, must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ and the length must not longer than 53") ) -// ListDefaultLimit is the default limit for number of items returned in a list. -var ListDefaultLimit int64 = 512 - // ValidName is a regular expression for names. // // According to the Kubernetes help text, the regular expression it uses is: