Repository: doitintl/kube-no-trouble (go)

Issue:
Detect K8s version and suggest only relevant issues
We can try to detect a version of the cluster a user is running and suggest only updates relevant for the existing/next minor version, since we have info on since what version are the replacement resources available.

I.e. if user runs 1.15, and is dealing with upgrade to 1.16, no point flagging deprecation in 1.22 that are only available for replacement in 1.18.

Pull request:
feat: Filter non-relevant results
This PR implements filtering of non-relevant versions, i.e. versions that the user can't upgrade to as they're not available in the used K8S version.



Closes #130

Patch:
diff --git a/cmd/kubent/main.go b/cmd/kubent/main.go
index e7d47b3..ee37875 100644
--- a/cmd/kubent/main.go
+++ b/cmd/kubent/main.go
@@ -76,14 +76,21 @@ func initCollectors(config *config.Config) []collector.Collector {
 	return collectors
 }
 
-func getServerVersion(collectors []collector.Collector) (string, error) {
-	for _, c := range collectors {
-		versionCol, ok := c.(collector.VersionCollector)
-		if ok {
-			return versionCol.GetServerVersion()
+func getServerVersion(cv *config.Version, collectors []collector.Collector) error {
+	if cv.Version == nil {
+		for _, c := range collectors {
+			if versionCol, ok := c.(collector.VersionCollector); ok {
+				goversion, err := versionCol.GetServerVersion()
+				if err != nil {
+					return fmt.Errorf("failed to detect k8s version: %w", err)
+				}
+
+				cv.SetFromVersion(goversion)
+				return nil
+			}
 		}
 	}
-	return "", nil
+	return nil
 }
 
 func main() {
@@ -104,13 +111,10 @@ func main() {
 	log.Info().Msg("Initializing collectors and retrieving data")
 	initCollectors := initCollectors(config)
 
-	if config.TargetVersion == "" {
-		config.TargetVersion, err = getServerVersion(initCollectors)
-		if err != nil {
-			log.Fatal().Err(err).Msg("Failed to detect K8s version")
-		}
+	getServerVersion(&config.TargetVersion, initCollectors)
+	if config.TargetVersion.Version != nil {
+		log.Info().Msgf("Target K8s version is %s", config.TargetVersion.String())
 	}
-	log.Info().Msgf("Target K8s version is %s", config.TargetVersion)
 
 	collectors := getCollectors(initCollectors)
 
@@ -137,6 +141,11 @@ func main() {
 		log.Fatal().Err(err).Str("name", "Rego").Msg("Failed to evaluate input")
 	}
 
+	results, err = printer.FilterNonRelevantResults(results, config.TargetVersion.Version)
+	if err != nil {
+		log.Fatal().Err(err).Str("name", "Rego").Msg("Failed to filter results")
+	}
+
 	printer, err := printer.NewPrinter(config.Output)
 	if err != nil {
 		log.Fatal().Err(err).Msg("Failed to create printer")
diff --git a/go.mod b/go.mod
index 166b1bb..c294b16 100644
--- a/go.mod
+++ b/go.mod
@@ -7,6 +7,7 @@ require (
 	github.com/DATA-DOG/go-sqlmock v1.4.1 // indirect
 	github.com/ghodss/yaml v1.0.0
 	github.com/google/gofuzz v1.1.0 // indirect
+	github.com/hashicorp/go-version v1.3.0
 	github.com/jmoiron/sqlx v1.2.0 // indirect
 	github.com/lib/pq v1.3.0 // indirect
 	github.com/open-policy-agent/opa v0.28.0
diff --git a/go.sum b/go.sum
index 0a4ec30..1e81136 100644
--- a/go.sum
+++ b/go.sum
@@ -322,6 +322,8 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv
 github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
 github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
+github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw=
+github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
 github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
 github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
diff --git a/pkg/collector/collector.go b/pkg/collector/collector.go
index 61f9417..1e043cc 100644
--- a/pkg/collector/collector.go
+++ b/pkg/collector/collector.go
@@ -1,12 +1,16 @@
 package collector
 
+import (
+	goversion "github.com/hashicorp/go-version"
+)
+
 type Collector interface {
 	Get() ([]map[string]interface{}, error)
 	Name() string
 }
 
 type VersionCollector interface {
-	GetServerVersion() (string, error)
+	GetServerVersion() (*goversion.Version, error)
 }
 
 type commonCollector struct {
diff --git a/pkg/collector/fake.go b/pkg/collector/fake.go
index 4ad4103..6770fe7 100644
--- a/pkg/collector/fake.go
+++ b/pkg/collector/fake.go
@@ -1,5 +1,9 @@
 package collector
 
+import (
+	goversion "github.com/hashicorp/go-version"
+)
+
 const FAKE_VERSION = "1.2.3"
 
 type fakeCollector struct {
@@ -16,6 +20,8 @@ func NewFakeCollector() *fakeCollector {
 	}
 }
 
-func (c *fakeCollector) GetServerVersion() (string, error) {
-	return FAKE_VERSION, nil
+func (c *fakeCollector) GetServerVersion() (*goversion.Version, error) {
+	version, err := goversion.NewVersion(FAKE_VERSION)
+
+	return version, err
 }
diff --git a/pkg/collector/kube.go b/pkg/collector/kube.go
index 251de2b..35d64aa 100644
--- a/pkg/collector/kube.go
+++ b/pkg/collector/kube.go
@@ -2,6 +2,8 @@ package collector
 
 import (
 	"fmt"
+
+	goversion "github.com/hashicorp/go-version"
 	"k8s.io/client-go/discovery"
 	"k8s.io/client-go/tools/clientcmd"
 )
@@ -30,10 +32,11 @@ func newKubeCollector(kubeconfig string, discoveryClient discovery.DiscoveryInte
 	return col, nil
 }
 
-func (c *kubeCollector) GetServerVersion() (string, error) {
+func (c *kubeCollector) GetServerVersion() (*goversion.Version, error) {
 	version, err := c.discoveryClient.ServerVersion()
 	if err != nil {
-		return "", fmt.Errorf("failed to get server version %w", err)
+		return nil, fmt.Errorf("failed to get server version %w", err)
 	}
-	return version.Major + "." + version.Minor, nil
+
+	return goversion.NewVersion(version.String())
 }
diff --git a/pkg/config/config.go b/pkg/config/config.go
index b2996d9..d94f395 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -4,11 +4,11 @@ import (
 	"fmt"
 	"os"
 	"path/filepath"
-	"strconv"
 	"strings"
 	"unicode"
 
 	"github.com/doitintl/kube-no-trouble/pkg/printer"
+
 	"github.com/rs/zerolog"
 	flag "github.com/spf13/pflag"
 	"k8s.io/client-go/util/homedir"
@@ -24,12 +24,13 @@ type Config struct {
 	Kubeconfig      string
 	LogLevel        ZeroLogLevel
 	Output          string
-	TargetVersion   string
+	TargetVersion   Version
 }
 
 func NewFromFlags() (*Config, error) {
 	config := Config{
-		LogLevel: ZeroLogLevel(zerolog.InfoLevel),
+		LogLevel:      ZeroLogLevel(zerolog.InfoLevel),
+		TargetVersion: *NewVersion(),
 	}
 
 	home := homedir.HomeDir()
@@ -42,7 +43,7 @@ func NewFromFlags() (*Config, error) {
 	flag.StringVarP(&config.Kubeconfig, "kubeconfig", "k", envOrString("KUBECONFIG", filepath.Join(home, ".kube", "config")), "path to the kubeconfig file")
 	flag.StringVarP(&config.Output, "output", "o", "text", "output format - [text|json]")
 	flag.VarP(&config.LogLevel, "log-level", "l", "set log level (trace, debug, info, warn, error, fatal, panic, disabled)")
-	flag.StringVarP(&config.TargetVersion, "target-version", "t", "", "target K8s version in major.minor format (autodetected by default)")
+	flag.VarP(&config.TargetVersion, "target-version", "t", "target K8s version in SemVer format (autodetected by default)")
 
 	flag.Parse()
 
@@ -54,10 +55,6 @@ func NewFromFlags() (*Config, error) {
 		return nil, fmt.Errorf("failed to validate arguments: %w", err)
 	}
 
-	if err := validateTargetVersion(config.TargetVersion); err != nil {
-		return nil, fmt.Errorf("failed to validate arguments: %w", err)
-	}
-
 	return &config, nil
 }
 
@@ -84,19 +81,3 @@ func validateAdditionalResources(resources []string) error {
 	}
 	return nil
 }
-
-func validateTargetVersion(version string) error {
-	if version != "" {
-		parts := strings.Split(version, ".")
-		if len(parts) < 2 || len(parts) > 3 {
-			return fmt.Errorf("failed to parse target version, expected format is major.minor, got: %s", version)
-		}
-
-		for _, p := range parts {
-			if _, err := strconv.ParseUint(p, 10, 8); err != nil {
-				return fmt.Errorf("failed to parse target version, all parts are expected to be a number, got: %s", p)
-			}
-		}
-	}
-	return nil
-}
diff --git a/pkg/config/version.go b/pkg/config/version.go
new file mode 100644
index 0000000..0fec767
--- /dev/null
+++ b/pkg/config/version.go
@@ -0,0 +1,38 @@
+package config
+
+import (
+	goversion "github.com/hashicorp/go-version"
+)
+
+type Version struct {
+	*goversion.Version
+}
+
+func (v *Version) String() string {
+	if v.Version != nil {
+		return v.Version.String()
+	}
+	return ""
+}
+
+func (v *Version) Set(s string) error {
+	version, err := goversion.NewVersion(s)
+	if err != nil {
+		return err
+	}
+	v.Version = version
+	return nil
+}
+
+func (v *Version) SetFromVersion(new *goversion.Version) error {
+	v.Version = new
+	return nil
+}
+
+func (v *Version) Type() string {
+	return "string"
+}
+
+func NewVersion() *Version {
+	return &Version{}
+}
diff --git a/pkg/judge/judge.go b/pkg/judge/judge.go
index c4816cf..299ea59 100644
--- a/pkg/judge/judge.go
+++ b/pkg/judge/judge.go
@@ -1,5 +1,9 @@
 package judge
 
+import (
+	goversion "github.com/hashicorp/go-version"
+)
+
 type Result struct {
 	Name        string
 	Namespace   string
@@ -7,7 +11,7 @@ type Result struct {
 	ApiVersion  string
 	RuleSet     string
 	ReplaceWith string
-	Since       string
+	Since       *goversion.Version
 }
 
 type Judge interface {
diff --git a/pkg/judge/rego.go b/pkg/judge/rego.go
index 3fbbb7a..344ce1d 100644
--- a/pkg/judge/rego.go
+++ b/pkg/judge/rego.go
@@ -2,6 +2,7 @@ package judge
 
 import (
 	"context"
+	goversion "github.com/hashicorp/go-version"
 
 	"github.com/doitintl/kube-no-trouble/pkg/rules"
 	"github.com/open-policy-agent/opa/rego"
@@ -50,6 +51,12 @@ func (j *RegoJudge) Eval(input []map[string]interface{}) ([]Result, error) {
 		for _, e := range r.Expressions {
 			for _, i := range e.Value.([]interface{}) {
 				m := i.(map[string]interface{})
+
+				since, err := goversion.NewVersion(m["Since"].(string))
+				if err != nil {
+					return nil, err
+				}
+
 				results = append(results, Result{
 					Name:        m["Name"].(string),
 					Namespace:   m["Namespace"].(string),
@@ -57,7 +64,7 @@ func (j *RegoJudge) Eval(input []map[string]interface{}) ([]Result, error) {
 					ApiVersion:  m["ApiVersion"].(string),
 					ReplaceWith: m["ReplaceWith"].(string),
 					RuleSet:     m["RuleSet"].(string),
-					Since:       m["Since"].(string),
+					Since:       since,
 				})
 			}
 		}
diff --git a/pkg/printer/filter.go b/pkg/printer/filter.go
new file mode 100644
index 0000000..49dfd0d
--- /dev/null
+++ b/pkg/printer/filter.go
@@ -0,0 +1,23 @@
+package printer
+
+import (
+	"github.com/doitintl/kube-no-trouble/pkg/judge"
+
+	goversion "github.com/hashicorp/go-version"
+)
+
+func FilterNonRelevantResults(results []judge.Result, tv *goversion.Version) ([]judge.Result, error) {
+	if tv != nil {
+		filtered := []judge.Result{}
+
+		for i := range results {
+			if results[i].Since.LessThanOrEqual(tv) {
+				filtered = append(filtered, results[i])
+			}
+		}
+
+		return filtered, nil
+	}
+
+	return results, nil
+}


Test patch:
diff --git a/cmd/kubent/main_test.go b/cmd/kubent/main_test.go
index c977229..aea9790 100644
--- a/cmd/kubent/main_test.go
+++ b/cmd/kubent/main_test.go
@@ -10,6 +10,7 @@ import (
 	"github.com/doitintl/kube-no-trouble/pkg/collector"
 	"github.com/doitintl/kube-no-trouble/pkg/config"
 
+	goversion "github.com/hashicorp/go-version"
 	"github.com/rs/zerolog"
 )
 
@@ -146,13 +147,14 @@ func TestMainExitCodes(t *testing.T) {
 func TestGetServerVersionNone(t *testing.T) {
 	collectors := []collector.Collector{}
 
-	version, err := getServerVersion(collectors)
-	if err != nil {
+	version := config.NewVersion()
+
+	if err := getServerVersion(version, collectors); err != nil {
 		t.Errorf("Failed to get version with error: %s", err)
 	}
 
-	if version != "" {
-		t.Errorf("Expected no version to be detected, instead got: %s", version)
+	if version.Version != nil {
+		t.Errorf("Expected no version to be detected, instead got: %s", version.String())
 	}
 }
 
@@ -165,29 +167,32 @@ func TestGetServerVersionNotSupported(t *testing.T) {
 	}
 
 	collectors = storeCollector(fileCollector, err, collectors)
+	version := config.NewVersion()
 
-	version, err := getServerVersion(collectors)
+	err = getServerVersion(version, collectors)
 	if err != nil {
 		t.Errorf("Failed to get version with error: %s", err)
 	}
 
-	if version != "" {
-		t.Errorf("Expected no version to be detected, instead got: %s", version)
+	if version.Version != nil {
+		t.Errorf("Expected no version to be detected, instead got: %s", version.String())
 	}
 }
 
 func TestGetServerVersion(t *testing.T) {
 	collectors := []collector.Collector{}
+	version := config.NewVersion()
 
 	fc := collector.NewFakeCollector()
 	collectors = storeCollector(fc, nil, collectors)
 
-	version, err := getServerVersion(collectors)
+	err := getServerVersion(version, collectors)
 	if err != nil {
 		t.Errorf("Failed to get version with error: %s", err)
 	}
 
-	if version != collector.FAKE_VERSION {
-		t.Errorf("Expected no version to be detected, instead got: %s", version)
+	fakeVersion, err := goversion.NewVersion(collector.FAKE_VERSION)
+	if version.Compare(fakeVersion) != 0 {
+		t.Errorf("Expected %s version to be detected, instead got: %s", fakeVersion.String(), version.String())
 	}
 }
diff --git a/pkg/collector/kube_test.go b/pkg/collector/kube_test.go
index 2243e1c..ef769ce 100644
--- a/pkg/collector/kube_test.go
+++ b/pkg/collector/kube_test.go
@@ -3,6 +3,7 @@ package collector
 import (
 	"testing"
 
+	goversion "github.com/hashicorp/go-version"
 	"k8s.io/apimachinery/pkg/version"
 	discoveryFake "k8s.io/client-go/discovery/fake"
 	"k8s.io/client-go/kubernetes/fake"
@@ -18,7 +19,6 @@ func TestNewKubeCollector(t *testing.T) {
 	if col == nil {
 		t.Errorf("Should return collector, instrad got nil")
 	}
-
 }
 
 func TestNewKubeCollectorError(t *testing.T) {
@@ -30,14 +30,12 @@ func TestNewKubeCollectorError(t *testing.T) {
 }
 
 func TestGetServerVersion(t *testing.T) {
-	expectedMajor := "1"
-	expectedMinor := "2"
-	expectedVersion := expectedMajor + "." + expectedMinor
+	gitVersion := "v1.2.3"
+	expectedVersion, _ := goversion.NewVersion(gitVersion)
 
 	clientSet := fake.NewSimpleClientset()
 	clientSet.Discovery().(*discoveryFake.FakeDiscovery).FakedServerVersion = &version.Info{
-		Major: expectedMajor,
-		Minor: expectedMinor,
+		GitVersion: gitVersion,
 	}
 
 	collector, err := newKubeCollector("", clientSet.Discovery())
@@ -47,10 +45,10 @@ func TestGetServerVersion(t *testing.T) {
 
 	version, err := collector.GetServerVersion()
 	if err != nil {
-		t.Errorf("Failed to get version with error: %s", err)
+		t.Fatalf("Failed to get version with error: %s", err)
 	}
 
-	if version != expectedVersion {
-		t.Errorf("Expected no version to be detected, instead got: %s", version)
+	if !version.Equal(expectedVersion) {
+		t.Errorf("Expected version: %s, instead got: %s", expectedVersion.String(), version.String())
 	}
 }
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index e5bbe5c..90096e6 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -1,6 +1,7 @@
 package config
 
 import (
+	goversion "github.com/hashicorp/go-version"
 	"os"
 	"testing"
 
@@ -153,27 +154,53 @@ func TestValidateAdditionalResourcesFail(t *testing.T) {
 	}
 }
 
-func TestValidateTargetVersion(t *testing.T) {
+func TestTargetVersion(t *testing.T) {
 	validVersions := []string{
-		"", "1.16", "1.16.3", "1.2.3",
-	}
-	invalidVersions := []string{
-		"1", "v12.3.4", "v1.2", "1.blah", "nope",
+		"1.16", "1.16.3", "1.2.3",
 	}
 
+	oldArgs := os.Args[1]
+	defer func() { os.Args[1] = oldArgs }()
+
 	for _, v := range validVersions {
-		err := validateTargetVersion(v)
+		// reset for testing
+		pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
+
+		os.Args[1] = "--target-version=" + v
+		config, err := NewFromFlags()
 
 		if err != nil {
-			t.Errorf("Expected %s to fail validation, it failed instead with: %s", v, err)
+			t.Errorf("Flags parsing failed %s", err)
+		}
+
+		expected, _ := goversion.NewVersion(v)
+		if config.TargetVersion.Version == nil {
+			t.Fatalf("Target version not parsed correctly: expected: %s, got: %s", expected.String(), config.TargetVersion)
 		}
+
+		if !config.TargetVersion.Equal(expected) {
+			t.Fatalf("Target version not parsed correctly: expected: %s, got: %s", expected.String(), config.TargetVersion.String())
+		}
+	}
+}
+
+func TestTargetVersionInvalid(t *testing.T) {
+	invalidVersions := []string{
+		"1.blah", "nope",
 	}
 
+	oldArgs := os.Args[1]
+	defer func() { os.Args[1] = oldArgs }()
+
 	for _, v := range invalidVersions {
-		err := validateTargetVersion(v)
+		// reset for testing
+		pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ContinueOnError)
 
-		if err == nil {
-			t.Errorf("Expected %s to fail validation, it succeeded instead", v)
+		os.Args[1] = "--target-version=" + v
+		config, _ := NewFromFlags()
+
+		if config.TargetVersion.Version != nil {
+			t.Errorf("expected --target-version flag parsing to fail for: %s", v)
 		}
 	}
 }
diff --git a/pkg/printer/filter_test.go b/pkg/printer/filter_test.go
new file mode 100644
index 0000000..77a12b7
--- /dev/null
+++ b/pkg/printer/filter_test.go
@@ -0,0 +1,74 @@
+package printer
+
+import (
+	"testing"
+
+	"github.com/doitintl/kube-no-trouble/pkg/judge"
+
+	goversion "github.com/hashicorp/go-version"
+)
+
+var testVersion1, _ = goversion.NewVersion("1.1.1")
+var testVersion2, _ = goversion.NewVersion("2.2.2")
+
+var testInput []judge.Result = []judge.Result{
+	{
+		Name:        "testName1",
+		Kind:        "testKind1",
+		Namespace:   "testNamespace1",
+		ApiVersion:  "v1",
+		RuleSet:     "testRuleset1",
+		ReplaceWith: "testReplaceWith1",
+		Since:       testVersion1,
+	},
+	{
+		Name:        "testName2",
+		Kind:        "testKind2",
+		Namespace:   "testNamespace2",
+		ApiVersion:  "v1",
+		RuleSet:     "testRuleset2",
+		ReplaceWith: "testReplaceWith2",
+		Since:       testVersion2,
+	},
+}
+
+func TestFilterNonRelevantResults(t *testing.T) {
+	filterVersion, _ := goversion.NewVersion("2.0.0")
+
+	results, err := FilterNonRelevantResults(testInput, filterVersion)
+	if err != nil {
+		t.Fatalf("failed to filter results: %s", err)
+	}
+
+	if len(results) != 1 {
+		t.Errorf("expected 1 result after filter, got %d intead", len(results))
+	}
+}
+
+func TestFilterNonRelevantResultsEmpty(t *testing.T) {
+	filterVersion, _ := goversion.NewVersion("2.0.0")
+
+	var input []judge.Result = []judge.Result{}
+
+	results, err := FilterNonRelevantResults(input, filterVersion)
+	if err != nil {
+		t.Fatalf("failed to filter results: %s", err)
+	}
+
+	if len(results) != 0 {
+		t.Errorf("expected 0 results after filter, got %d intead", len(results))
+	}
+}
+
+func TestFilterNonRelevantResultsNilVersion(t *testing.T) {
+	var filterVersion *goversion.Version
+
+	results, err := FilterNonRelevantResults(testInput, filterVersion)
+	if err != nil {
+		t.Fatalf("failed to filter results: %s", err)
+	}
+
+	if len(results) != len(testInput) {
+		t.Errorf("expected same number of results as in input: %d, got %d intead", len(testInput), len(results))
+	}
+}
diff --git a/pkg/printer/json_test.go b/pkg/printer/json_test.go
index 2867dbb..88e4f93 100644
--- a/pkg/printer/json_test.go
+++ b/pkg/printer/json_test.go
@@ -7,30 +7,9 @@ import (
 	"github.com/doitintl/kube-no-trouble/pkg/judge"
 )
 
-var findingsJsonTesting []judge.Result = []judge.Result{
-	{
-		Name:        "testName1",
-		Kind:        "testKind1",
-		Namespace:   "testNamespace1",
-		ApiVersion:  "v1",
-		RuleSet:     "testRuleset1",
-		ReplaceWith: "testReplaceWith1",
-		Since:       "testSince1",
-	},
-	{
-		Name:        "testName2",
-		Kind:        "testKind2",
-		Namespace:   "testNamespace2",
-		ApiVersion:  "v1",
-		RuleSet:     "testRuleset2",
-		ReplaceWith: "testReplaceWith2",
-		Since:       "testSince2",
-	},
-}
-
 func TestJsonPopulateOutput(t *testing.T) {
 	printer := &jsonPrinter{}
-	output, err := printer.populateOutput(findingsJsonTesting)
+	output, err := printer.populateOutput(testInput)
 
 	if err != nil {
 		t.Fatal(err)