Skip to content

Commit

Permalink
do input validation before creating CRD
Browse files Browse the repository at this point in the history
moved the snapshotnameprefix validation
before creating the CRD. this will help
us to catch the invalid CLI args ASAP.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Jul 22, 2019
1 parent 1454b6e commit ab2994d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cmd/csi-snapshotter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ab2994d

Please sign in to comment.