cephfs: newVolumeOptions() does not need all secrets, only credentials

There is no need to pass all secrets on to newVolumeOptions(), it only
needs the credentials. As the caller of newVolumeOptions() already has
the credentials generated, just pass them along instead of the raw
secrets.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-10-01 09:10:10 +02:00 committed by mergify[bot]
parent 66046e4312
commit 9bd10d2698
2 changed files with 2 additions and 8 deletions

View File

@ -151,7 +151,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
} }
defer cs.VolumeLocks.Release(requestName) defer cs.VolumeLocks.Release(requestName)
volOptions, err := newVolumeOptions(ctx, requestName, req, secret) volOptions, err := newVolumeOptions(ctx, requestName, req, cr)
if err != nil { if err != nil {
util.ErrorLog(ctx, "validation and extraction of volume options failed: %v", err) util.ErrorLog(ctx, "validation and extraction of volume options failed: %v", err)
return nil, status.Error(codes.InvalidArgument, err.Error()) return nil, status.Error(codes.InvalidArgument, err.Error())

View File

@ -171,7 +171,7 @@ func getClusterInformation(options map[string]string) (*util.ClusterInfo, error)
// newVolumeOptions generates a new instance of volumeOptions from the provided // newVolumeOptions generates a new instance of volumeOptions from the provided
// CSI request parameters. // CSI request parameters.
func newVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVolumeRequest, func newVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVolumeRequest,
secret map[string]string) (*volumeOptions, error) { cr *util.Credentials) (*volumeOptions, error) {
var ( var (
opts volumeOptions opts volumeOptions
err error err error
@ -210,12 +210,6 @@ func newVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVo
opts.RequestName = requestName opts.RequestName = requestName
cr, err := util.NewAdminCredentials(secret)
if err != nil {
return nil, err
}
defer cr.DeleteCredentials()
err = opts.Connect(cr) err = opts.Connect(cr)
if err != nil { if err != nil {
return nil, err return nil, err