From a992840c9bea0105dd5ea45f730968a569b1e9a8 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Mon, 30 May 2022 12:18:23 +0200 Subject: [PATCH] Give UpdateMachine a more meaningful name --- machine.go | 6 +++--- poll.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/machine.go b/machine.go index 3f37909..d1ef246 100644 --- a/machine.go +++ b/machine.go @@ -362,9 +362,9 @@ func (h *Headscale) GetMachineByMachineKey( return &m, nil } -// UpdateMachine takes a Machine struct pointer (typically already loaded from database +// UpdateMachineFromDatabase takes a Machine struct pointer (typically already loaded from database // and updates it with the latest data from the database. -func (h *Headscale) UpdateMachine(machine *Machine) error { +func (h *Headscale) UpdateMachineFromDatabase(machine *Machine) error { if result := h.db.Find(machine).First(&machine); result.Error != nil { return result.Error } @@ -463,7 +463,7 @@ func (machine *Machine) GetHostInfo() tailcfg.Hostinfo { } func (h *Headscale) isOutdated(machine *Machine) bool { - if err := h.UpdateMachine(machine); err != nil { + if err := h.UpdateMachineFromDatabase(machine); err != nil { // It does not seem meaningful to propagate this error as the end result // will have to be that the machine has to be considered outdated. return true diff --git a/poll.go b/poll.go index dcadadf..a74d857 100644 --- a/poll.go +++ b/poll.go @@ -319,7 +319,7 @@ func (h *Headscale) PollNetMapStream( // TODO(kradalby): Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err = h.UpdateMachine(machine) + err = h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream"). @@ -385,7 +385,7 @@ func (h *Headscale) PollNetMapStream( // TODO(kradalby): Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err = h.UpdateMachine(machine) + err = h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream"). @@ -475,7 +475,7 @@ func (h *Headscale) PollNetMapStream( // TODO(kradalby): Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err = h.UpdateMachine(machine) + err = h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream"). @@ -526,7 +526,7 @@ func (h *Headscale) PollNetMapStream( // TODO: Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err := h.UpdateMachine(machine) + err := h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream").