Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/docker/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"strings"

pluginmanager "github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/cli/command"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -26,8 +27,10 @@ func processAliases(dockerCli command.Cli, cmd *cobra.Command, args, osArgs []st
if _, ok := allowedAliases[k]; !ok {
return args, osArgs, errors.Errorf("not allowed to alias %q (allowed: %#v)", k, allowedAliases)
}
if _, _, err := cmd.Find(strings.Split(v, " ")); err == nil {
return args, osArgs, errors.Errorf("not allowed to alias with builtin %q as target", v)
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)
}
}
aliases = append(aliases, [2][]string{{k}, {v}})
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ func runDocker(dockerCli *command.DockerCli) error {
return err
}

err = pluginmanager.AddPluginCommandStubs(dockerCli, cmd)
args, os.Args, err = processAliases(dockerCli, cmd, args, os.Args)
if err != nil {
return err
}

args, os.Args, err = processAliases(dockerCli, cmd, args, os.Args)
err = pluginmanager.AddPluginCommandStubs(dockerCli, cmd)
if err != nil {
return err
}
Expand Down