Merge pull request #1045 from JasonYangShadow/issue/967
Fix the issue that the same tag added via `node set` is ignored
This commit is contained in:
@@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fixed a bug when using `wwctl container import --force` to replace an existing container
|
||||
will generate an error #474
|
||||
- Create `/etc/systemd/network/10-persistent-net-<netdev>.link` file per network device
|
||||
- Fix the issue that the same tag added in `node set` is ignored. #967
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -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