mirror of
https://github.com/helm/helm.git
synced 2026-04-22 23:00:01 -04:00
Merge pull request #1645 from rodcloutier/Windows_archive_backslash_support
fix(helm): added support for compressed charts containing \ in file paths
This commit is contained in:
commit
7f4ea91028
25 changed files with 135 additions and 7 deletions
8
pkg/chartutil/chartfile_test.go
Normal file → Executable file
8
pkg/chartutil/chartfile_test.go
Normal file → Executable file
|
|
@ -30,10 +30,10 @@ func TestLoadChartfile(t *testing.T) {
|
|||
t.Errorf("Failed to open %s: %s", testfile, err)
|
||||
return
|
||||
}
|
||||
verifyChartfile(t, f)
|
||||
verifyChartfile(t, f, "frobnitz")
|
||||
}
|
||||
|
||||
func verifyChartfile(t *testing.T, f *chart.Metadata) {
|
||||
func verifyChartfile(t *testing.T, f *chart.Metadata, name string) {
|
||||
|
||||
if f == nil {
|
||||
t.Fatal("Failed verifyChartfile because f is nil")
|
||||
|
|
@ -44,8 +44,8 @@ func verifyChartfile(t *testing.T, f *chart.Metadata) {
|
|||
t.Errorf("Expected API Version %q, got %q", ApiVersionV1, f.ApiVersion)
|
||||
}
|
||||
|
||||
if f.Name != "frobnitz" {
|
||||
t.Errorf("Expected frobnitz, got %s", f.Name)
|
||||
if f.Name != name {
|
||||
t.Errorf("Expected %s, got %s", name, f.Name)
|
||||
}
|
||||
|
||||
if f.Description != "This is a frobnitz." {
|
||||
|
|
|
|||
|
|
@ -84,8 +84,17 @@ func LoadArchive(in io.Reader) (*chart.Chart, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
parts := strings.Split(hd.Name, "/")
|
||||
n := strings.Join(parts[1:], "/")
|
||||
// Archive could contain \ if generated on Windows
|
||||
delimiter := "/"
|
||||
if strings.ContainsRune(hd.Name, '\\') {
|
||||
delimiter = "\\"
|
||||
}
|
||||
|
||||
parts := strings.Split(hd.Name, delimiter)
|
||||
n := strings.Join(parts[1:], delimiter)
|
||||
|
||||
// Normalize the path to the / delimiter
|
||||
n = strings.Replace(n, delimiter, "/", -1)
|
||||
|
||||
if parts[0] == "Chart.yaml" {
|
||||
return nil, errors.New("chart yaml not in base directory")
|
||||
|
|
|
|||
19
pkg/chartutil/load_test.go
Normal file → Executable file
19
pkg/chartutil/load_test.go
Normal file → Executable file
|
|
@ -42,6 +42,18 @@ func TestLoadFile(t *testing.T) {
|
|||
verifyRequirements(t, c)
|
||||
}
|
||||
|
||||
// Packaging the chart on a Windows machine will produce an
|
||||
// archive that has \\ as delimiters. Test that we support these archives
|
||||
func TestLoadFileBackslash(t *testing.T) {
|
||||
c, err := Load("testdata/frobnitz_backslash-1.2.3.tgz")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to load testdata: %s", err)
|
||||
}
|
||||
verifyChartFileAndTemplate(t, c, "frobnitz_backslash")
|
||||
verifyChart(t, c)
|
||||
verifyRequirements(t, c)
|
||||
}
|
||||
|
||||
func verifyChart(t *testing.T, c *chart.Chart) {
|
||||
if c.Metadata.Name == "" {
|
||||
t.Fatalf("No chart metadata found on %v", c)
|
||||
|
|
@ -142,7 +154,12 @@ func verifyRequirementsLock(t *testing.T, c *chart.Chart) {
|
|||
}
|
||||
|
||||
func verifyFrobnitz(t *testing.T, c *chart.Chart) {
|
||||
verifyChartfile(t, c.Metadata)
|
||||
verifyChartFileAndTemplate(t, c, "frobnitz")
|
||||
}
|
||||
|
||||
func verifyChartFileAndTemplate(t *testing.T, c *chart.Chart, name string) {
|
||||
|
||||
verifyChartfile(t, c.Metadata, name)
|
||||
|
||||
if len(c.Templates) != 1 {
|
||||
t.Fatalf("Expected 1 template, got %d", len(c.Templates))
|
||||
|
|
|
|||
BIN
pkg/chartutil/testdata/frobnitz_backslash-1.2.3.tgz
vendored
Executable file
BIN
pkg/chartutil/testdata/frobnitz_backslash-1.2.3.tgz
vendored
Executable file
Binary file not shown.
1
pkg/chartutil/testdata/frobnitz_backslash/.helmignore
vendored
Executable file
1
pkg/chartutil/testdata/frobnitz_backslash/.helmignore
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
ignore/
|
||||
17
pkg/chartutil/testdata/frobnitz_backslash/Chart.yaml
vendored
Executable file
17
pkg/chartutil/testdata/frobnitz_backslash/Chart.yaml
vendored
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: v1
|
||||
name: frobnitz_backslash
|
||||
description: This is a frobnitz.
|
||||
version: "1.2.3"
|
||||
keywords:
|
||||
- frobnitz
|
||||
- sprocket
|
||||
- dodad
|
||||
maintainers:
|
||||
- name: The Helm Team
|
||||
email: helm@example.com
|
||||
- name: Someone Else
|
||||
email: nobody@example.com
|
||||
sources:
|
||||
- https://example.com/foo/bar
|
||||
home: http://example.com
|
||||
icon: https://example.com/64x64.png
|
||||
1
pkg/chartutil/testdata/frobnitz_backslash/INSTALL.txt
vendored
Executable file
1
pkg/chartutil/testdata/frobnitz_backslash/INSTALL.txt
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
This is an install document. The client may display this.
|
||||
1
pkg/chartutil/testdata/frobnitz_backslash/LICENSE
vendored
Executable file
1
pkg/chartutil/testdata/frobnitz_backslash/LICENSE
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
LICENSE placeholder.
|
||||
11
pkg/chartutil/testdata/frobnitz_backslash/README.md
vendored
Executable file
11
pkg/chartutil/testdata/frobnitz_backslash/README.md
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
# Frobnitz
|
||||
|
||||
This is an example chart.
|
||||
|
||||
## Usage
|
||||
|
||||
This is an example. It has no usage.
|
||||
|
||||
## Development
|
||||
|
||||
For developer info, see the top-level repository.
|
||||
1
pkg/chartutil/testdata/frobnitz_backslash/charts/_ignore_me
vendored
Executable file
1
pkg/chartutil/testdata/frobnitz_backslash/charts/_ignore_me
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
This should be ignored by the loader, but may be included in a chart.
|
||||
4
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/Chart.yaml
vendored
Executable file
4
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/Chart.yaml
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
name: alpine
|
||||
description: Deploy a basic Alpine Linux pod
|
||||
version: 0.1.0
|
||||
home: https://k8s.io/helm
|
||||
9
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/README.md
vendored
Executable file
9
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/README.md
vendored
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
This example was generated using the command `helm create alpine`.
|
||||
|
||||
The `templates/` directory contains a very simple pod resource with a
|
||||
couple of parameters.
|
||||
|
||||
The `values.toml` file contains the default values for the
|
||||
`alpine-pod.yaml` template.
|
||||
|
||||
You can install this example using `helm install docs/examples/alpine`.
|
||||
4
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/charts/mast1/Chart.yaml
vendored
Executable file
4
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/charts/mast1/Chart.yaml
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
name: mast1
|
||||
description: A Helm chart for Kubernetes
|
||||
version: 0.1.0
|
||||
home: ""
|
||||
4
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/charts/mast1/values.yaml
vendored
Executable file
4
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/charts/mast1/values.yaml
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
# Default values for mast1.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare name/value pairs to be passed into your templates.
|
||||
# name = "value"
|
||||
BIN
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/charts/mast2-0.1.0.tgz
vendored
Executable file
BIN
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/charts/mast2-0.1.0.tgz
vendored
Executable file
Binary file not shown.
16
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml
vendored
Executable file
16
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/templates/alpine-pod.yaml
vendored
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: {{.Release.Name}}-{{.Chart.Name}}
|
||||
labels:
|
||||
heritage: {{.Release.Service}}
|
||||
chartName: {{.Chart.Name}}
|
||||
chartVersion: {{.Chart.Version | quote}}
|
||||
annotations:
|
||||
"helm.sh/created": "{{.Release.Time.Seconds}}"
|
||||
spec:
|
||||
restartPolicy: {{default "Never" .restart_policy}}
|
||||
containers:
|
||||
- name: waiter
|
||||
image: "alpine:3.3"
|
||||
command: ["/bin/sleep","9000"]
|
||||
2
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/values.yaml
vendored
Executable file
2
pkg/chartutil/testdata/frobnitz_backslash/charts/alpine/values.yaml
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
# The pod name
|
||||
name: "my-alpine"
|
||||
BIN
pkg/chartutil/testdata/frobnitz_backslash/charts/mariner-4.3.2.tgz
vendored
Executable file
BIN
pkg/chartutil/testdata/frobnitz_backslash/charts/mariner-4.3.2.tgz
vendored
Executable file
Binary file not shown.
1
pkg/chartutil/testdata/frobnitz_backslash/docs/README.md
vendored
Executable file
1
pkg/chartutil/testdata/frobnitz_backslash/docs/README.md
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
This is a placeholder for documentation.
|
||||
8
pkg/chartutil/testdata/frobnitz_backslash/icon.svg
vendored
Executable file
8
pkg/chartutil/testdata/frobnitz_backslash/icon.svg
vendored
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="1.0" width="256" height="256" id="test">
|
||||
<desc>Example icon</desc>
|
||||
<rect id="first" x="2" y="2" width="40" height="60" fill="navy"/>
|
||||
<rect id="second" x="15" y="4" width="40" height="60" fill="red"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 374 B |
0
pkg/chartutil/testdata/frobnitz_backslash/ignore/me.txt
vendored
Executable file
0
pkg/chartutil/testdata/frobnitz_backslash/ignore/me.txt
vendored
Executable file
8
pkg/chartutil/testdata/frobnitz_backslash/requirements.lock
vendored
Executable file
8
pkg/chartutil/testdata/frobnitz_backslash/requirements.lock
vendored
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
dependencies:
|
||||
- name: alpine
|
||||
version: "0.1.0"
|
||||
repository: https://example.com/charts
|
||||
- name: mariner
|
||||
version: "4.3.2"
|
||||
repository: https://example.com/charts
|
||||
digest: invalid
|
||||
7
pkg/chartutil/testdata/frobnitz_backslash/requirements.yaml
vendored
Executable file
7
pkg/chartutil/testdata/frobnitz_backslash/requirements.yaml
vendored
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
dependencies:
|
||||
- name: alpine
|
||||
version: "0.1.0"
|
||||
repository: https://example.com/charts
|
||||
- name: mariner
|
||||
version: "4.3.2"
|
||||
repository: https://example.com/charts
|
||||
1
pkg/chartutil/testdata/frobnitz_backslash/templates/template.tpl
vendored
Executable file
1
pkg/chartutil/testdata/frobnitz_backslash/templates/template.tpl
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
Hello {{.Name | default "world"}}
|
||||
6
pkg/chartutil/testdata/frobnitz_backslash/values.yaml
vendored
Executable file
6
pkg/chartutil/testdata/frobnitz_backslash/values.yaml
vendored
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
# A values file contains configuration.
|
||||
|
||||
name: "Some Name"
|
||||
|
||||
section:
|
||||
name: "Name in a section"
|
||||
Loading…
Reference in a new issue