github.com/kubeshop/testkube@v1.17.23/pkg/tcl/testworkflowstcl/testworkflowprocessor/constants/constants.go (about) 1 // Copyright 2024 Testkube. 2 // 3 // Licensed as a Testkube Pro file under the Testkube Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt 8 9 package constants 10 11 import ( 12 "fmt" 13 "os" 14 "path/filepath" 15 "strings" 16 17 corev1 "k8s.io/api/core/v1" 18 19 testworkflowsv1 "github.com/kubeshop/testkube-operator/api/testworkflows/v1" 20 "github.com/kubeshop/testkube/pkg/version" 21 ) 22 23 const ( 24 DefaultInternalPath = "/.tktw" 25 DefaultDataPath = "/data" 26 DefaultTerminationLogPath = "/dev/termination-log" 27 DefaultFsGroup = int64(1001) 28 ExecutionIdLabelName = "testworkflowid" 29 ExecutionIdMainPodLabelName = "testworkflowid-main" 30 SignatureAnnotationName = "testworkflows.testkube.io/signature" 31 ) 32 33 var ( 34 // DefaultImage has a busybox shell along with utilities, 35 // take in mind that it should not use shared libraries, like busybox:1.36.1 does. 36 // :*-musl or :*-uclibc should be used instead. 37 DefaultImage = "busybox:1.36.1-musl" 38 39 InternalBinPath = filepath.Join(DefaultInternalPath, "bin") 40 DefaultShellPath = filepath.Join(InternalBinPath, "sh") 41 DefaultInitPath = filepath.Join(DefaultInternalPath, "init") 42 DefaultStatePath = filepath.Join(DefaultInternalPath, "state") 43 InitScript = strings.TrimSpace(strings.NewReplacer( 44 "<bin>", InternalBinPath, 45 "<init>", DefaultInitPath, 46 "<state>", DefaultStatePath, 47 "<terminationLog>", DefaultTerminationLogPath, 48 ).Replace(` 49 set -e 50 trap '[ $? -eq 0 ] && exit 0 || echo -n "failed,1" > <terminationLog> && exit 1' EXIT 51 echo "Configuring state..." 52 touch <state> && chmod 777 <state> 53 echo "Configuring init process..." 54 cp /init <init> 55 echo "Configuring shell..." 56 cp -rf /bin /.tktw/bin 57 echo -n ',0' > <terminationLog> && echo 'Done.' && exit 0 58 `)) 59 DefaultShellHeader = "set -e\n" 60 DefaultContainerConfig = testworkflowsv1.ContainerConfig{ 61 Image: DefaultImage, 62 Env: []corev1.EnvVar{ 63 {Name: "CI", Value: "1"}, 64 }, 65 } 66 DefaultInitImage = getInitImage() 67 DefaultToolkitImage = getToolkitImage() 68 ) 69 70 func getInitImage() string { 71 img := os.Getenv("TESTKUBE_TW_INIT_IMAGE") 72 if img == "" { 73 ver := version.Version 74 if ver == "" || ver == "dev" { 75 ver = "latest" 76 } 77 img = fmt.Sprintf("kubeshop/testkube-tw-init:%s", ver) 78 } 79 return img 80 } 81 82 func getToolkitImage() string { 83 img := os.Getenv("TESTKUBE_TW_TOOLKIT_IMAGE") 84 if img == "" { 85 ver := version.Version 86 if ver == "" || ver == "dev" { 87 ver = "latest" 88 } 89 img = fmt.Sprintf("kubeshop/testkube-tw-toolkit:%s", ver) 90 } 91 return img 92 }