some clarifications for tags (#2531)

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2025-04-18 09:33:02 +02:00 committed by GitHub
parent 1e0516b99d
commit 8e7e52cf3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 13 deletions

View file

@ -194,7 +194,8 @@ func (hsdb *HSDatabase) SetTags(
})
}
// SetTags takes a Node struct pointer and update the forced tags.
// SetTags takes a NodeID and update the forced tags.
// It will overwrite any tags with the new list.
func SetTags(
tx *gorm.DB,
nodeID types.NodeID,
@ -209,14 +210,9 @@ func SetTags(
return nil
}
var newTags []string
for _, tag := range tags {
if !slices.Contains(newTags, tag) {
newTags = append(newTags, tag)
}
}
b, err := json.Marshal(newTags)
slices.Sort(tags)
tags = slices.Compact(tags)
b, err := json.Marshal(tags)
if err != nil {
return err
}