skip warnings on commented out and empty lines

main
msfendourakis 2021-02-01 12:24:44 +02:00
parent 4e486b3b07
commit 7b2db4ca87
1 changed files with 30 additions and 26 deletions

View File

@ -39,6 +39,9 @@ func (r *DriftIgnore) readIgnoreFile() error {
line := scanner.Text() line := scanner.Text()
typeVal := readDriftIgnoreLine(line) typeVal := readDriftIgnoreLine(line)
nbArgs := len(typeVal) nbArgs := len(typeVal)
if nbArgs == 0 || strings.HasPrefix(line, "#") {
continue // skip empty or commented out lines
} else {
if nbArgs < 2 { if nbArgs < 2 {
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"line": line, "line": line,
@ -70,6 +73,7 @@ func (r *DriftIgnore) readIgnoreFile() error {
ignoreSublist = append(ignoreSublist, path) ignoreSublist = append(ignoreSublist, path)
r.driftExclusionList[res] = ignoreSublist r.driftExclusionList[res] = ignoreSublist
} }
}
if err := scanner.Err(); err != nil { if err := scanner.Err(); err != nil {
return err return err