mirror of https://github.com/docker/docs.git
Rename attributes to labels.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
bf04e484f9
commit
1dead64e11
|
|
@ -75,7 +75,7 @@ func manage(c *cli.Context) {
|
|||
s := scheduler.NewScheduler(
|
||||
cluster,
|
||||
&strategy.BinPackingPlacementStrategy{OvercommitRatio: 0.05},
|
||||
[]filter.Filter{&filter.AttributeFilter{}, &filter.PortFilter{}},
|
||||
[]filter.Filter{&filter.LabelFilter{}, &filter.PortFilter{}},
|
||||
)
|
||||
|
||||
log.Fatal(api.ListenAndServe(cluster, s, c.String("addr"), c.App.Version))
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@ import (
|
|||
"github.com/samalba/dockerclient"
|
||||
)
|
||||
|
||||
// AttributeFilter selects only nodes that match certain attributes. Attributes
|
||||
// include storagedriver, executiondriver and so on.
|
||||
type AttributeFilter struct {
|
||||
// LabelFilter selects only nodes that match certain labels.
|
||||
type LabelFilter struct {
|
||||
}
|
||||
|
||||
func (f *AttributeFilter) extractConstraints(env []string) map[string]string {
|
||||
func (f *LabelFilter) extractConstraints(env []string) map[string]string {
|
||||
constraints := make(map[string]string)
|
||||
for _, e := range env {
|
||||
if strings.HasPrefix(e, "constraint:") {
|
||||
|
|
@ -25,7 +24,7 @@ func (f *AttributeFilter) extractConstraints(env []string) map[string]string {
|
|||
return constraints
|
||||
}
|
||||
|
||||
func (f *AttributeFilter) Filter(config *dockerclient.ContainerConfig, nodes []*cluster.Node) ([]*cluster.Node, error) {
|
||||
func (f *LabelFilter) Filter(config *dockerclient.ContainerConfig, nodes []*cluster.Node) ([]*cluster.Node, error) {
|
||||
constraints := f.extractConstraints(config.Env)
|
||||
for k, v := range constraints {
|
||||
candidates := []*cluster.Node{}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAttributeFilter(t *testing.T) {
|
||||
func TestLabeleFilter(t *testing.T) {
|
||||
var (
|
||||
f = AttributeFilter{}
|
||||
f = LabelFilter{}
|
||||
nodes = []*cluster.Node{
|
||||
cluster.NewNode("node-1"),
|
||||
cluster.NewNode("node-2"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue