diff --git a/api/v1/testkube.yaml b/api/v1/testkube.yaml index 26fafe0525..50079b8db7 100644 --- a/api/v1/testkube.yaml +++ b/api/v1/testkube.yaml @@ -8243,6 +8243,8 @@ components: runningContext: description: running context for the test workflow execution (Pro edition only) $ref: "#/components/schemas/TestWorkflowRunningContext" + config: + $ref: "#/components/schemas/TestWorkflowConfigValue" required: - id - name diff --git a/pkg/api/v1/testkube/model_test_workflow_execution.go b/pkg/api/v1/testkube/model_test_workflow_execution.go index 6fdea115b9..35fdd19bdb 100644 --- a/pkg/api/v1/testkube/model_test_workflow_execution.go +++ b/pkg/api/v1/testkube/model_test_workflow_execution.go @@ -43,4 +43,5 @@ type TestWorkflowExecution struct { DisableWebhooks bool `json:"disableWebhooks,omitempty"` Tags map[string]string `json:"tags,omitempty"` RunningContext *TestWorkflowRunningContext `json:"runningContext,omitempty"` + Config map[string]string `json:"config,omitempty"` } diff --git a/pkg/testworkflows/testworkflowexecutor/executor.go b/pkg/testworkflows/testworkflowexecutor/executor.go index b586b92c36..9a91acd528 100644 --- a/pkg/testworkflows/testworkflowexecutor/executor.go +++ b/pkg/testworkflows/testworkflowexecutor/executor.go @@ -32,6 +32,7 @@ import ( configRepo "github.com/kubeshop/testkube/pkg/repository/config" "github.com/kubeshop/testkube/pkg/repository/testworkflow" "github.com/kubeshop/testkube/pkg/secretmanager" + "github.com/kubeshop/testkube/pkg/testworkflows" "github.com/kubeshop/testkube/pkg/testworkflows/executionworker/controller" "github.com/kubeshop/testkube/pkg/testworkflows/executionworker/executionworkertypes" "github.com/kubeshop/testkube/pkg/testworkflows/testworkflowconfig" @@ -45,6 +46,8 @@ const ( SaveLogsRetryMaxAttempts = 10 SaveLogsRetryBaseDelay = 300 * time.Millisecond + + ConfigSizeLimit = 3 * 1024 * 1024 ) //go:generate mockgen -destination=./mock_executor.go -package=testworkflowexecutor "github.com/kubeshop/testkube/pkg/testworkflows/testworkflowexecutor" TestWorkflowExecutor @@ -467,7 +470,23 @@ func (e *executor) initialize(ctx context.Context, workflow *testworkflowsv1.Tes RunningContext: request.RunningContext, } - // Try to resolve tags initially + // Store the configuration if it is small and not sensitive + if testworkflows.CountMapBytes(request.Config) < ConfigSizeLimit { + storeConfig := true + schema := workflow.Spec.Config + + for k, _ := range request.Config { + if s, ok := schema[k]; ok && s.Sensitive { + storeConfig = false + } + } + + if storeConfig { + execution.Config = request.Config + } + } + + // Try to resolve tags initialily if workflow.Spec.Execution != nil { execution.Tags = workflow.Spec.Execution.Tags } diff --git a/pkg/testworkflows/utils.go b/pkg/testworkflows/utils.go index a3719c87f8..7df6ad52db 100644 --- a/pkg/testworkflows/utils.go +++ b/pkg/testworkflows/utils.go @@ -108,3 +108,12 @@ func GetClusterID(ctx context.Context, configMap configRepo.Repository) string { } return clusterID } + +// CountMapBytes returns the total bytes of the map +func CountMapBytes(m map[string]string) int { + totalBytes := 0 + for k, v := range m { + totalBytes += len(k) + len(v) + } + return totalBytes +}