From 448e17dc9352c53bcf49a10baafb949d50cc9ee4 Mon Sep 17 00:00:00 2001 From: Jacek Wysocki Date: Fri, 7 Jan 2022 08:33:20 +0100 Subject: [PATCH] fix: openapi spec for tests (#690) * fix: openapi spec for tests * fix: openapi spec for tests output data * fix: removed unnecessary todo items in code --- api/v1/testkube.yaml | 14 ++++---------- internal/app/api/v1/server.go | 1 - pkg/api/v1/client/direct.go | 2 -- pkg/api/v1/client/proxy.go | 3 --- pkg/executor/client/job.go | 1 - 5 files changed, 4 insertions(+), 17 deletions(-) diff --git a/api/v1/testkube.yaml b/api/v1/testkube.yaml index a354ad04c29..1eafdf3d215 100644 --- a/api/v1/testkube.yaml +++ b/api/v1/testkube.yaml @@ -35,9 +35,6 @@ paths: summary: "Create new test" description: "Create new test action" operationId: createTest - parameters: - - $ref: "#/components/parameters/Tags" - - $ref: "#/components/parameters/TextSearch" requestBody: $ref: "#/components/schemas/TestUpsertRequest" responses: @@ -64,20 +61,17 @@ paths: description: "Returns array of tests" operationId: listTests parameters: - - $ref: "#/components/parameters/TextSearch" - - $ref: "#/components/parameters/PageSize" - - $ref: "#/components/parameters/PageIndex" - - $ref: "#/components/parameters/ExecutionsStatusFilter" - - $ref: "#/components/parameters/StartDateFilter" - - $ref: "#/components/parameters/EndDateFilter" - $ref: "#/components/parameters/Tags" + - $ref: "#/components/parameters/TextSearch" responses: 200: description: successful operation content: application/json: schema: - $ref: "#/components/schemas/Test" + type: array + items: + $ref: "#/components/schemas/Test" 500: description: "problem with getting script executions from storage" content: diff --git a/internal/app/api/v1/server.go b/internal/app/api/v1/server.go index 185568e0056..4b7601ec250 100644 --- a/internal/app/api/v1/server.go +++ b/internal/app/api/v1/server.go @@ -30,7 +30,6 @@ func NewServer( testsClient *testscr.TestsClient, ) TestKubeAPI { - // TODO consider moving to server pkg as some API_HTTPSERVER_ config prefix var httpConfig server.Config envconfig.Process("APISERVER", &httpConfig) diff --git a/pkg/api/v1/client/direct.go b/pkg/api/v1/client/direct.go index ab83bc4f53a..eecc1bc1f76 100644 --- a/pkg/api/v1/client/direct.go +++ b/pkg/api/v1/client/direct.go @@ -172,7 +172,6 @@ func (c DirectScriptsAPI) UpdateScript(options UpsertScriptOptions) (script test // ExecuteScript starts new external script execution, reads data and returns ID // Execution is started asynchronously client can check later for results func (c DirectScriptsAPI) ExecuteScript(id, namespace, executionName string, executionParams map[string]string) (execution testkube.Execution, err error) { - // TODO call executor API - need to get parameters (what executor?) taken from CRD? uri := c.getURI("/scripts/%s/executions", id) // get script to get script tags @@ -601,7 +600,6 @@ func (c DirectScriptsAPI) ListTests(namespace string, tags []string) (tests test // ExecuteTest starts new external test execution, reads data and returns ID func (c DirectScriptsAPI) ExecuteTest(id, namespace, executionName string, executionParams map[string]string) (execution testkube.TestExecution, err error) { - // TODO call executor API - need to get parameters (what executor?) taken from CRD? uri := c.getURI("/tests/%s/executions", id) request := testkube.TestExecutionRequest{ diff --git a/pkg/api/v1/client/proxy.go b/pkg/api/v1/client/proxy.go index a9f4925c76c..eb511b37e32 100644 --- a/pkg/api/v1/client/proxy.go +++ b/pkg/api/v1/client/proxy.go @@ -172,7 +172,6 @@ func (c ProxyScriptsAPI) UpdateScript(options UpsertScriptOptions) (script testk // ExecuteScript starts new external script execution, reads data and returns ID // Execution is started asynchronously client can check later for results func (c ProxyScriptsAPI) ExecuteScript(id, namespace, executionName string, executionParams map[string]string) (execution testkube.Execution, err error) { - // TODO call executor API - need to get parameters (what executor?) taken from CRD? uri := c.getURI("/scripts/%s/executions", id) // get script to get script tags @@ -479,7 +478,6 @@ func (c ProxyScriptsAPI) GetExecutionArtifacts(executionID string) (artifacts te } func (c ProxyScriptsAPI) DownloadFile(executionID, fileName, destination string) (artifact string, err error) { - // TODO consider use Query param for filename uri := c.getURI("/executions/%s/artifacts/%s", executionID, url.QueryEscape(fileName)) req, err := c.GetProxy("GET"). Suffix(uri). @@ -612,7 +610,6 @@ func (c ProxyScriptsAPI) getTestFromResponse(resp rest.Result) (test testkube.Te // ExecuteTest starts new external test execution, reads data and returns ID // Execution is started asynchronously client can check later for results func (c ProxyScriptsAPI) ExecuteTest(id, namespace, executionName string, executionParams map[string]string) (execution testkube.TestExecution, err error) { - // TODO call executor API - need to get parameters (what executor?) taken from CRD? uri := c.getURI("/tests/%s/executions", id) request := testkube.ExecutionRequest{ diff --git a/pkg/executor/client/job.go b/pkg/executor/client/job.go index 12c011c8410..8d17ad884c7 100644 --- a/pkg/executor/client/job.go +++ b/pkg/executor/client/job.go @@ -35,7 +35,6 @@ type JobExecutor struct { // Watch will get valid execution after async Execute, execution will be returned when success or error occurs // Worker should set valid state for success or error after script completion // TODO add timeout -// TODO rethink how to get real time logs func (c JobExecutor) Watch(id string) (events chan ResultEvent) { events = make(chan ResultEvent)