@@ -21,20 +21,16 @@ import (
21
21
"encoding/json"
22
22
"errors"
23
23
"fmt"
24
- "net/url"
25
24
"os"
26
- "path/filepath"
27
25
"strings"
28
26
"time"
29
27
30
- "github.com/google/uuid"
31
28
"github.com/mitchellh/mapstructure"
32
29
"github.com/sirupsen/logrus"
33
30
"github.com/spf13/cobra"
34
31
35
32
"sigs.k8s.io/release-sdk/git"
36
33
"sigs.k8s.io/release-sdk/github"
37
- "sigs.k8s.io/release-sdk/object"
38
34
"sigs.k8s.io/release-utils/http"
39
35
)
40
36
@@ -43,13 +39,12 @@ const (
43
39
)
44
40
45
41
type 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
53
48
}
54
49
55
50
var testGridOpts = & TestGridOptions {}
@@ -73,8 +68,6 @@ const (
73
68
74
69
boardInforming = "informing"
75
70
boardBlocking = "blocking"
76
-
77
- layoutISO = "2006-01-02"
78
71
)
79
72
80
73
// testGridCmd represents the base command when called without any subcommands
@@ -102,9 +95,6 @@ func init() {
102
95
testGridCmd .PersistentFlags ().StringVar (& testGridOpts .testgridURL ,
103
96
"testgrid-url" , "https://testgrid.k8s.io" , "The TestGrid URL" )
104
97
105
- testGridCmd .PersistentFlags ().StringVar (& testGridOpts .renderTronURL ,
106
- "rendertron-url" , "https://render-tron.appspot.com/screenshot" , "The RenderTron URL service" )
107
-
108
98
testGridCmd .PersistentFlags ().IntVar (& testGridOpts .gitHubIssue ,
109
99
"github-issue" , - 1 , "The GitHub Issue for the release cut" )
110
100
@@ -154,12 +144,6 @@ func runTestGridShot(opts *TestGridOptions) error {
154
144
}
155
145
}
156
146
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
- }
163
147
}
164
148
165
149
err := generateIssueComment (testgridJobs , opts )
@@ -170,46 +154,6 @@ func runTestGridShot(opts *TestGridOptions) error {
170
154
return nil
171
155
}
172
156
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
-
213
157
func generateIssueComment (testgridJobs []TestGridJob , opts * TestGridOptions ) error {
214
158
// Generate comment to GH
215
159
output := []string {}
@@ -229,9 +173,9 @@ func generateIssueComment(testgridJobs []TestGridJob, opts *TestGridOptions) err
229
173
output = append (output ,
230
174
fmt .Sprintf (
231
175
"<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 " +
233
177
"</p></details>" ,
234
- timeNow , state , job .DashboardName , job .JobName , opts .testgridURL , job . GCSLocation ),
178
+ timeNow , state , job .DashboardName , job .JobName , opts .testgridURL ),
235
179
)
236
180
237
181
haveState = true
0 commit comments