Skip to content

Commit

Permalink
change default report to only show Violations, use -verbose for complete
Browse files Browse the repository at this point in the history
report
  • Loading branch information
Larry Hitchon committed Apr 19, 2018
1 parent b142f22 commit 601cde1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
* Create a Provider interface for AWS calls, create a mock for testing SecurityGroupLinter
* Starting to have inconsistent naming in ops: is-true, is-false, has-properties vs. present, absent, empty, null
* Add options to Assertion type, for things like 'ignore-case' for string compares? Or just use a regex?
* Provide a default -query of 'Violations[]', and add an option for a full report
* Terraform converter wraps every map in an array - apparently it is valid HCL to have, e.g. "tags" appear multiple times in a resource
15 changes: 14 additions & 1 deletion cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
tags := flag.String("tags", "", "Run only tests with tags in this comma separated list")
ids := flag.String("ids", "", "Run only the rules in this comma separated list")
queryExpression := flag.String("query", "", "JMESPath expression to query the results")
verboseReport := flag.Bool("verbose", false, "Output a verbose report")
searchExpression := flag.String("search", "", "JMESPath expression to evaluation against the files")
validate := flag.Bool("validate", false, "Validate rules file")
versionFlag := flag.Bool("version", false, "Get program version")
Expand All @@ -55,7 +56,7 @@ func main() {
applyOptions := ApplyOptions{
Tags: makeTagList(*tags),
RuleIDs: makeRulesList(*ids),
QueryExpression: *queryExpression,
QueryExpression: makeQueryExpression(*queryExpression, *verboseReport),
SearchExpression: *searchExpression,
}
ruleSets, err := loadRuleSets(rulesFilenames)
Expand Down Expand Up @@ -224,3 +225,15 @@ func generateExitCode(report assertion.ValidationReport) int {
}
return 0
}

func makeQueryExpression(queryExpression string, verboseReport bool) string {
if queryExpression != "" {
return queryExpression
}
// return complete report when -verbose option is used
if verboseReport {
return ""
}
// default is to only report Violations
return "Violations[]"
}

0 comments on commit 601cde1

Please sign in to comment.