-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move cpu variant checks into platform matcher
Wrap platforms.Only and fallback to our ignore mismatches due to empty CPU variants. This just cleans things up and makes the logic re-usable in other places. Signed-off-by: Brian Goff <[email protected]> (cherry picked from commit 50f39e7) Signed-off-by: Brian Goff <[email protected]>
- Loading branch information
Showing
3 changed files
with
84 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package images | ||
|
||
import ( | ||
"testing" | ||
|
||
specs "github.com/opencontainers/image-spec/specs-go/v1" | ||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestOnlyPlatformWithFallback(t *testing.T) { | ||
p := specs.Platform{ | ||
OS: "linux", | ||
Architecture: "arm", | ||
Variant: "v8", | ||
} | ||
|
||
// Check no variant | ||
assert.Assert(t, OnlyPlatformWithFallback(p).Match(specs.Platform{ | ||
OS: p.OS, | ||
Architecture: p.Architecture, | ||
})) | ||
// check with variant | ||
assert.Assert(t, OnlyPlatformWithFallback(p).Match(specs.Platform{ | ||
OS: p.OS, | ||
Architecture: p.Architecture, | ||
Variant: p.Variant, | ||
})) | ||
// Make sure non-matches are false. | ||
assert.Assert(t, !OnlyPlatformWithFallback(p).Match(specs.Platform{ | ||
OS: p.OS, | ||
Architecture: "amd64", | ||
})) | ||
} |