Commit Graph

17 Commits

Author SHA1 Message Date
Maksym Pavlenko
3c8469a782 Use Platform instead of generated API
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-01-12 10:30:42 -08:00
Maksym Pavlenko
ca3b9b50fe Run gofmt 1.19
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-08-04 18:18:33 -07:00
James Sturtevant
83c80388b2 Initialize platform matchers for current platform
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
2022-02-10 08:03:25 -08:00
Sebastiaan van Stijn
bec6e4dd67
platforms.Normalize(): do not reset OSVersion and OSFeatures
Commit fb0688362c implemented the Normalize()
function, but marked these fields as deprecated.

It's unclear what the motivation was for this, as the fields are part of the OCI
Image spec. On Windows, the OSVersion field specifically is important when matching
images (as kernel versions may not be compatible).

This patch updates platforms.Normalize() to preserve the OSVersion and OSFeatures
fields.

As a follow-up, we should look at defining an appropriate string-representation
for these fields (possibly as part of the OCI Spec), and update platforms.Parse()
accordingly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-02-01 17:19:28 +01:00
haoyun
bbe46b8c43 feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
2022-01-07 10:27:03 +08:00
Sebastiaan van Stijn
f2c3122e9c
platforms: Format(): use path.Join() instead of joinNotEmpty()
path.Join() also skips empty components, making it the equivalent of
this function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-02 09:48:34 +02:00
Jason Hall
363f2c392c Derive cpuinfo as needed, instead of at init-time
This changes platforms.Parse to hit /proc to look up CPU info only when
it's needed, instead of in init(). This makes the package a bit easier
for other packages to consume, especially clients that don't call
platforms.Parse or need to lookup CPU info.

Signed-off-by: Jason Hall <jasonhall@redhat.com>
2021-01-19 14:10:39 -05:00
Shengjing Zhu
90cd777a6c platforms: fill default arm variant when parse platform specifier
arm has been supported, but something is missing, causes test failure

    --- FAIL: TestParseSelector/linux (0.00s)
        platforms_test.go:292: arm support not fully implemented: not implemented
    --- FAIL: TestParseSelector/macOS (0.00s)
        platforms_test.go:292: arm support not fully implemented: not implemented

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2020-01-08 13:35:49 +08:00
chentanjun
92a5b08a68 fix-grammar-mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-28 16:10:08 +08:00
Ian Campbell
c83f9773bc platforms: Add MustParse
This function is analogous to `regexp.MustCompile` and can simplify production
of a `Platform` from a hard-coded strings, e.g. for global variable
initialisation.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2018-08-15 11:30:46 +01:00
Derek McGowan
db3c5afc6d
Normalize arm64 to an empty variant
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-06-23 16:35:46 -07:00
Derek McGowan
37ab93e2c8
Fix arm platform matching
The normalization was being inconsistently applied causing a
failure to match some platforms in manifest lists.
Fix the matcher and normalization to be more consistent and
add changes to parser to prevent the defaulted variants from being
set in the platform structure.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-06-21 17:07:58 -07:00
Jess Valarezo
ac8008437a update platforms Parse to return platform spec, decouple matcher
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2018-02-27 14:21:49 -08:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Stephen J Day
775f7cea47
platforms: update format for platform specifier
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-13 11:41:45 -07:00
Stephen J Day
94f6be5f10
platforms: implement matcher support
Matching support is now implemented in the platforms package. The
`Parse` function now returns a matcher object that can be used to
match OCI platform specifications. We define this as an interface to
allow the creation of helpers oriented around platform selection.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-08 19:22:29 -07:00
Stephen J Day
fb0688362c
platforms: define selectors for platforms
For supporting selection of images and runtimes in the containerized
world, there is thin support for selecting objects by platform. This
package defines a syntax to display to users that can express specific
platforms in addition to wild cards for matching platforms.

The plan is to extend this to provide support for parsing flag
arguments and displaying platform types for images. This package will
also provide a configurable matcher to allow match of platforms against
arbitrary targets, invariant to the Go compilation.

The internals are based the OCI Image Spec model.

This changeset is being submitted for feedback on the approach before
this gets larger. Specifically, review the unit tests and raise any
concerns.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-08 15:05:21 -07:00