MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / compareContainers

Function compareContainers

pkg/specs/podspec_diff.go:264–290  ·  view source on GitHub ↗
(currentContainers, targetContainers []corev1.Container)

Source from the content-addressed store, hash-verified

262}
263
264func compareContainers(currentContainers, targetContainers []corev1.Container) (bool, string) {
265 current := make(map[string]corev1.Container)
266 target := make(map[string]corev1.Container)
267 for _, c := range currentContainers {
268 current[c.Name] = c
269 }
270 for _, c := range targetContainers {
271 target[c.Name] = c
272 }
273 for name, currentContainer := range current {
274 container2, found := target[name]
275 if !found {
276 return false, fmt.Sprintf("container %s has been removed", name)
277 }
278 match, diff := doContainersMatch(currentContainer, container2)
279 if !match {
280 return false, fmt.Sprintf("container %s differs in %s", name, diff)
281 }
282 }
283 for name := range target {
284 _, found := current[name]
285 if !found {
286 return false, fmt.Sprintf("container %s has been added", name)
287 }
288 }
289 return true, ""
290}

Callers 1

ComparePodSpecsFunction · 0.85

Calls 1

doContainersMatchFunction · 0.85

Tested by

no test coverage detected