mirror of
https://github.com/containerd/containerd.git
synced 2026-06-24 08:48:48 +00:00
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 <github@gone.nl>
This commit is contained in:
@@ -110,7 +110,7 @@ type RemoteOpt func(*Client, *RemoteContext) error
|
||||
// content for
|
||||
func WithPlatform(platform string) RemoteOpt {
|
||||
if platform == "" {
|
||||
platform = platforms.DefaultString()
|
||||
platform = platforms.Format(platforms.DefaultSpec()) // For 1.7 continue using the old format without os-version included.
|
||||
}
|
||||
return func(_ *Client, c *RemoteContext) error {
|
||||
for _, p := range c.Platforms {
|
||||
|
||||
@@ -132,7 +132,7 @@ func NewFetchConfig(ctx context.Context, clicontext *cli.Context) (*FetchConfig,
|
||||
if !clicontext.Bool("all-platforms") {
|
||||
p := clicontext.StringSlice("platform")
|
||||
if len(p) == 0 {
|
||||
p = append(p, platforms.DefaultString())
|
||||
p = append(p, platforms.Format(platforms.DefaultSpec())) // For 1.7 continue using the old format without os-version included.
|
||||
}
|
||||
config.Platforms = p
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ When you are done, use the unmount command.
|
||||
cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "Mount the image for the specified platform",
|
||||
Value: platforms.DefaultString(),
|
||||
Value: platforms.Format(platforms.DefaultSpec()), // For 1.7 continue using the old format without os-version included.
|
||||
},
|
||||
),
|
||||
Action: func(context *cli.Context) (retErr error) {
|
||||
|
||||
@@ -49,7 +49,7 @@ var defaultSpecCommand = cli.Command{
|
||||
ctx, cancel := commands.AppContext(context)
|
||||
defer cancel()
|
||||
|
||||
platform := platforms.DefaultString()
|
||||
platform := platforms.Format(platforms.DefaultSpec()) // For 1.7 continue using the old format without os-version included.
|
||||
if plat := context.String("platform"); plat != "" {
|
||||
platform = plat
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func ReadSpec(path string) (*Spec, error) {
|
||||
// GenerateSpec will generate a default spec from the provided image
|
||||
// for use as a containerd container
|
||||
func GenerateSpec(ctx context.Context, client Client, c *containers.Container, opts ...SpecOpts) (*Spec, error) {
|
||||
return GenerateSpecWithPlatform(ctx, client, platforms.DefaultString(), c, opts...)
|
||||
return GenerateSpecWithPlatform(ctx, client, platforms.Format(platforms.DefaultSpec()), c, opts...) // For 1.7 continue using the old format without os-version included.
|
||||
}
|
||||
|
||||
// GenerateSpecWithPlatform will generate a default spec from the provided image
|
||||
|
||||
@@ -138,7 +138,7 @@ func ensureAdditionalGids(s *Spec) {
|
||||
// Use as the first option to clear the spec, then apply options afterwards.
|
||||
func WithDefaultSpec() SpecOpts {
|
||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||
return generateDefaultSpecWithPlatform(ctx, platforms.DefaultString(), c.ID, s)
|
||||
return generateDefaultSpecWithPlatform(ctx, platforms.Format(platforms.DefaultSpec()), c.ID, s) // For 1.7 continue using the old format without os-version included.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func Default() platforms.MatchComparer {
|
||||
|
||||
// DefaultString returns the default string specifier for the platform.
|
||||
func DefaultString() string {
|
||||
return platforms.DefaultString()
|
||||
return platforms.Format(platforms.DefaultSpec()) // For 1.7 continue using the old format without os-version included.
|
||||
}
|
||||
|
||||
// DefaultStrict returns strict form of Default.
|
||||
|
||||
@@ -23,5 +23,5 @@ import (
|
||||
)
|
||||
|
||||
func defaultPlatforms() []string {
|
||||
return []string{platforms.DefaultString()}
|
||||
return []string{platforms.Format(platforms.DefaultSpec())} // For 1.7 continue using the old format without os-version included.
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
func defaultPlatforms() []string {
|
||||
return []string{
|
||||
platforms.DefaultString(),
|
||||
platforms.Format(platforms.DefaultSpec()), // For 1.7 continue using the old format without os-version included.
|
||||
"linux/amd64",
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user