Skip to content

Commit f939362

Browse files
committed
Add remote reporting CLI
1 parent 4fa6111 commit f939362

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cmd/build.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/gitpod-io/leeway/pkg/leeway"
15+
"github.com/gitpod-io/leeway/pkg/remotereporter"
1516
"github.com/gookit/color"
1617
log "github.com/sirupsen/logrus"
1718
"github.com/spf13/cobra"
@@ -173,6 +174,7 @@ func addBuildFlags(cmd *cobra.Command) {
173174
cmd.Flags().String("coverage-output-path", "", "Output path where test coverage file will be copied after running tests")
174175
cmd.Flags().StringToString("docker-build-options", nil, "Options passed to all 'docker build' commands")
175176
cmd.Flags().String("report", "", "Generate a HTML report after the build has finished. (e.g. --report myreport.html)")
177+
cmd.Flags().String("remote-report", "", "Report the build progress to a remote endoint")
176178
}
177179

178180
func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, *leeway.FilesystemCache) {
@@ -249,6 +251,11 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, *leeway.FilesystemC
249251
} else if report != "" {
250252
reporter = append(reporter, leeway.NewHTMLReporter(report))
251253
}
254+
if ep, err := cmd.Flags().GetString("remote-report"); err != nil {
255+
log.Fatal(err)
256+
} else if ep != "" {
257+
reporter = append(reporter, remotereporter.NewReporter(ep))
258+
}
252259

253260
dontTest, err := cmd.Flags().GetBool("dont-test")
254261
if err != nil {

pkg/remotereporter/reporter.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package remotereporter
22

33
import (
44
"context"
5+
"net/http"
56
"time"
67

78
connect_go "github.com/bufbuild/connect-go"
@@ -11,6 +12,15 @@ import (
1112
"github.com/sirupsen/logrus"
1213
)
1314

15+
func NewReporter(endpoint string) *Reporter {
16+
httpclient := &http.Client{Timeout: 2 * time.Second}
17+
client := v1connect.NewReporterServiceClient(httpclient, endpoint)
18+
return &Reporter{
19+
sessionID: time.Now().Format(time.RFC3339Nano),
20+
Client: client,
21+
}
22+
}
23+
1424
type Reporter struct {
1525
Client v1connect.ReporterServiceClient
1626

0 commit comments

Comments
 (0)