create: load default buildkit config if none specified

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2022-05-13 11:53:53 +02:00
parent 98439f7f08
commit 8257a04a7d
3 changed files with 26 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package confutil
import (
"os"
"path"
"path/filepath"
"github.com/docker/cli/cli/command"
@ -24,6 +25,15 @@ func ConfigDir(dockerCli command.Cli) string {
return buildxConfig
}
// DefaultConfigFile returns the default BuildKit configuration file path
func DefaultConfigFile(dockerCli command.Cli) (string, bool) {
f := path.Join(ConfigDir(dockerCli), "buildkitd.default.toml")
if _, err := os.Stat(f); err == nil {
return f, true
}
return "", false
}
// loadConfigTree loads BuildKit config toml tree
func loadConfigTree(fp string) (*toml.Tree, error) {
f, err := os.Open(fp)