vendor update for CSI 0.3.0

This commit is contained in:
gman
2018-07-18 16:47:22 +02:00
parent 6f484f92fc
commit 8ea659f0d5
6810 changed files with 438061 additions and 193861 deletions

View File

@ -17,12 +17,23 @@ limitations under the License.
package hostpath
import (
"fmt"
"github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/golang/glog"
"github.com/kubernetes-csi/drivers/pkg/csi-common"
)
const (
kib int64 = 1024
mib int64 = kib * 1024
gib int64 = mib * 1024
gib100 int64 = gib * 100
tib int64 = gib * 1024
tib100 int64 = tib * 100
)
type hostPath struct {
driver *csicommon.CSIDriver
@ -34,11 +45,24 @@ type hostPath struct {
cscap []*csi.ControllerServiceCapability
}
type hostPathVolume struct {
VolName string `json:"volName"`
VolID string `json:"volID"`
VolSize int64 `json:"volSize"`
VolPath string `json:"volPath"`
}
var hostPathVolumes map[string]hostPathVolume
var (
hostPathDriver *hostPath
vendorVersion = "0.2.0"
vendorVersion = "0.3.0"
)
func init() {
hostPathVolumes = map[string]hostPathVolume{}
}
func GetHostPathDriver() *hostPath {
return &hostPath{}
}
@ -81,3 +105,19 @@ func (hp *hostPath) Run(driverName, nodeID, endpoint string) {
s.Start(endpoint, hp.ids, hp.cs, hp.ns)
s.Wait()
}
func getVolumeByID(volumeID string) (hostPathVolume, error) {
if hostPathVol, ok := hostPathVolumes[volumeID]; ok {
return hostPathVol, nil
}
return hostPathVolume{}, fmt.Errorf("volume id %s does not exit in the volumes list", volumeID)
}
func getVolumeByName(volName string) (hostPathVolume, error) {
for _, hostPathVol := range hostPathVolumes {
if hostPathVol.VolName == volName {
return hostPathVol, nil
}
}
return hostPathVolume{}, fmt.Errorf("volume name %s does not exit in the volumes list", volName)
}