Skip to content

Commit

Permalink
fixed a bug on nil tags
Browse files Browse the repository at this point in the history
  • Loading branch information
deckarep committed Dec 22, 2023
1 parent b4515cc commit e08d0f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ linters:
disable-all: true
enable:
- bidichk
- goconst
- gofmt
- goimports
- govet
- misspell
- musttag
- revive

# Configuration for how we run golangci-lint
Expand Down
9 changes: 6 additions & 3 deletions app/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ func executeFilters(ctx context.Context, devList []tailscale.Device,
// Filter by 'tag' when provided - currently only supports full matching.
if f, exists := cfg.Filters["tag"]; exists {
normalizedTags := normalizeTags(dev.Tags)
wantsNoTags := f.Contains("nil") // User wants to filter out rows with tags.

// If the user does a filter like: 'tag:nil' they want to filter out those rows WITH tags.
wantsEmpty := f.Contains("nil")
// Determine if the device should be skipped based on tag presence and user's filter.
hasTags := len(dev.Tags) > 0
matchesTags := f.ContainsAny(normalizedTags...)

if !wantsEmpty && (len(dev.Tags) == 0) || !f.Contains(normalizedTags...) {
// Skip device if it doesn't match the filter criteria.
if (wantsNoTags && hasTags) || (!wantsNoTags && !matchesTags) {
continue
}
}
Expand Down

0 comments on commit e08d0f9

Please sign in to comment.