mirror of https://github.com/helm/helm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
723 B
31 lines
723 B
package rules
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func ParseIgnoreFile(filePath string) (map[string]string, error) {
|
|
patterns := make(map[string]string)
|
|
file, err := os.Open(filePath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer file.Close()
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
for scanner.Scan() {
|
|
line := strings.TrimSpace(scanner.Text())
|
|
if line != "" && !strings.HasPrefix(line, "#") {
|
|
parts := strings.SplitN(line, " ", 2)
|
|
if len(parts) > 1 {
|
|
patterns[parts[0]] = parts[1]
|
|
} else if len(parts) == 1 {
|
|
patterns[parts[0]] = ""
|
|
}
|
|
}
|
|
}
|
|
|
|
return patterns, scanner.Err()
|
|
} |