Simplify verifyNetworkingConfig()
@@ -305,7 +305,14 @@ func verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error {
if nwConfig == nil || len(nwConfig.EndpointsConfig) == 0 {
return nil
}
- if len(nwConfig.EndpointsConfig) == 1 {
+ if len(nwConfig.EndpointsConfig) > 1 {
+ l := make([]string, 0, len(nwConfig.EndpointsConfig))
+ for k := range nwConfig.EndpointsConfig {
+ l = append(l, k)
+ }
+ return errors.Errorf("Container cannot be connected to network endpoints: %s", strings.Join(l, ", "))
+ }
+
for k, v := range nwConfig.EndpointsConfig {
if v == nil {
return errdefs.InvalidParameter(errors.Errorf("no EndpointSettings for %s", k))
@@ -326,9 +333,3 @@ func verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error {
}
return nil
}
- l := make([]string, 0, len(nwConfig.EndpointsConfig))
- for k := range nwConfig.EndpointsConfig {
- l = append(l, k)
- }
- return errors.Errorf("Container cannot be connected to network endpoints: %s", strings.Join(l, ", "))
-}
