Skip to content

Commit

Permalink
Merge pull request #170 from depot/unpublish-buildx-shim
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie authored Aug 2, 2023
2 parents 18e9005 + 2f32cc0 commit 2964347
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 67 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,6 @@ Configure Docker to use Depot's remote builder infrastructure. This command inst
depot configure-docker
```

To configure `docker buildx build` to use the Depot plugin, you can specify the `--shim-buildx` flag.

```shell
depot configure-docker --shim-buildx
```

If you want to uninstall the plugin, you can specify the `--uninstall` flag.

```shell
Expand Down
61 changes: 0 additions & 61 deletions pkg/cmd/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package version
import (
"fmt"
"os"
"os/exec"
"path"

"github.com/docker/cli/cli/config"
Expand All @@ -12,7 +11,6 @@ import (
)

func NewCmdConfigureDocker() *cobra.Command {
shimBuildx := false
uninstall := false

cmd := &cobra.Command{
Expand Down Expand Up @@ -42,12 +40,6 @@ func NewCmdConfigureDocker() *cobra.Command {
return errors.Wrap(err, "could not install depot plugin")
}

if shimBuildx {
if err := installDepotBuildxPlugin(dir, self); err != nil {
return errors.Wrap(err, "could not install depot plugin")
}
}

if err := useDepotBuilderAlias(dir); err != nil {
return errors.Wrap(err, "could not set depot builder alias")
}
Expand All @@ -59,7 +51,6 @@ func NewCmdConfigureDocker() *cobra.Command {
}

flags := cmd.Flags()
flags.BoolVar(&shimBuildx, "shim-buildx", false, "Shim docker buildx build to use Depot")
flags.BoolVar(&uninstall, "uninstall", false, "Remove Docker plugin")

return cmd
Expand All @@ -85,58 +76,6 @@ func installDepotPlugin(dir, self string) error {
return nil
}

func installDepotBuildxPlugin(dir, self string) error {
if err := os.MkdirAll(path.Join(config.Dir(), "cli-plugins"), 0755); err != nil {
return errors.Wrap(err, "could not create cli-plugins directory")
}

symlink := path.Join(config.Dir(), "cli-plugins", "docker-buildx")
original := path.Join(config.Dir(), "cli-plugins", "original-docker-buildx")
global := "/usr/libexec/docker/cli-plugins/docker-buildx"

// If original plugin symlink does not exist, create it

if _, err := os.Stat(original); err != nil {
if !os.IsNotExist(err) {
return errors.Wrap(err, "could not stat original-docker-buildx plugin")
}

if _, err := os.Stat(symlink); err == nil {
err = os.Rename(symlink, original)
if err != nil {
return errors.Wrap(err, "could not rename existing symlink")
}
} else {
candidate, err := exec.LookPath("docker-buildx")
if err != nil {
if _, err := os.Stat(global); err == nil {
candidate = global
} else {
return errors.Wrap(err, "could not find docker-buildx plugin")
}
}
err = os.Symlink(candidate, original)
if err != nil {
return errors.Wrap(err, "could not create original-docker-buildx plugin")
}
}
}

// Original plugin exists, update current symlink

err := os.RemoveAll(symlink)
if err != nil {
return errors.Wrap(err, "could not remove existing symlink")
}

err = os.Symlink(self, symlink)
if err != nil {
return errors.Wrap(err, "could not create symlink")
}

return nil
}

func useDepotBuilderAlias(dir string) error {
cfg, err := config.Load(dir)
if err != nil {
Expand Down

0 comments on commit 2964347

Please sign in to comment.