DockerCLI/cmd/docker
Sebastiaan van Stijn 7af8aac169
fix broken alias check is buildx is installed as alias for builder
Commit cbec75e2f3 updated `runDocker()` to load
plugin-stubs before `processAliases()` was executed. As a result, plugin
stubs were considered as "builtin commands", causing the alias verification
to fail;

Without alias installed:

```bash
docker version
Client:
 Version:           22.06.0-beta.0-140-g3dad26ca2.m
 API version:       1.42
 Go version:        go1.19.1
 Git commit:        3dad26ca2
 Built:             Wed Sep 28 22:36:09 2022
 OS/Arch:           darwin/arm64
 Context:           default
...
```

After running `docker buildx install`;

```bash
./build/docker buildx install

cat ~/.docker/config.json
{
    "aliases": {
        "builder": "buildx"
    }
}

./build/docker version
not allowed to alias with builtin "buildx" as target
```

This patch moves loading the stubs _after_ the call to `processAliases()`, so
that verification passes. As an extra precaution, the `processAliases()` function
is also updated to exclude plugin-stub commands.

Note that cbec75e2f3 also introduced a performance
regression, which may be related to the early loading of plugins (and creating
stubs); it looks like various other code locations may also be loading plugins,
for example `tryPluginRun()` calls `pluginmanager.PluginRunCommand()`, which
also traverses plugin directories.

We should look under what circumstances the plugin stub-commands are actually
needed, and make sure that they're only created in those situations.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-29 22:40:51 +02:00
..
winresources Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00
aliases.go fix broken alias check is buildx is installed as alias for builder 2022-09-29 22:40:51 +02:00
builder.go build: use legacy builder for wcow if not opt-in with a builder component 2022-02-24 17:57:56 +01:00
builder_test.go replace uses of deprecated env.Patch() 2022-09-22 17:28:07 +02:00
completions.go Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
docker.go fix broken alias check is buildx is installed as alias for builder 2022-09-29 22:40:51 +02:00
docker_test.go Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
docker_windows_386.go Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00
docker_windows_amd64.go Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00
docker_windows_arm.go Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00
docker_windows_arm64.go Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00