1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

B #5477: GOCA - fix Del template method (#5480)

Signed-off-by: Pierre Lafievre <pierre.lafievre@iguanesolutions.com>
(cherry picked from commit c47c29c0632bd9fa4c4413425cd0076b152910d0)
(cherry picked from commit 4cdadfbcf31902bc73646f222fc149c95310ef05)
This commit is contained in:
Pierre Lafievre 2021-08-09 15:43:12 +02:00 committed by Ruben S. Montero
parent 6d07a4f844
commit 5370d945ae
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -420,20 +420,34 @@ func (t *Template) AddPairToVec(vecKey, key string, value interface{}) error {
// Del remove an element from Template objects
func (t *Template) Del(key string) {
for i := 0; i < len(t.Elements); i++ {
size := len(t.Elements)
for i := 0; i < size; {
if t.Elements[i].Key() != key {
i++
continue
}
t.Elements = append(t.Elements[:i], t.Elements[i+1:]...)
size--
}
}
// Del remove a pair from Template
func (t *Vector) Del(key string) {
for i := 0; i < len(t.Pairs); i++ {
if t.Pairs[i].XMLName.Local != key {
size := len(t.Pairs)
for i := 0; i < size; {
if t.Pairs[i].Key() != key {
i++
continue
}
t.Pairs = append(t.Pairs[:i], t.Pairs[i+1:]...)
size--
}
}