Prechádzať zdrojové kódy

api: Improve error on ContainerCreate with multiple endpoints

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Albin Kerouanton 1 rok pred
rodič
commit
5e15ed314b

+ 1 - 1
api/server/router/container/container_routes.go

@@ -615,7 +615,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
 			for k := range networkingConfig.EndpointsConfig {
 				l = append(l, k)
 			}
-			return errdefs.InvalidParameter(errors.Errorf("Container cannot be connected to network endpoints: %s", strings.Join(l, ", ")))
+			return errdefs.InvalidParameter(errors.Errorf("Container cannot be created with multiple network endpoints: %s", strings.Join(l, ", ")))
 		}
 	}
 

+ 3 - 3
integration/container/create_test.go

@@ -588,16 +588,16 @@ func TestCreateInvalidHostConfig(t *testing.T) {
 }
 
 func TestCreateWithMultipleEndpointSettings(t *testing.T) {
-	defer setupTest(t)()
-	ctx := context.Background()
+	ctx := setupTest(t)
 
 	testcases := []struct {
 		apiVersion  string
 		expectedErr string
 	}{
 		{apiVersion: "1.44"},
-		{apiVersion: "1.43", expectedErr: "Container cannot be connected to network endpoints"},
+		{apiVersion: "1.43", expectedErr: "Container cannot be created with multiple network endpoints"},
 	}
+
 	for _, tc := range testcases {
 		t.Run("with API v"+tc.apiVersion, func(t *testing.T) {
 			apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(tc.apiVersion))