Skip to content

Commit

Permalink
fix TestMergeExpose
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Oct 12, 2023
1 parent fb57559 commit 0da7863
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 0 additions & 5 deletions loader/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1468,11 +1468,6 @@ services:
Scale: 1,
},
},
Networks: types.Networks{},
Volumes: types.Volumes{},
Secrets: types.Secrets{},
Configs: types.Configs{},
Extensions: types.Extensions{},
Environment: map[string]string{consts.ComposeProjectName: "test"},
}, config)
}
13 changes: 13 additions & 0 deletions override/uncity.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package override

import (
"fmt"
"strconv"
"strings"

"github.com/compose-spec/compose-go/format"
Expand All @@ -32,6 +33,7 @@ var unique = map[tree.Path]indexer{}
func init() {
unique["services.*.environment"] = environmentIndexer
unique["services.*.volumes"] = volumeIndexer
unique["services.*.expose"] = exposeIndexer
}

// EnforceUnicity removes redefinition of elements declared in a sequence
Expand Down Expand Up @@ -104,3 +106,14 @@ func volumeIndexer(y any, p tree.Path) (string, error) {
}
return "", nil
}

func exposeIndexer(a any, path tree.Path) (string, error) {
switch v := a.(type) {
case string:
return v, nil
case int:
return strconv.Itoa(v), nil
default:
return "", fmt.Errorf("%s: unsupported expose value %s", path, a)
}
}

0 comments on commit 0da7863

Please sign in to comment.