Inital Quobyte dynamic provision
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user