mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-22 16:07:34 +00:00
Remove always nil error
This commit is contained in:
parent
5b169010be
commit
c80e364f02
10
acls.go
10
acls.go
@ -267,10 +267,8 @@ func expandAlias(
|
|||||||
|
|
||||||
// if alias is a namespace
|
// if alias is a namespace
|
||||||
nodes := filterMachinesByNamespace(machines, alias)
|
nodes := filterMachinesByNamespace(machines, alias)
|
||||||
nodes, err := excludeCorrectlyTaggedNodes(aclPolicy, nodes, alias)
|
nodes = excludeCorrectlyTaggedNodes(aclPolicy, nodes, alias)
|
||||||
if err != nil {
|
|
||||||
return ips, err
|
|
||||||
}
|
|
||||||
for _, n := range nodes {
|
for _, n := range nodes {
|
||||||
ips = append(ips, n.IPAddresses.ToStringSlice()...)
|
ips = append(ips, n.IPAddresses.ToStringSlice()...)
|
||||||
}
|
}
|
||||||
@ -305,7 +303,7 @@ func excludeCorrectlyTaggedNodes(
|
|||||||
aclPolicy ACLPolicy,
|
aclPolicy ACLPolicy,
|
||||||
nodes []Machine,
|
nodes []Machine,
|
||||||
namespace string,
|
namespace string,
|
||||||
) ([]Machine, error) {
|
) []Machine {
|
||||||
out := []Machine{}
|
out := []Machine{}
|
||||||
tags := []string{}
|
tags := []string{}
|
||||||
for tag, ns := range aclPolicy.TagOwners {
|
for tag, ns := range aclPolicy.TagOwners {
|
||||||
@ -330,7 +328,7 @@ func excludeCorrectlyTaggedNodes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return out, nil
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func expandPorts(portsStr string) (*[]tailcfg.PortRange, error) {
|
func expandPorts(portsStr string) (*[]tailcfg.PortRange, error) {
|
||||||
|
13
acls_test.go
13
acls_test.go
@ -1142,7 +1142,6 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
|||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "all nodes have invalid tags, don't exclude them",
|
name: "all nodes have invalid tags, don't exclude them",
|
||||||
@ -1212,25 +1211,15 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
|||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
got, err := excludeCorrectlyTaggedNodes(
|
got := excludeCorrectlyTaggedNodes(
|
||||||
test.args.aclPolicy,
|
test.args.aclPolicy,
|
||||||
test.args.nodes,
|
test.args.nodes,
|
||||||
test.args.namespace,
|
test.args.namespace,
|
||||||
)
|
)
|
||||||
if (err != nil) != test.wantErr {
|
|
||||||
t.Errorf(
|
|
||||||
"excludeCorrectlyTaggedNodes() error = %v, wantErr %v",
|
|
||||||
err,
|
|
||||||
test.wantErr,
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(got, test.want) {
|
if !reflect.DeepEqual(got, test.want) {
|
||||||
t.Errorf("excludeCorrectlyTaggedNodes() = %v, want %v", got, test.want)
|
t.Errorf("excludeCorrectlyTaggedNodes() = %v, want %v", got, test.want)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user