diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..dfd36699e --- /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 + - 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..c8f0365ec 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_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..3d5d6bea6 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) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 12920a39b..66be142ef 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -57,7 +57,6 @@ func init() { func TestMain(m *testing.M) { os.Unsetenv("HELM_HOME") - exitCode := m.Run() os.RemoveAll(testingDir) os.Exit(exitCode) 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..7ec03103c --- /dev/null +++ b/cmd/helm/testdata/output/dependency-list-no-requirements-windows.txt @@ -0,0 +1 @@ +WARNING: no requirements at testdata\testcharts\alpine\charts 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/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)