github.com/kubeshop/testkube@v1.17.23/pkg/api/v1/testkube/model_test_workflow_extended.go (about) 1 package testkube 2 3 import "github.com/kubeshop/testkube/pkg/utils" 4 5 type TestWorkflows []TestWorkflow 6 7 func (t TestWorkflows) Table() (header []string, output [][]string) { 8 header = []string{"Name", "Description", "Created", "Labels"} 9 for _, e := range t { 10 output = append(output, []string{ 11 e.Name, 12 e.Description, 13 e.Created.String(), 14 MapToString(e.Labels), 15 }) 16 } 17 18 return 19 } 20 21 func convertDotsInMap[T any](m map[string]T, fn func(string) string) map[string]T { 22 result := make(map[string]T) 23 for key, value := range m { 24 result[fn(key)] = value 25 } 26 return result 27 } 28 29 func (w *TestWorkflow) ConvertDots(fn func(string) string) *TestWorkflow { 30 if w == nil { 31 return w 32 } 33 if w.Labels == nil { 34 w.Labels = convertDotsInMap(w.Labels, fn) 35 } 36 if w.Spec.Pod != nil { 37 w.Spec.Pod.Labels = convertDotsInMap(w.Spec.Pod.Labels, fn) 38 w.Spec.Pod.Annotations = convertDotsInMap(w.Spec.Pod.Annotations, fn) 39 w.Spec.Pod.NodeSelector = convertDotsInMap(w.Spec.Pod.NodeSelector, fn) 40 } 41 if w.Spec.Job != nil { 42 w.Spec.Job.Labels = convertDotsInMap(w.Spec.Job.Labels, fn) 43 w.Spec.Job.Annotations = convertDotsInMap(w.Spec.Job.Annotations, fn) 44 } 45 for i := range w.Spec.Use { 46 if w.Spec.Use[i].Config != nil { 47 w.Spec.Use[i].Config = convertDotsInMap(w.Spec.Use[i].Config, fn) 48 } 49 } 50 for i := range w.Spec.Setup { 51 w.Spec.Setup[i].ConvertDots(fn) 52 } 53 for i := range w.Spec.Steps { 54 w.Spec.Steps[i].ConvertDots(fn) 55 } 56 for i := range w.Spec.After { 57 w.Spec.After[i].ConvertDots(fn) 58 } 59 return w 60 } 61 62 func (w *TestWorkflow) EscapeDots() *TestWorkflow { 63 return w.ConvertDots(utils.EscapeDots) 64 } 65 66 func (w *TestWorkflow) UnscapeDots() *TestWorkflow { 67 return w.ConvertDots(utils.UnescapeDots) 68 } 69 70 func (w *TestWorkflow) GetObjectRef() *ObjectRef { 71 return &ObjectRef{ 72 Name: w.Name, 73 Namespace: w.Namespace, 74 } 75 } 76 77 func (w *TestWorkflow) QuoteWorkflowTextFields() { 78 }