Clear alpha MountPropagation fields.

According to api_changes.md, alpha fields must be cleared when corresponding
feature is disabled.
This commit is contained in:
Jan Safranek
2017-09-04 10:40:54 +02:00
parent 156c4b443b
commit 876109a53c
3 changed files with 23 additions and 0 deletions

View File

@@ -243,4 +243,20 @@ func DropDisabledAlphaFields(podSpec *api.PodSpec) {
}
}
}
for i := range podSpec.Containers {
DropDisabledVolumeMountsAlphaFields(podSpec.Containers[i].VolumeMounts)
}
for i := range podSpec.InitContainers {
DropDisabledVolumeMountsAlphaFields(podSpec.InitContainers[i].VolumeMounts)
}
}
// DropDisabledVolumeMountsAlphaFields removes disabled fields from []VolumeMount.
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a VolumeMount
func DropDisabledVolumeMountsAlphaFields(volumeMounts []api.VolumeMount) {
if !utilfeature.DefaultFeatureGate.Enabled(features.MountPropagation) {
for i := range volumeMounts {
volumeMounts[i].MountPropagation = nil
}
}
}