Skip to content

Commit

Permalink
fix: pass pvc names
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin committed Dec 16, 2024
1 parent c83e10b commit 3520a1a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmd/tcl/testworkflow-toolkit/commands/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func NewParallelCmd() *cobra.Command {
testworkflowconfig.CreateResourceMachine(&cfg.Resource),
testworkflowconfig.CreateWorkerMachine(&cfg.Worker),
baseMachine,
testworkflowconfig.CreatePvcMachine(cfg.Execution.Pvcs),

Check failure on line 208 in cmd/tcl/testworkflow-toolkit/commands/parallel.go

View workflow job for this annotation

GitHub Actions / Lint Go

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 208 in cmd/tcl/testworkflow-toolkit/commands/parallel.go

View workflow job for this annotation

GitHub Actions / Lint Go

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 208 in cmd/tcl/testworkflow-toolkit/commands/parallel.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 208 in cmd/tcl/testworkflow-toolkit/commands/parallel.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 208 in cmd/tcl/testworkflow-toolkit/commands/parallel.go

View workflow job for this annotation

GitHub Actions / Integration Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 208 in cmd/tcl/testworkflow-toolkit/commands/parallel.go

View workflow job for this annotation

GitHub Actions / Integration Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)
params.MachineAt(index),
)

Expand Down
1 change: 1 addition & 0 deletions cmd/tcl/testworkflow-toolkit/commands/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func NewServicesCmd() *cobra.Command {
testworkflowconfig.CreateResourceMachine(&cfg.Resource),
testworkflowconfig.CreateWorkerMachine(&cfg.Worker),
baseMachine,
testworkflowconfig.CreatePvcMachine(cfg.Execution.Pvcs),

Check failure on line 264 in cmd/tcl/testworkflow-toolkit/commands/services.go

View workflow job for this annotation

GitHub Actions / Lint Go

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs) (typecheck)

Check failure on line 264 in cmd/tcl/testworkflow-toolkit/commands/services.go

View workflow job for this annotation

GitHub Actions / Lint Go

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)) (typecheck)

Check failure on line 264 in cmd/tcl/testworkflow-toolkit/commands/services.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 264 in cmd/tcl/testworkflow-toolkit/commands/services.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 264 in cmd/tcl/testworkflow-toolkit/commands/services.go

View workflow job for this annotation

GitHub Actions / Integration Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)

Check failure on line 264 in cmd/tcl/testworkflow-toolkit/commands/services.go

View workflow job for this annotation

GitHub Actions / Integration Tests

cfg.Execution.Pvcs undefined (type testworkflowconfig.ExecutionConfig has no field or method Pvcs)
params.MachineAt(index),
)

Expand Down
1 change: 1 addition & 0 deletions pkg/testworkflows/testworkflowconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ExecutionConfig struct {
OrganizationId string `json:"o,omitempty"`
EnvironmentId string `json:"e,omitempty"`
ParentIds string `json:"p,omitempty"`
PvcNames []string `json:"P,omitempty"`
}

type WorkflowConfig struct {
Expand Down
10 changes: 4 additions & 6 deletions pkg/testworkflows/testworkflowconfig/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package testworkflowconfig
import (
"strings"

corev1 "k8s.io/api/core/v1"

"github.com/kubeshop/testkube/pkg/expressions"
)

Expand Down Expand Up @@ -84,15 +82,15 @@ func CreateWorkerMachine(cfg *WorkerConfig) expressions.Machine {
return expressions.CombinedMachines(machine)
}

func CreatePvcMachine(pvcs []corev1.PersistentVolumeClaim) expressions.Machine {
func CreatePvcMachine(pvcNames []string) expressions.Machine {
pvcMap := make(map[string]string)
for _, pvc := range pvcs {
name := pvc.Name
for _, pvcName := range pvcNames {
name := pvcName
if index := strings.LastIndex(name, "-"); index != -1 {
name = name[:index]
}

pvcMap[name+".name"] = pvc.Name
pvcMap[name+".name"] = pvcName
}

return expressions.NewMachine().RegisterStringMap("pvcs", pvcMap)
Expand Down
6 changes: 5 additions & 1 deletion pkg/testworkflows/testworkflowprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ func (p *processor) Bundle(ctx context.Context, workflow *testworkflowsv1.TestWo
createSecretMachine(mapEnv),
testworkflowconfig.CreateWorkerMachine(&options.Config.Worker),
testworkflowconfig.CreateResourceMachine(&options.Config.Resource),
testworkflowconfig.CreatePvcMachine(layer.Pvcs()))
testworkflowconfig.CreatePvcMachine(
common.MapSlice(layer.Pvcs(), func(p corev1.PersistentVolumeClaim) string { return p.Name })),
)

// Fetch resource root and resource ID
if options.Config.Resource.Id == "" {
Expand Down Expand Up @@ -174,6 +176,8 @@ func (p *processor) Bundle(ctx context.Context, workflow *testworkflowsv1.TestWo
return nil, errors.Wrap(err, "finalizing Pvc")
}
}
pvcNames := common.MapSlice(pvcs, func(p corev1.PersistentVolumeClaim) string { return p.Name })
options.Config.Execution.PvcNames = pvcNames

// Finalize Secrets
secrets := append(layer.Secrets(), options.Secrets...)
Expand Down

0 comments on commit 3520a1a

Please sign in to comment.