diff --git a/cmd/kubectl-testkube/commands/scripts/executions.go b/cmd/kubectl-testkube/commands/scripts/executions.go index 6124dd8eb1f..86552ab8042 100644 --- a/cmd/kubectl-testkube/commands/scripts/executions.go +++ b/cmd/kubectl-testkube/commands/scripts/executions.go @@ -12,9 +12,10 @@ func NewListExecutionsCmd() *cobra.Command { var tags []string cmd := &cobra.Command{ - Use: "executions [scriptName]", - Short: "List scripts executions", - Long: `Getting list of execution for given script name or recent executions if there is no script name passed`, + Use: "executions [scriptName]", + Aliases: []string{"el"}, + Short: "List scripts executions", + Long: `Getting list of execution for given script name or recent executions if there is no script name passed`, Run: func(cmd *cobra.Command, args []string) { var scriptID string limit := 10 diff --git a/internal/app/api/v1/tests.go b/internal/app/api/v1/tests.go index e5153425808..ff8577115a7 100644 --- a/internal/app/api/v1/tests.go +++ b/internal/app/api/v1/tests.go @@ -145,9 +145,15 @@ func (s TestKubeAPI) ExecuteTestHandler() fiber.Handler { return s.Error(c, http.StatusBadGateway, err) } + var request testkube.TestExecutionRequest + err = c.BodyParser(&request) + if err != nil { + return s.Error(c, http.StatusBadRequest, fmt.Errorf("test execution request body invalid: %w", err)) + } + test := testsmapper.MapCRToAPI(*crTest) s.Log.Debugw("executing test", "name", name, "test", test, "cr", crTest) - results := s.executeTest(ctx, test) + results := s.executeTest(ctx, request, test) c.Response().SetStatusCode(fiber.StatusCreated) return c.JSON(results) @@ -195,10 +201,12 @@ func (s TestKubeAPI) GetTestExecutionHandler() fiber.Handler { } } -func (s TestKubeAPI) executeTest(ctx context.Context, test testkube.Test) (testExecution testkube.TestExecution) { +func (s TestKubeAPI) executeTest(ctx context.Context, request testkube.TestExecutionRequest, test testkube.Test) (testExecution testkube.TestExecution) { s.Log.Debugw("Got test to execute", "test", test) + // TODO testExecution shold be based on request model testExecution = testkube.NewStartedTestExecution(fmt.Sprintf("%s.%s", test.Name, rand.Name())) + testExecution.Params = request.Params testExecution.Test = &testkube.ObjectRef{ Name: test.Name, Namespace: "testkube", @@ -277,7 +285,7 @@ func (s TestKubeAPI) executeTestStep(ctx context.Context, testExecution testkube return result.Err(err) } - l.Debug("executing script") + l.Debug("executing script", "params", testExecution.Params) options.Sync = true execution := s.executeScript(ctx, options) return newTestStepExecutionResult(execution, executeScriptStep)