Issue 274: Add line number to logger when encounter invalid driftignore line
parent
c7f7a3ac8d
commit
d6595ff9f1
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||||
|
@ -35,7 +36,7 @@ func (r *DriftIgnore) readIgnoreFile() error {
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
for scanner.Scan() {
|
for lineNumber := 1; scanner.Scan(); lineNumber++ {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
if line == "" || strings.HasPrefix(line, "#") {
|
if line == "" || strings.HasPrefix(line, "#") {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
|
@ -47,7 +48,8 @@ func (r *DriftIgnore) readIgnoreFile() error {
|
||||||
nbArgs := len(typeVal)
|
nbArgs := len(typeVal)
|
||||||
if nbArgs < 2 {
|
if nbArgs < 2 {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"line": line,
|
"line": strconv.Itoa(lineNumber),
|
||||||
|
"content": line,
|
||||||
}).Warnf("unable to parse line, invalid length, got %d expected >= 2", nbArgs)
|
}).Warnf("unable to parse line, invalid length, got %d expected >= 2", nbArgs)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue