Skip to content

Commit

Permalink
Merge pull request #260 from depot/buildx-0-13-proxy
Browse files Browse the repository at this point in the history
Fix buildkit proxy with buildx 0.13
  • Loading branch information
jacobwgillespie authored Mar 15, 2024
2 parents f54437a + c3005ab commit e9d792f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
41 changes: 41 additions & 0 deletions pkg/cmd/buildctl/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"net"
"net/url"
"os"
"strconv"
"strings"
"sync/atomic"

content "github.com/containerd/containerd/api/services/content/v1"
Expand Down Expand Up @@ -315,6 +317,12 @@ func (p *ControlProxy) ListWorkers(ctx context.Context, in *control.ListWorkersR
return nil, state.Err
}
}

md, ok := metadata.FromIncomingContext(ctx)
if ok && !isOlderThanBuildx013(md.Get("user-agent")) {
builds.Add(1)
}

return &control.ListWorkersResponse{
Record: platformWorkerRecords(p.platform),
}, nil
Expand Down Expand Up @@ -1060,3 +1068,36 @@ func forwardBuildxToBuildkit(buildx grpc.ServerStream, buildkit grpc.ClientStrea
}()
return ret
}

func isOlderThanBuildx013(userAgent []string) bool {
for _, ua := range userAgent {
parts := strings.Split(ua, "/")
if len(parts) < 2 {
continue
}

if parts[0] != "grpc-go" {
continue
}

parts = strings.Split(parts[1], ".")
if len(parts) < 2 {
continue
}

if parts[0] != "1" {
continue
}

minor, err := strconv.Atoi(parts[1])
if err != nil {
continue
}

if minor < 59 {
return true
}
}

return false
}
3 changes: 0 additions & 3 deletions pkg/cmd/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ func runConfigureBuildx(ctx context.Context, dockerCli command.Cli, project, tok
}

version := build.Version
if version == "0.0.0-dev" {
version = "latest"
}

image := "ghcr.io/depot/cli:" + version

Expand Down

0 comments on commit e9d792f

Please sign in to comment.