Skip to content

Commit 6ccdf69

Browse files
committed
platforms: mark aliases as deprecated
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 19a0561 commit 6ccdf69

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

platforms/platforms_deprecated.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,47 @@ import (
2222
)
2323

2424
// Platform is a type alias for convenience, so there is no need to import image-spec package everywhere.
25+
//
26+
// Deprecated: use [specs.Platform].
2527
type Platform = specs.Platform
2628

2729
// DefaultSpec returns the current platform's default platform specification.
30+
//
31+
// Deprecated: use [platforms.DefaultSpec].
2832
func DefaultSpec() specs.Platform {
2933
return platforms.DefaultSpec()
3034
}
3135

3236
// Default returns the default matcher for the platform.
37+
//
38+
// Deprecated: use [platforms.Default].
3339
func Default() platforms.MatchComparer {
3440
return platforms.Default()
3541
}
3642

3743
// DefaultString returns the default string specifier for the platform.
44+
//
45+
// Deprecated: use [platforms.DefaultString].
3846
func DefaultString() string {
3947
return platforms.Format(platforms.DefaultSpec()) // For 1.7 continue using the old format without os-version included.
4048
}
4149

4250
// DefaultStrict returns strict form of Default.
51+
//
52+
// Deprecated: use [platforms.DefaultStrict].
4353
func DefaultStrict() MatchComparer {
4454
return platforms.DefaultStrict()
4555
}
4656

4757
// MatchComparer is able to match and compare platforms to
4858
// filter and sort platforms.
59+
//
60+
// Deprecated: use [platforms.MatchComparer].
4961
type MatchComparer = platforms.MatchComparer
5062

5163
// Matcher matches platforms specifications, provided by an image or runtime.
64+
//
65+
// Deprecated: use [platforms.Matcher].
5266
type Matcher = platforms.Matcher
5367

5468
// NewMatcher returns a simple matcher based on the provided platform
@@ -59,6 +73,8 @@ type Matcher = platforms.Matcher
5973
// functionality.
6074
//
6175
// Applications should opt to use `Match` over directly parsing specifiers.
76+
//
77+
// Deprecated: use [platforms.NewMatcher].
6278
func NewMatcher(platform specs.Platform) platforms.Matcher {
6379
return platforms.NewMatcher(platform)
6480
}
@@ -71,17 +87,23 @@ func NewMatcher(platform specs.Platform) platforms.Matcher {
7187
// value will be matched against the known set of operating systems, then fall
7288
// back to the known set of architectures. The missing component will be
7389
// inferred based on the local environment.
90+
//
91+
// Deprecated: use [platforms.Parse].
7492
func Parse(specifier string) (specs.Platform, error) {
7593
return platforms.Parse(specifier)
7694
}
7795

7896
// MustParse is like Parses but panics if the specifier cannot be parsed.
7997
// Simplifies initialization of global variables.
98+
//
99+
// Deprecated: use [platforms.MustParse].
80100
func MustParse(specifier string) specs.Platform {
81101
return platforms.MustParse(specifier)
82102
}
83103

84104
// Format returns a string specifier from the provided platform specification.
105+
//
106+
// Deprecated: use [platforms.Format].
85107
func Format(platform specs.Platform) string {
86108
return platforms.Format(platform)
87109
}
@@ -90,6 +112,8 @@ func Format(platform specs.Platform) string {
90112
//
91113
// For example, if "Aarch64" is encountered, we change it to "arm64" or if
92114
// "x86_64" is encountered, it becomes "amd64".
115+
//
116+
// Deprecated: use [platforms.Normalize].
93117
func Normalize(platform specs.Platform) specs.Platform {
94118
return platforms.Normalize(platform)
95119
}
@@ -101,6 +125,8 @@ func Normalize(platform specs.Platform) specs.Platform {
101125
// For arm/v7, will also match arm/v6 and arm/v5
102126
// For arm/v6, will also match arm/v5
103127
// For amd64, will also match 386
128+
//
129+
// Deprecated: use [platforms.Only].
104130
func Only(platform specs.Platform) platforms.MatchComparer {
105131
return platforms.Only(platform)
106132
}
@@ -113,26 +139,38 @@ func Only(platform specs.Platform) platforms.MatchComparer {
113139
//
114140
// OnlyStrict matches non-canonical forms.
115141
// So, "arm64" matches "arm/64/v8".
142+
//
143+
// Deprecated: use [platforms.OnlyStrict].
116144
func OnlyStrict(platform specs.Platform) platforms.MatchComparer {
117145
return platforms.OnlyStrict(platform)
118146
}
119147

120148
// Ordered returns a platform MatchComparer which matches any of the platforms
121149
// but orders them in order they are provided.
150+
//
151+
// Deprecated: use [platforms.Ordered].
122152
func Ordered(platform ...specs.Platform) platforms.MatchComparer {
123153
return platforms.Ordered(platform...)
124154
}
125155

126156
// Any returns a platform MatchComparer which matches any of the platforms
127157
// with no preference for ordering.
158+
//
159+
// Deprecated: use [platforms.Any].
128160
func Any(platform ...specs.Platform) platforms.MatchComparer {
129161
return platforms.Any(platform...)
130162
}
131163

132164
// All is a platform MatchComparer which matches all platforms
133165
// with preference for ordering.
166+
//
167+
// Deprecated: use [platforms.All].
134168
var All = platforms.All
135169

170+
// GetWindowsOsVersion returns the version of Windows of the local system,
171+
// it returns an empty string on other platforms.
172+
//
173+
// Deprecated: this function is deprecated, and removed in github.com/containerd/platforms
136174
func GetWindowsOsVersion() string {
137175
return getWindowsOsVersion()
138176
}

platforms/platforms_deprecated_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func getWindowsOsVersion() string {
3030
return fmt.Sprintf("%d.%d.%d", major, minor, build)
3131
}
3232

33+
// Deprecated: this function is deprecated, and removed in github.com/containerd/platforms
3334
func GetOsVersion(osVersionPrefix string) osversion.OSVersion {
3435
parts := strings.Split(osVersionPrefix, ".")
3536
if len(parts) < 3 {

0 commit comments

Comments
 (0)