From 779c61ecaa91866f5e5651d51d2436561b45b603 Mon Sep 17 00:00:00 2001
From: Povilas Versockas
Date: Mon, 28 Oct 2024 12:43:33 +0200
Subject: [PATCH] fix: [TKC-24240] Remove unused bulk endpoints
---
api/v1/testkube.yaml | 75 --------------------
internal/app/api/v1/server.go | 2 -
internal/app/api/v1/testworkflows.go | 59 ---------------
internal/app/api/v1/testworkflowtemplates.go | 12 ----
4 files changed, 148 deletions(-)
diff --git a/api/v1/testkube.yaml b/api/v1/testkube.yaml
index 2327923163..4df420cb30 100644
--- a/api/v1/testkube.yaml
+++ b/api/v1/testkube.yaml
@@ -3577,44 +3577,6 @@ paths:
type: array
items:
$ref: "#/components/schemas/Problem"
- delete:
- tags:
- - test-workflows
- - api
- - pro
- parameters:
- - $ref: "#/components/parameters/Selector"
- - $ref: "#/components/parameters/TestWorkflowNames"
- summary: Delete test workflows
- description: Delete test workflows from the kubernetes cluster
- operationId: deleteTestWorkflows
- responses:
- 204:
- description: no content
- 400:
- description: "problem with selector parsing - probably some bad input occurs"
- content:
- application/problem+json:
- schema:
- type: array
- items:
- $ref: "#/components/schemas/Problem"
- 402:
- description: "missing Pro subscription for a commercial feature"
- content:
- application/problem+json:
- schema:
- type: array
- items:
- $ref: "#/components/schemas/Problem"
- 502:
- description: problem communicating with kubernetes cluster
- content:
- application/problem+json:
- schema:
- type: array
- items:
- $ref: "#/components/schemas/Problem"
post:
tags:
- test-workflows
@@ -4618,43 +4580,6 @@ paths:
type: array
items:
$ref: "#/components/schemas/Problem"
- delete:
- tags:
- - test-workflows
- - api
- - pro
- parameters:
- - $ref: "#/components/parameters/Selector"
- summary: Delete test workflow templates
- description: Delete test workflow templates from the kubernetes cluster
- operationId: deleteTestWorkflowTemplates
- responses:
- 204:
- description: no content
- 400:
- description: "problem with selector parsing - probably some bad input occurs"
- content:
- application/problem+json:
- schema:
- type: array
- items:
- $ref: "#/components/schemas/Problem"
- 402:
- description: "missing Pro subscription for a commercial feature"
- content:
- application/problem+json:
- schema:
- type: array
- items:
- $ref: "#/components/schemas/Problem"
- 502:
- description: problem communicating with kubernetes cluster
- content:
- application/problem+json:
- schema:
- type: array
- items:
- $ref: "#/components/schemas/Problem"
post:
tags:
- test-workflows
diff --git a/internal/app/api/v1/server.go b/internal/app/api/v1/server.go
index e555f095ec..24ce3ed91c 100644
--- a/internal/app/api/v1/server.go
+++ b/internal/app/api/v1/server.go
@@ -130,7 +130,6 @@ func (s *TestkubeAPI) Init(server server.HTTPServer) {
testWorkflows := root.Group("/test-workflows")
testWorkflows.Get("/", s.ListTestWorkflowsHandler())
testWorkflows.Post("/", s.CreateTestWorkflowHandler())
- testWorkflows.Delete("/", s.DeleteTestWorkflowsHandler())
testWorkflows.Get("/:id", s.GetTestWorkflowHandler())
testWorkflows.Put("/:id", s.UpdateTestWorkflowHandler())
testWorkflows.Delete("/:id", s.DeleteTestWorkflowHandler())
@@ -168,7 +167,6 @@ func (s *TestkubeAPI) Init(server server.HTTPServer) {
testWorkflowTemplates := root.Group("/test-workflow-templates")
testWorkflowTemplates.Get("/", s.ListTestWorkflowTemplatesHandler())
testWorkflowTemplates.Post("/", s.CreateTestWorkflowTemplateHandler())
- testWorkflowTemplates.Delete("/", s.DeleteTestWorkflowTemplatesHandler())
testWorkflowTemplates.Get("/:id", s.GetTestWorkflowTemplateHandler())
testWorkflowTemplates.Put("/:id", s.UpdateTestWorkflowTemplateHandler())
testWorkflowTemplates.Delete("/:id", s.DeleteTestWorkflowTemplateHandler())
diff --git a/internal/app/api/v1/testworkflows.go b/internal/app/api/v1/testworkflows.go
index df995257e1..436a2681e5 100644
--- a/internal/app/api/v1/testworkflows.go
+++ b/internal/app/api/v1/testworkflows.go
@@ -78,65 +78,6 @@ func (s *TestkubeAPI) DeleteTestWorkflowHandler() fiber.Handler {
}
}
-func (s *TestkubeAPI) DeleteTestWorkflowsHandler() fiber.Handler {
- errPrefix := "failed to delete test workflows"
- return func(c *fiber.Ctx) error {
- selector := c.Query("selector")
-
- var (
- workflows *testworkflowsv1.TestWorkflowList
- err error
- )
- testWorkflowNames := c.Query("testWorkflowNames")
- if testWorkflowNames != "" {
- names := strings.Split(testWorkflowNames, ",")
- workflows = &testworkflowsv1.TestWorkflowList{}
- for _, name := range names {
- workflow, err := s.TestWorkflowsClient.Get(name)
- if err != nil {
- return s.ClientError(c, errPrefix, err)
- }
- workflows.Items = append(workflows.Items, *workflow)
- }
- } else {
- workflows, err = s.TestWorkflowsClient.List(selector)
- if err != nil {
- return s.BadGateway(c, errPrefix, "client problem", err)
- }
- }
-
- // Delete
- err = s.TestWorkflowsClient.DeleteByLabels(selector)
- if err != nil {
- return s.ClientError(c, errPrefix, err)
- }
-
- // Mark as deleted
- for range workflows.Items {
- s.Metrics.IncDeleteTestWorkflow(err)
- }
-
- // Delete the executions
- skipExecutions := c.Query("skipDeleteExecutions", "")
- if skipExecutions != "true" {
- names := common.MapSlice(workflows.Items, func(t testworkflowsv1.TestWorkflow) string {
- return t.Name
- })
-
- err = s.TestWorkflowOutput.DeleteOutputForTestWorkflows(context.Background(), names)
- if err != nil {
- return s.ClientError(c, "deleting executions output", err)
- }
- err = s.TestWorkflowResults.DeleteByTestWorkflows(context.Background(), names)
- if err != nil {
- return s.ClientError(c, "deleting executions", err)
- }
- }
-
- return c.SendStatus(http.StatusNoContent)
- }
-}
-
func (s *TestkubeAPI) CreateTestWorkflowHandler() fiber.Handler {
errPrefix := "failed to create test workflow"
return func(c *fiber.Ctx) (err error) {
diff --git a/internal/app/api/v1/testworkflowtemplates.go b/internal/app/api/v1/testworkflowtemplates.go
index 8cefdbbce0..f92f133142 100644
--- a/internal/app/api/v1/testworkflowtemplates.go
+++ b/internal/app/api/v1/testworkflowtemplates.go
@@ -60,18 +60,6 @@ func (s *TestkubeAPI) DeleteTestWorkflowTemplateHandler() fiber.Handler {
}
}
-func (s *TestkubeAPI) DeleteTestWorkflowTemplatesHandler() fiber.Handler {
- errPrefix := "failed to delete test workflow templates"
- return func(c *fiber.Ctx) error {
- selector := c.Query("selector")
- err := s.TestWorkflowTemplatesClient.DeleteByLabels(selector)
- if err != nil {
- return s.ClientError(c, errPrefix, err)
- }
- return c.SendStatus(http.StatusNoContent)
- }
-}
-
func (s *TestkubeAPI) CreateTestWorkflowTemplateHandler() fiber.Handler {
errPrefix := "failed to create test workflow template"
return func(c *fiber.Ctx) (err error) {