diff --git a/pkg/lint/lint.go b/pkg/lint/lint.go index 4c620d24c..53b45c5e6 100644 --- a/pkg/lint/lint.go +++ b/pkg/lint/lint.go @@ -18,8 +18,6 @@ package lint import ( "path/filepath" - "os" - "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/lint/rules" "helm.sh/helm/v3/pkg/lint/support" diff --git a/pkg/lint/rules/isignored.go b/pkg/lint/rules/isignored.go new file mode 100644 index 000000000..8f3274a0d --- /dev/null +++ b/pkg/lint/rules/isignored.go @@ -0,0 +1,23 @@ +package rules + +import ( + "path/filepath" + "strings" +) + +func IsIgnored(path string, patterns []string) bool { + for _, pattern := range patterns { + cleanedPath := filepath.Clean(path) + cleanedPattern := filepath.Clean(pattern) + if match, err := filepath.Match(cleanedPattern, cleanedPath); err == nil && match { + return true + } + if strings.HasSuffix(cleanedPattern, "/") || strings.HasSuffix(cleanedPattern, "\\") { + patternDir := strings.TrimRight(cleanedPattern, "/\\") + if strings.HasPrefix(cleanedPath, patternDir) { + return true + } + } + } + return false +}