Skip to content

Commit 68913c8

Browse files
list only authorized collections (#825)
Co-authored-by: Anthony Allen <[email protected]>
1 parent 6779630 commit 68913c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

exporter/common.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
var systemDBs = []string{"admin", "config", "local"} //nolint:gochecknoglobals
3333

3434
func listCollections(ctx context.Context, client *mongo.Client, database string, filterInNamespaces []string, skipViews bool) ([]string, error) {
35+
opts := &options.ListCollectionsOptions{NameOnly: pointer.ToBool(true), AuthorizedCollections: pointer.ToBool(true)}
3536
filter := bson.D{} // Default=empty -> list all collections
3637

3738
// if there is a filter with the list of collections we want, create a filter like
@@ -62,7 +63,7 @@ func listCollections(ctx context.Context, client *mongo.Client, database string,
6263
filter = append(filter, primitive.E{Key: "type", Value: "collection"})
6364
}
6465

65-
collections, err := client.Database(database).ListCollectionNames(ctx, filter)
66+
collections, err := client.Database(database).ListCollectionNames(ctx, filter, opts)
6667
if err != nil {
6768
return nil, errors.Wrap(err, "cannot get the list of collections for discovery")
6869
}

0 commit comments

Comments
 (0)