forked from goss-org/goss
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a silent output When using goss as a helathchecking endpoint, it may be desirable to suppress verbose test output so that potential malicious entities can't scrape healthcheck endpoints for system information. Add the `silent` output, which simply checks whether any tests have failed and returns 1 or 0 accordingly, without printing any output. * Document silent output format
- Loading branch information
1 parent
e2b72aa
commit f0913b1
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package outputs | ||
|
||
import ( | ||
"io" | ||
"time" | ||
|
||
"github.com/aelsabbahy/goss/resource" | ||
) | ||
|
||
type Silent struct{} | ||
|
||
func (r Silent) Output(w io.Writer, results <-chan []resource.TestResult, startTime time.Time) (exitCode int) { | ||
var failed int | ||
for resultGroup := range results { | ||
for _, testResult := range resultGroup { | ||
switch testResult.Result { | ||
case resource.FAIL: | ||
failed++ | ||
} | ||
} | ||
} | ||
|
||
if failed > 0 { | ||
return 1 | ||
} | ||
return 0 | ||
} | ||
|
||
func init() { | ||
RegisterOutputer("silent", &Silent{}) | ||
} |