mirror of https://github.com/docker/docs.git
Merge pull request #300 from vieux/match_only_name_image
match only repo in affinity image
This commit is contained in:
commit
e7aba669dd
|
@ -2,6 +2,7 @@ package filter
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/swarm/cluster"
|
||||
|
@ -39,7 +40,7 @@ func (f *AffinityFilter) Filter(config *dockerclient.ContainerConfig, nodes []*c
|
|||
break
|
||||
}
|
||||
for _, tag := range image.RepoTags {
|
||||
if affinity.Match(tag) {
|
||||
if affinity.Match(tag, strings.Split(tag, ":")[0]) {
|
||||
candidates = append(candidates, node)
|
||||
break done
|
||||
}
|
||||
|
|
|
@ -131,6 +131,14 @@ func TestAffinityFilter(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Len(t, result, 2)
|
||||
|
||||
// Validate images by name
|
||||
result, err = f.Filter(&dockerclient.ContainerConfig{
|
||||
Env: []string{"affinity:image==image-1"},
|
||||
}, nodes)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, result, 1)
|
||||
assert.Equal(t, result[0], nodes[1])
|
||||
|
||||
// Not support = any more
|
||||
result, err = f.Filter(&dockerclient.ContainerConfig{
|
||||
Env: []string{"affinity:image=image-0:tag3"},
|
||||
|
|
Loading…
Reference in New Issue