MCPcopy
hub / github.com/kubernetes/kubectl / equalIgnoreHash

Function equalIgnoreHash

pkg/polymorphichelpers/rollback.go:173–180  ·  view source on GitHub ↗

equalIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash] We ignore pod-template-hash because: 1. The hash result would be different upon podTemplateSpec API changes (e.g. the addition of a new field will cause the hash code to chang

(template1, template2 *corev1.PodTemplateSpec)

Source from the content-addressed store, hash-verified

171// (e.g. the addition of a new field will cause the hash code to change)
172// 2. The deployment template won't have hash labels
173func equalIgnoreHash(template1, template2 *corev1.PodTemplateSpec) bool {
174 t1Copy := template1.DeepCopy()
175 t2Copy := template2.DeepCopy()
176 // Remove hash labels from template.Labels before comparing
177 delete(t1Copy.Labels, appsv1.DefaultDeploymentUniqueLabelKey)
178 delete(t2Copy.Labels, appsv1.DefaultDeploymentUniqueLabelKey)
179 return apiequality.Semantic.DeepEqual(t1Copy, t2Copy)
180}
181
182// annotationsToSkip lists the annotations that should be preserved from the deployment and not
183// copied from the replicaset when rolling a deployment back

Callers 1

RollbackMethod · 0.70

Calls 1

DeepCopyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…