Skip to content

Commit 19a0561

Browse files
committed
adjust default platform for backward-compatibility
The platforms.DefaultString() function in the new module returns a string including the os-version. The existing code does not expect that to be the case, so using the previous format instead. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 6ff3e09 commit 19a0561

9 files changed

Lines changed: 9 additions & 9 deletions

File tree

client_opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ type RemoteOpt func(*Client, *RemoteContext) error
110110
// content for
111111
func WithPlatform(platform string) RemoteOpt {
112112
if platform == "" {
113-
platform = platforms.DefaultString()
113+
platform = platforms.Format(platforms.DefaultSpec()) // For 1.7 continue using the old format without os-version included.
114114
}
115115
return func(_ *Client, c *RemoteContext) error {
116116
for _, p := range c.Platforms {

cmd/ctr/commands/content/fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func NewFetchConfig(ctx context.Context, clicontext *cli.Context) (*FetchConfig,
132132
if !clicontext.Bool("all-platforms") {
133133
p := clicontext.StringSlice("platform")
134134
if len(p) == 0 {
135-
p = append(p, platforms.DefaultString())
135+
p = append(p, platforms.Format(platforms.DefaultSpec())) // For 1.7 continue using the old format without os-version included.
136136
}
137137
config.Platforms = p
138138
}

cmd/ctr/commands/images/mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ When you are done, use the unmount command.
4646
cli.StringFlag{
4747
Name: "platform",
4848
Usage: "Mount the image for the specified platform",
49-
Value: platforms.DefaultString(),
49+
Value: platforms.Format(platforms.DefaultSpec()), // For 1.7 continue using the old format without os-version included.
5050
},
5151
),
5252
Action: func(context *cli.Context) (retErr error) {

cmd/ctr/commands/oci/oci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var defaultSpecCommand = cli.Command{
4949
ctx, cancel := commands.AppContext(context)
5050
defer cancel()
5151

52-
platform := platforms.DefaultString()
52+
platform := platforms.Format(platforms.DefaultSpec()) // For 1.7 continue using the old format without os-version included.
5353
if plat := context.String("platform"); plat != "" {
5454
platform = plat
5555
}

oci/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func ReadSpec(path string) (*Spec, error) {
6464
// GenerateSpec will generate a default spec from the provided image
6565
// for use as a containerd container
6666
func GenerateSpec(ctx context.Context, client Client, c *containers.Container, opts ...SpecOpts) (*Spec, error) {
67-
return GenerateSpecWithPlatform(ctx, client, platforms.DefaultString(), c, opts...)
67+
return GenerateSpecWithPlatform(ctx, client, platforms.Format(platforms.DefaultSpec()), c, opts...) // For 1.7 continue using the old format without os-version included.
6868
}
6969

7070
// GenerateSpecWithPlatform will generate a default spec from the provided image

oci/spec_opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func ensureAdditionalGids(s *Spec) {
138138
// Use as the first option to clear the spec, then apply options afterwards.
139139
func WithDefaultSpec() SpecOpts {
140140
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
141-
return generateDefaultSpecWithPlatform(ctx, platforms.DefaultString(), c.ID, s)
141+
return generateDefaultSpecWithPlatform(ctx, platforms.Format(platforms.DefaultSpec()), c.ID, s) // For 1.7 continue using the old format without os-version included.
142142
}
143143
}
144144

platforms/platforms_deprecated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func Default() platforms.MatchComparer {
3636

3737
// DefaultString returns the default string specifier for the platform.
3838
func DefaultString() string {
39-
return platforms.DefaultString()
39+
return platforms.Format(platforms.DefaultSpec()) // For 1.7 continue using the old format without os-version included.
4040
}
4141

4242
// DefaultStrict returns strict form of Default.

runtime/v2/manager_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ import (
2323
)
2424

2525
func defaultPlatforms() []string {
26-
return []string{platforms.DefaultString()}
26+
return []string{platforms.Format(platforms.DefaultSpec())} // For 1.7 continue using the old format without os-version included.
2727
}

runtime/v2/manager_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
func defaultPlatforms() []string {
2424
return []string{
25-
platforms.DefaultString(),
25+
platforms.Format(platforms.DefaultSpec()), // For 1.7 continue using the old format without os-version included.
2626
"linux/amd64",
2727
}
2828
}

0 commit comments

Comments
 (0)