@@ -21,20 +21,16 @@ import (
2121 "encoding/json"
2222 "errors"
2323 "fmt"
24- "net/url"
2524 "os"
26- "path/filepath"
2725 "strings"
2826 "time"
2927
30- "github.com/google/uuid"
3128 "github.com/mitchellh/mapstructure"
3229 "github.com/sirupsen/logrus"
3330 "github.com/spf13/cobra"
3431
3532 "sigs.k8s.io/release-sdk/git"
3633 "sigs.k8s.io/release-sdk/github"
37- "sigs.k8s.io/release-sdk/object"
3834 "sigs.k8s.io/release-utils/http"
3935)
4036
@@ -43,13 +39,12 @@ const (
4339)
4440
4541type TestGridOptions struct {
46- branch string
47- boards []string
48- states []string
49- bucket string
50- testgridURL string
51- renderTronURL string
52- gitHubIssue int
42+ branch string
43+ boards []string
44+ states []string
45+ bucket string
46+ testgridURL string
47+ gitHubIssue int
5348}
5449
5550var testGridOpts = & TestGridOptions {}
@@ -73,8 +68,6 @@ const (
7368
7469 boardInforming = "informing"
7570 boardBlocking = "blocking"
76-
77- layoutISO = "2006-01-02"
7871)
7972
8073// testGridCmd represents the base command when called without any subcommands
@@ -102,9 +95,6 @@ func init() {
10295 testGridCmd .PersistentFlags ().StringVar (& testGridOpts .testgridURL ,
10396 "testgrid-url" , "https://testgrid.k8s.io" , "The TestGrid URL" )
10497
105- testGridCmd .PersistentFlags ().StringVar (& testGridOpts .renderTronURL ,
106- "rendertron-url" , "https://render-tron.appspot.com/screenshot" , "The RenderTron URL service" )
107-
10898 testGridCmd .PersistentFlags ().IntVar (& testGridOpts .gitHubIssue ,
10999 "github-issue" , - 1 , "The GitHub Issue for the release cut" )
110100
@@ -154,12 +144,6 @@ func runTestGridShot(opts *TestGridOptions) error {
154144 }
155145 }
156146 testgridJobs = append (testgridJobs , testgridJobsTemp ... )
157-
158- dateNow := fmt .Sprintf ("%s-%s" , time .Now ().UTC ().Format (layoutISO ), uuid .NewString ())
159- testgridJobs , err = processDashboards (testgridJobs , dateNow , opts )
160- if err != nil {
161- return fmt .Errorf ("processing the dashboards: %w" , err )
162- }
163147 }
164148
165149 err := generateIssueComment (testgridJobs , opts )
@@ -170,46 +154,6 @@ func runTestGridShot(opts *TestGridOptions) error {
170154 return nil
171155}
172156
173- func processDashboards (testgridJobs []TestGridJob , date string , opts * TestGridOptions ) ([]TestGridJob , error ) {
174- for i , job := range testgridJobs {
175- testGridJobURL := fmt .Sprintf ("%s/%s#%s&width=30" , opts .testgridURL , job .DashboardName , job .JobName )
176- rendertronURL := fmt .Sprintf ("%s/%s?width=3000&height=2500" , opts .renderTronURL , url .PathEscape (testGridJobURL ))
177- logrus .Infof ("rendertronURL for %s: %s" , testGridJobURL , rendertronURL )
178-
179- content , err := http .NewAgent ().WithTimeout (300 * time .Second ).Get (rendertronURL )
180- if err != nil {
181- return testgridJobs , fmt .Errorf ("failed to get the testgrid screenshot: %w" , err )
182- }
183-
184- jobFile := fmt .Sprintf ("/tmp/%s-%s-%s.jpg" , job .DashboardName , strings .ReplaceAll (job .JobName , " " , "_" ), job .Status )
185- f , err := os .Create (jobFile )
186- if err != nil {
187- return testgridJobs , fmt .Errorf ("failed to create the file %s: %w" , jobFile , err )
188- }
189-
190- _ , err = f .Write (content )
191- f .Close ()
192- if err != nil {
193- return testgridJobs , fmt .Errorf ("failed to write the content to the file %s: %w" , jobFile , err )
194- }
195- logrus .Infof ("Screenshot saved for %s: %s" , job .JobName , jobFile )
196-
197- gcsPath := filepath .Join (opts .bucket , "testgridshot" , opts .branch , date , filepath .Base (jobFile ))
198-
199- gcs := object .NewGCS ()
200- if err := gcs .CopyToRemote (jobFile , gcsPath ); err != nil {
201- return testgridJobs , fmt .Errorf ("failed to upload the file %s to GCS bucket %s: %w" , jobFile , gcsPath , err )
202- }
203- if err := os .Remove (jobFile ); err != nil {
204- return testgridJobs , fmt .Errorf ("remove jobfile: %w" , err )
205- }
206- testgridJobs [i ].GCSLocation = fmt .Sprintf ("https://storage.googleapis.com/%s" , gcsPath )
207- logrus .Infof ("Screenshot will be available for job %s at %s" , job .JobName , testgridJobs [i ].GCSLocation )
208- }
209-
210- return testgridJobs , nil
211- }
212-
213157func generateIssueComment (testgridJobs []TestGridJob , opts * TestGridOptions ) error {
214158 // Generate comment to GH
215159 output := []string {}
@@ -229,9 +173,9 @@ func generateIssueComment(testgridJobs []TestGridJob, opts *TestGridOptions) err
229173 output = append (output ,
230174 fmt .Sprintf (
231175 "<details><summary><tt>%[1]s</tt> %[2]s <a href=\" %[5]s/%[3]s#%[4]s&width=30\" >%[3]s#%[4]s - TestGrid</a></summary><p>\n " +
232- "\n ![ %[3]s#%[4]s](%[6]s) \n \n " +
176+ "\n %[3]s#%[4]s\n \n " +
233177 "</p></details>" ,
234- timeNow , state , job .DashboardName , job .JobName , opts .testgridURL , job . GCSLocation ),
178+ timeNow , state , job .DashboardName , job .JobName , opts .testgridURL ),
235179 )
236180
237181 haveState = true
0 commit comments