diff --git a/cmd/tcl/testworkflow-toolkit/spawn/utils.go b/cmd/tcl/testworkflow-toolkit/spawn/utils.go index df3cf93ed24..75713eb6794 100644 --- a/cmd/tcl/testworkflow-toolkit/spawn/utils.go +++ b/cmd/tcl/testworkflow-toolkit/spawn/utils.go @@ -33,6 +33,7 @@ import ( "github.com/kubeshop/testkube/pkg/api/v1/testkube" "github.com/kubeshop/testkube/pkg/expressions" "github.com/kubeshop/testkube/pkg/testworkflows/testworkflowcontroller" + "github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor" "github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/constants" ) @@ -173,6 +174,7 @@ func ProcessFetch(transferSrv transfer.Server, fetch []testworkflowsv1.StepParal Env: []corev1.EnvVar{ {Name: "TK_NS", Value: env.Namespace()}, {Name: "TK_REF", Value: env.Ref()}, + testworkflowprocessor.BypassToolkitCheck, }, Args: &result, }, diff --git a/pkg/testworkflows/testworkflowprocessor/utils.go b/pkg/testworkflows/testworkflowprocessor/utils.go index 58e475fb03f..cd0fa239e7a 100644 --- a/pkg/testworkflows/testworkflowprocessor/utils.go +++ b/pkg/testworkflows/testworkflowprocessor/utils.go @@ -10,9 +10,15 @@ import ( "github.com/kubeshop/testkube/internal/common" "github.com/kubeshop/testkube/pkg/expressions" + "github.com/kubeshop/testkube/pkg/rand" "github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/constants" ) +var BypassToolkitCheck = corev1.EnvVar{ + Name: "TK_TC_SECURITY", + Value: rand.String(20), +} + func AnnotateControlledBy(obj metav1.Object, rootId, id string) { labels := obj.GetLabels() if labels == nil { @@ -122,8 +128,12 @@ func buildKubernetesContainers(stage Stage, init *initProcess, fsGroup *int64, m init.ResetResults() } + bypass := false refEnvVar := "" for _, e := range cr.Env { + if e.Name == BypassToolkitCheck.Name && e.Value == BypassToolkitCheck.Value { + bypass = true + } if e.Name == "TK_REF" { refEnvVar = e.Value } @@ -135,7 +145,7 @@ func buildKubernetesContainers(stage Stage, init *initProcess, fsGroup *int64, m SetCommand(cr.Command...). SetArgs(cr.Args...). SetWorkingDir(cr.WorkingDir). - SetToolkit(cr.Image == constants.DefaultToolkitImage && c.Ref() == refEnvVar) + SetToolkit(bypass || (cr.Image == constants.DefaultToolkitImage && c.Ref() == refEnvVar)) for _, env := range cr.Env { if strings.Contains(env.Value, "{{") {