From a248e2a842366929eadffb3222c1f2c9fc1c23a8 Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Thu, 17 Jan 2019 13:23:11 +0900 Subject: [PATCH] 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. --- cmd/options/options.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/options/options.go b/cmd/options/options.go index 473ed930..4c10ec8c 100644 --- a/cmd/options/options.go +++ b/cmd/options/options.go @@ -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.