Change the unique namespace on the node

This commit is contained in:
Alex Dadgar
2016-01-26 12:11:02 -08:00
parent 0ad3575897
commit 7929ee76dc
3 changed files with 5 additions and 5 deletions

View File

@@ -82,7 +82,7 @@ func EscapedConstraints(constraints []*Constraint) []*Constraint {
// computed node class optimization.
func constraintTargetEscapes(target string) bool {
switch {
case strings.HasPrefix(target, "$unique."):
case strings.HasPrefix(target, "$node.unique."):
return true
case strings.HasPrefix(target, "$attr."):

View File

@@ -296,13 +296,13 @@ func resolveConstraintTarget(target string, node *structs.Node) (interface{}, bo
// Handle the interpolations
switch {
case "$unique.node.id" == target:
case "$node.unique.id" == target:
return node.ID, true
case "$node.datacenter" == target:
return node.Datacenter, true
case "$unique.node.name" == target:
case "$node.unique.name" == target:
return node.Name, true
case "$node.class" == target:

View File

@@ -189,7 +189,7 @@ func TestResolveConstraintTarget(t *testing.T) {
node := mock.Node()
cases := []tcase{
{
target: "$unique.node.id",
target: "$node.unique.id",
node: node,
val: node.ID,
result: true,
@@ -201,7 +201,7 @@ func TestResolveConstraintTarget(t *testing.T) {
result: true,
},
{
target: "$unique.node.name",
target: "$node.unique.name",
node: node,
val: node.Name,
result: true,