From 07750ea43a89ab9e71ae82cf8ba6f854e600646e Mon Sep 17 00:00:00 2001
From: Liz Rice <liz@lizrice.com>
Date: Fri, 23 Jun 2017 10:48:49 +0100
Subject: [PATCH] Don't output message about config file if output format is
 JSON

---
 cmd/common.go | 2 ++
 cmd/root.go   | 4 +---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/common.go b/cmd/common.go
index a296999..63940d4 100644
--- a/cmd/common.go
+++ b/cmd/common.go
@@ -225,6 +225,8 @@ func colorPrint(state check.State, s string) {
 
 // prettyPrint outputs the results to stdout in human-readable format
 func prettyPrint(warnings []string, r *check.Controls, summary check.Summary) {
+	colorPrint(check.INFO, fmt.Sprintf("Using config file: %s\n", viper.ConfigFileUsed()))
+
 	for _, w := range warnings {
 		colorPrint(check.WARN, w)
 	}
diff --git a/cmd/root.go b/cmd/root.go
index 2506c54..b1c5bc4 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -96,9 +96,7 @@ func initConfig() {
 	viper.SetDefault("federatedFile", cfgDir+"/federated.yaml")
 
 	// If a config file is found, read it in.
-	if err := viper.ReadInConfig(); err == nil {
-		colorPrint(check.INFO, fmt.Sprintf("Using config file: %s\n", viper.ConfigFileUsed()))
-	} else {
+	if err := viper.ReadInConfig(); err != nil {
 		colorPrint(check.FAIL, fmt.Sprintf("Failed to read config file: %v\n", err))
 		os.Exit(1)
 	}
-- 
GitLab