bake: fix BUILDX_BAKE_FILE env behavior
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
+3
-3
@@ -465,13 +465,13 @@ func bakeCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
filesFromEnv := false
|
||||
if len(options.files) == 0 {
|
||||
envFiles, err := bakeEnvFiles(os.LookupEnv)
|
||||
if err != nil {
|
||||
if envFiles, err := bakeEnvFiles(os.LookupEnv); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if len(envFiles) > 0 {
|
||||
options.files = envFiles
|
||||
filesFromEnv = true
|
||||
}
|
||||
}
|
||||
// reset to nil to avoid override is unset
|
||||
if !cmd.Flags().Lookup("no-cache").Changed {
|
||||
cFlags.noCache = nil
|
||||
|
||||
@@ -2204,6 +2204,22 @@ target "second" {
|
||||
}
|
||||
`)
|
||||
|
||||
t.Run("no env", func(t *testing.T) {
|
||||
dir := tmpdir(t,
|
||||
fstest.CreateFile("docker-bake.hcl", bakeFileFirst, 0600),
|
||||
fstest.CreateFile("first", []byte("first"), 0600),
|
||||
)
|
||||
cmd := buildxCmd(sb,
|
||||
withDir(dir),
|
||||
withArgs("bake", "--progress=plain", "first"))
|
||||
|
||||
dt, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, string(dt))
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions`)
|
||||
require.NotContains(t, string(dt), `from BUILDX_BAKE_FILE env`)
|
||||
require.Contains(t, string(dt), `#1 reading docker-bake.hcl`)
|
||||
})
|
||||
|
||||
t.Run("single file", func(t *testing.T) {
|
||||
dir := tmpdir(t,
|
||||
fstest.CreateFile("first.hcl", bakeFileFirst, 0600),
|
||||
|
||||
Reference in New Issue
Block a user