From ab2994d6c3b5dfc7a5bddbe9ca1c3ee18f96d6c0 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 22 Jul 2019 11:49:26 +0530 Subject: [PATCH] do input validation before creating CRD moved the snapshotnameprefix validation before creating the CRD. this will help us to catch the invalid CLI args ASAP. Signed-off-by: Madhu Rajanna --- cmd/csi-snapshotter/main.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index df1b11663..8454fc09d 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -97,6 +97,10 @@ func main() { klog.Warning("--snapshotter is deprecated and will have no effect") } + if len(*snapshotNamePrefix) == 0 { + klog.Error("Snapshot name prefix cannot be of length 0") + os.Exit(1) + } // Create the client config. Use kubeconfig if given, otherwise assume in-cluster. config, err := buildConfig(*kubeconfig) if err != nil { @@ -173,11 +177,6 @@ func main() { os.Exit(1) } - if len(*snapshotNamePrefix) == 0 { - klog.Error("Snapshot name prefix cannot be of length 0") - os.Exit(1) - } - klog.V(2).Infof("Start NewCSISnapshotController with snapshotter [%s] kubeconfig [%s] csiTimeout [%+v] csiAddress [%s] createSnapshotContentRetryCount [%d] createSnapshotContentInterval [%+v] resyncPeriod [%+v] snapshotNamePrefix [%s] snapshotNameUUIDLength [%d]", *snapshotterName, *kubeconfig, *csiTimeout, *csiAddress, createSnapshotContentRetryCount, *createSnapshotContentInterval, *resyncPeriod, *snapshotNamePrefix, snapshotNameUUIDLength) snapShotter := snapshotter.NewSnapshotter(csiConn)