forked from toolshed/abra
fix!: disable traefik linting when DOMAIN isn't present
Also reformats the linting output to be more readable. Closes coop-cloud/organising#319.
This commit is contained in:
@ -30,38 +30,62 @@ var recipeLintCommand = cli.Command{
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
tableCol := []string{"ref", "rule", "satisfied", "severity", "resolve"}
|
||||
tableCol := []string{"ref", "rule", "severity", "satisfied", "skipped", "resolve"}
|
||||
table := formatter.CreateTable(tableCol)
|
||||
|
||||
hasError := false
|
||||
bar := formatter.CreateProgressbar(-1, "running recipe lint rules...")
|
||||
for level := range lint.LintRules {
|
||||
for _, rule := range lint.LintRules[level] {
|
||||
ok, err := rule.Function(recipe)
|
||||
if err != nil {
|
||||
logrus.Warn(err)
|
||||
if internal.OnlyErrors && rule.Level != "error" {
|
||||
logrus.Debugf("skipping %s, does not have level \"error\"", rule.Ref)
|
||||
continue
|
||||
}
|
||||
|
||||
if !ok && rule.Level == "error" {
|
||||
hasError = true
|
||||
skipped := false
|
||||
if rule.Skip(recipe) {
|
||||
skipped = true
|
||||
}
|
||||
|
||||
var result string
|
||||
if ok {
|
||||
result = "yes"
|
||||
} else {
|
||||
result = "NO"
|
||||
skippedOutput := "-"
|
||||
if skipped {
|
||||
skippedOutput = "yes"
|
||||
}
|
||||
|
||||
if internal.OnlyErrors {
|
||||
if !ok && rule.Level == "error" {
|
||||
table.Append([]string{rule.Ref, rule.Description, result, rule.Level, rule.HowToResolve})
|
||||
bar.Add(1)
|
||||
satisfied := false
|
||||
if !skipped {
|
||||
ok, err := rule.Function(recipe)
|
||||
if err != nil {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
|
||||
if !ok && rule.Level == "error" {
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if ok {
|
||||
satisfied = true
|
||||
}
|
||||
} else {
|
||||
table.Append([]string{rule.Ref, rule.Description, result, rule.Level, rule.HowToResolve})
|
||||
bar.Add(1)
|
||||
}
|
||||
|
||||
satisfiedOutput := "yes"
|
||||
if !satisfied {
|
||||
satisfiedOutput = "NO"
|
||||
if skipped {
|
||||
satisfiedOutput = "-"
|
||||
}
|
||||
}
|
||||
|
||||
table.Append([]string{
|
||||
rule.Ref,
|
||||
rule.Description,
|
||||
rule.Level,
|
||||
satisfiedOutput,
|
||||
skippedOutput,
|
||||
rule.HowToResolve,
|
||||
})
|
||||
|
||||
bar.Add(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user