mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-23 02:24:10 +00:00
fix: list-routes command now respects identifier filter with JSON output
Fixes #2927 In v0.27.0, the list-routes command with -i flag and -o json output was returning all nodes instead of just the specified node. The issue was that JSON output was happening before the identifier filtering logic. This change moves the JSON output to after both the identifier filter and route existence filter are applied, ensuring the correct filtered results are returned. This restores the v0.26.1 behavior where: headscale nodes list-routes -i 12 -o json correctly returns only node 12's route information.
This commit is contained in:
parent
22ee2bfc9c
commit
5d0a6ab0e9
1 changed files with 5 additions and 4 deletions
|
|
@ -220,10 +220,6 @@ var listNodeRoutesCmd = &cobra.Command{
|
|||
)
|
||||
}
|
||||
|
||||
if output != "" {
|
||||
SuccessOutput(response.GetNodes(), "", output)
|
||||
}
|
||||
|
||||
nodes := response.GetNodes()
|
||||
if identifier != 0 {
|
||||
for _, node := range response.GetNodes() {
|
||||
|
|
@ -238,6 +234,11 @@ var listNodeRoutesCmd = &cobra.Command{
|
|||
return (n.GetSubnetRoutes() != nil && len(n.GetSubnetRoutes()) > 0) || (n.GetApprovedRoutes() != nil && len(n.GetApprovedRoutes()) > 0) || (n.GetAvailableRoutes() != nil && len(n.GetAvailableRoutes()) > 0)
|
||||
})
|
||||
|
||||
if output != "" {
|
||||
SuccessOutput(nodes, "", output)
|
||||
return
|
||||
}
|
||||
|
||||
tableData, err := nodeRoutesToPtables(nodes)
|
||||
if err != nil {
|
||||
ErrorOutput(err, fmt.Sprintf("Error converting to table: %s", err), output)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue