mirror of https://github.com/docker/cli.git
Merge pull request #3795 from thaJeztah/ignore_stubs_in_aliases
fix broken alias check is buildx is installed as alias for builder
This commit is contained in:
commit
a496a7d501
|
@ -4,6 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
pluginmanager "github.com/docker/cli/cli-plugins/manager"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -26,9 +27,11 @@ func processAliases(dockerCli command.Cli, cmd *cobra.Command, args, osArgs []st
|
||||||
if _, ok := allowedAliases[k]; !ok {
|
if _, ok := allowedAliases[k]; !ok {
|
||||||
return args, osArgs, errors.Errorf("not allowed to alias %q (allowed: %#v)", k, allowedAliases)
|
return args, osArgs, errors.Errorf("not allowed to alias %q (allowed: %#v)", k, allowedAliases)
|
||||||
}
|
}
|
||||||
if _, _, err := cmd.Find(strings.Split(v, " ")); err == nil {
|
if c, _, err := cmd.Find(strings.Split(v, " ")); err == nil {
|
||||||
|
if c.Annotations[pluginmanager.CommandAnnotationPlugin] != "true" {
|
||||||
return args, osArgs, errors.Errorf("not allowed to alias with builtin %q as target", v)
|
return args, osArgs, errors.Errorf("not allowed to alias with builtin %q as target", v)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
aliases = append(aliases, [2][]string{{k}, {v}})
|
aliases = append(aliases, [2][]string{{k}, {v}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,12 +218,12 @@ func runDocker(dockerCli *command.DockerCli) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pluginmanager.AddPluginCommandStubs(dockerCli, cmd)
|
args, os.Args, err = processAliases(dockerCli, cmd, args, os.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
args, os.Args, err = processAliases(dockerCli, cmd, args, os.Args)
|
err = pluginmanager.AddPluginCommandStubs(dockerCli, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue