File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -465,12 +465,12 @@ func bakeCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
465465 RunE : func (cmd * cobra.Command , args []string ) error {
466466 filesFromEnv := false
467467 if len (options .files ) == 0 {
468- envFiles , err := bakeEnvFiles (os .LookupEnv )
469- if err != nil {
468+ if envFiles , err := bakeEnvFiles (os .LookupEnv ); err != nil {
470469 return err
470+ } else if len (envFiles ) > 0 {
471+ options .files = envFiles
472+ filesFromEnv = true
471473 }
472- options .files = envFiles
473- filesFromEnv = true
474474 }
475475 // reset to nil to avoid override is unset
476476 if ! cmd .Flags ().Lookup ("no-cache" ).Changed {
Original file line number Diff line number Diff line change @@ -2204,6 +2204,22 @@ target "second" {
22042204}
22052205` )
22062206
2207+ t .Run ("no env" , func (t * testing.T ) {
2208+ dir := tmpdir (t ,
2209+ fstest .CreateFile ("docker-bake.hcl" , bakeFileFirst , 0600 ),
2210+ fstest .CreateFile ("first" , []byte ("first" ), 0600 ),
2211+ )
2212+ cmd := buildxCmd (sb ,
2213+ withDir (dir ),
2214+ withArgs ("bake" , "--progress=plain" , "first" ))
2215+
2216+ dt , err := cmd .CombinedOutput ()
2217+ require .NoError (t , err , string (dt ))
2218+ require .Contains (t , string (dt ), `#1 [internal] load local bake definitions` )
2219+ require .NotContains (t , string (dt ), `from BUILDX_BAKE_FILE env` )
2220+ require .Contains (t , string (dt ), `#1 reading docker-bake.hcl` )
2221+ })
2222+
22072223 t .Run ("single file" , func (t * testing.T ) {
22082224 dir := tmpdir (t ,
22092225 fstest .CreateFile ("first.hcl" , bakeFileFirst , 0600 ),
You can’t perform that action at this time.
0 commit comments