mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
Fix driver name as per CSI spec
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
@ -20,18 +20,21 @@ import (
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/container-storage-interface/spec/lib/go/csi/v0"
|
||||
"github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// PluginFolder is the kubelet plugin directory for cephfs plugin
|
||||
PluginFolder = "/var/lib/kubelet/plugins/csi-cephfsplugin"
|
||||
// Version of the cephfs csi driver
|
||||
Version = "0.3.0"
|
||||
)
|
||||
|
||||
var (
|
||||
// PluginFolder is the kubelet plugin directory for cephfs plugin
|
||||
PluginFolder = "/var/lib/kubelet/plugins/"
|
||||
)
|
||||
|
||||
type cephfsDriver struct {
|
||||
driver *csicommon.CSIDriver
|
||||
|
||||
|
@ -23,12 +23,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
cephRootPrefix = PluginFolder + "/controller/volumes/root-"
|
||||
cephVolumesRoot = "csi-volumes"
|
||||
|
||||
namespacePrefix = "ns-"
|
||||
)
|
||||
|
||||
var (
|
||||
cephRootPrefix = PluginFolder + "/controller/volumes/root-"
|
||||
)
|
||||
|
||||
func getCephRootPathLocal(volId volumeID) string {
|
||||
return cephRootPrefix + string(volId)
|
||||
}
|
||||
|
@ -21,20 +21,23 @@ import (
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
"github.com/container-storage-interface/spec/lib/go/csi/v0"
|
||||
"github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
"k8s.io/kubernetes/pkg/util/nsenter"
|
||||
"k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
// PluginFolder defines the location of rbdplugin
|
||||
const (
|
||||
PluginFolder = "/var/lib/kubelet/plugins/csi-rbdplugin"
|
||||
rbdDefaultAdminId = "admin"
|
||||
rbdDefaultUserId = rbdDefaultAdminId
|
||||
)
|
||||
|
||||
var (
|
||||
// PluginFolder defines the location of rbdplugin
|
||||
PluginFolder = "/var/lib/kubelet/plugins/"
|
||||
)
|
||||
|
||||
type rbd struct {
|
||||
driver *csicommon.CSIDriver
|
||||
|
||||
|
41
pkg/util/util.go
Normal file
41
pkg/util/util.go
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
)
|
||||
|
||||
// ValidateDriverName validates the driver name
|
||||
func ValidateDriverName(driverName string) error {
|
||||
if len(driverName) == 0 {
|
||||
return errors.New("driver name is empty")
|
||||
}
|
||||
|
||||
if len(driverName) > 63 {
|
||||
return errors.New("driver name length should be less than 63 chars")
|
||||
}
|
||||
var err error
|
||||
for _, msg := range validation.IsDNS1123Subdomain(strings.ToLower(driverName)) {
|
||||
if err == nil {
|
||||
err = errors.New(msg)
|
||||
continue
|
||||
}
|
||||
err = errors.Wrap(err, msg)
|
||||
}
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user