Change to a go generics set implementation, no more casting 🎉
This commit is contained in:
parent
fc502e1e79
commit
59a1a85a2b
5 changed files with 10 additions and 23 deletions
13
machine.go
13
machine.go
|
@ -9,7 +9,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/set"
|
||||
mapset "github.com/deckarep/golang-set/v2"
|
||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
@ -469,17 +469,10 @@ func (h *Headscale) isOutdated(machine *Machine) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
namespaceSet := set.New(set.ThreadSafe)
|
||||
namespaceSet := mapset.NewSet[string]()
|
||||
namespaceSet.Add(machine.Namespace.Name)
|
||||
|
||||
namespaces := make([]string, namespaceSet.Size())
|
||||
for index, namespace := range namespaceSet.List() {
|
||||
if name, ok := namespace.(string); ok {
|
||||
namespaces[index] = name
|
||||
}
|
||||
}
|
||||
|
||||
lastChange := h.getLastStateChange(namespaces...)
|
||||
lastChange := h.getLastStateChange(namespaceSet.ToSlice()...)
|
||||
lastUpdate := machine.CreatedAt
|
||||
if machine.LastSuccessfulUpdate != nil {
|
||||
lastUpdate = *machine.LastSuccessfulUpdate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue