Refactor platforms.Only with a "platformVector" helper#4891
Merged
dmcgowan merged 1 commit intocontainerd:masterfrom Dec 29, 2020
Merged
Refactor platforms.Only with a "platformVector" helper#4891dmcgowan merged 1 commit intocontainerd:masterfrom
dmcgowan merged 1 commit intocontainerd:masterfrom
Conversation
This improves the hard-coded list of ARM fallbacks in the `platform.Only` implementation (by doing a descending loop over variant numbers instead, which is all the hard-coded list was doing). Making this a separate function can then more easily be recursive later for handling an `arm64`->`arm` fallback (or similar), but I think it makes the code a lot more clear too (so we're calculating a vector of platforms separately from building a matcher object). This also makes a minor adjustment in `TestImagePullWithDistSourceLabel` which had an implicit assumption that `platforms.Only` would only ever result in a single suitable manifest, which isn't strictly true (and is likely failing as-is when run on any 32bit `arm` system that's `v6` or higher, which this fixes 😅). Signed-off-by: Tianon Gravi <[email protected]>
|
Build succeeded.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This improves the hard-coded list of ARM fallbacks in the
platform.Onlyimplementation (by doing a descending loop over variant numbers instead, which is all the hard-coded list was doing).Making this a separate function can then more easily be recursive later for handling an
arm64->armfallback (or similar), but I think it makes the code a lot more clear too (so we're calculating a vector of platforms separately from building a matcher object).This also makes a minor adjustment in
TestImagePullWithDistSourceLabelwhich had an implicit assumption thatplatforms.Onlywould only ever result in a single suitable manifest, which isn't strictly true (and is likely failing as-is when run on any 32bitarmsystem that'sv6or higher, which this fixes 😅).Additionally, this makes
singlePlatformComparerunused, so rather than switch implementations whenlen(vector) == 1, I opted to remove it because there really shouldn't be much overhead in looping over a single vector list item vs just using/comparing it directly (but I'm happy to revert/adjust if that's preferred).This splits off another bit from #4528 which should be (hopefully?) less controversial as well. 😄 ❤️