diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..5be7628a4 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,18 @@ +version: "{build}" +clone_folder: c:\go\src\k8s.io\helm +environment: + GOPATH: c:\go + PATH: c:\ProgramData\bin;$(PATH) +install: + - ps: iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/fishworks/gofish/master/scripts/install.ps1')) + - gofish init + - gofish install dep + - go version + - dep ensure -vendor-only +cache: + - vendor -> Gopkg.lock +build: "off" +deploy: "off" +test_script: + - go build .\cmd\... + - go test .\... diff --git a/cmd/helm/create_test.go b/cmd/helm/create_test.go index 7f23c1f6e..8e1ce8386 100644 --- a/cmd/helm/create_test.go +++ b/cmd/helm/create_test.go @@ -86,7 +86,7 @@ func TestCreateStarterCmd(t *testing.T) { defer testChdir(t, tdir)() // Run a create - if _, err := executeCommand(nil, fmt.Sprintf("--home=%s create --starter=starterchart %s", hh, cname)); err != nil { + if _, err := executeCommand(nil, fmt.Sprintf("--home='%s' create --starter=starterchart %s", hh.String(), cname)); err != nil { t.Errorf("Failed to run create: %s", err) return } diff --git a/cmd/helm/dependency.go b/cmd/helm/dependency.go index 2fd639d7d..f28e8eff0 100644 --- a/cmd/helm/dependency.go +++ b/cmd/helm/dependency.go @@ -135,7 +135,7 @@ func (o *dependencyLisOptions) run(out io.Writer) error { } if c.Metadata.Dependencies == nil { - fmt.Fprintf(out, "WARNING: no dependencies at %s/charts\n", o.chartpath) + fmt.Fprintf(out, "WARNING: no dependencies at %s\n", filepath.Join(o.chartpath, "charts")) return nil } diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go index 5c2f004fb..64e32a4b3 100644 --- a/cmd/helm/dependency_build_test.go +++ b/cmd/helm/dependency_build_test.go @@ -43,7 +43,7 @@ func TestDependencyBuildCmd(t *testing.T) { t.Fatal(err) } - cmd := fmt.Sprintf("--home=%s dependency build %s", hh, hh.Path(chartname)) + cmd := fmt.Sprintf("--home='%s' dependency build '%s'", hh, hh.Path(chartname)) out, err := executeCommand(nil, cmd) // In the first pass, we basically want the same results as an update. diff --git a/cmd/helm/dependency_test.go b/cmd/helm/dependency_test.go index 709741b7a..80b357a77 100644 --- a/cmd/helm/dependency_test.go +++ b/cmd/helm/dependency_test.go @@ -16,27 +16,38 @@ limitations under the License. package main import ( + "runtime" "testing" ) func TestDependencyListCmd(t *testing.T) { - tests := []cmdTestCase{{ + noSuchChart := cmdTestCase{ name: "No such chart", cmd: "dependency list /no/such/chart", - golden: "output/dependency-list-no-chart.txt", + golden: "output/dependency-list-no-chart-linux.txt", wantError: true, - }, { + } + + noDependencies := cmdTestCase{ name: "No dependencies", cmd: "dependency list testdata/testcharts/alpine", - golden: "output/dependency-list-no-requirements.txt", - }, { - name: "Dependencies in chart dir", - cmd: "dependency list testdata/testcharts/reqtest", - golden: "output/dependency-list.txt", - }, { - name: "Dependencies in chart archive", - cmd: "dependency list testdata/testcharts/reqtest-0.1.0.tgz", - golden: "output/dependency-list-archive.txt", - }} + golden: "output/dependency-list-no-requirements-linux.txt", + } + + if runtime.GOOS == "windows" { + noSuchChart.golden = "output/dependency-list-no-chart-windows.txt" + noDependencies.golden = "output/dependency-list-no-requirements-windows.txt" + } + + tests := []cmdTestCase{noSuchChart, + noDependencies, { + name: "Dependencies in chart dir", + cmd: "dependency list testdata/testcharts/reqtest", + golden: "output/dependency-list.txt", + }, { + name: "Dependencies in chart archive", + cmd: "dependency list testdata/testcharts/reqtest-0.1.0.tgz", + golden: "output/dependency-list-archive.txt", + }} runTestCmd(t, tests) } diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 5a9d80585..fba560ee8 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -52,7 +52,7 @@ func TestDependencyUpdateCmd(t *testing.T) { t.Fatal(err) } - out, err := executeCommand(nil, fmt.Sprintf("--home=%s dependency update %s", hh, hh.Path(chartname))) + out, err := executeCommand(nil, fmt.Sprintf("--home='%s' dependency update '%s'", hh.String(), hh.Path(chartname))) if err != nil { t.Logf("Output: %s", out) t.Fatal(err) @@ -95,7 +95,7 @@ func TestDependencyUpdateCmd(t *testing.T) { t.Fatal(err) } - out, err = executeCommand(nil, fmt.Sprintf("--home=%s dependency update %s", hh, hh.Path(chartname))) + out, err = executeCommand(nil, fmt.Sprintf("--home='%s' dependency update '%s'", hh, hh.Path(chartname))) if err != nil { t.Logf("Output: %s", out) t.Fatal(err) @@ -133,7 +133,7 @@ func TestDependencyUpdateCmd_SkipRefresh(t *testing.T) { t.Fatal(err) } - out, err := executeCommand(nil, fmt.Sprintf("--home=%s dependency update --skip-refresh %s", hh, hh.Path(chartname))) + out, err := executeCommand(nil, fmt.Sprintf("--home='%s' dependency update --skip-refresh %s", hh, hh.Path(chartname))) if err == nil { t.Fatal("Expected failure to find the repo with skipRefresh") } diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 12920a39b..6d2d63fc9 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -40,32 +40,21 @@ import ( "k8s.io/helm/pkg/storage/driver" ) -// base temp directory -var testingDir string - func testTimestamper() time.Time { return time.Unix(242085845, 0).UTC() } func init() { - var err error - testingDir, err = ioutil.TempDir(testingDir, "helm") - if err != nil { - panic(err) - } - action.Timestamper = testTimestamper } func TestMain(m *testing.M) { os.Unsetenv("HELM_HOME") - exitCode := m.Run() - os.RemoveAll(testingDir) os.Exit(exitCode) } func testTempDir(t *testing.T) string { t.Helper() - d, err := ioutil.TempDir(testingDir, "helm") + d, err := ioutil.TempDir("", "helm") if err != nil { t.Fatal(err) } diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index 69635aa4d..9606a4d00 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -46,7 +46,7 @@ func TestInstall(t *testing.T) { // Install, values from yaml { name: "install with values file", - cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml", + cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml", golden: "output/install-with-values-file.txt", }, // Install, no hooks diff --git a/cmd/helm/package_test.go b/cmd/helm/package_test.go index fb032bc4b..f6a35ac77 100644 --- a/cmd/helm/package_test.go +++ b/cmd/helm/package_test.go @@ -17,10 +17,12 @@ package main import ( "bytes" + "fmt" "io/ioutil" "os" "path/filepath" "regexp" + "runtime" "strings" "testing" @@ -54,6 +56,13 @@ func TestSetVersion(t *testing.T) { } func TestPackage(t *testing.T) { + statExe := "stat" + statFileMsg := "no such file or directory" + if runtime.GOOS == "windows" { + statExe = "FindFirstFile" + statFileMsg = "The system cannot find the file specified." + } + defer resetEnv()() tests := []struct { @@ -115,7 +124,7 @@ func TestPackage(t *testing.T) { name: "package --destination does-not-exist", args: []string{"testdata/testcharts/alpine"}, flags: map[string]string{"destination": "does-not-exist"}, - expect: "stat does-not-exist: no such file or directory", + expect: fmt.Sprintf("failed to save: %s does-not-exist: %s", statExe, statFileMsg), err: true, }, { @@ -135,7 +144,7 @@ func TestPackage(t *testing.T) { name: "package --values does-not-exist", args: []string{"testdata/testcharts/alpine"}, flags: map[string]string{"values": "does-not-exist"}, - expect: "does-not-exist: no such file or directory", + expect: fmt.Sprintf("does-not-exist: %s", statFileMsg), err: true, }, } diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go index cd09b26cb..f837df627 100644 --- a/cmd/helm/pull_test.go +++ b/cmd/helm/pull_test.go @@ -129,7 +129,7 @@ func TestPullCmd(t *testing.T) { os.RemoveAll(outdir) os.Mkdir(outdir, 0755) - cmd := strings.Join(append(tt.args, "-d", outdir, "--home", hh.String()), " ") + cmd := strings.Join(append(tt.args, "-d", "'"+outdir+"'", "--home", "'"+hh.String()+"'"), " ") out, err := executeCommand(nil, "fetch "+cmd) if err != nil { if tt.wantError { diff --git a/cmd/helm/repo_add_test.go b/cmd/helm/repo_add_test.go index 9de2be773..be320bc7c 100644 --- a/cmd/helm/repo_add_test.go +++ b/cmd/helm/repo_add_test.go @@ -42,7 +42,7 @@ func TestRepoAddCmd(t *testing.T) { tests := []cmdTestCase{{ name: "add a repository", - cmd: fmt.Sprintf("repo add test-name %s --home %s", srv.URL(), hh), + cmd: fmt.Sprintf("repo add test-name %s --home '%s'", srv.URL(), hh), golden: "output/repo-add.txt", }} diff --git a/cmd/helm/root_test.go b/cmd/helm/root_test.go index bd41b6ab6..163b24bb6 100644 --- a/cmd/helm/root_test.go +++ b/cmd/helm/root_test.go @@ -20,6 +20,8 @@ import ( "os" "path/filepath" "testing" + + "k8s.io/client-go/util/homedir" ) func TestRootCmd(t *testing.T) { @@ -32,7 +34,7 @@ func TestRootCmd(t *testing.T) { { name: "defaults", args: "home", - home: filepath.Join(os.Getenv("HOME"), "/.helm"), + home: filepath.Join(homedir.HomeDir(), ".helm"), }, { name: "with --home set", diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 44285cb1a..20e556401 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -208,7 +208,8 @@ func (o *templateOptions) run(out io.Writer) error { } in := func(needle string, haystack []string) bool { // make needle path absolute - d := strings.Split(needle, string(os.PathSeparator)) + // NOTE: chart manifest names always use backslashes as path separators, even on Windows + d := strings.Split(needle, "/") dd := d[1:] an := filepath.Join(o.chartPath, strings.Join(dd, string(os.PathSeparator))) diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 417030d1c..6dcc71fa3 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "fmt" "path/filepath" "testing" ) @@ -31,42 +32,42 @@ func TestTemplateCmd(t *testing.T) { tests := []cmdTestCase{ { name: "check name", - cmd: "template " + chartPath, + cmd: fmt.Sprintf("template '%s'", chartPath), golden: "output/template.txt", }, { name: "check set name", - cmd: "template -x templates/service.yaml --set service.name=apache " + chartPath, + cmd: fmt.Sprintf("template '%s' -x '%s' --set service.name=apache", chartPath, filepath.Join("templates", "service.yaml")), golden: "output/template-set.txt", }, { name: "check execute absolute", - cmd: "template -x " + absChartPath + "/templates/service.yaml --set service.name=apache " + chartPath, + cmd: fmt.Sprintf("template '%s' -x '%s' --set service.name=apache", chartPath, filepath.Join(absChartPath, "templates", "service.yaml")), golden: "output/template-absolute.txt", }, { name: "check release name", - cmd: "template --name test " + chartPath, + cmd: fmt.Sprintf("template '%s' --name test", chartPath), golden: "output/template-name.txt", }, { name: "check notes", - cmd: "template --notes " + chartPath, + cmd: fmt.Sprintf("template '%s' --notes", chartPath), golden: "output/template-notes.txt", }, { name: "check values files", - cmd: "template --values " + chartPath + "/charts/subchartA/values.yaml " + chartPath, + cmd: fmt.Sprintf("template '%s' --values '%s'", chartPath, filepath.Join(chartPath, "/charts/subchartA/values.yaml")), golden: "output/template-values-files.txt", }, { name: "check name template", - cmd: `template --name-template='foobar-{{ b64enc "abc" }}-baz' ` + chartPath, + cmd: fmt.Sprintf(`template '%s' --name-template='foobar-{{ b64enc "abc" }}-baz'`, chartPath), golden: "output/template-name-template.txt", }, { name: "check kube version", - cmd: "template --kube-version 1.6 " + chartPath, + cmd: fmt.Sprintf("template '%s' --kube-version 1.6", chartPath), golden: "output/template-kube-version.txt", }, { diff --git a/cmd/helm/testdata/output/dependency-list-no-chart.txt b/cmd/helm/testdata/output/dependency-list-no-chart-linux.txt similarity index 100% rename from cmd/helm/testdata/output/dependency-list-no-chart.txt rename to cmd/helm/testdata/output/dependency-list-no-chart-linux.txt diff --git a/cmd/helm/testdata/output/dependency-list-no-chart-windows.txt b/cmd/helm/testdata/output/dependency-list-no-chart-windows.txt new file mode 100644 index 000000000..8127e347d --- /dev/null +++ b/cmd/helm/testdata/output/dependency-list-no-chart-windows.txt @@ -0,0 +1 @@ +Error: FindFirstFile \no\such\chart: The system cannot find the path specified. diff --git a/cmd/helm/testdata/output/dependency-list-no-requirements.txt b/cmd/helm/testdata/output/dependency-list-no-requirements-linux.txt similarity index 100% rename from cmd/helm/testdata/output/dependency-list-no-requirements.txt rename to cmd/helm/testdata/output/dependency-list-no-requirements-linux.txt diff --git a/cmd/helm/testdata/output/dependency-list-no-requirements-windows.txt b/cmd/helm/testdata/output/dependency-list-no-requirements-windows.txt new file mode 100644 index 000000000..c1ba49d24 --- /dev/null +++ b/cmd/helm/testdata/output/dependency-list-no-requirements-windows.txt @@ -0,0 +1 @@ +WARNING: no dependencies at testdata\testcharts\alpine\charts diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go index 15b4067c8..c45f77026 100644 --- a/cmd/helm/upgrade_test.go +++ b/cmd/helm/upgrade_test.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "fmt" "testing" "k8s.io/helm/pkg/chart" @@ -89,55 +90,55 @@ func TestUpgradeCmd(t *testing.T) { tests := []cmdTestCase{ { name: "upgrade a release", - cmd: "upgrade funny-bunny " + chartPath, + cmd: fmt.Sprintf("upgrade funny-bunny '%s'", chartPath), golden: "output/upgrade.txt", rels: []*release.Release{relMock("funny-bunny", 2, ch)}, }, { name: "upgrade a release with timeout", - cmd: "upgrade funny-bunny --timeout 120 " + chartPath, + cmd: fmt.Sprintf("upgrade funny-bunny --timeout 120 '%s'", chartPath), golden: "output/upgrade-with-timeout.txt", rels: []*release.Release{relMock("funny-bunny", 3, ch2)}, }, { name: "upgrade a release with --reset-values", - cmd: "upgrade funny-bunny --reset-values " + chartPath, + cmd: fmt.Sprintf("upgrade funny-bunny --reset-values '%s'", chartPath), golden: "output/upgrade-with-reset-values.txt", rels: []*release.Release{relMock("funny-bunny", 4, ch2)}, }, { name: "upgrade a release with --reuse-values", - cmd: "upgrade funny-bunny --reuse-values " + chartPath, + cmd: fmt.Sprintf("upgrade funny-bunny --reuse-values '%s'", chartPath), golden: "output/upgrade-with-reset-values2.txt", rels: []*release.Release{relMock("funny-bunny", 5, ch2)}, }, { name: "install a release with 'upgrade --install'", - cmd: "upgrade zany-bunny -i " + chartPath, + cmd: fmt.Sprintf("upgrade zany-bunny -i '%s'", chartPath), golden: "output/upgrade-with-install.txt", rels: []*release.Release{relMock("zany-bunny", 1, ch)}, }, { name: "install a release with 'upgrade --install' and timeout", - cmd: "upgrade crazy-bunny -i --timeout 120 " + chartPath, + cmd: fmt.Sprintf("upgrade crazy-bunny -i --timeout 120 '%s'", chartPath), golden: "output/upgrade-with-install-timeout.txt", rels: []*release.Release{relMock("crazy-bunny", 1, ch)}, }, { name: "upgrade a release with wait", - cmd: "upgrade crazy-bunny --wait " + chartPath, + cmd: fmt.Sprintf("upgrade crazy-bunny --wait '%s'", chartPath), golden: "output/upgrade-with-wait.txt", rels: []*release.Release{relMock("crazy-bunny", 2, ch2)}, }, { name: "upgrade a release with missing dependencies", - cmd: "upgrade bonkers-bunny" + missingDepsPath, + cmd: fmt.Sprintf("upgrade bonkers-bunny%s", missingDepsPath), golden: "output/upgrade-with-missing-dependencies.txt", wantError: true, }, { name: "upgrade a release with bad dependencies", - cmd: "upgrade bonkers-bunny " + badDepsPath, + cmd: fmt.Sprintf("upgrade bonkers-bunny '%s'", badDepsPath), golden: "output/upgrade-with-bad-dependencies.txt", wantError: true, }, diff --git a/cmd/helm/verify_test.go b/cmd/helm/verify_test.go index f4ddc42f1..4d01c61b9 100644 --- a/cmd/helm/verify_test.go +++ b/cmd/helm/verify_test.go @@ -27,7 +27,7 @@ func TestVerifyCmd(t *testing.T) { statPathMsg := "no such file or directory" statFileMsg := statPathMsg if runtime.GOOS == "windows" { - statExe = "GetFileAttributesEx" + statExe = "FindFirstFile" statPathMsg = "The system cannot find the path specified." statFileMsg = "The system cannot find the file specified." } diff --git a/pkg/chartutil/dependencies_test.go b/pkg/chartutil/dependencies_test.go index 6d54fd3cc..55a3efc78 100644 --- a/pkg/chartutil/dependencies_test.go +++ b/pkg/chartutil/dependencies_test.go @@ -15,6 +15,8 @@ limitations under the License. package chartutil import ( + "os" + "path/filepath" "sort" "strconv" "testing" @@ -315,7 +317,12 @@ func TestDependentChartWithSubChartsHelmignore(t *testing.T) { } func TestDependentChartsWithSubChartsSymlink(t *testing.T) { - c := loadChart(t, "testdata/joonix") + joonix := filepath.Join("testdata", "joonix") + if err := os.Symlink(filepath.Join("..", "..", "frobnitz"), filepath.Join(joonix, "charts", "frobnitz")); err != nil { + t.Fatal(err) + } + defer os.RemoveAll(filepath.Join(joonix, "charts", "frobnitz")) + c := loadChart(t, joonix) if c.Name() != "joonix" { t.Fatalf("unexpected chart name: %s", c.Name()) diff --git a/pkg/chartutil/testdata/joonix/charts/.gitkeep b/pkg/chartutil/testdata/joonix/charts/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/chartutil/testdata/joonix/charts/frobnitz b/pkg/chartutil/testdata/joonix/charts/frobnitz deleted file mode 120000 index fde1b78ac..000000000 --- a/pkg/chartutil/testdata/joonix/charts/frobnitz +++ /dev/null @@ -1 +0,0 @@ -../../frobnitz \ No newline at end of file diff --git a/pkg/getter/plugingetter_test.go b/pkg/getter/plugingetter_test.go index 9bfe6144d..7c0bd6c1e 100644 --- a/pkg/getter/plugingetter_test.go +++ b/pkg/getter/plugingetter_test.go @@ -18,6 +18,7 @@ package getter import ( "os" "path/filepath" + "runtime" "strings" "testing" @@ -67,6 +68,10 @@ func TestCollectPlugins(t *testing.T) { } func TestPluginGetter(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("TODO: refactor this test to work on windows") + } + oldhh := os.Getenv("HELM_HOME") defer os.Setenv("HELM_HOME", oldhh) os.Setenv("HELM_HOME", "") diff --git a/pkg/helm/helmpath/helmhome_unix_test.go b/pkg/helm/helmpath/helmhome_unix_test.go index ff866bfc0..adf620181 100644 --- a/pkg/helm/helmpath/helmhome_unix_test.go +++ b/pkg/helm/helmpath/helmhome_unix_test.go @@ -22,7 +22,7 @@ import ( ) func TestHelmHome(t *testing.T) { - hh := Home("/r") + hh := Home("/r/users/helmtest") isEq := func(t *testing.T, a, b string) { if a != b { t.Error(runtime.GOOS) @@ -30,13 +30,13 @@ 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.Cache(), "/r/repository/cache") - isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml") - isEq(t, hh.Starters(), "/r/starters") - isEq(t, hh.Archive(), "/r/cache/archive") + isEq(t, hh.String(), "/r/users/helmtest") + isEq(t, hh.Repository(), "/r/users/helmtest/repository") + isEq(t, hh.RepositoryFile(), "/r/users/helmtest/repository/repositories.yaml") + isEq(t, hh.Cache(), "/r/users/helmtest/repository/cache") + isEq(t, hh.CacheIndex("t"), "/r/users/helmtest/repository/cache/t-index.yaml") + isEq(t, hh.Starters(), "/r/users/helmtest/starters") + isEq(t, hh.Archive(), "/r/users/helmtest/cache/archive") } func TestHelmHome_expand(t *testing.T) { diff --git a/pkg/helm/helmpath/helmhome_windows_test.go b/pkg/helm/helmpath/helmhome_windows_test.go index b962c6298..9f14909f6 100644 --- a/pkg/helm/helmpath/helmhome_windows_test.go +++ b/pkg/helm/helmpath/helmhome_windows_test.go @@ -20,18 +20,18 @@ import ( ) func TestHelmHome(t *testing.T) { - hh := Home("r:\\") + hh := Home("r:\\users\\helmtest") isEq := func(t *testing.T, a, b string) { if a != b { t.Errorf("Expected %q, got %q", b, a) } } - isEq(t, hh.String(), "r:\\") - isEq(t, hh.Repository(), "r:\\repository") - isEq(t, hh.RepositoryFile(), "r:\\repository\\repositories.yaml") - isEq(t, hh.Cache(), "r:\\repository\\cache") - isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml") - isEq(t, hh.Starters(), "r:\\starters") - isEq(t, hh.Archive(), "r:\\cache\\archive") + isEq(t, hh.String(), "r:\\users\\helmtest") + isEq(t, hh.Repository(), "r:\\users\\helmtest\\repository") + isEq(t, hh.RepositoryFile(), "r:\\users\\helmtest\\repository\\repositories.yaml") + isEq(t, hh.Cache(), "r:\\users\\helmtest\\repository\\cache") + isEq(t, hh.CacheIndex("t"), "r:\\users\\helmtest\\repository\\cache\\t-index.yaml") + isEq(t, hh.Starters(), "r:\\users\\helmtest\\starters") + isEq(t, hh.Archive(), "r:\\users\\helmtest\\cache\\archive") } diff --git a/pkg/repo/index.go b/pkg/repo/index.go index 68a6d75b5..6c577f469 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -21,6 +21,7 @@ import ( "fmt" "io/ioutil" "os" + "path" "path/filepath" "sort" "strings" @@ -110,7 +111,7 @@ func (i IndexFile) Add(md *chart.Metadata, filename, baseURL, digest string) { _, file := filepath.Split(filename) u, err = urlutil.URLJoin(baseURL, file) if err != nil { - u = filepath.Join(baseURL, file) + u = path.Join(baseURL, file) } } cr := &ChartVersion{ @@ -246,9 +247,11 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) { var parentDir string parentDir, fname = filepath.Split(fname) + // filepath.Split appends an extra slash to the end of parentDir. We want to strip that out. + parentDir = strings.TrimSuffix(parentDir, string(os.PathSeparator)) parentURL, err := urlutil.URLJoin(baseURL, parentDir) if err != nil { - parentURL = filepath.Join(baseURL, parentDir) + parentURL = path.Join(baseURL, parentDir) } c, err := loader.Load(arch)