mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
cleanup: move genSnapFromOptions to volumeoptions
moved genSnapFromOptions function to volumeoptions.go which is more appropriated than util. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
73e2ffe8b8
commit
31696a6ce0
@ -23,7 +23,6 @@ import (
|
|||||||
"github.com/ceph/ceph-csi/internal/util"
|
"github.com/ceph/ceph-csi/internal/util"
|
||||||
"github.com/ceph/ceph-csi/internal/util/log"
|
"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"
|
||||||
"github.com/golang/protobuf/ptypes/timestamp"
|
"github.com/golang/protobuf/ptypes/timestamp"
|
||||||
)
|
)
|
||||||
@ -36,24 +35,6 @@ func execCommandErr(ctx context.Context, program string, args ...string) error {
|
|||||||
return err
|
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) {
|
func parseTime(ctx context.Context, createTime time.Time) (*timestamp.Timestamp, error) {
|
||||||
tm, err := ptypes.TimestampProto(createTime)
|
tm, err := ptypes.TimestampProto(createTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
|
|
||||||
cerrors "github.com/ceph/ceph-csi/internal/cephfs/errors"
|
cerrors "github.com/ceph/ceph-csi/internal/cephfs/errors"
|
||||||
"github.com/ceph/ceph-csi/internal/util"
|
"github.com/ceph/ceph-csi/internal/util"
|
||||||
|
"github.com/ceph/ceph-csi/internal/util/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type volumeOptions struct {
|
type volumeOptions struct {
|
||||||
@ -586,3 +587,21 @@ func newSnapshotOptionsFromID(
|
|||||||
|
|
||||||
return &volOptions, &info, &sid, nil
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user