compose: ignore dotenv that is a directory
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
+6
-3
@@ -263,10 +263,13 @@ func loadDotEnv(curenv map[string]string, workingDir string) (map[string]string,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err = os.Stat(ef); os.IsNotExist(err) {
|
||||
return curenv, nil
|
||||
} else if err != nil {
|
||||
if st, err := os.Stat(ef); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return curenv, nil
|
||||
}
|
||||
return nil, err
|
||||
} else if st.IsDir() {
|
||||
return curenv, nil
|
||||
}
|
||||
|
||||
dt, err := os.ReadFile(ef)
|
||||
|
||||
@@ -846,6 +846,22 @@ services:
|
||||
require.Equal(t, map[string]string{"base": "target:base"}, c.Targets[1].Contexts)
|
||||
}
|
||||
|
||||
func TestDotEnvDir(t *testing.T) {
|
||||
tmpdir := t.TempDir()
|
||||
require.NoError(t, os.Mkdir(filepath.Join(tmpdir, ".env"), 0755))
|
||||
|
||||
dt := []byte(`
|
||||
services:
|
||||
foo:
|
||||
build:
|
||||
context: .
|
||||
`)
|
||||
|
||||
chdir(t, tmpdir)
|
||||
_, err := ParseComposeFiles([]File{{Name: "compose.yml", Data: dt}})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// chdir changes the current working directory to the named directory,
|
||||
// and then restore the original working directory at the end of the test.
|
||||
func chdir(t *testing.T, dir string) {
|
||||
|
||||
Reference in New Issue
Block a user