Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new "bashbrew remote arches" command #56

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

tianon
Copy link
Member

@tianon tianon commented Nov 11, 2022

This command will, given a remote image reference, look up the list of platforms from it and match them to supported bashbrew architectures (providing content descriptors for each).

(This builds on both #54 and #55 because the former creates the initial version of the interfaces this uses and the latter touches go.mod significantly enough to be worth not trying to do independently.)

I'd be totally happy ditching #54 in favor of this (and can roll up/squash that code), if you prefer, @yosifkit. 🙇

$ bashbrew remote arches hello-world
docker.io/library/hello-world:latest -> sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af
  amd64 -> sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4
  arm32v5 -> sha256:7b8b7289d0536a08eabdf71c20246e23f7116641db7e1d278592236ea4dcb30c
  arm32v7 -> sha256:f130bd2d67e6e9280ac6d0a6c83857bfaf70234e8ef4236876eccfbd30973b1c
  arm64v8 -> sha256:432f982638b3aefab73cc58ab28f5c16e96fdb504e8c134fc58dff4bae8bf338
  i386 -> sha256:995efde2e81b21d1ea7066aa77a59298a62a9e9fbb4b77f36c189774ec9b1089
  mips64le -> sha256:eb11b1a194ff8e236a01eff392c4e1296a53b0fb4780d8b0382f7996a15d5392
  ppc64le -> sha256:b836bb24a270b9cc935962d8228517fde0f16990e88893d935efcb1b14c0017a
  riscv64 -> sha256:98c9722322be649df94780d3fbe594fce7996234b259f27eac9428b84050c849
  s390x -> sha256:c7b6944911848ce39b44ed660d95fb54d69bbd531de724c7ce6fc9f743c0b861
  windows-amd64 -> sha256:fb353688bcf45fc724fde3d1dcd7935ddf56803e2b7027164a7acc28758002f6
  windows-amd64 -> sha256:c597fadc51747a7392f4d0312e9740aaee11793a47658a77a4ba51bd5d9b6be0
$ bashbrew remote arches --json hello-world | jq
{
  "ref": "docker.io/library/hello-world:latest",
  "desc": {
    "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
    "digest": "sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af",
    "size": 2561
  },
  "arches": {
    "amd64": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4",
        "size": 525,
        "platform": {
          "architecture": "amd64",
          "os": "linux"
        }
      }
    ],
    "arm32v5": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:7b8b7289d0536a08eabdf71c20246e23f7116641db7e1d278592236ea4dcb30c",
        "size": 525,
        "platform": {
          "architecture": "arm",
          "os": "linux",
          "variant": "v5"
        }
      }
    ],
    "arm32v7": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:f130bd2d67e6e9280ac6d0a6c83857bfaf70234e8ef4236876eccfbd30973b1c",
        "size": 525,
        "platform": {
          "architecture": "arm",
          "os": "linux",
          "variant": "v7"
        }
      }
    ],
    "arm64v8": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:432f982638b3aefab73cc58ab28f5c16e96fdb504e8c134fc58dff4bae8bf338",
        "size": 525,
        "platform": {
          "architecture": "arm64",
          "os": "linux",
          "variant": "v8"
        }
      }
    ],
    "i386": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:995efde2e81b21d1ea7066aa77a59298a62a9e9fbb4b77f36c189774ec9b1089",
        "size": 525,
        "platform": {
          "architecture": "386",
          "os": "linux"
        }
      }
    ],
    "mips64le": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:eb11b1a194ff8e236a01eff392c4e1296a53b0fb4780d8b0382f7996a15d5392",
        "size": 525,
        "platform": {
          "architecture": "mips64le",
          "os": "linux"
        }
      }
    ],
    "ppc64le": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:b836bb24a270b9cc935962d8228517fde0f16990e88893d935efcb1b14c0017a",
        "size": 525,
        "platform": {
          "architecture": "ppc64le",
          "os": "linux"
        }
      }
    ],
    "riscv64": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:98c9722322be649df94780d3fbe594fce7996234b259f27eac9428b84050c849",
        "size": 525,
        "platform": {
          "architecture": "riscv64",
          "os": "linux"
        }
      }
    ],
    "s390x": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:c7b6944911848ce39b44ed660d95fb54d69bbd531de724c7ce6fc9f743c0b861",
        "size": 525,
        "platform": {
          "architecture": "s390x",
          "os": "linux"
        }
      }
    ],
    "windows-amd64": [
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:fb353688bcf45fc724fde3d1dcd7935ddf56803e2b7027164a7acc28758002f6",
        "size": 946,
        "platform": {
          "architecture": "amd64",
          "os": "windows",
          "os.version": "10.0.20348.1249"
        }
      },
      {
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "digest": "sha256:c597fadc51747a7392f4d0312e9740aaee11793a47658a77a4ba51bd5d9b6be0",
        "size": 946,
        "platform": {
          "architecture": "amd64",
          "os": "windows",
          "os.version": "10.0.17763.3650"
        }
      }
    ]
  }
}

@tianon
Copy link
Member Author

tianon commented Nov 11, 2022

(I added some basic godoc comments to the registry/ package in this PR, FWIW 👀)

@codecov-commenter
Copy link

codecov-commenter commented Nov 11, 2022

Codecov Report

Merging #56 (b05f0ed) into master (8281cbe) will increase coverage by 1.22%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #56      +/-   ##
==========================================
+ Coverage   76.15%   77.38%   +1.22%     
==========================================
  Files           6        6              
  Lines         604      619      +15     
==========================================
+ Hits          460      479      +19     
+ Misses        111      108       -3     
+ Partials       33       32       -1     
Impacted Files Coverage Δ
architecture/oci-platform.go 100.00% <100.00%> (ø)
manifest/fetch.go 70.00% <100.00%> (+11.30%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

This command will, given a remote image reference, look up the list of platforms from it and match them to supported bashbrew architectures (providing content descriptors for each).

Also, refactor registry code to be more correct: previously, this couldn't fetch from Docker without `DOCKERHUB_PUBLIC_PROXY` (see `registry-1.docker.io` change) and was ignoring content digests.  Now it works correctly with or without `DOCKERHUB_PUBLIC_PROXY`, verifies the size of every object it pulls, verifies the digest, _and_ should continue working with the in-progress Moby containerd-integration (where the local image ID becomes the digest of the manifest or index instead of the digest of the config blob as it is today).
@yosifkit yosifkit merged commit 6acd73c into docker-library:master Nov 18, 2022
@yosifkit yosifkit deleted the bashbrew-remote-arches branch November 18, 2022 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants