Skip to content

Commit

Permalink
fix: storing execution parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
  • Loading branch information
vsukhin committed Feb 11, 2025
1 parent 68ccbff commit bd8a06f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
10 changes: 9 additions & 1 deletion api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9921,13 +9921,21 @@ components:
value:
type: string
description: configuration value
emptyValue:
type: boolean
description: configuration value is empty
defaultValue:
type: string
description: configuration value default
emptyDefaultValue:
type: boolean
description: configuration value default is empty
truncated:
type: boolean
description: indicates if the value is truncated

sensitive:
type: boolean
description: marks value as sensitive

TestWorkflowConfigValue:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ package testkube
type TestWorkflowExecutionConfigValue struct {
// configuration value
Value string `json:"value,omitempty"`
// configuration value is empty
EmptyValue bool `json:"emptyValue,omitempty"`
// configuration value default
DefaultValue string `json:"defaultValue,omitempty"`
// configuration value default is empty
EmptyDefaultValue bool `json:"emptyDefaultValue,omitempty"`
// indicates if the value is truncated
Truncated bool `json:"truncated,omitempty"`
// marks value as sensitive
Sensitive bool `json:"sensitive,omitempty"`
}
41 changes: 23 additions & 18 deletions pkg/repository/testworkflow/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,32 @@ func populateConfigParams(resolvedWorkflow *testkube.TestWorkflow, configParams

for k, v := range resolvedWorkflow.Spec.Config {
if v.Sensitive {
return nil
configParams[k] = testkube.TestWorkflowExecutionConfigValue{
Sensitive: true,
}

continue
}
if v.Default_ != nil {
if _, ok := configParams[k]; !ok {
configParams[k] = testkube.TestWorkflowExecutionConfigValue{
DefaultValue: v.Default_.Value,
}
} else {
value := configParams[k].Value
truncated := false
if len(value) > configParamSizeLimit {
value = value[:configParamSizeLimit]
truncated = true
}
configParams[k] = testkube.TestWorkflowExecutionConfigValue{
DefaultValue: v.Default_.Value,
Value: value,
Truncated: truncated,
}

if _, ok := configParams[k]; !ok {
configParams[k] = testkube.TestWorkflowExecutionConfigValue{
EmptyValue: true,
}
}

data := configParams[k]
if len(data.Value) > configParamSizeLimit {
data.Value = data.Value[:configParamSizeLimit]
data.Truncated = true
}

if v.Default_ != nil {
data.DefaultValue = v.Default_.Value
} else {
data.EmptyDefaultValue = true
}

configParams[k] = data
}

return configParams
Expand Down
9 changes: 1 addition & 8 deletions pkg/testworkflows/testworkflowexecutor/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,7 @@ func (s *scheduler) Schedule(ctx context.Context, sensitiveDataHandler Sensitive
intermediate = append(intermediate, current)

// Inject configuration
storeConfig := true
schema := workflow.Spec.Config
for k := range v.Config {
if s, ok := schema[k]; ok && s.Sensitive {
storeConfig = false
}
}
if storeConfig && testworkflows.CountMapBytes(v.Config) < ConfigSizeLimit {
if testworkflows.CountMapBytes(v.Config) < ConfigSizeLimit {
current.StoreConfig(v.Config)
}

Expand Down

0 comments on commit bd8a06f

Please sign in to comment.