Skip to content

Update uses of Image platform fields in OCI image-spec#44125

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:image_spec_no_literal
Sep 15, 2022
Merged

Update uses of Image platform fields in OCI image-spec#44125
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:image_spec_no_literal

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Sep 10, 2022

The OCI image spec is considering to change the Image struct and embedding the Platform type (see opencontainers/image-spec#959) in the go implementation. Moby currently uses some struct-literals to propagate the platform fields, which will break once those changes in the OCI spec are merged.

Ideally (once that change arrives) we would update the code to set the Platform information as a whole, instead of assigning related fields individually, but in some cases in the code, image platform information is only partially set (for example, OSVersion and OSFeatures are not preserved in all cases). This may be on purpose, so needs to be reviewed.

This patch keeps the current behavior (assigning only specific fields), but removes the use of struct-literals to make the code compatible with the upcoming changes in the image-spec module.

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

The OCI image spec is considering to change the Image struct and embedding the
Platform type (see opencontainers/image-spec#959) in the go implementation.
Moby currently uses some struct-literals to propagate the platform fields,
which will break once those changes in the OCI spec are merged.

Ideally (once that change arrives) we would update the code to set the Platform
information as a whole, instead of assigning related fields individually, but
in some cases in the code, image platform information is only partially set
(for example, OSVersion and OSFeatures are not preserved in all cases). This
may be on purpose, so needs to be reviewed.

This patch keeps the current behavior (assigning only specific fields), but
removes the use of struct-literals to make the code compatible with the
upcoming changes in the image-spec module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Comment on lines +25 to +28
img := ocispec.Image{}
img.Architecture = pl.Architecture
img.OS = pl.OS
img.Variant = pl.Variant
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Similar to https://github.com/moby/buildkit/pull/3104/files#r967629557;

This is where I noticed that in some cases we're discarding the OSVersion and OSFeatures fields (there may be other locations where we do this). Perhaps this is intentional, but we should probably review the code to see if we unintentionally discard those fields, and update the code where needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FWIW; Variant was added in a2aaf4c (#43239). Before that, only OS and Architecture were set (and not normalised)

@cpuguy83 cpuguy83 merged commit 0f2376d into moby:master Sep 15, 2022
@thaJeztah thaJeztah deleted the image_spec_no_literal branch September 15, 2022 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants