mirror of https://github.com/docker/cli.git
Merge pull request #2842 from thaJeztah/platform_experimental
build: remove PersistentPreRunE hack for experimental --platform
This commit is contained in:
commit
51a091485d
|
@ -113,25 +113,6 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap the global pre-run to handle non-BuildKit use of the --platform flag.
|
|
||||||
//
|
|
||||||
// We're doing it here so that we're only contacting the daemon when actually
|
|
||||||
// running the command, and not during initialization.
|
|
||||||
// TODO remove this hack once we no longer support the experimental use of --platform
|
|
||||||
rootFn := cmd.Root().PersistentPreRunE
|
|
||||||
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
|
|
||||||
if ok, _ := command.BuildKitEnabled(dockerCli.ServerInfo()); !ok {
|
|
||||||
f := cmd.Flag("platform")
|
|
||||||
delete(f.Annotations, "buildkit")
|
|
||||||
f.Annotations["version"] = []string{"1.32"}
|
|
||||||
f.Annotations["experimental"] = nil
|
|
||||||
}
|
|
||||||
if rootFn != nil {
|
|
||||||
return rootFn(cmd, args)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
|
|
||||||
flags.VarP(&options.tags, "tag", "t", "Name and optionally a tag in the 'name:tag' format")
|
flags.VarP(&options.tags, "tag", "t", "Name and optionally a tag in the 'name:tag' format")
|
||||||
|
|
|
@ -125,7 +125,6 @@ func PruneFilters(dockerCli Cli, pruneFilters filters.Args) filters.Args {
|
||||||
func AddPlatformFlag(flags *pflag.FlagSet, target *string) {
|
func AddPlatformFlag(flags *pflag.FlagSet, target *string) {
|
||||||
flags.StringVar(target, "platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"), "Set platform if server is multi-platform capable")
|
flags.StringVar(target, "platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"), "Set platform if server is multi-platform capable")
|
||||||
flags.SetAnnotation("platform", "version", []string{"1.32"})
|
flags.SetAnnotation("platform", "version", []string{"1.32"})
|
||||||
flags.SetAnnotation("platform", "experimental", nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateOutputPath validates the output paths of the `export` and `save` commands.
|
// ValidateOutputPath validates the output paths of the `export` and `save` commands.
|
||||||
|
|
Loading…
Reference in New Issue