Просмотр исходного кода

add update image batch endpoint

Alexander Belanger 4 лет назад
Родитель
Сommit
38aee8eb33
3 измененных файлов с 33 добавлено и 6 удалено
  1. 1 5
      api/client/deploy.go
  2. 31 0
      api/server/router/release.go
  3. 1 1
      docs/developing/backend-refactor-status.md

+ 1 - 5
api/client/deploy.go

@@ -95,11 +95,7 @@ func (c *Client) UpdateBatchImage(
 
 	req, err := http.NewRequest(
 		"POST",
-		fmt.Sprintf("%s/projects/%d/releases/image/update/batch?"+url.Values{
-			"cluster_id": []string{fmt.Sprintf("%d", clusterID)},
-			"namespace":  []string{namespace},
-			"storage":    []string{"secret"},
-		}.Encode(), c.BaseURL, projID),
+		fmt.Sprintf("%s/projects/%d/clusters/%d/namespaces/%s/releases/image/batch", c.BaseURL, projID, clusterID, namespace),
 		strings.NewReader(string(data)),
 	)
 

+ 31 - 0
api/server/router/release.go

@@ -444,5 +444,36 @@ func getReleaseRoutes(
 		Router:   r,
 	})
 
+	// POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/image/batch ->
+	// release.NewUpdateImageBatchHandler
+	updateImageBatchEndpoint := factory.NewAPIEndpoint(
+		&types.APIRequestMetadata{
+			Verb:   types.APIVerbUpdate,
+			Method: types.HTTPVerbPost,
+			Path: &types.Path{
+				Parent:       basePath,
+				RelativePath: "/releases/image/batch",
+			},
+			Scopes: []types.PermissionScope{
+				types.UserScope,
+				types.ProjectScope,
+				types.ClusterScope,
+				types.NamespaceScope,
+			},
+		},
+	)
+
+	updateImageBatchHandler := release.NewUpgradeReleaseHandler(
+		config,
+		factory.GetDecoderValidator(),
+		factory.GetResultWriter(),
+	)
+
+	routes = append(routes, &Route{
+		Endpoint: updateImageBatchEndpoint,
+		Handler:  updateImageBatchHandler,
+		Router:   r,
+	})
+
 	return routes, newPath
 }

+ 1 - 1
docs/developing/backend-refactor-status.md

@@ -124,7 +124,7 @@
 | <li>- [X] `GET /api/projects/{project_id}/registries/{registry_id}/repositories/*`                                          | AB          |                 |             |                  |
 | <li>- [X] `POST /api/projects/{project_id}/registries/{registry_id}/repository`                                             | AB          |                 |             |                  |
 | <li>- [x] `GET /api/projects/{project_id}/releases`                                                                         | AS          | yes             |             | yes              |
-| <li>- [ ] `POST /api/projects/{project_id}/releases/image/update/batch`                                                     |             |                 |             |                  |
+| <li>- [X] `POST /api/projects/{project_id}/releases/image/update/batch`                                                     | AB          |                 |             |                  |
 | <li>- [X] `GET /api/projects/{project_id}/releases/{name}/history`                                                          | AB          |                 |             |                  |
 | <li>- [X] `POST /api/projects/{project_id}/releases/{name}/notifications`                                                   | AB          |                 |             |                  |
 | <li>- [X] `GET /api/projects/{project_id}/releases/{name}/notifications`                                                    | AB          |                 |             |                  |