-
Notifications
You must be signed in to change notification settings - Fork 430
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
PMM-10072 Filter out profiler collection #589
Changes from 1 commit
932ac45
1002fa3
d5634f9
742f1b9
86e40cd
719dd5b
cdf054e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,10 @@ import ( | |
"go.mongodb.org/mongo-driver/mongo/options" | ||
) | ||
|
||
var systemDBs = []string{"admin", "config", "local"} //nolint:gochecknoglobals | ||
var ( | ||
systemDBs = []string{"admin", "config", "local"} //nolint:gochecknoglobals | ||
systemCollections = []string{"system.profile"} | ||
) | ||
|
||
func listCollections(ctx context.Context, client *mongo.Client, database string, filterInNamespaces []string) ([]string, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible to add tests for the new behavior of filtering collections? |
||
filter := bson.D{} // Default=empty -> list all collections | ||
|
@@ -63,7 +66,15 @@ func listCollections(ctx context.Context, client *mongo.Client, database string, | |
return nil, errors.Wrap(err, "cannot get the list of collections for discovery") | ||
} | ||
|
||
return collections, nil | ||
filteredCollections := []string{} | ||
for _, collection := range collections { | ||
if collection == systemCollections[0] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there is only one element in the systemCollections slice, could we use it as a constant variable? Or if you plan to add more elements to |
||
continue | ||
} | ||
filteredCollections = append(filteredCollections, collection) | ||
} | ||
|
||
return filteredCollections, nil | ||
ShashankSinha252 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// databases returns the list of databases matching the filters. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
systemCollections is a global variable (gochecknoglobals)