mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 03:08:15 +00:00
expand volume.Spec to include full Volume and PV
This commit is contained in:
@@ -60,7 +60,8 @@ func (plugin *hostPathPlugin) Name() string {
|
||||
}
|
||||
|
||||
func (plugin *hostPathPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
return spec.VolumeSource.HostPath != nil || spec.PersistentVolumeSource.HostPath != nil
|
||||
return (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.HostPath != nil) ||
|
||||
(spec.Volume != nil && spec.Volume.HostPath != nil)
|
||||
}
|
||||
|
||||
func (plugin *hostPathPlugin) GetAccessModes() []api.PersistentVolumeAccessMode {
|
||||
@@ -70,14 +71,14 @@ func (plugin *hostPathPlugin) GetAccessModes() []api.PersistentVolumeAccessMode
|
||||
}
|
||||
|
||||
func (plugin *hostPathPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volume.VolumeOptions, _ mount.Interface) (volume.Builder, error) {
|
||||
if spec.VolumeSource.HostPath != nil {
|
||||
if spec.Volume != nil && spec.Volume.HostPath != nil {
|
||||
return &hostPathBuilder{
|
||||
hostPath: &hostPath{path: spec.VolumeSource.HostPath.Path},
|
||||
hostPath: &hostPath{path: spec.Volume.HostPath.Path},
|
||||
readOnly: false,
|
||||
}, nil
|
||||
} else {
|
||||
return &hostPathBuilder{
|
||||
hostPath: &hostPath{path: spec.PersistentVolumeSource.HostPath.Path},
|
||||
hostPath: &hostPath{path: spec.PersistentVolume.Spec.HostPath.Path},
|
||||
readOnly: spec.ReadOnly,
|
||||
}, nil
|
||||
}
|
||||
@@ -92,10 +93,10 @@ func (plugin *hostPathPlugin) NewRecycler(spec *volume.Spec) (volume.Recycler, e
|
||||
}
|
||||
|
||||
func newRecycler(spec *volume.Spec, host volume.VolumeHost) (volume.Recycler, error) {
|
||||
if spec.PersistentVolumeSource.HostPath == nil {
|
||||
if spec.PersistentVolume == nil || spec.PersistentVolume.Spec.HostPath == nil {
|
||||
return nil, fmt.Errorf("spec.PersistentVolumeSource.HostPath is nil")
|
||||
}
|
||||
return &hostPathRecycler{spec.Name, spec.PersistentVolumeSource.HostPath.Path, host}, nil
|
||||
return &hostPathRecycler{spec.Name(), spec.PersistentVolume.Spec.HostPath.Path, host}, nil
|
||||
}
|
||||
|
||||
// HostPath volumes represent a bare host file or directory mount.
|
||||
|
||||
Reference in New Issue
Block a user