builder: set node worker ids

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-09-30 06:52:11 +02:00
parent e6756d951a
commit 197824c6f2
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7

View File

@ -2,6 +2,7 @@ package builder
import ( import (
"context" "context"
"sort"
"github.com/docker/buildx/driver" "github.com/docker/buildx/driver"
ctxkube "github.com/docker/buildx/driver/kubernetes/context" ctxkube "github.com/docker/buildx/driver/kubernetes/context"
@ -24,13 +25,16 @@ type Node struct {
Builder string Builder string
Driver *driver.DriverHandle Driver *driver.DriverHandle
DriverInfo *driver.Info DriverInfo *driver.Info
Platforms []ocispecs.Platform
GCPolicy []client.PruneInfo
Labels map[string]string
ImageOpt imagetools.Opt ImageOpt imagetools.Opt
ProxyConfig map[string]string ProxyConfig map[string]string
Version string Version string
Err error Err error
// worker settings
IDs []string
Platforms []ocispecs.Platform
GCPolicy []client.PruneInfo
Labels map[string]string
} }
// Nodes returns nodes for this builder. // Nodes returns nodes for this builder.
@ -188,12 +192,14 @@ func (n *Node) loadData(ctx context.Context) error {
return errors.Wrap(err, "listing workers") return errors.Wrap(err, "listing workers")
} }
for idx, w := range workers { for idx, w := range workers {
n.IDs = append(n.IDs, w.ID)
n.Platforms = append(n.Platforms, w.Platforms...) n.Platforms = append(n.Platforms, w.Platforms...)
if idx == 0 { if idx == 0 {
n.GCPolicy = w.GCPolicy n.GCPolicy = w.GCPolicy
n.Labels = w.Labels n.Labels = w.Labels
} }
} }
sort.Strings(n.IDs)
n.Platforms = platformutil.Dedupe(n.Platforms) n.Platforms = platformutil.Dedupe(n.Platforms)
inf, err := driverClient.Info(ctx) inf, err := driverClient.Info(ctx)
if err != nil { if err != nil {