MCPcopy
hub / github.com/moby/moby / validateNetworkingConfig

Method validateNetworkingConfig

daemon/create.go:371–395  ·  view source on GitHub ↗

validateNetworkingConfig checks whether a container's NetworkingConfig is valid.

(nwConfig *networktypes.NetworkingConfig)

Source from the content-addressed store, hash-verified

369
370// validateNetworkingConfig checks whether a container's NetworkingConfig is valid.
371func (daemon *Daemon) validateNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error {
372 if nwConfig == nil {
373 return nil
374 }
375
376 var errs []error
377 for k, v := range nwConfig.EndpointsConfig {
378 if v == nil {
379 errs = append(errs, fmt.Errorf("invalid config for network %s: EndpointsConfig is nil", k))
380 continue
381 }
382
383 // The referenced network k might not exist when the container is created, so just ignore the error in that case.
384 nw, _ := daemon.FindNetwork(k)
385 if err := validateEndpointSettings(nw, k, v); err != nil {
386 errs = append(errs, fmt.Errorf("invalid config for network %s: %w", k, err))
387 }
388 }
389
390 if len(errs) > 0 {
391 return errdefs.InvalidParameter(multierror.Join(errs...))
392 }
393
394 return nil
395}
396
397// maximumSpec returns the distribution platform with maximum compatibility for the current node.
398func maximumSpec() ocispec.Platform {

Callers 1

containerCreateMethod · 0.95

Calls 5

FindNetworkMethod · 0.95
InvalidParameterFunction · 0.92
JoinFunction · 0.92
validateEndpointSettingsFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected