Skip to content

Commit

Permalink
feat: move runnng context to tcl
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin committed Oct 16, 2024
1 parent f91bb1b commit 6f2ac47
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
15 changes: 0 additions & 15 deletions pkg/mapper/cdevents/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,21 +423,6 @@ func MapTestkubeRunningContextTypeToCDEventTiggerType(contextType string) string
return "other"
}

// MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType maps OpenAPI spec Test Workflow Running Context Actor to CDEvent Trigger Type
func MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(actor testkube.TestWorkflowRunningContextActorType) string {
switch actor {
case testkube.USER_TestWorkflowRunningContextActorType, testkube.PROGRAM_TestWorkflowRunningContextActorType:
return "manual"
case testkube.TESTWORKFLOW_TestWorkflowRunningContextActorType, testkube.TESTWORKFLOWEXECUTION_TestWorkflowRunningContextActorType,
testkube.TESTRIGGER_TestWorkflowRunningContextActorType:
return "event"
case testkube.CRON_TestWorkflowRunningContextActorType:
return "schedule"
}

return "other"
}

// MapTestkubeTestTypeToCDEventTestCaseType maps OpenAPI spec Test Type to CDEvent Test Case Type
func MapTestkubeTestTypeToCDEventTestCaseType(testType string) string {
var types = map[string]string{
Expand Down
18 changes: 18 additions & 0 deletions pkg/tcl/testworkflowstcl/mapper/cdevents.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mapper

import "github.com/kubeshop/testkube/pkg/api/v1/testkube"

// MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType maps OpenAPI spec Test Workflow Running Context Actor to CDEvent Trigger Type
func MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(actor testkube.TestWorkflowRunningContextActorType) string {
switch actor {
case testkube.USER_TestWorkflowRunningContextActorType, testkube.PROGRAM_TestWorkflowRunningContextActorType:
return "manual"
case testkube.TESTWORKFLOW_TestWorkflowRunningContextActorType, testkube.TESTWORKFLOWEXECUTION_TestWorkflowRunningContextActorType,
testkube.TESTRIGGER_TestWorkflowRunningContextActorType:
return "event"
case testkube.CRON_TestWorkflowRunningContextActorType:
return "schedule"
}

return "other"
}
18 changes: 18 additions & 0 deletions pkg/tcl/testworkflowstcl/triggers/executor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package triggers

import (
"github.com/kubeshop/testkube/internal/common"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
)

func GetRunningContext(name string) *testkube.TestWorkflowRunningContext {
return &testkube.TestWorkflowRunningContext{
Interface_: &testkube.TestWorkflowRunningContextInterface{
Type_: common.Ptr(testkube.INTERNAL_TestWorkflowRunningContextInterfaceType),
},
Actor: &testkube.TestWorkflowRunningContextActor{
Name: name,
Type_: common.Ptr(testkube.TESTRIGGER_TestWorkflowRunningContextActorType),
},
}
}

0 comments on commit 6f2ac47

Please sign in to comment.