From 31696a6ce0ca656ba031210e20689e3562561c6c Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 6 Sep 2021 17:50:55 +0530 Subject: [PATCH] cleanup: move genSnapFromOptions to volumeoptions moved genSnapFromOptions function to volumeoptions.go which is more appropriated than util. Signed-off-by: Madhu Rajanna --- internal/cephfs/util.go | 19 ------------------- internal/cephfs/volumeoptions.go | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/cephfs/util.go b/internal/cephfs/util.go index 05834a1c9..42ecb03ce 100644 --- a/internal/cephfs/util.go +++ b/internal/cephfs/util.go @@ -23,7 +23,6 @@ import ( "github.com/ceph/ceph-csi/internal/util" "github.com/ceph/ceph-csi/internal/util/log" - "github.com/container-storage-interface/spec/lib/go/csi" "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/timestamp" ) @@ -36,24 +35,6 @@ func execCommandErr(ctx context.Context, program string, args ...string) error { return err } -func genSnapFromOptions(ctx context.Context, req *csi.CreateSnapshotRequest) (snap *cephfsSnapshot, err error) { - cephfsSnap := &cephfsSnapshot{} - cephfsSnap.RequestName = req.GetName() - snapOptions := req.GetParameters() - - cephfsSnap.Monitors, cephfsSnap.ClusterID, err = util.GetMonsAndClusterID(snapOptions) - if err != nil { - log.ErrorLog(ctx, "failed getting mons (%s)", err) - - return nil, err - } - if namePrefix, ok := snapOptions["snapshotNamePrefix"]; ok { - cephfsSnap.NamePrefix = namePrefix - } - - return cephfsSnap, nil -} - func parseTime(ctx context.Context, createTime time.Time) (*timestamp.Timestamp, error) { tm, err := ptypes.TimestampProto(createTime) if err != nil { diff --git a/internal/cephfs/volumeoptions.go b/internal/cephfs/volumeoptions.go index 3a44cae22..ea62ecbe0 100644 --- a/internal/cephfs/volumeoptions.go +++ b/internal/cephfs/volumeoptions.go @@ -27,6 +27,7 @@ import ( cerrors "github.com/ceph/ceph-csi/internal/cephfs/errors" "github.com/ceph/ceph-csi/internal/util" + "github.com/ceph/ceph-csi/internal/util/log" ) type volumeOptions struct { @@ -586,3 +587,21 @@ func newSnapshotOptionsFromID( return &volOptions, &info, &sid, nil } + +func genSnapFromOptions(ctx context.Context, req *csi.CreateSnapshotRequest) (snap *cephfsSnapshot, err error) { + cephfsSnap := &cephfsSnapshot{} + cephfsSnap.RequestName = req.GetName() + snapOptions := req.GetParameters() + + cephfsSnap.Monitors, cephfsSnap.ClusterID, err = util.GetMonsAndClusterID(snapOptions) + if err != nil { + log.ErrorLog(ctx, "failed getting mons (%s)", err) + + return nil, err + } + if namePrefix, ok := snapOptions["snapshotNamePrefix"]; ok { + cephfsSnap.NamePrefix = namePrefix + } + + return cephfsSnap, nil +}