mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	refactor logic to override pod fields
This commit is contained in:
		@@ -247,11 +247,7 @@ var EphemeralContainersStrategy = podEphemeralContainersStrategy{Strategy}
 | 
			
		||||
 | 
			
		||||
// dropNonEphemeralContainerUpdates discards all changes except for pod.Spec.EphemeralContainers and certain metadata
 | 
			
		||||
func dropNonEphemeralContainerUpdates(newPod, oldPod *api.Pod) *api.Pod {
 | 
			
		||||
	pod := oldPod.DeepCopy()
 | 
			
		||||
	pod.Name = newPod.Name
 | 
			
		||||
	pod.Namespace = newPod.Namespace
 | 
			
		||||
	pod.ResourceVersion = newPod.ResourceVersion
 | 
			
		||||
	pod.UID = newPod.UID
 | 
			
		||||
	pod := mungePod(newPod, oldPod)
 | 
			
		||||
	pod.Spec.EphemeralContainers = newPod.Spec.EphemeralContainers
 | 
			
		||||
	return pod
 | 
			
		||||
}
 | 
			
		||||
@@ -286,11 +282,7 @@ var ResizeStrategy = podResizeStrategy{Strategy}
 | 
			
		||||
 | 
			
		||||
// dropNonPodResizeUpdates discards all changes except for pod.Spec.Containers[*].Resources,ResizePolicy and certain metadata
 | 
			
		||||
func dropNonPodResizeUpdates(newPod, oldPod *api.Pod) *api.Pod {
 | 
			
		||||
	pod := oldPod.DeepCopy()
 | 
			
		||||
	pod.Name = newPod.Name
 | 
			
		||||
	pod.Namespace = newPod.Namespace
 | 
			
		||||
	pod.ResourceVersion = newPod.ResourceVersion
 | 
			
		||||
	pod.UID = newPod.UID
 | 
			
		||||
	pod := mungePod(newPod, oldPod)
 | 
			
		||||
 | 
			
		||||
	oldCtrToIndex := make(map[string]int)
 | 
			
		||||
	for idx, ctr := range pod.Spec.Containers {
 | 
			
		||||
@@ -329,6 +321,17 @@ func (podResizeStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// mungePod mutates metadata information of old pod with the new pod.
 | 
			
		||||
func mungePod(newPod, oldPod *api.Pod) *api.Pod {
 | 
			
		||||
	pod := oldPod.DeepCopy()
 | 
			
		||||
	pod.Name = newPod.Name
 | 
			
		||||
	pod.Namespace = newPod.Namespace
 | 
			
		||||
	pod.ResourceVersion = newPod.ResourceVersion
 | 
			
		||||
	pod.UID = newPod.UID
 | 
			
		||||
 | 
			
		||||
	return pod
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
 | 
			
		||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
 | 
			
		||||
	pod, ok := obj.(*api.Pod)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user