Backend name with docker-compose and segments.
This commit is contained in:
parent
6ceb2af4a7
commit
bb3f28ffa7
2 changed files with 22 additions and 6 deletions
|
@ -850,8 +850,9 @@ func TestDockerGetFrontendRule(t *testing.T) {
|
|||
|
||||
func TestDockerGetBackendName(t *testing.T) {
|
||||
testCases := []struct {
|
||||
container docker.ContainerJSON
|
||||
expected string
|
||||
container docker.ContainerJSON
|
||||
segmentName string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
container: containerJSON(name("foo")),
|
||||
|
@ -874,6 +875,15 @@ func TestDockerGetBackendName(t *testing.T) {
|
|||
})),
|
||||
expected: "bar-foo",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"com.docker.compose.project": "foo",
|
||||
"com.docker.compose.service": "bar",
|
||||
"traefik.sauternes.backend": "titi",
|
||||
})),
|
||||
segmentName: "sauternes",
|
||||
expected: "bar-foo-titi",
|
||||
},
|
||||
}
|
||||
|
||||
for containerID, test := range testCases {
|
||||
|
@ -883,7 +893,8 @@ func TestDockerGetBackendName(t *testing.T) {
|
|||
|
||||
dData := parseContainer(test.container)
|
||||
segmentProperties := label.ExtractTraefikLabels(dData.Labels)
|
||||
dData.SegmentLabels = segmentProperties[""]
|
||||
dData.SegmentLabels = segmentProperties[test.segmentName]
|
||||
dData.SegmentName = test.segmentName
|
||||
|
||||
actual := getBackendName(dData)
|
||||
assert.Equal(t, test.expected, actual)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue