Skip to content

Commit

Permalink
add expression in validateRules()
Browse files Browse the repository at this point in the history
  • Loading branch information
daiksy committed Jul 13, 2016
1 parent 3b4b343 commit 94ad212
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ func validateRules(monitors []*(mkr.Monitor), label string) (bool, error) {
return false, fmt.Errorf("Monitor '%s' should have '%s': %s", label, f, v.FieldByName(f).Interface())
}
}
case "expression":
for _, f := range []string{"Name", "Expression"} {
vf := v.FieldByName(f)
if !vf.IsValid() || (vf.Type().String() == "string" && vf.Interface() == "") {
return false, fmt.Errorf("Monitor '%s' should have '%s': %s", label, f, v.FieldByName(f).Interface())
}
}
case "connectivity":
default:
return false, fmt.Errorf("Unknown type is found: %s", m.Type)
Expand Down

0 comments on commit 94ad212

Please sign in to comment.