Skip to content
Draft

save #776

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mongorestore/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/mongodb/mongo-tools/common/intents"
"github.com/mongodb/mongo-tools/common/log"
"github.com/mongodb/mongo-tools/common/util"
"github.com/samber/lo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
Expand Down Expand Up @@ -569,6 +570,13 @@ func (restore *MongoRestore) RestoreUsersOrRoles(users, roles *intents.Intent) e
// present in the dump, we try to infer the authentication version based on its absence.
// Returns the authentication version number and any errors that occur.
func (restore *MongoRestore) GetDumpAuthVersion() (int, error) {
if lo.EveryBy(
restore.dumpServerVersion[:],
func(v int) bool { return v == 0 },
) {
panic("GetDumpAuthVersion() called with empty dump server version")
}

// authSchema doc has been removed from system.version from 8.1+ (SERVER-83663)
// The only auth version used by server 8.1+ is 5
if restore.dumpServerVersion.GTE(db.Version{8, 1, 0}) {
Expand Down