diff --git a/lint/lint.go b/lint/lint.go index 6fd30ff3278..d63f00908ce 100644 --- a/lint/lint.go +++ b/lint/lint.go @@ -89,14 +89,16 @@ func resultWarns(result *schema.Result) []string { } // We need this since formats can only return bools, not // custom errors/messages. + var desc string switch format := ferr.Details()["format"].(string); format { case "path": - ferr.SetDescription("Path does not exist or is not accessible") + desc = "Path does not exist or is not accessible" case "host-no-port": - ferr.SetDescription("Address should be a host without port") + desc = "Address should be a host without port" default: panic(fmt.Sprintf("unexpected format type: %q", format)) } + ferr.SetDescription(desc) strs[i] = ferr.String() } return strs diff --git a/lint/lint_test.go b/lint/lint_test.go index 355eae37bce..753977d9632 100644 --- a/lint/lint_test.go +++ b/lint/lint_test.go @@ -63,6 +63,18 @@ var tests = []struct { "BadHost", `{"storage": {"host": "::::"}}`, "storage.host: Address should be a host without port", }, + { + "BadLogLevel", `{"log_level": "catastrophic"}`, + `log_level: log_level must be one of the following: "", "debug", "info", "warn", "error"`, + }, + { + "BadStorageType", `{"storage": {"type": "cd-rom"}}`, + `storage.type: storage.type must be one of the following: "", "redis"`, + }, + { + "BadPolicySource", `{"policies": {"policy_source": "internet"}}`, + `policies.policy_source: policies.policy_source must be one of the following: "", "service", "rpc"`, + }, } func allContains(got, want []string) bool { diff --git a/lint/schema.go b/lint/schema.go index cc20175bf5f..0d7a307949b 100644 --- a/lint/schema.go +++ b/lint/schema.go @@ -35,7 +35,8 @@ const confSchema = `{ "type": "integer" }, "type": { - "type": "string" + "type": "string", + "enum": ["", "redis"] }, "username": { "type": "string" @@ -367,7 +368,8 @@ const confSchema = `{ } }, "log_level": { - "type": "string" + "type": "string", + "enum": ["", "debug", "info", "warn", "error"] }, "logstash_network_addr": { "type": "string" @@ -457,7 +459,8 @@ const confSchema = `{ "type": "string" }, "policy_source": { - "type": "string" + "type": "string", + "enum": ["", "service", "rpc"] } } },