MCPcopy
hub / github.com/docker/compose / hasNetworkMismatch

Method hasNetworkMismatch

pkg/compose/reconcile.go:602–623  ·  view source on GitHub ↗

hasNetworkMismatch checks if the container is not connected to all expected networks.

(expected types.ServiceConfig, oc ObservedContainer)

Source from the content-addressed store, hash-verified

600
601// hasNetworkMismatch checks if the container is not connected to all expected networks.
602func (r *reconciler) hasNetworkMismatch(expected types.ServiceConfig, oc ObservedContainer) bool {
603 for _, net := range sortedKeys(expected.Networks) {
604 expectedID := ""
605 if obs, ok := r.observed.Networks[net]; ok {
606 expectedID = obs.ID
607 }
608 if expectedID == "" || expectedID == "swarm" {
609 continue
610 }
611 found := false
612 for _, netID := range oc.ConnectedNetworks {
613 if netID == expectedID {
614 found = true
615 break
616 }
617 }
618 if !found {
619 return true
620 }
621 }
622 return false
623}
624
625// hasVolumeMismatch checks if the container is missing any expected volume mounts.
626func (r *reconciler) hasVolumeMismatch(expected types.ServiceConfig, oc ObservedContainer) bool {

Callers 1

mustRecreateMethod · 0.95

Calls 1

sortedKeysFunction · 0.85

Tested by

no test coverage detected