Skip to content

Add support for Devices Filtering by Fields#75

Closed
nikita-vanyasin wants to merge 3 commits intotailscale:mainfrom
nikita-vanyasin:list-devices-filter
Closed

Add support for Devices Filtering by Fields#75
nikita-vanyasin wants to merge 3 commits intotailscale:mainfrom
nikita-vanyasin:list-devices-filter

Conversation

@nikita-vanyasin
Copy link
Copy Markdown
Contributor

  1. Refactor GET /devices call, to have one generic function that can be extended via Options arg. Change is backward compatible.
  2. Add support for passing 'filters' (Closes Add support for Devices Filtering by Fields #63)

FYI this PR is mostly vibe-coded.

Comment thread devices_test.go Outdated
server.ResponseCode = http.StatusOK
server.ResponseBody = expectedDevices

t.Run("with single filter", func(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we try to avoid any characters in test subnames that result in quoting by the testing package. So no spaces.

And we aim for brevity in the test subname, expanding on the brevity if necessary in a comment.

So this could be "single-filter" or "single"

Comment thread devices_test.go Outdated
assert.EqualValues(t, expectedDevices["devices"], actualDevices)
})

t.Run("with multiple filters", func(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"multiple-filters" or even "multiple"

Comment thread devices_test.go Outdated
assert.EqualValues(t, expectedDevices["devices"], actualDevices)
})

t.Run("with all fields and filter", func(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"all-fields-and-filter"

Comment thread devices_test.go Outdated
assert.EqualValues(t, expectedDevices["devices"], actualDevices)
})

t.Run("with empty options", func(t *testing.T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"empty-opts"

@neinkeinkaffee neinkeinkaffee self-assigned this Jan 30, 2026
@nikita-vanyasin
Copy link
Copy Markdown
Contributor Author

Hi @bradfitz and thanks for review.
I've adjusted all names for sub-tests as advised.

Best,
Nikita

@neinkeinkaffee
Copy link
Copy Markdown
Contributor

@nikita-vanyasin Thank you for the contribution! We’d like to merge it. But following an internal discussion and we’d actually like to take it one step further. We want to turn the options argument approach you’ve sketched out into a full-blown options pattern and make that the new default for this endpoint (and potentially other similar endpoints in the future for the next major release). What I’ll do is I’ll take your commits and add that additional change on top in a separate PR.

@neinkeinkaffee
Copy link
Copy Markdown
Contributor

Closing this as we've merged this contribution into #82.

@nikita-vanyasin
Copy link
Copy Markdown
Contributor Author

@nikita-vanyasin Thank you for the contribution! We’d like to merge it. But following an internal discussion and we’d actually like to take it one step further. We want to turn the options argument approach you’ve sketched out into a full-blown options pattern and make that the new default for this endpoint (and potentially other similar endpoints in the future for the next major release). What I’ll do is I’ll take your commits and add that additional change on top in a separate PR.

This is great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Devices Filtering by Fields

4 participants