fix(machine): remove duplicate in forcedTags

This commit is contained in:
Adrien Raffin-Caboisse 2022-07-25 10:54:51 +02:00
parent 0212db3fad
commit c46a34e6b8
No known key found for this signature in database
GPG key ID: 7FB60532DEBEAD6A
2 changed files with 50 additions and 1 deletions

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
}