fix tag ignored issue
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
7d17bcc6fa
commit
d0b396b89c
@@ -414,3 +414,69 @@ nodes:
|
||||
run_test(t, tt)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Node_Add(t *testing.T) {
|
||||
tests := []test_description{
|
||||
{
|
||||
args: []string{"--tagadd=email=node", "n01"},
|
||||
wantErr: false,
|
||||
stdout: "",
|
||||
inDB: `WW_INTERNAL: 43
|
||||
nodeprofiles:
|
||||
default:
|
||||
comment: testit
|
||||
tags:
|
||||
email: profile
|
||||
nodes:
|
||||
n01:
|
||||
profiles:
|
||||
- default`,
|
||||
outDb: `WW_INTERNAL: 43
|
||||
nodeprofiles:
|
||||
default:
|
||||
comment: testit
|
||||
tags:
|
||||
email: profile
|
||||
nodes:
|
||||
n01:
|
||||
profiles:
|
||||
- default
|
||||
tags:
|
||||
email: node
|
||||
`},
|
||||
{
|
||||
args: []string{"--tagadd=newtag=newval", "n01"},
|
||||
wantErr: false,
|
||||
stdout: "",
|
||||
inDB: `WW_INTERNAL: 43
|
||||
nodeprofiles:
|
||||
default:
|
||||
comment: testit
|
||||
tags:
|
||||
email: profile
|
||||
nodes:
|
||||
n01:
|
||||
profiles:
|
||||
- default
|
||||
tags:
|
||||
email: node`,
|
||||
outDb: `WW_INTERNAL: 43
|
||||
nodeprofiles:
|
||||
default:
|
||||
comment: testit
|
||||
tags:
|
||||
email: profile
|
||||
nodes:
|
||||
n01:
|
||||
profiles:
|
||||
- default
|
||||
tags:
|
||||
email: node
|
||||
newtag: newval
|
||||
`},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
run_test(t, tt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,11 @@ func recursiveSetter(source, target interface{}, nameArg string, setter func(*En
|
||||
newEntr := new(Entry)
|
||||
setter(newEntr, sourceIter.Value().String(), nameArg)
|
||||
targetValue.Elem().Field(i).SetMapIndex(sourceIter.Key(), reflect.ValueOf(newEntr))
|
||||
} else {
|
||||
// update the entry with latest value
|
||||
if entry, ok := targetValue.Elem().Field(i).MapIndex(sourceIter.Key()).Interface().(*Entry); ok {
|
||||
setter(entry, sourceIter.Value().String(), nameArg)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user