Skip to content

Commit

Permalink
Merge pull request #385 from errordeveloper/fix-308
Browse files Browse the repository at this point in the history
Allow users to have separate store paths
  • Loading branch information
tonistiigi committed Sep 10, 2020
2 parents 1c7434a + 4b2aab0 commit 0269388
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 15 additions & 2 deletions commands/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,27 @@ import (

// getStore returns current builder instance store
func getStore(dockerCli command.Cli) (*store.Txn, func(), error) {
dir := filepath.Dir(dockerCli.ConfigFile().Filename)
s, err := store.New(dir)
s, err := store.New(getConfigStorePath(dockerCli))
if err != nil {
return nil, nil, err
}
return s.Txn()
}

// getConfigStorePath will look for correct configuration store path;
// if `$BUILDX_CONFIG` is set - use it, otherwise use parent directory
// of Docker config file (i.e. `${DOCKER_CONFIG}/buildx`)
func getConfigStorePath(dockerCli command.Cli) string {
if buildxConfig := os.Getenv("BUILDX_CONFIG"); buildxConfig != "" {
logrus.Debugf("using config store %q based in \"$BUILDX_CONFIG\" environment variable", buildxConfig)
return buildxConfig
}

buildxConfig := filepath.Join(filepath.Dir(dockerCli.ConfigFile().Filename), "buildx")
logrus.Debugf("using default config store %q", buildxConfig)
return buildxConfig
}

// getCurrentEndpoint returns the current default endpoint value
func getCurrentEndpoint(dockerCli command.Cli) (string, error) {
name := dockerCli.CurrentContext()
Expand Down
1 change: 0 additions & 1 deletion store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
)

func New(root string) (*Store, error) {
root = filepath.Join(root, "buildx")
if err := os.MkdirAll(filepath.Join(root, "instances"), 0700); err != nil {
return nil, err
}
Expand Down

0 comments on commit 0269388

Please sign in to comment.