fix appveyor builds (#4934)

Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
pull/5248/head
Matthew Fisher 6 years ago committed by GitHub
parent bb265b52bb
commit 95c865513f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 .\...

@ -86,7 +86,7 @@ func TestCreateStarterCmd(t *testing.T) {
defer testChdir(t, tdir)() defer testChdir(t, tdir)()
// Run a create // 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) t.Errorf("Failed to run create: %s", err)
return return
} }

@ -135,7 +135,7 @@ func (o *dependencyLisOptions) run(out io.Writer) error {
} }
if c.Metadata.Dependencies == nil { 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 return nil
} }

@ -43,7 +43,7 @@ func TestDependencyBuildCmd(t *testing.T) {
t.Fatal(err) 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) out, err := executeCommand(nil, cmd)
// In the first pass, we basically want the same results as an update. // In the first pass, we basically want the same results as an update.

@ -16,27 +16,38 @@ limitations under the License.
package main package main
import ( import (
"runtime"
"testing" "testing"
) )
func TestDependencyListCmd(t *testing.T) { func TestDependencyListCmd(t *testing.T) {
tests := []cmdTestCase{{ noSuchChart := cmdTestCase{
name: "No such chart", name: "No such chart",
cmd: "dependency list /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, wantError: true,
}, { }
noDependencies := cmdTestCase{
name: "No dependencies", name: "No dependencies",
cmd: "dependency list testdata/testcharts/alpine", cmd: "dependency list testdata/testcharts/alpine",
golden: "output/dependency-list-no-requirements.txt", golden: "output/dependency-list-no-requirements-linux.txt",
}, { }
name: "Dependencies in chart dir",
cmd: "dependency list testdata/testcharts/reqtest", if runtime.GOOS == "windows" {
golden: "output/dependency-list.txt", noSuchChart.golden = "output/dependency-list-no-chart-windows.txt"
}, { noDependencies.golden = "output/dependency-list-no-requirements-windows.txt"
name: "Dependencies in chart archive", }
cmd: "dependency list testdata/testcharts/reqtest-0.1.0.tgz",
golden: "output/dependency-list-archive.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) runTestCmd(t, tests)
} }

@ -52,7 +52,7 @@ func TestDependencyUpdateCmd(t *testing.T) {
t.Fatal(err) 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 { if err != nil {
t.Logf("Output: %s", out) t.Logf("Output: %s", out)
t.Fatal(err) t.Fatal(err)
@ -95,7 +95,7 @@ func TestDependencyUpdateCmd(t *testing.T) {
t.Fatal(err) 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 { if err != nil {
t.Logf("Output: %s", out) t.Logf("Output: %s", out)
t.Fatal(err) t.Fatal(err)
@ -133,7 +133,7 @@ func TestDependencyUpdateCmd_SkipRefresh(t *testing.T) {
t.Fatal(err) 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 { if err == nil {
t.Fatal("Expected failure to find the repo with skipRefresh") t.Fatal("Expected failure to find the repo with skipRefresh")
} }

@ -40,32 +40,21 @@ import (
"k8s.io/helm/pkg/storage/driver" "k8s.io/helm/pkg/storage/driver"
) )
// base temp directory
var testingDir string
func testTimestamper() time.Time { return time.Unix(242085845, 0).UTC() } func testTimestamper() time.Time { return time.Unix(242085845, 0).UTC() }
func init() { func init() {
var err error
testingDir, err = ioutil.TempDir(testingDir, "helm")
if err != nil {
panic(err)
}
action.Timestamper = testTimestamper action.Timestamper = testTimestamper
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
os.Unsetenv("HELM_HOME") os.Unsetenv("HELM_HOME")
exitCode := m.Run() exitCode := m.Run()
os.RemoveAll(testingDir)
os.Exit(exitCode) os.Exit(exitCode)
} }
func testTempDir(t *testing.T) string { func testTempDir(t *testing.T) string {
t.Helper() t.Helper()
d, err := ioutil.TempDir(testingDir, "helm") d, err := ioutil.TempDir("", "helm")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -46,7 +46,7 @@ func TestInstall(t *testing.T) {
// Install, values from yaml // Install, values from yaml
{ {
name: "install with values file", 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", golden: "output/install-with-values-file.txt",
}, },
// Install, no hooks // Install, no hooks

@ -17,10 +17,12 @@ package main
import ( import (
"bytes" "bytes"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime"
"strings" "strings"
"testing" "testing"
@ -54,6 +56,13 @@ func TestSetVersion(t *testing.T) {
} }
func TestPackage(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()() defer resetEnv()()
tests := []struct { tests := []struct {
@ -115,7 +124,7 @@ func TestPackage(t *testing.T) {
name: "package --destination does-not-exist", name: "package --destination does-not-exist",
args: []string{"testdata/testcharts/alpine"}, args: []string{"testdata/testcharts/alpine"},
flags: map[string]string{"destination": "does-not-exist"}, 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, err: true,
}, },
{ {
@ -135,7 +144,7 @@ func TestPackage(t *testing.T) {
name: "package --values does-not-exist", name: "package --values does-not-exist",
args: []string{"testdata/testcharts/alpine"}, args: []string{"testdata/testcharts/alpine"},
flags: map[string]string{"values": "does-not-exist"}, 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, err: true,
}, },
} }

@ -129,7 +129,7 @@ func TestPullCmd(t *testing.T) {
os.RemoveAll(outdir) os.RemoveAll(outdir)
os.Mkdir(outdir, 0755) 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) out, err := executeCommand(nil, "fetch "+cmd)
if err != nil { if err != nil {
if tt.wantError { if tt.wantError {

@ -42,7 +42,7 @@ func TestRepoAddCmd(t *testing.T) {
tests := []cmdTestCase{{ tests := []cmdTestCase{{
name: "add a repository", 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", golden: "output/repo-add.txt",
}} }}

@ -20,6 +20,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
"k8s.io/client-go/util/homedir"
) )
func TestRootCmd(t *testing.T) { func TestRootCmd(t *testing.T) {
@ -32,7 +34,7 @@ func TestRootCmd(t *testing.T) {
{ {
name: "defaults", name: "defaults",
args: "home", args: "home",
home: filepath.Join(os.Getenv("HOME"), "/.helm"), home: filepath.Join(homedir.HomeDir(), ".helm"),
}, },
{ {
name: "with --home set", name: "with --home set",

@ -208,7 +208,8 @@ func (o *templateOptions) run(out io.Writer) error {
} }
in := func(needle string, haystack []string) bool { in := func(needle string, haystack []string) bool {
// make needle path absolute // 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:] dd := d[1:]
an := filepath.Join(o.chartPath, strings.Join(dd, string(os.PathSeparator))) an := filepath.Join(o.chartPath, strings.Join(dd, string(os.PathSeparator)))

@ -17,6 +17,7 @@ limitations under the License.
package main package main
import ( import (
"fmt"
"path/filepath" "path/filepath"
"testing" "testing"
) )
@ -31,42 +32,42 @@ func TestTemplateCmd(t *testing.T) {
tests := []cmdTestCase{ tests := []cmdTestCase{
{ {
name: "check name", name: "check name",
cmd: "template " + chartPath, cmd: fmt.Sprintf("template '%s'", chartPath),
golden: "output/template.txt", golden: "output/template.txt",
}, },
{ {
name: "check set name", 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", golden: "output/template-set.txt",
}, },
{ {
name: "check execute absolute", 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", golden: "output/template-absolute.txt",
}, },
{ {
name: "check release name", name: "check release name",
cmd: "template --name test " + chartPath, cmd: fmt.Sprintf("template '%s' --name test", chartPath),
golden: "output/template-name.txt", golden: "output/template-name.txt",
}, },
{ {
name: "check notes", name: "check notes",
cmd: "template --notes " + chartPath, cmd: fmt.Sprintf("template '%s' --notes", chartPath),
golden: "output/template-notes.txt", golden: "output/template-notes.txt",
}, },
{ {
name: "check values files", 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", golden: "output/template-values-files.txt",
}, },
{ {
name: "check name template", 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", golden: "output/template-name-template.txt",
}, },
{ {
name: "check kube version", 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", golden: "output/template-kube-version.txt",
}, },
{ {

@ -0,0 +1 @@
Error: FindFirstFile \no\such\chart: The system cannot find the path specified.

@ -0,0 +1 @@
WARNING: no dependencies at testdata\testcharts\alpine\charts

@ -17,6 +17,7 @@ limitations under the License.
package main package main
import ( import (
"fmt"
"testing" "testing"
"k8s.io/helm/pkg/chart" "k8s.io/helm/pkg/chart"
@ -89,55 +90,55 @@ func TestUpgradeCmd(t *testing.T) {
tests := []cmdTestCase{ tests := []cmdTestCase{
{ {
name: "upgrade a release", name: "upgrade a release",
cmd: "upgrade funny-bunny " + chartPath, cmd: fmt.Sprintf("upgrade funny-bunny '%s'", chartPath),
golden: "output/upgrade.txt", golden: "output/upgrade.txt",
rels: []*release.Release{relMock("funny-bunny", 2, ch)}, rels: []*release.Release{relMock("funny-bunny", 2, ch)},
}, },
{ {
name: "upgrade a release with timeout", 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", golden: "output/upgrade-with-timeout.txt",
rels: []*release.Release{relMock("funny-bunny", 3, ch2)}, rels: []*release.Release{relMock("funny-bunny", 3, ch2)},
}, },
{ {
name: "upgrade a release with --reset-values", 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", golden: "output/upgrade-with-reset-values.txt",
rels: []*release.Release{relMock("funny-bunny", 4, ch2)}, rels: []*release.Release{relMock("funny-bunny", 4, ch2)},
}, },
{ {
name: "upgrade a release with --reuse-values", 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", golden: "output/upgrade-with-reset-values2.txt",
rels: []*release.Release{relMock("funny-bunny", 5, ch2)}, rels: []*release.Release{relMock("funny-bunny", 5, ch2)},
}, },
{ {
name: "install a release with 'upgrade --install'", 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", golden: "output/upgrade-with-install.txt",
rels: []*release.Release{relMock("zany-bunny", 1, ch)}, rels: []*release.Release{relMock("zany-bunny", 1, ch)},
}, },
{ {
name: "install a release with 'upgrade --install' and timeout", 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", golden: "output/upgrade-with-install-timeout.txt",
rels: []*release.Release{relMock("crazy-bunny", 1, ch)}, rels: []*release.Release{relMock("crazy-bunny", 1, ch)},
}, },
{ {
name: "upgrade a release with wait", 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", golden: "output/upgrade-with-wait.txt",
rels: []*release.Release{relMock("crazy-bunny", 2, ch2)}, rels: []*release.Release{relMock("crazy-bunny", 2, ch2)},
}, },
{ {
name: "upgrade a release with missing dependencies", 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", golden: "output/upgrade-with-missing-dependencies.txt",
wantError: true, wantError: true,
}, },
{ {
name: "upgrade a release with bad dependencies", 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", golden: "output/upgrade-with-bad-dependencies.txt",
wantError: true, wantError: true,
}, },

@ -27,7 +27,7 @@ func TestVerifyCmd(t *testing.T) {
statPathMsg := "no such file or directory" statPathMsg := "no such file or directory"
statFileMsg := statPathMsg statFileMsg := statPathMsg
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
statExe = "GetFileAttributesEx" statExe = "FindFirstFile"
statPathMsg = "The system cannot find the path specified." statPathMsg = "The system cannot find the path specified."
statFileMsg = "The system cannot find the file specified." statFileMsg = "The system cannot find the file specified."
} }

@ -15,6 +15,8 @@ limitations under the License.
package chartutil package chartutil
import ( import (
"os"
"path/filepath"
"sort" "sort"
"strconv" "strconv"
"testing" "testing"
@ -315,7 +317,12 @@ func TestDependentChartWithSubChartsHelmignore(t *testing.T) {
} }
func TestDependentChartsWithSubChartsSymlink(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" { if c.Name() != "joonix" {
t.Fatalf("unexpected chart name: %s", c.Name()) t.Fatalf("unexpected chart name: %s", c.Name())

@ -18,6 +18,7 @@ package getter
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"testing" "testing"
@ -67,6 +68,10 @@ func TestCollectPlugins(t *testing.T) {
} }
func TestPluginGetter(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") oldhh := os.Getenv("HELM_HOME")
defer os.Setenv("HELM_HOME", oldhh) defer os.Setenv("HELM_HOME", oldhh)
os.Setenv("HELM_HOME", "") os.Setenv("HELM_HOME", "")

@ -22,7 +22,7 @@ import (
) )
func TestHelmHome(t *testing.T) { func TestHelmHome(t *testing.T) {
hh := Home("/r") hh := Home("/r/users/helmtest")
isEq := func(t *testing.T, a, b string) { isEq := func(t *testing.T, a, b string) {
if a != b { if a != b {
t.Error(runtime.GOOS) t.Error(runtime.GOOS)
@ -30,13 +30,13 @@ func TestHelmHome(t *testing.T) {
} }
} }
isEq(t, hh.String(), "/r") isEq(t, hh.String(), "/r/users/helmtest")
isEq(t, hh.Repository(), "/r/repository") isEq(t, hh.Repository(), "/r/users/helmtest/repository")
isEq(t, hh.RepositoryFile(), "/r/repository/repositories.yaml") isEq(t, hh.RepositoryFile(), "/r/users/helmtest/repository/repositories.yaml")
isEq(t, hh.Cache(), "/r/repository/cache") isEq(t, hh.Cache(), "/r/users/helmtest/repository/cache")
isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml") isEq(t, hh.CacheIndex("t"), "/r/users/helmtest/repository/cache/t-index.yaml")
isEq(t, hh.Starters(), "/r/starters") isEq(t, hh.Starters(), "/r/users/helmtest/starters")
isEq(t, hh.Archive(), "/r/cache/archive") isEq(t, hh.Archive(), "/r/users/helmtest/cache/archive")
} }
func TestHelmHome_expand(t *testing.T) { func TestHelmHome_expand(t *testing.T) {

@ -20,18 +20,18 @@ import (
) )
func TestHelmHome(t *testing.T) { func TestHelmHome(t *testing.T) {
hh := Home("r:\\") hh := Home("r:\\users\\helmtest")
isEq := func(t *testing.T, a, b string) { isEq := func(t *testing.T, a, b string) {
if a != b { if a != b {
t.Errorf("Expected %q, got %q", b, a) t.Errorf("Expected %q, got %q", b, a)
} }
} }
isEq(t, hh.String(), "r:\\") isEq(t, hh.String(), "r:\\users\\helmtest")
isEq(t, hh.Repository(), "r:\\repository") isEq(t, hh.Repository(), "r:\\users\\helmtest\\repository")
isEq(t, hh.RepositoryFile(), "r:\\repository\\repositories.yaml") isEq(t, hh.RepositoryFile(), "r:\\users\\helmtest\\repository\\repositories.yaml")
isEq(t, hh.Cache(), "r:\\repository\\cache") isEq(t, hh.Cache(), "r:\\users\\helmtest\\repository\\cache")
isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml") isEq(t, hh.CacheIndex("t"), "r:\\users\\helmtest\\repository\\cache\\t-index.yaml")
isEq(t, hh.Starters(), "r:\\starters") isEq(t, hh.Starters(), "r:\\users\\helmtest\\starters")
isEq(t, hh.Archive(), "r:\\cache\\archive") isEq(t, hh.Archive(), "r:\\users\\helmtest\\cache\\archive")
} }

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path"
"path/filepath" "path/filepath"
"sort" "sort"
"strings" "strings"
@ -110,7 +111,7 @@ func (i IndexFile) Add(md *chart.Metadata, filename, baseURL, digest string) {
_, file := filepath.Split(filename) _, file := filepath.Split(filename)
u, err = urlutil.URLJoin(baseURL, file) u, err = urlutil.URLJoin(baseURL, file)
if err != nil { if err != nil {
u = filepath.Join(baseURL, file) u = path.Join(baseURL, file)
} }
} }
cr := &ChartVersion{ cr := &ChartVersion{
@ -246,9 +247,11 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) {
var parentDir string var parentDir string
parentDir, fname = filepath.Split(fname) 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) parentURL, err := urlutil.URLJoin(baseURL, parentDir)
if err != nil { if err != nil {
parentURL = filepath.Join(baseURL, parentDir) parentURL = path.Join(baseURL, parentDir)
} }
c, err := loader.Load(arch) c, err := loader.Load(arch)

Loading…
Cancel
Save