mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-25 01:07:52 +00:00
Bugfix: the check to see if a node was already shared into a namespace
was incorrect.
This commit is contained in:
parent
9a7472218e
commit
b06e34f144
@ -21,12 +21,15 @@ func (h *Headscale) AddSharedMachineToNamespace(m *Machine, ns *Namespace) error
|
|||||||
return errorSameNamespace
|
return errorSameNamespace
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedMachine := SharedMachine{}
|
sharedMachines := []SharedMachine{}
|
||||||
if err := h.db.Where("machine_id = ? AND namespace_id", m.ID, ns.ID).First(&sharedMachine).Error; err == nil {
|
if err := h.db.Where("machine_id = ? AND namespace_id = ?", m.ID, ns.ID).Find(&sharedMachines).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(sharedMachines) > 0 {
|
||||||
return errorMachineAlreadyShared
|
return errorMachineAlreadyShared
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedMachine = SharedMachine{
|
sharedMachine := SharedMachine{
|
||||||
MachineID: m.ID,
|
MachineID: m.ID,
|
||||||
Machine: *m,
|
Machine: *m,
|
||||||
NamespaceID: ns.ID,
|
NamespaceID: ns.ID,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user