mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-25 07:46:49 +09:00
some clarifications for tags (#2531)
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
1 parent
1e0516b99d
commit
8e7e52cf3a
3 files changed
+18
-13
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user