MCPcopy
hub / github.com/alibaba/MongoShake / getDbVersionArray

Function getDbVersionArray

tools/pre-split/pre_split.go:171–198  ·  view source on GitHub ↗
(client *mongo.Client)

Source from the content-addressed store, hash-verified

169}
170
171func getDbVersionArray(client *mongo.Client) (Version, error) {
172 var version Version
173 var res bson.M
174 err := client.Database(DbAdmin).RunCommand(context.Background(), bson.M{"buildInfo": 1}).Decode(&res)
175 if err != nil {
176 return version, fmt.Errorf("error getting buildInfo: %v", err)
177 }
178
179 versionStr, ok := res["version"].(string)
180 if !ok {
181 return Version{}, fmt.Errorf("failed to retrieve version string")
182 }
183
184 versionParts := strings.Split(versionStr, ".")
185 if len(versionParts) != 3 {
186 return Version{}, fmt.Errorf("invalid version format: %s", versionStr)
187 }
188
189 for i, part := range versionParts {
190 num, err := strconv.Atoi(part)
191 if err != nil {
192 return Version{}, fmt.Errorf("nvalid version number: %s", part)
193 }
194 version[i] = num
195 }
196
197 return version, nil
198}
199
200// check if both client is created through mongos and have sufficient permissions(not implemented)
201func preCheck(src *mongo.Client, dst *mongo.Client) (Version, Version, error) {

Callers 1

preCheckFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected