IsReadOnly bool on builder

This commit is contained in:
markturansky
2015-06-29 12:54:43 -04:00
parent 124bb22f92
commit fae6759490
15 changed files with 118 additions and 6 deletions

View File

@@ -26,11 +26,12 @@ import (
)
func ProbeVolumePlugins() []volume.VolumePlugin {
return []volume.VolumePlugin{&persistentClaimPlugin{nil}}
return []volume.VolumePlugin{&persistentClaimPlugin{host: nil}}
}
type persistentClaimPlugin struct {
host volume.VolumeHost
host volume.VolumeHost
readOnly bool
}
var _ volume.VolumePlugin = &persistentClaimPlugin{}
@@ -52,6 +53,7 @@ func (plugin *persistentClaimPlugin) CanSupport(spec *volume.Spec) bool {
}
func (plugin *persistentClaimPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, opts volume.VolumeOptions, mounter mount.Interface) (volume.Builder, error) {
plugin.readOnly = spec.ReadOnly
claim, err := plugin.host.GetKubeClient().PersistentVolumeClaims(pod.Namespace).Get(spec.VolumeSource.PersistentVolumeClaim.ClaimName)
if err != nil {
glog.Errorf("Error finding claim: %+v\n", spec.VolumeSource.PersistentVolumeClaim.ClaimName)
@@ -87,6 +89,10 @@ func (plugin *persistentClaimPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod,
return builder, nil
}
func (plugin *persistentClaimPlugin) IsReadOnly() bool {
return plugin.readOnly
}
func (plugin *persistentClaimPlugin) NewCleaner(_ string, _ types.UID, _ mount.Interface) (volume.Cleaner, error) {
return nil, fmt.Errorf("This will never be called directly. The PV backing this claim has a cleaner. Kubelet uses that cleaner, not this one, when removing orphaned volumes.")
}