Skip to content

Commit df2c6a6

Browse files
Merge pull request #293 from depot/compose-name
Use the Compose name field if present
2 parents 64313f6 + d237416 commit df2c6a6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pkg/compose/compose.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ func TargetTags(files []bake.File) (map[string][]string, error) {
4444
return nil, err
4545
}
4646

47-
var projectName string
48-
path, err := filepath.Abs(files[0].Name)
49-
if err != nil {
50-
return nil, err
51-
}
52-
dir := filepath.Base(filepath.Dir(path))
53-
if dir != "." {
54-
projectName = dir
55-
}
56-
5747
details := compose.ConfigDetails{
5848
ConfigFiles: configFiles,
5949
Environment: envs,
@@ -67,6 +57,18 @@ func TargetTags(files []bake.File) (map[string][]string, error) {
6757
return nil, err
6858
}
6959

60+
projectName := cfg.Name
61+
if projectName == "" {
62+
path, err := filepath.Abs(files[0].Name)
63+
if err != nil {
64+
return nil, err
65+
}
66+
dir := filepath.Base(filepath.Dir(path))
67+
if dir != "." {
68+
projectName = dir
69+
}
70+
}
71+
7072
targetTags := map[string][]string{}
7173
for _, srv := range cfg.Services {
7274
if srv.Build == nil {

0 commit comments

Comments
 (0)