Skip to content

Conversation

@crazy-max
Copy link
Member

fixes #2969

JSON format for ls command without Go template (--format json) should not set nodes in formatter context.

@crazy-max crazy-max added this to the v0.21.0 milestone Feb 7, 2025
@crazy-max crazy-max requested a review from tonistiigi February 7, 2025 09:27
@crazy-max crazy-max marked this pull request as ready for review February 7, 2025 09:28
}
continue
}
if ctx.Format.IsJSON() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So JSON output does not allow seeing multi-node builders and their properties/endpoints?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json format marshals the builder with list of nodes:

buildx/commands/ls.go

Lines 211 to 213 in 0a4eb7e

func (c *lsContext) MarshalJSON() ([]byte, error) {
return json.Marshal(c.Builder)
}

{
   "Name":"builder",
   "Driver":"docker-container",
   "LastActivity":"2025-02-06T15:15:12Z",
   "Dynamic":false,
   "Nodes":[
      {
         "Name":"builder0",
         "Endpoint":"unix:///var/run/docker.sock",
         "Flags":[
            "--debug",
            "--allow-insecure-entitlement",
            "security.insecure",
            "--allow-insecure-entitlement",
            "network.host"
         ],
         "DriverOpts":{
            "env.BUILDKIT_STEP_LOG_MAX_SIZE":"10485760",
            "env.BUILDKIT_STEP_LOG_MAX_SPEED":"10485760",
            "env.JAEGER_TRACE":"localhost:6831",
            "image":"moby/buildkit:master"
         },
         "Status":"running",
         "Version":"4b36562",
         "IDs":[
            "v6u0iluh9v6ixuqwvybs60qzj"
         ],
         "Platforms":[
            "linux/amd64",
            "linux/amd64/v2",
            "linux/amd64/v3",
            "linux/arm64",
            "linux/riscv64",
            "linux/ppc64le",
            "linux/s390x",
            "linux/386",
            "linux/arm/v7",
            "linux/arm/v6"
         ],
         "GCPolicy":[
            {
               "all":false,
               "filter":[
                  "type==source.local,type==exec.cachemount,type==source.git.checkout"
               ],
               "keepDuration":172800000000000,
               "reservedSpace":0,
               "maxUsedSpace":512000000,
               "minFreeSpace":0
            },
            {
               "all":false,
               "filter":null,
               "keepDuration":5184000000000000,
               "reservedSpace":10000000000,
               "maxUsedSpace":100000000000,
               "minFreeSpace":202000000000
            },
            {
               "all":false,
               "filter":null,
               "keepDuration":0,
               "reservedSpace":10000000000,
               "maxUsedSpace":100000000000,
               "minFreeSpace":202000000000
            },
            {
               "all":true,
               "filter":null,
               "keepDuration":0,
               "reservedSpace":10000000000,
               "maxUsedSpace":100000000000,
               "minFreeSpace":202000000000
            }
         ],
         "Labels":{
            "org.mobyproject.buildkit.worker.executor":"oci",
            "org.mobyproject.buildkit.worker.hostname":"e885c15d9fbc",
            "org.mobyproject.buildkit.worker.network":"host",
            "org.mobyproject.buildkit.worker.oci.process-mode":"sandbox",
            "org.mobyproject.buildkit.worker.selinux.enabled":"false",
            "org.mobyproject.buildkit.worker.snapshotter":"overlayfs"
         }
      }
   ]
}

While table and go template output has an entry for each builder and node. This is similar to what docker service ps does: https://docs.docker.com/reference/cli/docker/service/ps/#examples.

@tonistiigi tonistiigi merged commit b8e9c28 into docker:master Feb 10, 2025
127 checks passed
@crazy-max crazy-max deleted the fix-ls-json branch February 10, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"docker buildx ls --format json" lists each entry twice

2 participants