From d6595ff9f114823fbbd2463dbdbaaf790038b2fa Mon Sep 17 00:00:00 2001 From: Louis TOUSSAINT Date: Fri, 5 Mar 2021 00:48:33 +0100 Subject: [PATCH] Issue 274: Add line number to logger when encounter invalid driftignore line --- pkg/filter/driftignore.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/filter/driftignore.go b/pkg/filter/driftignore.go index 688ab791..1bc403a4 100644 --- a/pkg/filter/driftignore.go +++ b/pkg/filter/driftignore.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "os" + "strconv" "strings" "github.com/cloudskiff/driftctl/pkg/resource" @@ -35,7 +36,7 @@ func (r *DriftIgnore) readIgnoreFile() error { defer file.Close() scanner := bufio.NewScanner(file) - for scanner.Scan() { + for lineNumber := 1; scanner.Scan(); lineNumber++ { line := scanner.Text() if line == "" || strings.HasPrefix(line, "#") { logrus.WithFields(logrus.Fields{ @@ -47,7 +48,8 @@ func (r *DriftIgnore) readIgnoreFile() error { nbArgs := len(typeVal) if nbArgs < 2 { logrus.WithFields(logrus.Fields{ - "line": line, + "line": strconv.Itoa(lineNumber), + "content": line, }).Warnf("unable to parse line, invalid length, got %d expected >= 2", nbArgs) continue }