builder: correct the command path for docker build
The command path sent for `docker build` should be `docker` rather than `docker build` to be consistent with the other command paths. * `docker buildx build` has a command path of `docker buildx` * `docker builder build` has a command path of `docker builder` * `docker image build` has a command path of `docker image` The reason this gets set to `docker buildx` rather than `docker buildx build` is because the `build` portion of the command path is processed by the plugin. So the command path only contains the portions of the command path that were processed by this tool. Since the `build` of `docker build` gets forwarded to `buildx`, it is not included in the command path. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
Родитель
a2f3f40233
Коммит
9392831817
|
@ -69,7 +69,7 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
|
|||
}
|
||||
|
||||
// is this a build that should be forwarded to the builder?
|
||||
fwargs, fwosargs, alias, forwarded := forwardBuilder(builderAlias, args, osargs)
|
||||
fwargs, fwosargs, fwcmdpath, forwarded := forwardBuilder(builderAlias, args, osargs)
|
||||
if !forwarded {
|
||||
return args, osargs, nil, nil
|
||||
}
|
||||
|
@ -117,33 +117,37 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
|
|||
}
|
||||
|
||||
// overwrite the command path for this plugin using the alias name.
|
||||
cmd.Annotations[pluginmanager.CommandAnnotationPluginCommandPath] = fmt.Sprintf("%s %s", cmd.CommandPath(), alias)
|
||||
cmd.Annotations[pluginmanager.CommandAnnotationPluginCommandPath] = strings.Join(append([]string{cmd.CommandPath()}, fwcmdpath...), " ")
|
||||
|
||||
return fwargs, fwosargs, envs, nil
|
||||
}
|
||||
|
||||
func forwardBuilder(alias string, args, osargs []string) ([]string, []string, string, bool) {
|
||||
aliases := [][2][]string{
|
||||
func forwardBuilder(alias string, args, osargs []string) ([]string, []string, []string, bool) {
|
||||
aliases := [][3][]string{
|
||||
{
|
||||
{"builder"},
|
||||
{alias},
|
||||
{"builder"},
|
||||
},
|
||||
{
|
||||
{"build"},
|
||||
{alias, "build"},
|
||||
{},
|
||||
},
|
||||
{
|
||||
{"image", "build"},
|
||||
{alias, "build"},
|
||||
{"image"},
|
||||
},
|
||||
}
|
||||
for _, al := range aliases {
|
||||
if fwargs, changed := command.StringSliceReplaceAt(args, al[0], al[1], 0); changed {
|
||||
fwosargs, _ := command.StringSliceReplaceAt(osargs, al[0], al[1], -1)
|
||||
return fwargs, fwosargs, al[0][0], true
|
||||
fwcmdpath := al[2]
|
||||
return fwargs, fwosargs, fwcmdpath, true
|
||||
}
|
||||
}
|
||||
return args, osargs, "", false
|
||||
return args, osargs, nil, false
|
||||
}
|
||||
|
||||
// hasBuilderName checks if a builder name is defined in args or env vars
|
||||
|
|
Загрузка…
Ссылка в новой задаче