Add validation for the required flag

If --system-log-monitors or --custom-plugin-monitors are not
specified, npd gave us unclear message.

This patch adds the validation and clear error message.
This commit is contained in:
Kenjiro Nakayama
2019-01-17 13:23:11 +09:00
parent 53ee78d372
commit a248e2a842

View File

@@ -80,6 +80,9 @@ func (npdo *NodeProblemDetectorOptions) ValidOrDie() {
panic(fmt.Sprintf("apiserver-override %q is not a valid HTTP URI: %v",
npdo.ApiServerOverride, err))
}
if len(npdo.SystemLogMonitorConfigPaths) == 0 && len(npdo.CustomPluginMonitorConfigPaths) == 0 {
panic(fmt.Sprintf("Either --system-log-monitors or --custom-plugin-monitors is required"))
}
}
// SetNodeNameOrDie sets `NodeName` field with valid value.