github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/testsuites/renderer/testsuite_obj.go (about) 1 package renderer 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/renderer" 8 "github.com/kubeshop/testkube/pkg/api/v1/client" 9 "github.com/kubeshop/testkube/pkg/api/v1/testkube" 10 "github.com/kubeshop/testkube/pkg/ui" 11 ) 12 13 func TestSuiteRenderer(client client.Client, ui *ui.UI, obj interface{}) error { 14 ts, ok := obj.(testkube.TestSuite) 15 if !ok { 16 return fmt.Errorf("can't use '%T' as testkube.TestSuite in RenderObj for test suite", obj) 17 } 18 19 ui.Warn("Name: ", ts.Name) 20 ui.Warn("Namespace:", ts.Namespace) 21 if ts.Description != "" { 22 ui.NL() 23 ui.Warn("Description: ", ts.Description) 24 } 25 if len(ts.Labels) > 0 { 26 ui.NL() 27 ui.Warn("Labels: ", testkube.MapToString(ts.Labels)) 28 } 29 if ts.Schedule != "" { 30 ui.NL() 31 ui.Warn("Schedule: ", ts.Schedule) 32 } 33 34 if ts.ExecutionRequest != nil { 35 ui.Warn("Execution request: ") 36 if ts.ExecutionRequest.Name != "" { 37 ui.Warn(" Name: ", ts.ExecutionRequest.Name) 38 } 39 40 if len(ts.ExecutionRequest.Variables) > 0 { 41 renderer.RenderVariables(ts.ExecutionRequest.Variables) 42 } 43 44 if ts.ExecutionRequest.HttpProxy != "" { 45 ui.Warn(" Http proxy: ", ts.ExecutionRequest.HttpProxy) 46 } 47 48 if ts.ExecutionRequest.HttpsProxy != "" { 49 ui.Warn(" Https proxy: ", ts.ExecutionRequest.HttpsProxy) 50 } 51 52 if ts.ExecutionRequest.JobTemplate != "" { 53 ui.Warn(" Job template: ", "\n", ts.ExecutionRequest.JobTemplate) 54 } 55 56 if ts.ExecutionRequest.JobTemplateReference != "" { 57 ui.Warn(" Job template reference: ", ts.ExecutionRequest.JobTemplateReference) 58 } 59 60 if ts.ExecutionRequest.CronJobTemplate != "" { 61 ui.Warn(" Cron job template: ", "\n", ts.ExecutionRequest.CronJobTemplate) 62 } 63 64 if ts.ExecutionRequest.CronJobTemplateReference != "" { 65 ui.Warn(" Cron job template reference: ", ts.ExecutionRequest.CronJobTemplateReference) 66 } 67 68 if ts.ExecutionRequest.ScraperTemplate != "" { 69 ui.Warn(" Scraper template: ", "\n", ts.ExecutionRequest.ScraperTemplate) 70 } 71 72 if ts.ExecutionRequest.ScraperTemplateReference != "" { 73 ui.Warn(" Scraper template reference: ", ts.ExecutionRequest.ScraperTemplateReference) 74 } 75 76 if ts.ExecutionRequest.PvcTemplate != "" { 77 ui.Warn(" PVC template: ", "\n", ts.ExecutionRequest.PvcTemplate) 78 } 79 80 if ts.ExecutionRequest.PvcTemplateReference != "" { 81 ui.Warn(" PVC template reference: ", ts.ExecutionRequest.PvcTemplateReference) 82 } 83 } 84 85 batches := append(ts.Before, ts.Steps...) 86 batches = append(batches, ts.After...) 87 88 ui.NL() 89 ui.Warn("Test batches:", fmt.Sprintf("%d", len(batches))) 90 d := [][]string{{"Names", "Stop on failure", "Download artifacts"}} 91 for _, batch := range batches { 92 var names []string 93 for _, step := range batch.Execute { 94 names = append(names, step.FullName()) 95 } 96 97 downloadArtifacts := "" 98 if batch.DownloadArtifacts != nil { 99 if batch.DownloadArtifacts.AllPreviousSteps { 100 downloadArtifacts = "all previous steps" 101 } else { 102 if len(batch.DownloadArtifacts.PreviousStepNumbers) != 0 { 103 downloadArtifacts = fmt.Sprintf("previous step numbers: %v", batch.DownloadArtifacts.PreviousStepNumbers) 104 } 105 106 if len(batch.DownloadArtifacts.PreviousTestNames) != 0 { 107 downloadArtifacts = fmt.Sprintf("previous test names: %v", batch.DownloadArtifacts.PreviousTestNames) 108 } 109 } 110 } 111 112 d = append(d, []string{ 113 fmt.Sprintf("[%s]", strings.Join(names, ", ")), 114 fmt.Sprintf("%v", batch.StopOnFailure), 115 downloadArtifacts, 116 }) 117 } 118 119 ui.Table(ui.NewArrayTable(d), ui.Writer) 120 ui.NL() 121 122 return nil 123 124 }