Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client] Fix multiple peer name filtering in netbird status command #2798

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

mgarces
Copy link
Contributor

@mgarces mgarces commented Oct 28, 2024

Describe your changes

Issue ticket number and link

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

Description

The current implementation of peer name filtering in the skipDetailByFilters function has a logic issue that prevents filtering by multiple peer names. This PR fixes the issue by:

Changing the initial value of nameEval to true (meaning skip by default)
Inverting the logic to look for matches instead of non-matches
Setting nameEval = false when a match is found (meaning don't skip)

Before the fix:

  • When using --filter-by-names peer-01,peer-02.netbird.cloud, the command would fail to show both peers because:
  1. The function would set nameEval = true if ANY name didn't match
  2. This caused peers to be skipped even if they matched one of the filters

After the fix:

  • The new logic starts with nameEval = true (skip by default)
  • When a peer's FQDN matches ANY of the provided filters, nameEval is set to false
  • This allows the command to properly show all peers that match any of the provided name filters

Example:

Bash

netbird status -d --filter-by-names peer-01,peer-02.netbird.cloud

Now correctly shows both peers that match either name.

Testing:

  • Tested with single peer name filter
  • Tested with multiple peer name filters
  • Tested in combination with other filters (status, IPs)

This fix maintains compatibility with existing functionality while correctly implementing the intended multiple peer name filtering behavior.

@CLAassistant
Copy link

CLAassistant commented Oct 28, 2024

CLA assistant check
All committers have signed the CLA.

pascal-fischer
pascal-fischer previously approved these changes Oct 28, 2024
Copy link

sonarcloud bot commented Oct 28, 2024

@mgarces mgarces added the good first issue Good for newcomers label Oct 28, 2024
@pascal-fischer pascal-fischer changed the title Fix multiple peer name filtering in netbird status command [client] Fix multiple peer name filtering in netbird status command Oct 28, 2024
@pascal-fischer pascal-fischer merged commit 01f2490 into main Oct 29, 2024
21 checks passed
@pascal-fischer pascal-fischer deleted the bug/filter-by-names branch October 29, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants