Inital Quobyte dynamic provision

This commit is contained in:
Johannes Scheuermann
2016-08-20 15:39:30 +02:00
parent 00a203df1e
commit 0b7cb5f2ae
9 changed files with 458 additions and 17 deletions

View File

@@ -22,6 +22,7 @@ import (
"path"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/util/mount"
)
@@ -126,3 +127,33 @@ func GetSecret(namespace, secretName string, kubeClient clientset.Interface) (ma
}
return secret, nil
}
// AddVolumeAnnotations adds a golang Map as annotation to a PersistentVolume
func AddVolumeAnnotations(pv *api.PersistentVolume, annotations map[string]string) {
if pv.Annotations == nil {
pv.Annotations = map[string]string{}
}
for k, v := range annotations {
pv.Annotations[k] = v
}
}
// ParseVolumeAnnotations reads the defined annoations from a PersistentVolume
func ParseVolumeAnnotations(pv *api.PersistentVolume, parseAnnotations []string) (map[string]string, error) {
result := map[string]string{}
if pv.Annotations == nil {
return result, fmt.Errorf("cannot parse volume annotations: no annotations found")
}
for _, annotation := range parseAnnotations {
if val, ok := pv.Annotations[annotation]; ok {
result[annotation] = val
} else {
return result, fmt.Errorf("cannot parse volume annotations: annotation %s not found", annotation)
}
}
return result, nil
}