@@ -73,7 +73,6 @@ Tarballs can also be specified by simply providing the path to the .tar, .tar.gz
73
73
}
74
74
75
75
func outputResults (resultMap map [string ]util.Result ) {
76
-
77
76
// Outputs diff/analysis results in alphabetical order by analyzer name
78
77
sortedTypes := []string {}
79
78
for analyzerType := range resultMap {
@@ -84,7 +83,7 @@ func outputResults(resultMap map[string]util.Result) {
84
83
// Get the writer
85
84
writer , err := getWriter (outputFile )
86
85
if err != nil {
87
- logrus . Error (err )
86
+ errors . Wrap (err , "getting writer for output file" )
88
87
}
89
88
90
89
results := make ([]interface {}, len (resultMap ))
@@ -100,7 +99,6 @@ func outputResults(resultMap map[string]util.Result) {
100
99
}
101
100
}
102
101
if json {
103
-
104
102
err := util .JSONify (writer , results )
105
103
if err != nil {
106
104
logrus .Error (err )
@@ -176,20 +174,14 @@ func getCacheDir(imageName string) (string, error) {
176
174
func getWriter (outputFile string ) (io.Writer , error ) {
177
175
var err error
178
176
var outWriter io.Writer
179
-
180
177
// If the user specifies an output file, ensure exists
181
178
if outputFile != "" {
182
-
183
179
// Don't overwrite a file that exists, unless given --force
184
- if _ , err := os .Stat (outputFile ); ! os .IsNotExist (err ) {
185
- if ! forceWrite {
186
- logrus .Error ("file exist, will not overwrite." )
187
- }
180
+ if _ , err := os .Stat (outputFile ); ! os .IsNotExist (err ) && ! forceWrite {
181
+ errors .Wrap (err , "file exist, will not overwrite." )
188
182
}
189
-
190
183
// Otherwise, output file is an io.writer
191
184
outWriter , err = os .Create (outputFile )
192
-
193
185
}
194
186
// If still doesn't exist, return stdout as the io.Writer
195
187
if outputFile == "" {
0 commit comments