MCPcopy Create free account
hub / github.com/docker/cli / LoadNetworks

Function LoadNetworks

cli/compose/loader/loader.go:541–568  ·  view source on GitHub ↗

LoadNetworks produces a NetworkConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation

(source map[string]any, version string)

Source from the content-addressed store, hash-verified

539// LoadNetworks produces a NetworkConfig map from a compose file Dict
540// the source Dict is not validated if directly used. Use Load() to enable validation
541func LoadNetworks(source map[string]any, version string) (map[string]types.NetworkConfig, error) {
542 networks := make(map[string]types.NetworkConfig)
543 err := Transform(source, &networks)
544 if err != nil {
545 return networks, err
546 }
547 for name, nw := range networks {
548 if !nw.External.External {
549 continue
550 }
551 switch {
552 case nw.External.Name != "":
553 if nw.Name != "" {
554 return nil, fmt.Errorf("network %s: network.external.name and network.name conflict; only use network.name", name)
555 }
556 if versions.GreaterThanOrEqualTo(version, "3.5") {
557 logrus.Warnf("network %s: network.external.name is deprecated in favor of network.name", name)
558 }
559 nw.Name = nw.External.Name
560 nw.External.Name = ""
561 case nw.Name == "":
562 nw.Name = name
563 }
564 nw.Extras = loadExtras(name, source)
565 networks[name] = nw
566 }
567 return networks, nil
568}
569
570func externalVolumeError(volume, key string) error {
571 return fmt.Errorf(`conflicting parameters "external" and %q specified for volume %q`, key, volume)

Calls 2

TransformFunction · 0.85
loadExtrasFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…