Skip to content

Commit 547512d

Browse files
onprem: 2.8.0-rc.2
1 parent c2e0d10 commit 547512d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

codefresh/files/mongoSetCompatibilityVersion.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ waitForMongoDB() {
1616
done
1717
}
1818

19+
getMongoDBVersion() {
20+
local version=$(mongosh ${MONGODB_ROOT_URI} --eval "db.version()" 2>&1)
21+
echo $version
22+
}
23+
1924
parseMongoURI() {
2025
local proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
2126
local parameters="$(echo $1 | grep '?' | cut -d '?' -f2)"; if [[ -n $parameters ]]; then parameters="?${parameters}"; fi
@@ -33,4 +38,10 @@ parseMongoURI $MONGO_URI
3338

3439
waitForMongoDB
3540

36-
mongosh ${MONGODB_ROOT_URI} --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"$MONGODB_COMPAT_VERSION\", confirm: true } )"
41+
MONGO_VERSION=$(getMongoDBVersion)
42+
43+
if [[ $MONGO_VERSION == 7* ]]; then
44+
mongosh ${MONGODB_ROOT_URI} --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"$MONGODB_COMPAT_VERSION\", confirm: true } )"
45+
else
46+
mongosh ${MONGODB_ROOT_URI} --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"$MONGODB_COMPAT_VERSION\" } )"
47+
fi

0 commit comments

Comments
 (0)