Skip to content

Commit

Permalink
fix: register 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 12, 2024
1 parent 5417211 commit 597a69a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 21 additions & 1 deletion pkg/testworkflows/testworkflowconfig/expressions.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package testworkflowconfig

import "github.com/kubeshop/testkube/pkg/expressions"
import (
"strings"

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

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

func CreateExecutionMachine(cfg *ExecutionConfig) expressions.Machine {
return expressions.NewMachine().
Expand Down Expand Up @@ -77,3 +83,17 @@ func CreateWorkerMachine(cfg *WorkerConfig) expressions.Machine {
})
return expressions.CombinedMachines(machine)
}

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

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

return expressions.NewMachine().RegisterStringMap("pvcs", pvcMap)
}
3 changes: 2 additions & 1 deletion pkg/testworkflows/testworkflowprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func (p *processor) Bundle(ctx context.Context, workflow *testworkflowsv1.TestWo
machines = append(machines,
createSecretMachine(mapEnv),
testworkflowconfig.CreateWorkerMachine(&options.Config.Worker),
testworkflowconfig.CreateResourceMachine(&options.Config.Resource))
testworkflowconfig.CreateResourceMachine(&options.Config.Resource),
testworkflowconfig.CreatePvcMachine(layer.Pvcs()))

// Fetch resource root and resource ID
if options.Config.Resource.Id == "" {
Expand Down

0 comments on commit 597a69a

Please sign in to comment.