fix(machine): remove duplicate in forcedTags

This commit is contained in:
Adrien Raffin-Caboisse committed 2022-07-25 11:04:30 +02:00
1 parent 0212db3fad
commit c46a34e6b8
2 files changed
+50 -1

No files matched your search

+7 -1
View File
@@ -374,7 +374,13 @@ func (h *Headscale) UpdateMachineFromDatabase(machine *Machine) error {
// SetTags takes a Machine struct pointer and update the forced tags.
func (h *Headscale) SetTags(machine *Machine, tags []string) error {
machine.ForcedTags = tags
newTags := []string{}
for _, tag := range tags {
if !contains(newTags, tag) {
newTags = append(newTags, tag)
}
}
machine.ForcedTags = newTags
if err := h.UpdateACLRules(); err != nil && !errors.Is(err, errEmptyPolicy) {
return err
}