@@ -3,6 +3,7 @@ package mongo
33import (
44 "context"
55 "fmt"
6+ "log/slog"
67 "slices"
78
89 "go.mongodb.org/mongo-driver/bson"
@@ -13,6 +14,12 @@ Perform a collection operation across all environments
1314 - Do not preform unless given approval from a Tech Lead
1415*/
1516func (db * DB ) BulkOperation (ctx context.Context , operation CollectionOperation , arg string ) error {
17+ slog .LogAttrs (
18+ ctx ,
19+ slog .LevelInfo ,
20+ "Performing bulk operation" ,
21+ slog .String ("arg" , arg ),
22+ )
1623 databaseNames , err := db .Client .ListDatabaseNames (ctx , bson.D {})
1724 databaseNames = filterSystemDatabases (databaseNames )
1825
@@ -22,13 +29,20 @@ func (db *DB) BulkOperation(ctx context.Context, operation CollectionOperation,
2229 for _ , name := range databaseNames {
2330 if err := operation (ctx , arg ); err != nil {
2431 return fmt .Errorf ("failed to perform operation on %s: %w" , name , err )
32+ } else {
33+ slog .LogAttrs (
34+ ctx ,
35+ slog .LevelInfo ,
36+ "Successfully performed operation on database" ,
37+ slog .String ("database_name" , name ),
38+ )
2539 }
2640 }
2741 return nil
2842}
2943
3044func filterSystemDatabases (databases []string ) []string {
31- systemNames := []string {"local" ,"admin" }
45+ systemNames := []string {"local" ,"admin" , "encryption" , "config " }
3246 ret := make ([]string ,0 );
3347 for _ , v := range databases {
3448 if ! slices .Contains (systemNames ,v ){
0 commit comments