diff --git a/cli/app.go b/cli/app.go index bc3dfbf..b0158af 100644 --- a/cli/app.go +++ b/cli/app.go @@ -48,7 +48,7 @@ func main() { } if *validate { - validateRules(flag.Args(), LintRules) + validateRules(flag.Args()) return } @@ -74,14 +74,13 @@ func main() { applyRules(ruleSets, flag.Args(), applyOptions) } -func validateRules(filenames []string, rules string) { - ruleSet, err := assertion.ParseRules(rules) +func validateRules(filenames []string) { + builtInRuleSet, err := loadBuiltInRuleSet("assets/lint-rules.yml") if err != nil { - fmt.Println("Unable to parse validation rules") - fmt.Println(err.Error()) + fmt.Printf("Unable to load build-in rules for validation: %v\n", err) return } - ruleSets := []assertion.RuleSet{ruleSet} + ruleSets := []assertion.RuleSet{builtInRuleSet} applyOptions := ApplyOptions{ QueryExpression: "Violations[]", } diff --git a/cli/lint-rules.go b/cli/assets/lint-rules.yml similarity index 93% rename from cli/lint-rules.go rename to cli/assets/lint-rules.yml index ad8d75f..af3f03a 100644 --- a/cli/lint-rules.go +++ b/cli/assets/lint-rules.yml @@ -1,7 +1,4 @@ -package main - -// LintRules string containing YAML for -validate option -var LintRules = `--- +--- version: 1 description: Rules for config-lint type: LintRules @@ -54,7 +51,7 @@ rules: assertions: - every: key: rules - assertions: + expressions: - key: id op: present @@ -88,13 +85,13 @@ rules: op: present - id: VALID_EXPRESSION - message: "There are mutually exclusive in the same expression: key,or,xor,and,not,every,some,none" + message: "These are mutually exclusive in the same expression: key,or,xor,and,not,every,some,none" resource: LintRule severity: FAILURE assertions: - every: key: "assertions[]" - assertions: + expressions: - xor: - key: "@" op: has-properties @@ -120,4 +117,3 @@ rules: - key: "@" op: has-properties value: none -`