Skip to content

Commit ceda219

Browse files
committed
WIP: bktec bazel listen stub subcommand (not yet implemented)
1 parent a1ce56d commit ceda219

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.dll
88
*.so
99
*.dylib
10+
/bktec
1011

1112
# Test binary, built with `go test -c`
1213
*.test

internal/bes/bes.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package bes
2+
3+
import (
4+
"fmt"
5+
"net"
6+
)
7+
8+
var host = "127.0.0.1"
9+
var port = 60242 // 0 for OS-allocated
10+
11+
func Listen() error {
12+
addr := fmt.Sprintf("%s:%d", host, port)
13+
listener, err := net.Listen("tcp", addr)
14+
if err != nil {
15+
return fmt.Errorf("listening on %s: %w", addr, err)
16+
}
17+
fmt.Println("Bazel BES listener: grpc://" + listener.Addr().String())
18+
19+
// TODO
20+
21+
return nil
22+
}

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import (
77
"errors"
88
"flag"
99
"fmt"
10+
"log"
1011
"os"
1112
"os/exec"
1213
"strconv"
1314
"syscall"
1415
"time"
1516

1617
"github.com/buildkite/test-engine-client/internal/api"
18+
"github.com/buildkite/test-engine-client/internal/bes"
1719
"github.com/buildkite/test-engine-client/internal/config"
1820
"github.com/buildkite/test-engine-client/internal/debug"
1921
"github.com/buildkite/test-engine-client/internal/env"
@@ -69,6 +71,11 @@ func main() {
6971
logErrorAndExit(16, "upload: %v", err)
7072
}
7173
os.Exit(0)
74+
} else if flag.Arg(0) == "bazel" && flag.Arg(1) == "listen" {
75+
if err := bes.Listen(); err != nil {
76+
log.Fatal(err)
77+
}
78+
os.Exit(0)
7279
}
7380

7481
// get config

0 commit comments

Comments
 (0)