-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
101 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,24 @@ | ||
package mongo | ||
|
||
import ( | ||
"github.com/crawlab-team/crawlab/trace" | ||
"github.com/apex/log" | ||
"github.com/spf13/viper" | ||
"go.mongodb.org/mongo-driver/mongo" | ||
) | ||
|
||
func GetMongoDb(dbName string, opts ...DbOption) (db *mongo.Database) { | ||
func GetMongoDb(dbName string) *mongo.Database { | ||
// Use default database name if not provided | ||
if dbName == "" { | ||
dbName = viper.GetString("mongo.db") | ||
} | ||
if dbName == "" { | ||
dbName = "test" | ||
} | ||
|
||
_opts := &DbOptions{} | ||
for _, op := range opts { | ||
op(_opts) | ||
if dbName = viper.GetString("mongo.db"); dbName == "" { | ||
dbName = "test" | ||
} | ||
} | ||
|
||
var c *mongo.Client | ||
if _opts.client == nil { | ||
var err error | ||
c, err = GetMongoClient() | ||
if err != nil { | ||
trace.PrintError(err) | ||
return nil | ||
} | ||
} else { | ||
c = _opts.client | ||
c, err := GetMongoClient() | ||
if err != nil { | ||
log.Errorf("error getting mongo client: %v", err) | ||
return nil | ||
} | ||
|
||
return c.Database(dbName, nil) | ||
return c.Database(dbName) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Exit on error | ||
set -e | ||
|
||
# Update package list and install OpenJDK 11 | ||
DEBIAN_FRONTEND=noninteractive apt-get update && \ | ||
apt-get install -y --no-install-recommends openjdk-11-jdk && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
version="11.0.12-open" | ||
|
||
# Install SDKMAN! | ||
curl -s "https://get.sdkman.io" | bash | ||
|
||
# Source SDKMAN! | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
|
||
# Install Java 11 (you can specify vendor, e.g., 11.0.12-open for OpenJDK) | ||
sdk install java ${version} | ||
|
||
# Set Java 11 as default | ||
sdk default java ${version} | ||
|
||
# Create symbolic links | ||
ln -sf "$(sdkman which java)" /usr/local/bin/java | ||
ln -sf "$(sdkman which javac)" /usr/local/bin/javac | ||
|
||
# Verify | ||
java_version=$(java -version) | ||
if [[ $java_version =~ "${version}" ]]; then | ||
: | ||
else | ||
echo "ERROR: java version does not match. expect \"${version}\", but actual is \"${java_version}\"" | ||
exit 1 | ||
fi | ||
javac_version=$(javac -version) | ||
if [[ $javac_version =~ "${version}" ]]; then | ||
: | ||
else | ||
echo "ERROR: javac version does not match. expect \"${version}\", but actual is \"${javac_version}\"" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters