Skip to content

Commit

Permalink
passing request args
Browse files Browse the repository at this point in the history
  • Loading branch information
exu committed Jan 25, 2022
1 parent 943827f commit 3e330c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions cmd/kubectl-testkube/commands/scripts/executions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions internal/app/api/v1/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3e330c7

Please sign in to comment.