diff --git a/.github/buildx-releases.json b/.github/buildx-releases.json index fb8e9a8a..85299613 100644 --- a/.github/buildx-releases.json +++ b/.github/buildx-releases.json @@ -1,43 +1,84 @@ { "latest": { - "id": 103872471, - "tag_name": "v0.10.5", - "html_url": "https://github.com/docker/buildx/releases/tag/v0.10.5", - "assets": [ - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.darwin-amd64", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.darwin-amd64.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.darwin-amd64.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.darwin-arm64", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.darwin-arm64.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.darwin-arm64.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-amd64", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-amd64.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-amd64.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm-v6", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm-v6.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm-v6.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm-v7", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm-v7.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm-v7.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm64", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm64.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-arm64.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-ppc64le", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-ppc64le.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-ppc64le.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-riscv64", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-riscv64.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-riscv64.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-s390x", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-s390x.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-s390x.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.windows-amd64.exe", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.windows-amd64.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.windows-amd64.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.windows-arm64.exe", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.windows-arm64.provenance.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.windows-arm64.sbom.json", - "https://github.com/docker/buildx/releases/download/v0.10.5/checksums.txt" + "id": 108385289, + "tag_name": "v0.11.0", + "html_url": "https://github.com/docker/buildx/releases/tag/v0.11.0", + "assets": [ + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-amd64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-amd64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-amd64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-arm64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-arm64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-arm64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v6", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v6.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v6.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v7", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v7.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v7.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-ppc64le", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-ppc64le.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-ppc64le.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-riscv64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-riscv64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-riscv64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-s390x", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-s390x.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-s390x.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-amd64.exe", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-amd64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-amd64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-arm64.exe", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-arm64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-arm64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/checksums.txt" + ] + }, + "v0.11.0": { + "id": 108385289, + "tag_name": "v0.11.0", + "html_url": "https://github.com/docker/buildx/releases/tag/v0.11.0", + "assets": [ + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-amd64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-amd64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-amd64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-arm64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-arm64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.darwin-arm64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v6", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v6.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v6.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v7", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v7.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm-v7.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-arm64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-ppc64le", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-ppc64le.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-ppc64le.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-riscv64", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-riscv64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-riscv64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-s390x", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-s390x.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-s390x.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-amd64.exe", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-amd64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-amd64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-arm64.exe", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-arm64.provenance.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.windows-arm64.sbom.json", + "https://github.com/docker/buildx/releases/download/v0.11.0/checksums.txt" ] }, "v0.11.0-rc2": { diff --git a/.github/workflows/buildx-releases-json.yml b/.github/workflows/buildx-releases-json.yml index 1f03e24d..4151d3b0 100644 --- a/.github/workflows/buildx-releases-json.yml +++ b/.github/workflows/buildx-releases-json.yml @@ -45,7 +45,7 @@ jobs: git add -A . - name: Create PR - uses: peter-evans/create-pull-request@284f54f989303d2699d373481a0cfa13ad5a6666 + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 with: base: main branch: bot/buildx-releases-json diff --git a/.github/workflows/docker-releases-json.yml b/.github/workflows/docker-releases-json.yml index e320d32a..be723f74 100644 --- a/.github/workflows/docker-releases-json.yml +++ b/.github/workflows/docker-releases-json.yml @@ -45,7 +45,7 @@ jobs: git add -A . - name: Create PR - uses: peter-evans/create-pull-request@284f54f989303d2699d373481a0cfa13ad5a6666 + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 with: base: main branch: bot/docker-releases-json diff --git a/__tests__/buildx/builder.test.ts b/__tests__/buildx/builder.test.ts index 2afe58b0..fab65b12 100644 --- a/__tests__/buildx/builder.test.ts +++ b/__tests__/buildx/builder.test.ts @@ -210,6 +210,189 @@ describe('parseInspect', () => { } ] } + ], + [ + 'inspect8.txt', + { + "name": "builder-52aa0611-faf0-42ac-a940-461e4e287d68", + "driver": "docker-container", + "lastActivity": new Date("2023-06-13T13:52:31.000Z"), + "nodes": [ + { + "buildkit": "v0.11.6", + "buildkitd-flags": "--debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host", + "driver-opts": [ + "image=moby/buildkit:buildx-stable-1", + "network=host", + ], + "endpoint": "unix:///var/run/docker.sock", + "name": "builder-52aa0611-faf0-42ac-a940-461e4e287d680", + "platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6", + "status": "running", + "labels": { + "org.mobyproject.buildkit.worker.executor": "oci", + "org.mobyproject.buildkit.worker.hostname": "fv-az572-38", + "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", + }, + "gcPolicy": [ + { + "all": false, + "filter": [ + "type==source.local", + "type==exec.cachemount", + "type==source.git.checkout" + ], + "keepDuration": "48h0m0s", + "keepBytes": "488.3MiB", + }, + { + "all": false, + "keepDuration": "1440h0m0s", + "keepBytes": "8.382GiB", + }, + { + "all": false, + "keepBytes": "8.382GiB", + }, + { + "all": true, + "keepBytes": "8.382GiB", + } + ] + } + ] + } + ], + [ + 'inspect9.txt', + { + "name": "default", + "driver": "docker", + "lastActivity": new Date("2023-06-13T18:13:43.000Z"), + "nodes": [ + { + "buildkit": "v0.11.7-0.20230525183624-798ad6b0ce9f", + "endpoint": "default", + "name": "default", + "platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6", + "status": "running", + "gcPolicy": [ + { + "all": true, + "keepBytes": "100GiB", + } + ] + } + ] + } + ], + [ + 'inspect10.txt', + { + "name": "remote-builder", + "driver": "remote", + "lastActivity": new Date("2023-04-20T12:47:49.000Z"), + "nodes": [ + { + "name": "remote-builder0", + "endpoint": "docker-container://buildx_buildkit_dk-remote-builder0", + "status": "inactive" + }, + { + "name": "aws_graviton2", + "endpoint": "tcp://10.0.0.1:1234", + "driver-opts": [ + "cacert=/home/user/.certs/aws_graviton2/ca.pem", + "cert=/home/user/.certs/aws_graviton2/cert.pem", + "key=/home/user/.certs/aws_graviton2/key.pem" + ], + "status": "running", + "buildkit": "v0.11.6", + "platforms": "darwin/arm64,linux/arm64,linux/arm/v5,linux/arm/v6,linux/arm/v7,windows/arm64", + "labels": { + "org.mobyproject.buildkit.worker.executor": "oci", + "org.mobyproject.buildkit.worker.hostname": "77ebc22e2d82", + "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" + }, + "gcPolicy": [ + { + "all": false, + "filter": [ + "type==source.local", + "type==exec.cachemount", + "type==source.git.checkout" + ], + "keepDuration": "48h0m0s", + "keepBytes": "488.3MiB" + }, + { + "all": false, + "keepDuration": "1440h0m0s", + "keepBytes": "23.28GiB" + }, + { + "all": false, + "keepBytes": "23.28GiB" + }, + { + "all": true, + "keepBytes": "23.28GiB" + } + ] + }, + { + "name": "linuxone_s390x", + "endpoint": "tcp://10.0.0.2:1234", + "driver-opts": [ + "cacert=/home/user/.certs/linuxone_s390x/ca.pem", + "cert=/home/user/.certs/linuxone_s390x/cert.pem", + "key=/home/user/.certs/linuxone_s390x/key.pem" + ], + "status": "running", + "buildkit": "v0.11.6", + "platforms": "linux/s390x", + "labels": { + "org.mobyproject.buildkit.worker.executor": "oci", + "org.mobyproject.buildkit.worker.hostname": "9d0d62a96818", + "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" + }, + "gcPolicy": [ + { + "all": false, + "keepBytes": "488.3MiB", + "filter": [ + "type==source.local", + "type==exec.cachemount", + "type==source.git.checkout" + ], + "keepDuration": "48h0m0s" + }, + { + "all": false, + "keepDuration": "1440h0m0s", + "keepBytes": "9.313GiB" + }, + { + "all": false, + "keepBytes": "9.313GiB" + }, + { + "all": true, + "keepBytes": "9.313GiB" + } + ] + } + ], + } ] ])('given %p', async (inspectFile, expected) => { expect(await Builder.parseInspect(fs.readFileSync(path.join(fixturesDir, inspectFile)).toString())).toEqual(expected); diff --git a/__tests__/fixtures/inspect10.txt b/__tests__/fixtures/inspect10.txt new file mode 100644 index 00000000..aa6ee843 --- /dev/null +++ b/__tests__/fixtures/inspect10.txt @@ -0,0 +1,67 @@ +Name: remote-builder +Driver: remote +Last Activity: 2023-04-20 12:47:49 +0000 UTC + +Nodes: +Name: remote-builder0 +Endpoint: docker-container://buildx_buildkit_dk-remote-builder0 +Status: inactive +Platforms: + +Name: aws_graviton2 +Endpoint: tcp://10.0.0.1:1234 +Driver Options: cacert="/home/user/.certs/aws_graviton2/ca.pem" cert="/home/user/.certs/aws_graviton2/cert.pem" key="/home/user/.certs/aws_graviton2/key.pem" +Status: running +Buildkit: v0.11.6 +Platforms: darwin/arm64*, linux/arm64*, linux/arm/v5*, linux/arm/v6*, linux/arm/v7*, windows/arm64* +Labels: + org.mobyproject.buildkit.worker.executor: oci + org.mobyproject.buildkit.worker.hostname: 77ebc22e2d82 + 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 +GC Policy rule#0: + All: false + Filters: type==source.local,type==exec.cachemount,type==source.git.checkout + Keep Duration: 48h0m0s + Keep Bytes: 488.3MiB +GC Policy rule#1: + All: false + Keep Duration: 1440h0m0s + Keep Bytes: 23.28GiB +GC Policy rule#2: + All: false + Keep Bytes: 23.28GiB +GC Policy rule#3: + All: true + Keep Bytes: 23.28GiB + +Name: linuxone_s390x +Endpoint: tcp://10.0.0.2:1234 +Driver Options: cacert="/home/user/.certs/linuxone_s390x/ca.pem" cert="/home/user/.certs/linuxone_s390x/cert.pem" key="/home/user/.certs/linuxone_s390x/key.pem" +Status: running +Buildkit: v0.11.6 +Platforms: linux/s390x* +Labels: + org.mobyproject.buildkit.worker.executor: oci + org.mobyproject.buildkit.worker.hostname: 9d0d62a96818 + 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 +GC Policy rule#0: + All: false + Filters: type==source.local,type==exec.cachemount,type==source.git.checkout + Keep Duration: 48h0m0s + Keep Bytes: 488.3MiB +GC Policy rule#1: + All: false + Keep Duration: 1440h0m0s + Keep Bytes: 9.313GiB +GC Policy rule#2: + All: false + Keep Bytes: 9.313GiB +GC Policy rule#3: + All: true + Keep Bytes: 9.313GiB diff --git a/__tests__/fixtures/inspect8.txt b/__tests__/fixtures/inspect8.txt new file mode 100644 index 00000000..0434bd6d --- /dev/null +++ b/__tests__/fixtures/inspect8.txt @@ -0,0 +1,34 @@ +Name: builder-52aa0611-faf0-42ac-a940-461e4e287d68 +Driver: docker-container +Last Activity: 2023-06-13 13:52:31 +0000 UTC + +Nodes: +Name: builder-52aa0611-faf0-42ac-a940-461e4e287d680 +Endpoint: unix:///var/run/docker.sock +Driver Options: image="moby/buildkit:buildx-stable-1" network="host" +Status: running +Flags: --debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host +Buildkit: v0.11.6 +Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6 +Labels: + org.mobyproject.buildkit.worker.executor: oci + org.mobyproject.buildkit.worker.hostname: fv-az572-38 + 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 +GC Policy rule#0: + All: false + Filters: type==source.local,type==exec.cachemount,type==source.git.checkout + Keep Duration: 48h0m0s + Keep Bytes: 488.3MiB +GC Policy rule#1: + All: false + Keep Duration: 1440h0m0s + Keep Bytes: 8.382GiB +GC Policy rule#2: + All: false + Keep Bytes: 8.382GiB +GC Policy rule#3: + All: true + Keep Bytes: 8.382GiB diff --git a/__tests__/fixtures/inspect9.txt b/__tests__/fixtures/inspect9.txt new file mode 100644 index 00000000..8da0bbb4 --- /dev/null +++ b/__tests__/fixtures/inspect9.txt @@ -0,0 +1,14 @@ +Name: default +Driver: docker +Last Activity: 2023-06-13 18:13:43 +0000 UTC + +Nodes: +Name: default +Endpoint: default +Status: running +Buildkit: v0.11.7-0.20230525183624-798ad6b0ce9f +Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6 +GC Policy rule#0: + All: true + Filters: + Keep Bytes: 100GiB diff --git a/package.json b/package.json index bee8f545..95e85a8e 100644 --- a/package.json +++ b/package.json @@ -51,12 +51,12 @@ "@actions/http-client": "^2.0.1", "@actions/io": "^1.1.2", "@actions/tool-cache": "^2.0.1", - "@octokit/plugin-rest-endpoint-methods": "^7.2.1", + "@octokit/plugin-rest-endpoint-methods": "^7.2.3", "async-retry": "^1.3.3", "csv-parse": "^5.4.0", "handlebars": "^4.7.7", "jwt-decode": "^3.1.2", - "semver": "^7.5.1", + "semver": "^7.5.3", "tmp": "^0.2.1" }, "devDependencies": { diff --git a/src/buildx/builder.ts b/src/buildx/builder.ts index 862253cd..37ee9c81 100644 --- a/src/buildx/builder.ts +++ b/src/buildx/builder.ts @@ -19,7 +19,7 @@ import * as core from '@actions/core'; import {Buildx} from './buildx'; import {Exec} from '../exec'; -import {BuilderInfo, NodeInfo} from '../types/builder'; +import {BuilderInfo, GCPolicy, NodeInfo} from '../types/builder'; export interface BuilderOpts { buildx?: Buildx; @@ -72,55 +72,73 @@ export class Builder { const builder: BuilderInfo = { nodes: [] }; - let node: NodeInfo = {}; + let parsingType: string | undefined; + let currentNode: NodeInfo = {}; + let currentGCPolicy: GCPolicy | undefined; for (const line of data.trim().split(`\n`)) { const [key, ...rest] = line.split(':'); + const lkey = key.toLowerCase(); const value = rest.map(v => v.trim()).join(':'); - if (key.length == 0 || value.length == 0) { + if (key.length == 0) { continue; } - switch (key.toLowerCase()) { - case 'name': { + switch (true) { + case lkey == 'name': { + parsingType = undefined; if (builder.name == undefined) { builder.name = value; } else { - if (Object.keys(node).length > 0) { - builder.nodes.push(node); - node = {}; + if (currentGCPolicy && currentNode.gcPolicy) { + currentNode.gcPolicy.push(currentGCPolicy); + currentGCPolicy = undefined; } - node.name = value; + if (currentNode.name) { + builder.nodes.push(currentNode); + } + currentNode = {name: value}; } break; } - case 'driver': { + case lkey == 'driver': { + parsingType = undefined; builder.driver = value; break; } - case 'last activity': { + case lkey == 'last activity': { + parsingType = undefined; builder.lastActivity = new Date(value); break; } - case 'endpoint': { - node.endpoint = value; + case lkey == 'endpoint': { + parsingType = undefined; + currentNode.endpoint = value; break; } - case 'driver options': { - node['driver-opts'] = (value.match(/([a-zA-Z0-9_.]+)="([^"]*)"/g) || []).map(v => v.replace(/^(.*)="(.*)"$/g, '$1=$2')); + case lkey == 'driver options': { + parsingType = undefined; + currentNode['driver-opts'] = (value.match(/([a-zA-Z0-9_.]+)="([^"]*)"/g) || []).map(v => v.replace(/^(.*)="(.*)"$/g, '$1=$2')); break; } - case 'status': { - node.status = value; + case lkey == 'status': { + parsingType = undefined; + currentNode.status = value; break; } - case 'flags': { - node['buildkitd-flags'] = value; + case lkey == 'flags': { + parsingType = undefined; + currentNode['buildkitd-flags'] = value; break; } - case 'buildkit': { - node.buildkit = value; + case lkey == 'buildkit': { + parsingType = undefined; + currentNode.buildkit = value; break; } - case 'platforms': { + case lkey == 'platforms': { + parsingType = undefined; + if (!value) { + break; + } let platforms: Array = []; // if a preferred platform is being set then use only these // https://docs.docker.com/engine/reference/commandline/buildx_inspect/#get-information-about-a-builder-instance @@ -134,13 +152,63 @@ export class Builder { // otherwise set all platforms available platforms = value.split(', '); } - node.platforms = platforms.join(','); + currentNode.platforms = platforms.join(','); + break; + } + case lkey == 'labels': { + parsingType = 'label'; + currentNode.labels = {}; + break; + } + case lkey.startsWith('gc policy rule#'): { + parsingType = 'gcpolicy'; + if (currentNode.gcPolicy && currentGCPolicy) { + currentNode.gcPolicy.push(currentGCPolicy); + currentGCPolicy = undefined; + } break; } + default: { + switch (parsingType || '') { + case 'label': { + currentNode.labels = currentNode.labels || {}; + currentNode.labels[key.trim()] = value; + break; + } + case 'gcpolicy': { + currentNode.gcPolicy = currentNode.gcPolicy || []; + currentGCPolicy = currentGCPolicy || {}; + switch (lkey.trim()) { + case 'all': { + currentGCPolicy.all = value == 'true'; + break; + } + case 'filters': { + if (value) { + currentGCPolicy.filter = value.split(','); + } + break; + } + case 'keep duration': { + currentGCPolicy.keepDuration = value; + break; + } + case 'keep bytes': { + currentGCPolicy.keepBytes = value; + break; + } + } + break; + } + } + } } } - if (Object.keys(node).length > 0) { - builder.nodes.push(node); + if (currentGCPolicy && currentNode.gcPolicy) { + currentNode.gcPolicy.push(currentGCPolicy); + } + if (currentNode.name) { + builder.nodes.push(currentNode); } return builder; } diff --git a/src/types/builder.ts b/src/types/builder.ts index da8d4e60..617f4342 100644 --- a/src/types/builder.ts +++ b/src/types/builder.ts @@ -32,4 +32,13 @@ export interface Node { export interface NodeInfo extends Node { status?: string; buildkit?: string; + labels?: Record; + gcPolicy?: Array; +} + +export interface GCPolicy { + all?: boolean; + filter?: string[]; + keepDuration?: string; + keepBytes?: string; } diff --git a/yarn.lock b/yarn.lock index 711fd24d..79968816 100644 --- a/yarn.lock +++ b/yarn.lock @@ -810,7 +810,7 @@ __metadata: "@actions/http-client": ^2.0.1 "@actions/io": ^1.1.2 "@actions/tool-cache": ^2.0.1 - "@octokit/plugin-rest-endpoint-methods": ^7.2.1 + "@octokit/plugin-rest-endpoint-methods": ^7.2.3 "@types/csv-parse": ^1.2.2 "@types/node": ^16.18.21 "@types/semver": ^7.5.0 @@ -831,7 +831,7 @@ __metadata: jwt-decode: ^3.1.2 prettier: ^2.8.7 rimraf: ^4.4.1 - semver: ^7.5.1 + semver: ^7.5.3 tmp: ^0.2.1 ts-jest: ^29.0.5 ts-node: ^10.9.1 @@ -1349,6 +1349,13 @@ __metadata: languageName: node linkType: hard +"@octokit/openapi-types@npm:^12.11.0": + version: 12.11.0 + resolution: "@octokit/openapi-types@npm:12.11.0" + checksum: 8a7d4bd6288cc4085cabe0ca9af2b87c875c303af932cb138aa1b2290eb69d32407759ac23707bb02776466e671244a902e9857896903443a69aff4b6b2b0e3b + languageName: node + linkType: hard + "@octokit/openapi-types@npm:^18.0.0": version: 18.0.0 resolution: "@octokit/openapi-types@npm:18.0.0" @@ -1375,25 +1382,25 @@ __metadata: linkType: hard "@octokit/plugin-rest-endpoint-methods@npm:^5.13.0": - version: 5.13.0 - resolution: "@octokit/plugin-rest-endpoint-methods@npm:5.13.0" + version: 5.16.2 + resolution: "@octokit/plugin-rest-endpoint-methods@npm:5.16.2" dependencies: - "@octokit/types": ^6.34.0 + "@octokit/types": ^6.39.0 deprecation: ^2.3.1 peerDependencies: "@octokit/core": ">=3" - checksum: f331457e4317130adb456b27df2a99609fb54a4dc2da6f87009e567c7325680c901abf18ad08483535bab4ec1c892e4236f4135a2804603aebb12c0698c678c8 + checksum: 30fcc50c335d1093f03573d9fa3a4b7d027fc98b215c43e07e82ee8dabfa0af0cf1b963feb542312ae32d897a2f68dc671577206f30850215517bebedc5a2c73 languageName: node linkType: hard -"@octokit/plugin-rest-endpoint-methods@npm:^7.2.1": - version: 7.2.1 - resolution: "@octokit/plugin-rest-endpoint-methods@npm:7.2.1" +"@octokit/plugin-rest-endpoint-methods@npm:^7.2.3": + version: 7.2.3 + resolution: "@octokit/plugin-rest-endpoint-methods@npm:7.2.3" dependencies: - "@octokit/types": ^9.3.1 + "@octokit/types": ^10.0.0 peerDependencies: "@octokit/core": ">=3" - checksum: 069e52305f9d2e85fb83819a80860e526b9da2e0936640975f749a2c63020674053e6f4b5af771651a93320172579b0779bf3d663c8adcd090f152aac29f4ad4 + checksum: 21dfb98514dbe900c29cddb13b335bbce43d613800c6b17eba3c1fd31d17e69c1960f3067f7bf864bb38fdd5043391f4a23edee42729d8c7fbabd00569a80336 languageName: node linkType: hard @@ -1460,6 +1467,15 @@ __metadata: languageName: node linkType: hard +"@octokit/types@npm:^10.0.0": + version: 10.0.0 + resolution: "@octokit/types@npm:10.0.0" + dependencies: + "@octokit/openapi-types": ^18.0.0 + checksum: 8aafba2ff0cd2435fb70c291bf75ed071c0fa8a865cf6169648732068a35dec7b85a345851f18920ec5f3e94ee0e954988485caac0da09ec3f6781cc44fe153a + languageName: node + linkType: hard + "@octokit/types@npm:^5.0.0, @octokit/types@npm:^5.0.1": version: 5.4.1 resolution: "@octokit/types@npm:5.4.1" @@ -1487,12 +1503,12 @@ __metadata: languageName: node linkType: hard -"@octokit/types@npm:^9.3.1": - version: 9.3.1 - resolution: "@octokit/types@npm:9.3.1" +"@octokit/types@npm:^6.39.0": + version: 6.41.0 + resolution: "@octokit/types@npm:6.41.0" dependencies: - "@octokit/openapi-types": ^18.0.0 - checksum: 56fce104114730553c79175261f288a263055af4a6de848130fa964940460ee4fe8fa610f33dd0862c2c178d7d97f703e44a799898f3b52583e7ce5ae595f8ff + "@octokit/openapi-types": ^12.11.0 + checksum: fd6f75e0b19b90d1a3d244d2b0c323ed8f2f05e474a281f60a321986683548ef2e0ec2b3a946aa9405d6092e055344455f69f58957c60f58368c8bdda5b7d2ab languageName: node linkType: hard @@ -5888,14 +5904,14 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.x, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.1": - version: 7.5.1 - resolution: "semver@npm:7.5.1" +"semver@npm:7.x, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.3": + version: 7.5.3 + resolution: "semver@npm:7.5.3" dependencies: lru-cache: ^6.0.0 bin: semver: bin/semver.js - checksum: d16dbedad53c65b086f79524b9ef766bf38670b2395bdad5c957f824dcc566b624988013564f4812bcace3f9d405355c3635e2007396a39d1bffc71cfec4a2fc + checksum: 9d58db16525e9f749ad0a696a1f27deabaa51f66e91d2fa2b0db3de3e9644e8677de3b7d7a03f4c15bc81521e0c3916d7369e0572dbde250d9bedf5194e2a8a7 languageName: node linkType: hard