Skip to content

Commit

Permalink
fix: [TKC-3010] Change Execution config model
Browse files Browse the repository at this point in the history
  • Loading branch information
povilasv committed Dec 17, 2024
1 parent d642b54 commit 1985fb2
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 20 deletions.
22 changes: 20 additions & 2 deletions api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8244,7 +8244,7 @@ components:
description: running context for the test workflow execution (Pro edition only)
$ref: "#/components/schemas/TestWorkflowRunningContext"
config:
$ref: "#/components/schemas/TestWorkflowConfigValue"
$ref: "#/components/schemas/TestWorkflowExecutionConfig"
required:
- id
- name
Expand Down Expand Up @@ -8283,7 +8283,7 @@ components:
description: running context for the test workflow execution (Pro edition only)
$ref: "#/components/schemas/TestWorkflowRunningContext"
config:
$ref: "#/components/schemas/TestWorkflowConfigValue"
$ref: "#/components/schemas/TestWorkflowExecutionConfig"
required:
- id
- name
Expand Down Expand Up @@ -9518,6 +9518,24 @@ components:
items:
$ref: "#/components/schemas/VolumeMount"

TestWorkflowExecutionConfig:
type: object
description: map of configuration values used in the test workflow execution
additionalProperties:
$ref: "#/components/schemas/TestWorkflowExecutionConfigValue"

TestWorkflowExecutionConfigValue:
type: object
description: configuration values used in the test workflow execution
properties:
value:
type: string
description: configuration value
defaultValue:
type: string
description: configuration value default


TestWorkflowConfigValue:
type: object
description: configuration values to pass to the template
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/v1/testkube/model_test_workflow_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type TestWorkflowExecution struct {
// test workflow execution name started the test workflow execution
TestWorkflowExecutionName string `json:"testWorkflowExecutionName,omitempty"`
// whether webhooks on the execution of this test workflow are disabled
DisableWebhooks bool `json:"disableWebhooks,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
RunningContext *TestWorkflowRunningContext `json:"runningContext,omitempty"`
Config map[string]string `json:"config,omitempty"`
DisableWebhooks bool `json:"disableWebhooks,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
RunningContext *TestWorkflowRunningContext `json:"runningContext,omitempty"`
Config map[string]TestWorkflowExecutionConfigValue `json:"config,omitempty"`
}
18 changes: 18 additions & 0 deletions pkg/api/v1/testkube/model_test_workflow_execution_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Testkube API
*
* Testkube provides a Kubernetes-native framework for test definition, execution and results
*
* API version: 1.0.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package testkube

// configuration values used in the test workflow execution
type TestWorkflowExecutionConfig struct {
// configuration value
Value string `json:"value,omitempty"`
// configuration value
DefaultValue string `json:"defaultValue,omitempty"`
}
18 changes: 18 additions & 0 deletions pkg/api/v1/testkube/model_test_workflow_execution_config_value.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Testkube API
*
* Testkube provides a Kubernetes-native framework for test definition, execution and results
*
* API version: 1.0.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package testkube

// configuration values used in the test workflow execution
type TestWorkflowExecutionConfigValue struct {
// configuration value
Value string `json:"value,omitempty"`
// configuration value default
DefaultValue string `json:"defaultValue,omitempty"`
}
12 changes: 6 additions & 6 deletions pkg/api/v1/testkube/model_test_workflow_execution_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ type TestWorkflowExecutionSummary struct {
// when the execution has been scheduled to run
ScheduledAt time.Time `json:"scheduledAt,omitempty"`
// when the execution result's status has changed last time (queued, passed, failed)
StatusAt time.Time `json:"statusAt,omitempty"`
Result *TestWorkflowResultSummary `json:"result,omitempty"`
Workflow *TestWorkflowSummary `json:"workflow"`
Tags map[string]string `json:"tags,omitempty"`
RunningContext *TestWorkflowRunningContext `json:"runningContext,omitempty"`
Config map[string]string `json:"config,omitempty"`
StatusAt time.Time `json:"statusAt,omitempty"`
Result *TestWorkflowResultSummary `json:"result,omitempty"`
Workflow *TestWorkflowSummary `json:"workflow"`
Tags map[string]string `json:"tags,omitempty"`
RunningContext *TestWorkflowRunningContext `json:"runningContext,omitempty"`
Config map[string]TestWorkflowExecutionConfigValue `json:"config,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ type TestWorkflowStepExecuteTestWorkflowRef struct {
ExecutionName string `json:"executionName,omitempty"`
Tarball map[string]TestWorkflowTarballRequest `json:"tarball,omitempty"`
Config map[string]string `json:"config,omitempty"`
Selector *LabelSelector `json:"selector,omitempty"`
Count *BoxedString `json:"count,omitempty"`
MaxCount *BoxedString `json:"maxCount,omitempty"`
// matrix of parameters to spawn instances
Matrix map[string]interface{} `json:"matrix,omitempty"`
// parameters that should be distributed across sharded instances
Shards map[string]interface{} `json:"shards,omitempty"`
Selector *LabelSelector `json:"selector,omitempty"`
Shards map[string]interface{} `json:"shards,omitempty"`
}
11 changes: 5 additions & 6 deletions pkg/testworkflows/testworkflowexecutor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,19 @@ func (e *executor) initialize(ctx context.Context, workflow *testworkflowsv1.Tes
if testworkflows.CountMapBytes(request.Config) < ConfigSizeLimit {
storeConfig := true
schema := workflow.Spec.Config
config := make(map[string]string)
for k, v := range schema {
config := make(map[string]testkube.TestWorkflowExecutionConfigValue)
for _, v := range schema {
if v.Sensitive {
storeConfig = false
break
}
if v.Default != nil {
config[k] = v.Default.String()
}
}

for k, v := range request.Config {
if _, ok := schema[k]; ok {
config[k] = v
config[k] = testkube.TestWorkflowExecutionConfigValue{
Value: v,
}
}
}

Expand Down

0 comments on commit 1985fb2

Please sign in to comment.