Skip to content

Conversation

@mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Mar 17, 2020

This carries over #786 , updating it on top of the later changes to warn instead of reporting an error.

Then, the error messages were updated (now that they don’t abort) to make more sense with multiple platform options. See the added test for an example.

See individual commit messages for details.

@mtrmac
Copy link
Collaborator Author

mtrmac commented Mar 17, 2020

@vrothberg PTAL, I think this (and #820) are the major things worth waiting for before a release.

@mtrmac mtrmac changed the title Adds the option to choose an image by the variant field in a manifest Add the option to choose an image by the variant field in a manifest Mar 17, 2020
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Just a couple of nits.

I wished we wouldn't have to hard-code all the different variants; it feels like whack a mole on the long run. But I don't have an alternative at hand.

copy/copy.go Outdated

"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/image"
platform "github.com/containers/image/v5/internal/pkg/platform"
Copy link
Member

Choose a reason for hiding this comment

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

This seems redundant (and smells like VSCode?).

copy/copy.go Outdated
wantedArch = sys.ArchitectureChoice
// runtimeMatchWarning returns an error message warning about the mismatch
// between an image config and set of platforms by a runtime, or "" if the two match.
func runtimeMatchWarning(cfg *imgspecv1.Image, platforms []imgspecv1.Platform) string {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Using an error (instead of a string) as return value seems more idiomatic to me. Can we change it?

copy/copy.go Outdated
matches = false
}
if matches {
break
Copy link
Member

Choose a reason for hiding this comment

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

We could return here.

copy/copy.go Outdated
for _, o := range platforms {
options.append(fmt.Sprintf("%s+%s", o.OS, o.Architecture))
}
return fmt.Sprintf("Image operating system mismatch: image uses OS %q+architecture %q, expecting one of %q",
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to only keep the default case here. I don't like the precedence of OS over the arch as both could very well mismatch.

Copy link
Member

Choose a reason for hiding this comment

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

It would simply this function quite a bit as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, the default can be good enough.

In that case I’m tempted to inline the warning generator back and drop the tests. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

SGTM 👍

@vrothberg
Copy link
Member

@mtrmac, sorry for not mentioning earlier. Could you squash the commits into one?

@mtrmac
Copy link
Collaborator Author

mtrmac commented Mar 18, 2020

Updated and squashed now.

@rhatdan
Copy link
Member

rhatdan commented Mar 18, 2020

LGTM

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM, @mtrmac feel free to merge

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.

4 participants