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

How do we set the manifest platform."os.version" property? #1137

Closed
rgl opened this issue Oct 1, 2021 · 7 comments
Closed

How do we set the manifest platform."os.version" property? #1137

rgl opened this issue Oct 1, 2021 · 7 comments

Comments

@rgl
Copy link

rgl commented Oct 1, 2021

How do we set the manifest platform."os.version" property like the golang:1.17.1 image?

PS C:\Users\vagrant\Desktop\example-docker-buildx-go> .\crane.exe manifest golang:1.17.1 | jq
{
  "manifests": [
    ...
    {
      "digest": "sha256:203c24bdb4c98895e3425bce051aa6c43b55f20daaf339cc628d9b6cd20d7d58",
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "platform": {
        "architecture": "amd64",
        "os": "windows",
        "os.version": "10.0.14393.4651"
      },
      "size": 3402
    }
  ],
  "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
  "schemaVersion": 2
}
@imjasonh
Copy link
Collaborator

imjasonh commented Oct 1, 2021

Using pkg/v1/mutate.AppendManifests:

idx := mutate.AppendManifests(empty.Index, mutate.IndexAddendum{
  Add: img,
  Descriptor: v1.Descriptor{
    Platform: v1.Platform{
      Architecture: "amd64",
      OS: "windows",
      OSVersion: "10.0.14393.4651",
    },
  },
})

@jonjohnsonjr
Copy link
Collaborator

Also note that this field can be present in the config file, so you may also need to set it in the underlying image:

@rgl
Copy link
Author

rgl commented Oct 1, 2021

By any chance, can that be done from the crane application (e.g. without writing a custom go app)?

Or even, just let us modify the manifest json, and somehow use crane to upload it?

@imjasonh
Copy link
Collaborator

imjasonh commented Oct 1, 2021

By any chance, can that be done from the crane application (e.g. without writing a custom go app)?

Nope, crane doesn't include much functionality for modifying indexes or manifest lists, sorry. :(

I wrote https://github.com/imjasonh/combine to combine two manifest lists, if that happens to be what you're after.

@rgl
Copy link
Author

rgl commented Oct 1, 2021

@imjasonh, I think combine almost is what I'm looking for!

To explain a bit more, at https://github.com/rgl/example-docker-buildx-go/blob/add-windows/.github/workflows/build.yml I'm using docker buildx to produce a multi-arch image (published at https://hub.docker.com/layers/ruilopes/example-docker-buildx-go/staging--v1.3.0-test12-linux).

And then I use docker build (not buildx) to create a non-multi-arch windows 2019 image (published at https://hub.docker.com/layers/169706351/ruilopes/example-docker-buildx-go/staging--v1.3.0-test12-windowsnanoserver-1809).

And, in the near future, I want to also add a windows 2022 image.

So, I'm looking for a tool that can take an arbitrary number of manifests or images and merge them all into a single manifest.

But for doing this, I believe I first need to include a proper platform."os.version" property in the windows images, which I don't known how to do with an existing tool.

So, I'm kinda stuck and would appreciate any help you could provide :-)

@jonjohnsonjr
Copy link
Collaborator

Or even, just let us modify the manifest json, and somehow use crane to upload it?

If you're willing to do this manually, I have a fork of crane with an edit command that I use for experiments (I'd need to rewrite a bunch of k8s dependencies to make it mergeable): https://github.com/jonjohnsonjr/go-containerregistry/tree/editor

This will pop open an editor for you to do whatever you need:

crane edit manifest $IMAGE

So, I'm looking for a tool that can take an arbitrary number of manifests or images and merge them all into a single manifest.

I'm interested in this and there have been some attempts (#891) but I wasn't ever really happy with the UX. I'm thinking we should just have something similar to crane append called crane amend that only works on manifest lists and call it a day.

cc @tianon

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants