From 2780623076ba92647565e40b954fb3fb41c26956 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Mon, 6 Sep 2021 14:43:43 +0200 Subject: [PATCH] Renamed SharedNode to SharedMachine --- db.go | 2 +- machine.go | 2 +- namespaces.go | 4 ++-- sharing.go | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/db.go b/db.go index 4435f048..42c5eee9 100644 --- a/db.go +++ b/db.go @@ -44,7 +44,7 @@ func (h *Headscale) initDB() error { return err } - err = db.AutoMigrate(&SharedNode{}) + err = db.AutoMigrate(&SharedMachine{}) if err != nil { return err } diff --git a/machine.go b/machine.go index bbacee5a..c5a8a2a9 100644 --- a/machine.go +++ b/machine.go @@ -183,7 +183,7 @@ func (h *Headscale) getPeers(m Machine) (*[]*tailcfg.Node, error) { } // We fetch here machines that are shared to the `Namespace` of the machine we are getting peers for - sharedNodes := []SharedNode{} + sharedNodes := []SharedMachine{} if err := h.db.Preload("Namespace").Preload("Machine").Where("namespace_id = ?", m.NamespaceID).Find(&sharedNodes).Error; err != nil { return nil, err diff --git a/namespaces.go b/namespaces.go index 57674ff3..e7d207b2 100644 --- a/namespaces.go +++ b/namespaces.go @@ -103,8 +103,8 @@ func (h *Headscale) ListSharedMachinesInNamespace(name string) (*[]Machine, erro if err != nil { return nil, err } - sharedNodes := []SharedNode{} - if err := h.db.Preload("Namespace").Where(&SharedNode{NamespaceID: n.ID}).Find(&sharedNodes).Error; err != nil { + sharedNodes := []SharedMachine{} + if err := h.db.Preload("Namespace").Where(&SharedMachine{NamespaceID: n.ID}).Find(&sharedNodes).Error; err != nil { return nil, err } diff --git a/sharing.go b/sharing.go index 54d9976b..db16ef33 100644 --- a/sharing.go +++ b/sharing.go @@ -5,8 +5,8 @@ import "gorm.io/gorm" const errorSameNamespace = Error("Destination namespace same as origin") const errorNodeAlreadyShared = Error("Node already shared to this namespace") -// SharedNode is a join table to support sharing nodes between namespaces -type SharedNode struct { +// SharedMachine is a join table to support sharing nodes between namespaces +type SharedMachine struct { gorm.Model MachineID uint64 Machine Machine @@ -20,12 +20,12 @@ func (h *Headscale) AddSharedMachineToNamespace(m *Machine, ns *Namespace) error return errorSameNamespace } - sn := SharedNode{} + sn := SharedMachine{} if err := h.db.Where("machine_id = ? AND namespace_id", m.ID, ns.ID).First(&sn).Error; err == nil { return errorNodeAlreadyShared } - sn = SharedNode{ + sn = SharedMachine{ MachineID: m.ID, Machine: *m, NamespaceID: ns.ID,