Skip to content

Commit

Permalink
builder: remove alias logic
Browse files Browse the repository at this point in the history
The aliases (configurable through the `~/.docker/config.json`) were a temporary
solution while buildx was not yet the default. They're an internal-use (undocumented)
option, so we don't have to take other uses into account.

This removes some of the logic to read the aliasses-config from the configuration
file, and hard-codes it to assume `buildx`.

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Feb 3, 2022
1 parent ca169d6 commit 8464bf7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 66 deletions.
50 changes: 0 additions & 50 deletions cmd/docker/aliases.go

This file was deleted.

21 changes: 6 additions & 15 deletions cmd/docker/builder.go
Expand Up @@ -59,17 +59,8 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
}
}

// if a builder alias is defined, use it instead
// of the default one
builderAlias := builderDefaultPlugin
aliasMap := dockerCli.ConfigFile().Aliases
if v, ok := aliasMap[keyBuilderAlias]; ok {
useBuilder = true
builderAlias = v
}

// is this a build that should be forwarded to the builder?
fwargs, fwosargs, forwarded := forwardBuilder(builderAlias, args, osargs)
fwargs, fwosargs, forwarded := forwardBuilder(args, osargs)
if !forwarded {
return args, osargs, nil
}
Expand All @@ -81,7 +72,7 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
}

// check plugin is available if cmd forwarded
plugin, perr := pluginmanager.GetPlugin(builderAlias, dockerCli, cmd.Root())
plugin, perr := pluginmanager.GetPlugin(builderDefaultPlugin, dockerCli, cmd.Root())
if perr == nil && plugin != nil {
perr = plugin.Err
}
Expand All @@ -98,19 +89,19 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
return fwargs, fwosargs, nil
}

func forwardBuilder(alias string, args, osargs []string) ([]string, []string, bool) {
func forwardBuilder(args, osargs []string) ([]string, []string, bool) {
aliases := [][2][]string{
{
{"builder"},
{alias},
{"buildx"},
},
{
{"build"},
{alias, "build"},
{"buildx", "build"},
},
{
{"image", "build"},
{alias, "build"},
{"buildx", "build"},
},
}
for _, al := range aliases {
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker/docker.go
Expand Up @@ -228,7 +228,7 @@ func runDocker(dockerCli *command.DockerCli) error {
return err
}

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

0 comments on commit 8464bf7

Please sign in to comment.