mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	Merge pull request #385 from errordeveloper/fix-308
Allow users to have separate store paths
This commit is contained in:
		@@ -22,14 +22,27 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// getStore returns current builder instance store
 | 
					// getStore returns current builder instance store
 | 
				
			||||||
func getStore(dockerCli command.Cli) (*store.Txn, func(), error) {
 | 
					func getStore(dockerCli command.Cli) (*store.Txn, func(), error) {
 | 
				
			||||||
	dir := filepath.Dir(dockerCli.ConfigFile().Filename)
 | 
						s, err := store.New(getConfigStorePath(dockerCli))
 | 
				
			||||||
	s, err := store.New(dir)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, nil, err
 | 
							return nil, nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return s.Txn()
 | 
						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
 | 
					// getCurrentEndpoint returns the current default endpoint value
 | 
				
			||||||
func getCurrentEndpoint(dockerCli command.Cli) (string, error) {
 | 
					func getCurrentEndpoint(dockerCli command.Cli) (string, error) {
 | 
				
			||||||
	name := dockerCli.CurrentContext()
 | 
						name := dockerCli.CurrentContext()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,6 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func New(root string) (*Store, error) {
 | 
					func New(root string) (*Store, error) {
 | 
				
			||||||
	root = filepath.Join(root, "buildx")
 | 
					 | 
				
			||||||
	if err := os.MkdirAll(filepath.Join(root, "instances"), 0700); err != nil {
 | 
						if err := os.MkdirAll(filepath.Join(root, "instances"), 0700); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user