Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: remove mongosh resource (#15884)

Danny Xu4967fddd65d3
diff --git a/backend/component/config/profile.go b/backend/component/config/profile.go
index e26fa35400..eac233f539 100644
--- a/backend/component/config/profile.go
+++ b/backend/component/config/profile.go
@@ -31,7 +31,7 @@ type Profile struct {
Debug bool
// DataDir is the directory stores the data including Bytebase's own database, backups, etc.
DataDir string
- // ResourceDir is the directory stores the resources including embedded postgres, mysqlutil, mongoutil and etc.
+ // ResourceDir is the directory that stores resources, including embedded Postgres.
ResourceDir string
// Demo mode.
Demo bool
diff --git a/backend/component/dbfactory/dbfactory.go b/backend/component/dbfactory/dbfactory.go
index 544916a089..2f3723eee5 100644
--- a/backend/component/dbfactory/dbfactory.go
+++ b/backend/component/dbfactory/dbfactory.go
@@ -14,15 +14,13 @@ import (
// DBFactory is the factory for building database driver.
type DBFactory struct {
- mongoBinDir string
- store *store.Store
+ store *store.Store
}
// New creates a new database driver factory.
-func New(store *store.Store, mongoBinDir string) *DBFactory {
+func New(store *store.Store) *DBFactory {
return &DBFactory{
- mongoBinDir: mongoBinDir,
- store: store,
+ store: store,
}
}
@@ -40,12 +38,7 @@ func (d *DBFactory) GetAdminDatabaseDriver(ctx context.Context, instance *store.
}
// GetDataSourceDriver returns the database driver for a data source.
-func (d *DBFactory) GetDataSourceDriver(ctx context.Context, instance *store.InstanceMessage, dataSource *storepb.DataSource, connectionContext db.ConnectionContext) (db.Driver, error) {
- dbBinDir := ""
- if instance.Metadata.GetEngine() == storepb.Engine_MONGODB {
- dbBinDir = d.mongoBinDir
- }
-
+func (*DBFactory) GetDataSourceDriver(ctx context.Context, instance *store.InstanceMessage, dataSource *storepb.DataSource, connectionContext db.ConnectionContext) (db.Driver, error) {
password, err := secretlib.ReplaceExternalSecret(ctx, dataSource.GetPassword(), dataSource.GetExternalSecret())
if err != nil {
return nil, err
@@ -56,9 +49,6 @@ func (d *DBFactory) GetDataSourceDriver(ctx context.Context, instance *store.Ins
driver, err := db.Open(
ctx,
instance.Metadata.GetEngine(),
- db.DriverConfig{
- DBBinDir: dbBinDir,
- },
db.ConnectionConfig{
DataSource: dataSource,
ConnectionContext: connectionContext,
diff --git a/backend/plugin/db/bigquery/bigquery.go b/backend/plugin/db/bigquery/bigquery.go
index 9d12faa8ff..978a85e83e 100644
--- a/backend/plugin/db/bigquery/bigquery.go
+++ b/backend/plugin/db/bigquery/bigquery.go
@@ -41,7 +41,7 @@ type Driver struct {
databaseName string
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/cassandra/cassandra.go b/backend/plugin/db/cassandra/cassandra.go
index 34142e8fa2..39a474b95e 100644
--- a/backend/plugin/db/cassandra/cassandra.go
+++ b/backend/plugin/db/cassandra/cassandra.go
@@ -41,7 +41,7 @@ type Driver struct {
session *gocql.Session
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/clickhouse/clickhouse.go b/backend/plugin/db/clickhouse/clickhouse.go
index 7313638526..b607ba8ea0 100644
--- a/backend/plugin/db/clickhouse/clickhouse.go
+++ b/backend/plugin/db/clickhouse/clickhouse.go
@@ -52,7 +52,7 @@ type Driver struct {
db *sql.DB
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/cockroachdb/cockroachdb.go b/backend/plugin/db/cockroachdb/cockroachdb.go
index 8713c1202e..bfbfb82fa3 100644
--- a/backend/plugin/db/cockroachdb/cockroachdb.go
+++ b/backend/plugin/db/cockroachdb/cockroachdb.go
@@ -45,8 +45,7 @@ func init() {
// Driver is the Postgres driver.
type Driver struct {
- dbBinDir string
- config db.ConnectionConfig
+ config db.ConnectionConfig
db *sql.DB
sshClient *ssh.Client
@@ -57,10 +56,8 @@ type Driver struct {
connectionCtx db.ConnectionContext
}
-func newDriver(config db.DriverConfig) db.Driver {
- return &Driver{
- dbBinDir: config.DBBinDir,
- }
+func newDriver() db.Driver {
+ return &Driver{}
}
// Open opens a Postgres driver.
diff --git a/backend/plugin/db/cosmosdb/cosmosdb.go b/backend/plugin/db/cosmosdb/cosmosdb.go
index 9fea0e9d94..f4c647afe9 100644
--- a/backend/plugin/db/cosmosdb/cosmosdb.go
+++ b/backend/plugin/db/cosmosdb/cosmosdb.go
@@ -35,7 +35,7 @@ type Driver struct {
databaseName string
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/databricks/databricks.go b/backend/plugin/db/databricks/databricks.go
index 2b7260e6da..52f40fb12f 100644
--- a/backend/plugin/db/databricks/databricks.go
+++ b/backend/plugin/db/databricks/databricks.go
@@ -33,7 +33,7 @@ type Driver struct {
Client *databricks.WorkspaceClient
}
-func NewDatabricksDriver(db.DriverConfig) db.Driver {
+func NewDatabricksDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/dm/dm.go b/backend/plugin/db/dm/dm.go
index 20339b02f6..f9f7694917 100644
--- a/backend/plugin/db/dm/dm.go
+++ b/backend/plugin/db/dm/dm.go
@@ -38,7 +38,7 @@ type Driver struct {
databaseName string
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.go
index 788f605309..d9ea9df07b 100644
--- a/backend/plugin/db/driver.go
+++ b/backend/plugin/db/driver.go
@@ -66,13 +66,7 @@ var (
drivers = make(map[storepb.Engine]driverFunc)
)
-// DriverConfig is the driver configuration.
-type DriverConfig struct {
- // The directiory contains db specific utilites, mongosh for MongoDB.
- DBBinDir string
-}
-
-type driverFunc func(DriverConfig) Driver
+type driverFunc func() Driver
// MigrationType is the type of a migration.
type MigrationType string
@@ -210,7 +204,7 @@ func Register(dbType storepb.Engine, f driverFunc) {
}
// Open opens a database specified by its database driver type and connection config without verifying the connection.
-func Open(ctx context.Context, dbType storepb.Engine, driverConfig DriverConfig, connectionConfig ConnectionConfig) (Driver, error) {
+func Open(ctx context.Context, dbType storepb.Engine, connectionConfig ConnectionConfig) (Driver, error) {
driversMu.RLock()
f, ok := drivers[dbType]
driversMu.RUnlock()
@@ -218,7 +212,7 @@ func Open(ctx context.Context, dbType storepb.Engine, driverConfig DriverConfig,
return nil, errors.Errorf("db: unknown driver %v", dbType)
}
- driver, err := f(driverConfig).Open(ctx, dbType, connectionConfig)
+ driver, err := f().Open(ctx, dbType, connectionConfig)
if err != nil {
return nil, err
}
diff --git a/backend/plugin/db/dynamodb/dynamodb.go b/backend/plugin/db/dynamodb/dynamodb.go
index 0380f2a407..fed04dfe1f 100644
--- a/backend/plugin/db/dynamodb/dynamodb.go
+++ b/backend/plugin/db/dynamodb/dynamodb.go
@@ -38,7 +38,7 @@ type Driver struct {
awsConfig aws.Config
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/elasticsearch/elasticsearch.go b/backend/plugin/db/elasticsearch/elasticsearch.go
index a305428091..db83d6f34c 100644
--- a/backend/plugin/db/elasticsearch/elasticsearch.go
+++ b/backend/plugin/db/elasticsearch/elasticsearch.go
@@ -25,7 +25,7 @@ import (
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
-func elasticsearchDriverFunc(db.DriverConfig) db.Driver {
+func elasticsearchDriverFunc() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/hive/hive.go b/backend/plugin/db/hive/hive.go
index b89e596055..7987590a83 100644
--- a/backend/plugin/db/hive/hive.go
+++ b/backend/plugin/db/hive/hive.go
@@ -26,7 +26,7 @@ import (
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
-func hiveDriverFunc(db.DriverConfig) db.Driver {
+func hiveDriverFunc() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/mongodb/mongodb.go b/backend/plugin/db/mongodb/mongodb.go
index fceaa61662..a9bcb6b2c4 100644
--- a/backend/plugin/db/mongodb/mongodb.go
+++ b/backend/plugin/db/mongodb/mongodb.go
@@ -25,7 +25,6 @@ import (
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/plugin/db"
"github.com/bytebase/bytebase/backend/plugin/db/util"
- "github.com/bytebase/bytebase/backend/resources/mongoutil"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
@@ -38,14 +37,13 @@ func init() {
// Driver is the MongoDB driver.
type Driver struct {
- dbBinDir string
connCfg db.ConnectionConfig
client *mongo.Client
databaseName string
}
-func newDriver(dc db.DriverConfig) db.Driver {
- return &Driver{dbBinDir: dc.DBBinDir}
+func newDriver() db.Driver {
+ return &Driver{}
}
// Open opens a MongoDB driver.
@@ -169,7 +167,7 @@ func (d *Driver) Execute(ctx context.Context, statement string, _ db.ExecuteOpti
}
mongoshArgs = append(mongoshArgs, "--file", tempFile.Name())
- mongoshCmd := exec.CommandContext(ctx, mongoutil.GetMongoshPath(d.dbBinDir), mongoshArgs...)
+ mongoshCmd := exec.CommandContext(ctx, "mongosh", mongoshArgs...)
var errContent bytes.Buffer
mongoshCmd.Stderr = &errContent
if err := mongoshCmd.Run(); err != nil {
@@ -266,7 +264,7 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, q
evalArg = fmt.Sprintf(`'%s'`, evalArg)
mongoshArgs := []string{
- mongoutil.GetMongoshPath(d.dbBinDir),
+ "mongosh",
// quote the connectionURI because we execute the mongosh via sh, and the multi-queries part contains '&', which will be translated to the background process.
fmt.Sprintf(`"%s"`, connectionURI),
"--quiet",
diff --git a/backend/plugin/db/mssql/mssql.go b/backend/plugin/db/mssql/mssql.go
index 43e357a92b..c6d054fa8d 100644
--- a/backend/plugin/db/mssql/mssql.go
+++ b/backend/plugin/db/mssql/mssql.go
@@ -48,7 +48,7 @@ type Driver struct {
certFilePath string
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/mysql/mysql.go b/backend/plugin/db/mysql/mysql.go
index 26170bb03e..77fcd2070f 100644
--- a/backend/plugin/db/mysql/mysql.go
+++ b/backend/plugin/db/mysql/mysql.go
@@ -60,7 +60,7 @@ type Driver struct {
openCleanUp []func()
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/obo/obo.go b/backend/plugin/db/obo/obo.go
index 071b850eca..d2317379ab 100644
--- a/backend/plugin/db/obo/obo.go
+++ b/backend/plugin/db/obo/obo.go
@@ -36,7 +36,7 @@ type Driver struct {
databaseName string
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/oracle/oracle.go b/backend/plugin/db/oracle/oracle.go
index 969a1ffac1..3ce064eb9b 100644
--- a/backend/plugin/db/oracle/oracle.go
+++ b/backend/plugin/db/oracle/oracle.go
@@ -49,7 +49,7 @@ type Driver struct {
connectionCtx db.ConnectionContext
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/pg/pg.go b/backend/plugin/db/pg/pg.go
index f37108cf56..2ad40ed331 100644
--- a/backend/plugin/db/pg/pg.go
+++ b/backend/plugin/db/pg/pg.go
@@ -49,8 +49,7 @@ func init() {
// Driver is the Postgres driver.
type Driver struct {
- dbBinDir string
- config db.ConnectionConfig
+ config db.ConnectionConfig
db *sql.DB
sshClient *ssh.Client
@@ -61,10 +60,8 @@ type Driver struct {
connectionCtx db.ConnectionContext
}
-func newDriver(config db.DriverConfig) db.Driver {
- return &Driver{
- dbBinDir: config.DBBinDir,
- }
+func newDriver() db.Driver {
+ return &Driver{}
}
// Open opens a Postgres driver.
diff --git a/backend/plugin/db/redis/redis.go b/backend/plugin/db/redis/redis.go
index 7eef6f9d8f..70a8b40833 100644
--- a/backend/plugin/db/redis/redis.go
+++ b/backend/plugin/db/redis/redis.go
@@ -41,7 +41,7 @@ type Driver struct {
databaseName string
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/redshift/redshift.go b/backend/plugin/db/redshift/redshift.go
index 4a1c016f48..855b5f6f23 100644
--- a/backend/plugin/db/redshift/redshift.go
+++ b/backend/plugin/db/redshift/redshift.go
@@ -60,7 +60,7 @@ type Driver struct {
datashare bool
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/risingwave/risingwave.go b/backend/plugin/db/risingwave/risingwave.go
index d0b10647a9..2ac2e53a06 100644
--- a/backend/plugin/db/risingwave/risingwave.go
+++ b/backend/plugin/db/risingwave/risingwave.go
@@ -43,8 +43,7 @@ func init() {
// Driver is the Postgres driver.
type Driver struct {
- dbBinDir string
- config db.ConnectionConfig
+ config db.ConnectionConfig
db *sql.DB
sshClient *ssh.Client
@@ -54,10 +53,8 @@ type Driver struct {
databaseName string
}
-func newDriver(config db.DriverConfig) db.Driver {
- return &Driver{
- dbBinDir: config.DBBinDir,
- }
+func newDriver() db.Driver {
+ return &Driver{}
}
// Open opens a RisingWave driver.
diff --git a/backend/plugin/db/snowflake/snowflake.go b/backend/plugin/db/snowflake/snowflake.go
index e5b130a6df..e01fbc78e1 100644
--- a/backend/plugin/db/snowflake/snowflake.go
+++ b/backend/plugin/db/snowflake/snowflake.go
@@ -43,7 +43,7 @@ type Driver struct {
databaseName string
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/spanner/spanner.go b/backend/plugin/db/spanner/spanner.go
index 860742bf74..bba017c95e 100644
--- a/backend/plugin/db/spanner/spanner.go
+++ b/backend/plugin/db/spanner/spanner.go
@@ -50,7 +50,7 @@ type Driver struct {
databaseName string
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/sqlite/sqlite.go b/backend/plugin/db/sqlite/sqlite.go
index df07be75e5..3bc50fd818 100644
--- a/backend/plugin/db/sqlite/sqlite.go
+++ b/backend/plugin/db/sqlite/sqlite.go
@@ -39,7 +39,7 @@ type Driver struct {
databaseName string
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/starrocks/starrocks.go b/backend/plugin/db/starrocks/starrocks.go
index 3b23de71af..a594bd7d24 100644
--- a/backend/plugin/db/starrocks/starrocks.go
+++ b/backend/plugin/db/starrocks/starrocks.go
@@ -51,7 +51,7 @@ type Driver struct {
openCleanUp []func()
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/tidb/tidb.go b/backend/plugin/db/tidb/tidb.go
index ffe70da311..adcdef016b 100644
--- a/backend/plugin/db/tidb/tidb.go
+++ b/backend/plugin/db/tidb/tidb.go
@@ -54,7 +54,7 @@ type Driver struct {
openCleanUp []func()
}
-func newDriver(_ db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/plugin/db/trino/trino.go b/backend/plugin/db/trino/trino.go
index 9561ac4f6c..024159a307 100644
--- a/backend/plugin/db/trino/trino.go
+++ b/backend/plugin/db/trino/trino.go
@@ -31,7 +31,7 @@ type Driver struct {
databaseName string
}
-func newDriver(db.DriverConfig) db.Driver {
+func newDriver() db.Driver {
return &Driver{}
}
diff --git a/backend/resources/README.md b/backend/resources/README.md
index 3b95b980d7..4fc835c245 100644
--- a/backend/resources/README.md
+++ b/backend/resources/README.md
@@ -22,15 +22,3 @@ https://github.com/zonkyio/embedded-postgres-binaries
./gradlew clean install -Pversion=16.0.0 -PpgVersion=16.0 -ParchName=arm64v8
Darwin should bring in "lib/libpq*".
-
-### mongoutil
-
-We embed mongoutil to execute the MongoDB commands input by users. It only contains the mongosh executable and the depending libs.
-
-monogoutil-linux-arm64 used for Linux x86_64: https://downloads.mongodb.com/compass/mongosh-1.6.1-linux-arm64.tgz, extract bin/mongosh, bin/mongosh_crypt_v1.so.
-
-monogoutil-linux-x86_64 used for Linux x86_64: https://downloads.mongodb.com/compass/mongosh-1.6.1-linux-x64.tgz, extract bin/mongosh, bin/mongosh_crypt_v1.so.
-
-monogoutil-darwin-arm64 used for MacOS Apple Silicon: https://downloads.mongodb.com/compass/mongosh-1.6.1-darwin-arm64.zip, extract bin/mongosh, bin/mongosh_crypt_v1.dylib.
-
-monogoutil-darwin-x86_64 used for MacOS Intel Silicon: https://downloads.mongodb.com/compass/mongosh-1.6.1-darwin-x64.zip, extract bin/mongosh, bin/mongosh_crypt_v1.dylib.
diff --git a/backend/resources/mongoutil/build_mongoutil.sh b/backend/resources/mongoutil/build_mongoutil.sh
deleted file mode 100755
index 07aedc0afd..0000000000
--- a/backend/resources/mongoutil/build_mongoutil.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-set -e
-
-OUT_PREFIX="mongoutil-1.6.1"
-
-pack(){
- if [[ ! -e $1 ]]; then
- echo "Downloading $1..."
- curl -o $1.tmp https://downloads.mongodb.com/compass/$1
- mv $1.tmp $1
- fi
-
- path=$1
- dir=${path%.*}
- case $2 in
- linux)
- tar -xzvf $1
- cd $dir
- tar -cJf ../${OUT_PREFIX}-$2-$3.txz bin/mongosh bin/mongosh_crypt_v1.so
- ;;
- darwin)
- unzip -o $1
- cd $dir
- tar -cJf ../${OUT_PREFIX}-$2-$3.txz bin/mongosh bin/mongosh_crypt_v1.dylib
- ;;
- esac
- cd ..
- rm -rf $dir
- rm $1
-}
-
-pack mongosh-1.6.1-darwin-arm64.zip darwin arm64
-pack mongosh-1.6.1-linux-x64.tgz linux amd64
-pack mongosh-1.6.1-linux-arm64.tgz linux arm64
diff --git a/backend/resources/mongoutil/mongoutil.go b/backend/resources/mongoutil/mongoutil.go
deleted file mode 100644
index fb4bfe5d6f..0000000000
--- a/backend/resources/mongoutil/mongoutil.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Package mongoutil provides the resource for MongoDB utility packages.
-package mongoutil
-
-import (
- "log/slog"
- "os"
- "path"
- "runtime"
- "strings"
-
- "github.com/pkg/errors"
-
- "github.com/bytebase/bytebase/backend/resources/utils"
-)
-
-// nolint
-// GetMongoshPath returns the mongosh path.
-func GetMongoshPath(binDir string) string {
- return path.Join(binDir, "mongosh")
-}
-
-// getTarnameAndVersion returns the mongoutil tarball name and version string.
-func getTarNameAndVersion() (tarname string, version string, err error) {
- var tarName string
- switch {
- case runtime.GOOS == "darwin" && runtime.GOARCH == "arm64":
- tarName = "mongoutil-1.6.1-darwin-arm64.txz"
- case runtime.GOOS == "linux" && runtime.GOARCH == "amd64":
- tarName = "mongoutil-1.6.1-linux-amd64.txz"
- case runtime.GOOS == "linux" && runtime.GOARCH == "arm64":
- tarName = "mongoutil-1.6.1-linux-arm64.txz"
- default:
- return "", "", errors.Errorf("unsupported platform: %s/%s", runtime.GOOS, runtime.GOARCH)
- }
- return tarName, strings.TrimSuffix(tarName, ".txz"), nil
-}
-
-// Install installs mongoutil in resourceDir.
-func Install(resourceDir string) (string, error) {
- tarName, version, err := getTarNameAndVersion()
- if err != nil {
- return "", errors.Wrap(err, "failed to get tarball name and version")
- }
-
- mongoutilDir := path.Join(resourceDir, version)
- if _, err := os.Stat(mongoutilDir); err != nil {
- if !os.IsNotExist(err) {
- return "", errors.Wrapf(err, "failed to check binary directory path %q", mongoutilDir)
- }
- // Install if not exist yet
- slog.Info("Installing MongoDB utilities, it may take about several minutes...")
- if err := utils.InstallImpl(resourceDir, mongoutilDir, tarName, version, resources); err != nil {
- return "", errors.Wrap(err, "cannot install mongoutil")
- }
- }
-
- return path.Join(mongoutilDir, "bin"), nil
-}
diff --git a/backend/resources/mongoutil/resources_darwin_arm64.go b/backend/resources/mongoutil/resources_darwin_arm64.go
deleted file mode 100644
index 472831d32f..0000000000
--- a/backend/resources/mongoutil/resources_darwin_arm64.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package mongoutil
-
-import "embed"
-
-//go:embed mongoutil-1.6.1-darwin-arm64.txz
-var resources embed.FS
diff --git a/backend/resources/mongoutil/resources_linux_amd64.go b/backend/resources/mongoutil/resources_linux_amd64.go
deleted file mode 100644
index a0a3ec0d50..0000000000
--- a/backend/resources/mongoutil/resources_linux_amd64.go
+++ /dev/null
@@ -1,8 +0,0 @@
-//go:build !docker
-
-package mongoutil
-
-import "embed"
-
-//go:embed mongoutil-1.6.1-linux-amd64.txz
-var resources embed.FS
diff --git a/backend/resources/mongoutil/resources_linux_arm64.go b/backend/resources/mongoutil/resources_linux_arm64.go
deleted file mode 100644
index cbc04f9279..0000000000
--- a/backend/resources/mongoutil/resources_linux_arm64.go
+++ /dev/null
@@ -1,8 +0,0 @@
-//go:build !docker
-
-package mongoutil
-
-import "embed"
-
-//go:embed mongoutil-1.6.1-linux-arm64.txz
-var resources embed.FS
diff --git a/backend/resources/mongoutil/resources_not_embeded_linux_amd64.go b/backend/resources/mongoutil/resources_not_embeded_linux_amd64.go
deleted file mode 100644
index ffd168001c..0000000000
--- a/backend/resources/mongoutil/resources_not_embeded_linux_amd64.go
+++ /dev/null
@@ -1,7 +0,0 @@
-//go:build docker
-
-package mongoutil
-
-import "embed"
-
-var resources embed.FS
diff --git a/backend/resources/mongoutil/resources_not_embeded_linux_arm64.go b/backend/resources/mongoutil/resources_not_embeded_linux_arm64.go
deleted file mode 100644
index ffd168001c..0000000000
--- a/backend/resources/mongoutil/resources_not_embeded_linux_arm64.go
+++ /dev/null
@@ -1,7 +0,0 @@
-//go:build docker
-
-package mongoutil
-
-import "embed"
-
-var resources embed.FS
diff --git a/backend/resources/utils/install_util_embeded.go b/backend/resources/utils/install_util_embeded.go
index fcbbee24b8..7f12fa84bd 100644
--- a/backend/resources/utils/install_util_embeded.go
+++ b/backend/resources/utils/install_util_embeded.go
@@ -12,7 +12,7 @@ import (
"github.com/pkg/errors"
)
-// InstallImpl installs mongoutil, mysqlutil, postgres in resourceDir.
+// InstallImpl installs postgres in resourceDir.
func InstallImpl(resourceDir, utilDir, tarName, version string, resources embed.FS) error {
tmpDir := path.Join(resourceDir, fmt.Sprintf("tmp-%s", version))
if err := os.RemoveAll(tmpDir); err != nil {
diff --git a/backend/resources/utils/install_util_not_embeded.go b/backend/resources/utils/install_util_not_embeded.go
index 2104d7e398..955ede42bd 100644
--- a/backend/resources/utils/install_util_not_embeded.go
+++ b/backend/resources/utils/install_util_not_embeded.go
@@ -12,7 +12,7 @@ import (
"github.com/pkg/errors"
)
-// InstallImpl installs mongoutil, mysqlutil, postgres in resourceDir.
+// InstallImpl installs postgres in resourceDir.
func InstallImpl(_, utilDir, tarName, version string, _ embed.FS) error {
preloadingDir := getPreloadingUtilDir(utilDir)
if _, err := os.Stat(preloadingDir); err != nil {
@@ -39,17 +39,6 @@ func InstallImpl(_, utilDir, tarName, version string, _ embed.FS) error {
// getPreloadingUtilDir returns the preloading directory which decided at the build time for the given util directory.
func getPreloadingUtilDir(utilDir string) string {
- // These paths must be consistent with the Dockerfile where decompressing the txz files.
- // we use these magic paths because the resources can only be extracted at build time. But at runtime we will decide real path according to the user input.
- // So we extract resources to these specific paths during build and then symlink them to actual paths.
- if strings.Contains(utilDir, "mysql") {
- // we only support linux/amd64 or linux/arm64 now.
- return fmt.Sprintf("/bytebase/resources/mysqlutil-8.0.33-linux-%s", runtime.GOARCH)
- }
- if strings.Contains(utilDir, "mongoutil") {
- // we only support linux/amd64 or linux/arm64 now.
- return fmt.Sprintf("/bytebase/resources/mongoutil-1.6.1-linux-%s", runtime.GOARCH)
- }
if strings.Contains(utilDir, "postgres") {
// we only support linux/amd64 or linux/arm64 now.
return fmt.Sprintf("/bytebase/resources/postgres-linux-%s-16", runtime.GOARCH)
diff --git a/backend/server/server.go b/backend/server/server.go
index 7c69bf027d..542562dc2a 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -42,7 +42,6 @@ import (
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
enterprisesvc "github.com/bytebase/bytebase/backend/enterprise/service"
"github.com/bytebase/bytebase/backend/migrator"
- "github.com/bytebase/bytebase/backend/resources/mongoutil"
"github.com/bytebase/bytebase/backend/resources/postgres"
"github.com/bytebase/bytebase/backend/runner/approval"
"github.com/bytebase/bytebase/backend/runner/metricreport"
@@ -124,12 +123,6 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
return nil, errors.Wrapf(err, "failed to create directory: %q", profile.ResourceDir)
}
- // Install mongoutil.
- mongoBinDir, err := mongoutil.Install(profile.ResourceDir)
- if err != nil {
- return nil, errors.Wrap(err, "cannot install mongo utility binaries")
- }
-
// Installs the Postgres and utility binaries and creates the 'activeProfile.pgUser' user/database
// to store Bytebase's own metadata.
pgBinDir, err := postgres.Install(profile.ResourceDir)
@@ -211,7 +204,7 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
return nil, errors.Wrapf(err, "failed to create iam manager")
}
s.webhookManager = webhook.NewManager(stores, s.iamManager)
- s.dbFactory = dbfactory.New(s.store, mongoBinDir)
+ s.dbFactory = dbfactory.New(s.store)
// Configure echo server.
s.echoServer = echo.New()
diff --git a/backend/tests/main_test.go b/backend/tests/main_test.go
index 05fc22eeda..fcd965aebc 100644
--- a/backend/tests/main_test.go
+++ b/backend/tests/main_test.go
@@ -6,8 +6,6 @@ import (
"os"
"testing"
- "github.com/bytebase/bytebase/backend/resources/mongoutil"
-
"github.com/bytebase/bytebase/backend/resources/postgres"
)
@@ -26,9 +24,6 @@ func startMain(ctx context.Context, m *testing.M) (int, error) {
if _, err := postgres.Install(resourceDir); err != nil {
return 0, err
}
- if _, err := mongoutil.Install(resourceDir); err != nil {
- return 0, err
- }
pgContainer, err := getPgContainer(ctx)
defer func() {
diff --git a/scripts/Dockerfile b/scripts/Dockerfile
index 8051b3e967..d2a555559f 100644
--- a/scripts/Dockerfile
+++ b/scripts/Dockerfile
@@ -46,8 +46,6 @@ COPY ./backend/resources /tmp/bytebase/resources/
# These paths must match the paths in backened/resources/utils/utils_dir.go.
# The real resource dir is decided by the backend at runtime. But we can only extract these at build time.
# we extract resources to a specific dir here and the backend will create symlinks at runtime.
-RUN mkdir -p /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
-RUN tar -Jxf /tmp/bytebase/resources/mongoutil/mongoutil-1.6.1-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
RUN mkdir -p /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16
RUN tar -Jxf /tmp/bytebase/resources/postgres/postgres-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16/
@@ -68,9 +66,14 @@ RUN addgroup --gid 113 --system bytebase && adduser --uid 113 --system bytebase
RUN mkdir -p /var/opt/bytebase
# Directory to store the demo data.
RUN mkdir -p /var/opt/bytebase/pgdata-demo
-# Our HEALTHCHECK instruction in dockerfile needs curl.
RUN apt-get update
-RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales curl psmisc procps libncurses5 krb5-user libkrb5-dev
+RUN apt-get install -y gnupg locales curl psmisc procps libncurses5 krb5-user libkrb5-dev
+# Install mongosh.
+RUN curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
+RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.0 main" | tee /etc/apt/sources.list.d/mongodb-org-8.0.list
+RUN apt-get update
+RUN apt-get install -y mongodb-mongosh
+
# Generate en_US.UTF-8 locale which is needed to start postgres server.
# Fix the posgres server issue (invalid value for parameter "lc_messages": "en_US.UTF-8").
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
diff --git a/scripts/Dockerfile.aws b/scripts/Dockerfile.aws
index 9bd4111241..224a468b21 100644
--- a/scripts/Dockerfile.aws
+++ b/scripts/Dockerfile.aws
@@ -46,8 +46,6 @@ COPY ./backend/resources /tmp/bytebase/resources/
# These paths must match the paths in backened/resources/utils/utils_dir.go.
# The real resource dir is decided by the backend at runtime. But we can only extract these at build time.
# we extract resources to a specific dir here and the backend will create symlinks at runtime.
-RUN mkdir -p /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
-RUN tar -Jxf /tmp/bytebase/resources/mongoutil/mongoutil-1.6.1-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
RUN mkdir -p /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16
RUN tar -Jxf /tmp/bytebase/resources/postgres/postgres-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16/