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:
Sebastiaan van Stijn
2024-06-03 19:54:30 +02:00
parent 6ff3e09d20
commit 19a056163c
9 changed files with 9 additions and 9 deletions

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -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) {

View File

@@ -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
}

View File

@@ -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

View File

@@ -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.
}
}

View File

@@ -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.

View File

@@ -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.
}

View File

@@ -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",
}
}