Skip to content

Commit

Permalink
Preload the Namespace from SharedMachines
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont committed Oct 17, 2021
1 parent 061efa1 commit 8094e6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (h *Headscale) getShared(m *Machine) (Machines, error) {
Msg("Finding shared peers")

sharedMachines := []SharedMachine{}
if err := h.db.Preload("Namespace").Preload("Machine").Where("namespace_id = ?",
if err := h.db.Preload("Namespace").Preload("Machine").Preload("Machine.Namespace").Where("namespace_id = ?",
m.NamespaceID).Find(&sharedMachines).Error; err != nil {
return Machines{}, err
}
Expand All @@ -113,7 +113,7 @@ func (h *Headscale) getSharedTo(m *Machine) (Machines, error) {
Msg("Finding peers in namespaces this machine is shared with")

sharedMachines := []SharedMachine{}
if err := h.db.Preload("Namespace").Preload("Machine").Where("machine_id = ?",
if err := h.db.Preload("Namespace").Preload("Machine").Preload("Machine.Namespace").Where("machine_id = ?",
m.ID).Find(&sharedMachines).Error; err != nil {
return Machines{}, err
}
Expand Down

0 comments on commit 8094e6f

Please sign in to comment.