mirror of
https://github.com/juanfont/headscale.git
synced 2025-10-25 02:20:15 +00:00
feat(acls): rewrite functions to be testable
Rewrite some function to get rid of the dependency on Headscale object. This allows us to write succinct test that are more easy to review and implement. The improvements of the tests allowed to write the removal of the tagged hosts from the namespace as specified here: https://tailscale.com/kb/1068/acl-tags/
This commit is contained in:
committed by
Adrien Raffin-Caboisse
parent
97eac3b938
commit
de59946447
13
machine.go
13
machine.go
@@ -119,6 +119,19 @@ func (machine Machine) isExpired() bool {
|
||||
return time.Now().UTC().After(*machine.Expiry)
|
||||
}
|
||||
|
||||
func (h *Headscale) ListAllMachines() ([]Machine, error) {
|
||||
machines := []Machine{}
|
||||
if err := h.db.Preload("AuthKey").
|
||||
Preload("AuthKey.Namespace").
|
||||
Preload("Namespace").
|
||||
Where("registered").
|
||||
Find(&machines).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return machines, nil
|
||||
}
|
||||
|
||||
func containsAddresses(inputs []string, addrs MachineAddresses) bool {
|
||||
for _, addr := range addrs.ToStringSlice() {
|
||||
if containsString(inputs, addr) {
|
||||
|
||||
Reference in New Issue
Block a user