mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Fix helmignore for .* (#3114)
When the first rule matching entry for top level dir will be empty string, the .* rule will match. Skip this entry as it's not needed for processing.
This commit is contained in:
parent
838d780894
commit
d762a42168
18 changed files with 85 additions and 0 deletions
|
|
@ -245,6 +245,11 @@ func LoadDir(dir string) (*chart.Chart, error) {
|
|||
|
||||
err = filepath.Walk(topdir, func(name string, fi os.FileInfo, err error) error {
|
||||
n := strings.TrimPrefix(name, topdir)
|
||||
if n == "" {
|
||||
// No need to process top level. Avoid bug with helmignore .* matching
|
||||
// empty names. See issue 1779.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Normalize to / since it will also work on Windows
|
||||
n = filepath.ToSlash(n)
|
||||
|
|
|
|||
|
|
@ -419,6 +419,12 @@ func TestDependentChartWithSubChartsAbsentInRequirements(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func TestDependentChartWithSubChartsHelmignore(t *testing.T) {
|
||||
if _, err := Load("testdata/dependent-chart-helmignore"); err != nil {
|
||||
t.Fatalf("Failed to load testdata: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDependentChartsWithSubchartsAllSpecifiedInRequirements(t *testing.T) {
|
||||
c, err := Load("testdata/dependent-chart-with-all-in-requirements-yaml")
|
||||
if err != nil {
|
||||
|
|
|
|||
2
pkg/chartutil/testdata/dependent-chart-helmignore/.helmignore
vendored
Normal file
2
pkg/chartutil/testdata/dependent-chart-helmignore/.helmignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ignore/
|
||||
.*
|
||||
17
pkg/chartutil/testdata/dependent-chart-helmignore/Chart.yaml
vendored
Normal file
17
pkg/chartutil/testdata/dependent-chart-helmignore/Chart.yaml
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
apiVersion: v1
|
||||
name: frobnitz
|
||||
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
|
||||
0
pkg/chartutil/testdata/dependent-chart-helmignore/charts/.ignore_me
vendored
Normal file
0
pkg/chartutil/testdata/dependent-chart-helmignore/charts/.ignore_me
vendored
Normal file
1
pkg/chartutil/testdata/dependent-chart-helmignore/charts/_ignore_me
vendored
Normal file
1
pkg/chartutil/testdata/dependent-chart-helmignore/charts/_ignore_me
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
This should be ignored by the loader, but may be included in a chart.
|
||||
4
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml
vendored
Normal file
4
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/Chart.yaml
vendored
Normal 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/dependent-chart-helmignore/charts/alpine/README.md
vendored
Normal file
9
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/README.md
vendored
Normal 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/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml
vendored
Normal file
4
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/Chart.yaml
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
name: mast1
|
||||
description: A Helm chart for Kubernetes
|
||||
version: 0.1.0
|
||||
home: ""
|
||||
4
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml
vendored
Normal file
4
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast1/values.yaml
vendored
Normal 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/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz
vendored
Normal file
BIN
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/charts/mast2-0.1.0.tgz
vendored
Normal file
Binary file not shown.
16
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml
vendored
Normal file
16
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/templates/alpine-pod.yaml
vendored
Normal 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/dependent-chart-helmignore/charts/alpine/values.yaml
vendored
Normal file
2
pkg/chartutil/testdata/dependent-chart-helmignore/charts/alpine/values.yaml
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# The pod name
|
||||
name: "my-alpine"
|
||||
1
pkg/chartutil/testdata/dependent-chart-helmignore/templates/template.tpl
vendored
Normal file
1
pkg/chartutil/testdata/dependent-chart-helmignore/templates/template.tpl
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
Hello {{.Name | default "world"}}
|
||||
6
pkg/chartutil/testdata/dependent-chart-helmignore/values.yaml
vendored
Normal file
6
pkg/chartutil/testdata/dependent-chart-helmignore/values.yaml
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# A values file contains configuration.
|
||||
|
||||
name: "Some Name"
|
||||
|
||||
section:
|
||||
name: "Name in a section"
|
||||
|
|
@ -82,6 +82,11 @@ func (r *Rules) Len() int {
|
|||
// Ignore evaluates path against the rules in order. Evaluation stops when a match
|
||||
// is found. Matching a negative rule will stop evaluation.
|
||||
func (r *Rules) Ignore(path string, fi os.FileInfo) bool {
|
||||
// Don't match on empty dirs.
|
||||
if path == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
// Disallow ignoring the current working directory.
|
||||
// See issue:
|
||||
// 1776 (New York City) Hamilton: "Pardon me, are you Aaron Burr, sir?"
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ func TestIgnore(t *testing.T) {
|
|||
// "." should never get ignored. https://github.com/kubernetes/helm/issues/1776
|
||||
{`.*`, ".", false},
|
||||
{`.*`, "./", false},
|
||||
{`.*`, ".joonix", true},
|
||||
{`.*`, "helm.txt", false},
|
||||
{`.*`, "", false},
|
||||
|
||||
// Directory tests
|
||||
{`cargo/`, "cargo", true},
|
||||
|
|
|
|||
0
pkg/ignore/testdata/.joonix
vendored
Normal file
0
pkg/ignore/testdata/.joonix
vendored
Normal file
Loading…
Reference in a new issue