validate: promote invalid values to an error
This commit is contained in:
parent
4e466c12da
commit
7447e133c9
@ -76,7 +76,7 @@ func checkValidity(cfg node, report *Report) {
|
|||||||
|
|
||||||
func checkNodeValidity(n, g node, r *Report) {
|
func checkNodeValidity(n, g node, r *Report) {
|
||||||
if err := config.AssertValid(n.Value, g.field.Tag.Get("valid")); err != nil {
|
if err := config.AssertValid(n.Value, g.field.Tag.Get("valid")); err != nil {
|
||||||
r.Warning(n.line, fmt.Sprintf("invalid value %v", n.Value))
|
r.Error(n.line, fmt.Sprintf("invalid value %v", n.Value))
|
||||||
}
|
}
|
||||||
switch g.Kind() {
|
switch g.Kind() {
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
|
@ -218,7 +218,7 @@ func TestCheckValidity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
config: "coreos:\n units:\n - command: lol",
|
config: "coreos:\n units:\n - command: lol",
|
||||||
entries: []Entry{{entryWarning, "invalid value lol", 3}},
|
entries: []Entry{{entryError, "invalid value lol", 3}},
|
||||||
},
|
},
|
||||||
|
|
||||||
// struct
|
// struct
|
||||||
@ -227,7 +227,7 @@ func TestCheckValidity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
config: "coreos:\n update:\n reboot_strategy: always",
|
config: "coreos:\n update:\n reboot_strategy: always",
|
||||||
entries: []Entry{{entryWarning, "invalid value always", 3}},
|
entries: []Entry{{entryError, "invalid value always", 3}},
|
||||||
},
|
},
|
||||||
|
|
||||||
// unknown
|
// unknown
|
||||||
|
Loading…
Reference in New Issue
Block a user