summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Cotter <matt.cotter@mongodb.com>2016-07-08 15:53:49 -0400
committerMatt Cotter <matt.cotter@mongodb.com>2016-07-14 15:51:35 -0400
commit472ac6b5bcb50e8869d03ecb044ce8ed3d779954 (patch)
tree77784c9847c806026e5d595b4ac0a4d089461bd8
parenta7e0e028e73c0b4f543c1ded1f4af0673630617a (diff)
downloadmongo-472ac6b5bcb50e8869d03ecb044ce8ed3d779954.tar.gz
SERVER-22734 add Enterprise to version in enterprise shell builds
-rw-r--r--etc/evergreen.yml2
-rw-r--r--src/mongo/scripting/mozjs/global.cpp2
-rw-r--r--src/mongo/shell/dbshell.cpp2
-rw-r--r--src/mongo/shell/shell_options.cpp4
-rw-r--r--src/mongo/util/version.cpp.in18
-rw-r--r--src/mongo/util/version.h6
6 files changed, 29 insertions, 5 deletions
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 4b6a7e88816..3d6650ce6a8 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -208,7 +208,7 @@ functions:
fi
bin_ver=$(${python|python} -c "import yaml; print(yaml.safe_load(open('compile_expansions.yml'))['version']);" | tr -d '[ \r\n]')
# Due to SERVER-23810, we cannot use $mongo_binary --quiet --nodb --eval "version();"
- mongo_ver=$($mongo_binary --version | cut -f2 -d ':' | tr -d '[ \r\n]')
+ mongo_ver=$($mongo_binary --version | rev | cut -f1 -d ' ' | rev | tr -d '[ \r\n]')
# The versions must match
if [ "$bin_ver" != "$mongo_ver" ]; then
echo "The mongo version is $mongo_ver, expected version is $bin_ver"
diff --git a/src/mongo/scripting/mozjs/global.cpp b/src/mongo/scripting/mozjs/global.cpp
index d56cdba7dec..c3bad26af31 100644
--- a/src/mongo/scripting/mozjs/global.cpp
+++ b/src/mongo/scripting/mozjs/global.cpp
@@ -85,7 +85,7 @@ void GlobalInfo::Functions::print::call(JSContext* cx, JS::CallArgs args) {
}
void GlobalInfo::Functions::version::call(JSContext* cx, JS::CallArgs args) {
- ValueReader(cx, args.rval()).fromStringData(versionString);
+ ValueReader(cx, args.rval()).fromStringData(enterpriseVersionString());
}
void GlobalInfo::Functions::gc::call(JSContext* cx, JS::CallArgs args) {
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 6c200662e97..07006940f2c 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -600,7 +600,7 @@ int _main(int argc, char* argv[], char** envp) {
}
if (!mongo::serverGlobalParams.quiet)
- cout << "MongoDB shell version: " << mongo::versionString << endl;
+ cout << "MongoDB shell version: " << mongo::enterpriseVersionString() << endl;
mongo::StartupTest::runTests();
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 7bafc00c54c..d759cba34df 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -200,7 +200,7 @@ Status addMongoShellOptions(moe::OptionSection* options) {
std::string getMongoShellHelp(StringData name, const moe::OptionSection& options) {
StringBuilder sb;
- sb << "MongoDB shell version: " << mongo::versionString << "\n";
+ sb << "MongoDB shell version: " << mongo::enterpriseVersionString() << "\n";
sb << "usage: " << name << " [options] [db address] [file names (ending in .js)]\n"
<< "db address can be:\n"
<< " foo foo database on local machine\n"
@@ -219,7 +219,7 @@ bool handlePreValidationMongoShellOptions(const moe::Environment& params,
return false;
}
if (params.count("version")) {
- cout << "MongoDB shell version: " << mongo::versionString << endl;
+ cout << "MongoDB shell version: " << mongo::enterpriseVersionString() << endl;
return false;
}
return true;
diff --git a/src/mongo/util/version.cpp.in b/src/mongo/util/version.cpp.in
index abe9c6315b6..64cc589c083 100644
--- a/src/mongo/util/version.cpp.in
+++ b/src/mongo/util/version.cpp.in
@@ -82,6 +82,15 @@ std::vector<std::string> compiledModules() {
return modules_list;
}
+bool hasEnterprise() {
+ for (const auto& module : compiledModules()) {
+ if (module == "enterprise") {
+ return true;
+ }
+ }
+ return false;
+}
+
bool isSameMajorVersion(const char* version) {
int major = -1, minor = -1;
pcrecpp::RE ver_regex("^(\\d+)\\.(\\d+)\\.");
@@ -98,6 +107,15 @@ string mongodVersion() {
return ss.str();
}
+string enterpriseVersionString() {
+ stringstream ss;
+ if (hasEnterprise()) {
+ ss << "Enterprise ";
+ }
+ ss << versionString;
+ return ss.str();
+}
+
const std::string openSSLVersion(const std::string& prefix, const std::string& suffix) {
#ifndef MONGO_CONFIG_SSL
return "";
diff --git a/src/mongo/util/version.h b/src/mongo/util/version.h
index 17a40eaa62e..e1388824aee 100644
--- a/src/mongo/util/version.h
+++ b/src/mongo/util/version.h
@@ -50,6 +50,12 @@ std::vector<std::string> compiledModules();
// Checks whether another version is the same major version as us
bool isSameMajorVersion(const char* version);
+// Checks whether this is an enterprise build or not (looks for enterprise module).
+bool hasEnterprise();
+
+// Returns the versionString, but prefixes with "Enterprise" if hasEnterprise.
+std::string enterpriseVersionString();
+
// Get/print the version of OpenSSL that's used at runtime
const std::string openSSLVersion(const std::string& prefix = "", const std::string& suffix = "");