Skip to content

Commit

Permalink
fix: [TKC-24240] Remove unused bulk endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
povilasv committed Oct 28, 2024
1 parent c08b9f8 commit 779c61e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 148 deletions.
75 changes: 0 additions & 75 deletions api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions internal/app/api/v1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
59 changes: 0 additions & 59 deletions internal/app/api/v1/testworkflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 0 additions & 12 deletions internal/app/api/v1/testworkflowtemplates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 779c61e

Please sign in to comment.