Skip to content

Commit e3ee547

Browse files
committed
chore: removed MongoDB from project
1 parent 5ade1f2 commit e3ee547

18 files changed

+46
-1351
lines changed

.github/workflows/go-test.yml

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
21
name: go-test
32

43
on:
54
push:
6-
branches: [ "*"]
5+
branches: ["*"]
76
pull_request:
8-
branches: [ "*" ]
7+
branches: ["*"]
98

109
env:
1110
BUILD_TYPE: Release
@@ -14,10 +13,9 @@ jobs:
1413
build:
1514
strategy:
1615
matrix:
17-
mongodb-version: ['6.0']
18-
os: [ 'ubuntu-22.04', 'ubuntu-20.04']
19-
postgres-images: [ 'postgres:latest']
20-
go-version: ['1.20']
16+
os: ["ubuntu-22.04", "ubuntu-20.04"]
17+
postgres-images: ["postgres:latest"]
18+
go-version: ["1.20"]
2119
runs-on: ${{ matrix.os }}
2220

2321
services:
@@ -37,25 +35,16 @@ jobs:
3735
--health-retries 5
3836
3937
steps:
40-
- uses: actions/checkout@v3
41-
42-
- name: Start MongoDB
43-
uses: supercharge/mongodb-github-action@1.8.0
44-
with:
45-
mongodb-version: ${{ matrix.mongodb-version }}
46-
mongodb-username: mbtestuser
47-
mongodb-password: mbtestpwd
48-
mongodb-db: mbtestdb
38+
- uses: actions/checkout@v3
4939

50-
- uses: actions/setup-go@v3
51-
with:
52-
go-version: ${{matrix.go-version}}
40+
- uses: actions/setup-go@v3
41+
with:
42+
go-version: ${{matrix.go-version}}
5343

54-
- name: Run all go tests
55-
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic
56-
env:
57-
MONGODB_HOST: localhost
58-
POSTGRES_HOST: localhost
59-
TEST_DATA_DIR: /home/runner/work/MassBank3/MassBank3/
60-
- name: Upload coverage to Codecov
61-
uses: codecov/codecov-action@v3
44+
- name: Run all go tests
45+
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic
46+
env:
47+
POSTGRES_HOST: localhost
48+
TEST_DATA_DIR: /home/runner/work/MassBank3/MassBank3/
49+
- name: Upload coverage to Codecov
50+
uses: codecov/codecov-action@v3

cmd/mb3dbtool/main.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ func main() {
2222
var userConfig = config.GetToolConfig()
2323
var db database.MB3Database
2424
var err error
25-
if userConfig.Database == database.MongoDB {
26-
db, err = database.NewMongoDB(userConfig.DBConfig)
27-
if err != nil {
28-
panic(err)
29-
}
30-
} else if userConfig.Database == database.Postgres {
25+
if userConfig.Database == database.Postgres {
3126
db, err = database.NewPostgresSQLDb(userConfig.DBConfig)
3227
if err != nil {
3328
panic(err)

compose/env.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MB3_FRONTEND_BASE_URL=/massbank3/
3030
# Database configuration
3131
# ----------------------
3232

33-
# The database type: "mongodb" or "postgres"
33+
# The database type: "postgres"
3434
DB_TYPE=postgres
3535

3636
# The port of the database

docker/docker-compose-common.yaml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
version: '3.1'
1+
version: "3.1"
22

33
services:
4-
5-
mongodb:
6-
image: docker.io/mongo:latest
7-
restart: always
8-
environment:
9-
MONGO_INITDB_ROOT_USERNAME: ${DB_USER}
10-
MONGO_INITDB_ROOT_PASSWORD: ${DB_PASSWORD}
11-
healthcheck:
12-
test: ["CMD","mongosh", "--eval", "\"db.adminCommand('ping')\""]
13-
interval: 30s
14-
timeout: 60s
15-
retries: 5
16-
start_period: 40s
17-
184
postgres:
195
image: docker.io/postgres:latest
206
restart: always
@@ -23,7 +9,15 @@ services:
239
POSTGRES_USER: ${DB_USER}
2410
POSTGRES_DB: ${DB_NAME}
2511
healthcheck:
26-
test: ["CMD-SHELL", "pg_isready", "-d", "$$POSTGRES_DB","-U", "$$POSTGRES_USER"]
12+
test:
13+
[
14+
"CMD-SHELL",
15+
"pg_isready",
16+
"-d",
17+
"$$POSTGRES_DB",
18+
"-U",
19+
"$$POSTGRES_USER",
20+
]
2721
interval: 30s
2822
timeout: 60s
2923
retries: 5
@@ -46,7 +40,6 @@ services:
4640
mb3frontend:
4741
restart: always
4842

49-
5043
cdkdepict:
5144
image: docker.io/simolecule/cdkdepict:latest
5245

docker/docker-compose-debug.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
version: "3.1"
22

33
services:
4-
mongodb:
5-
extends:
6-
file: docker-compose-common.yaml
7-
service: mongodb
8-
ports:
9-
- "27017:27017"
10-
114
postgres:
125
extends:
136
file: docker-compose-common.yaml
@@ -31,7 +24,6 @@ services:
3124
volumes:
3225
- ./debuglog:/var/log
3326
depends_on:
34-
- mongodb
3527
- postgres
3628

3729
mb3frontend:
@@ -53,8 +45,6 @@ services:
5345
depends_on:
5446
postgres:
5547
condition: service_healthy
56-
mongodb:
57-
condition: service_healthy
5848

5949
cdkdepict:
6050
extends:

docker/docker-compose-deploy.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
version: "3.1"
22

33
services:
4-
mongodb:
5-
extends:
6-
file: docker-compose-common.yaml
7-
service: mongodb
8-
94
postgres:
105
extends:
116
file: docker-compose-common.yaml
@@ -17,7 +12,6 @@ services:
1712
service: mb3server
1813
build: ../
1914
depends_on:
20-
- mongodb
2115
- postgres
2216

2317
mb3frontend:
@@ -47,5 +41,3 @@ services:
4741
depends_on:
4842
postgres:
4943
condition: service_healthy
50-
mongodb:
51-
condition: service_healthy

docker/docker-compose-test.yaml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
version: '3.1'
1+
version: "3.1"
22

33
services:
4-
5-
testmongo:
6-
extends:
7-
file: docker-compose-common.yaml
8-
service: mongodb
9-
environment:
10-
MONGO_INITDB_ROOT_USERNAME: "mbtestuser"
11-
MONGO_INITDB_ROOT_PASSWORD: "mbtestpwd"
12-
134
testpostgres:
145
extends:
156
file: docker-compose-common.yaml
167
service: postgres
178
environment:
189
POSTGRES_PASSWORD: "mbtestpwd"
19-
POSTGRES_USER: "mbtestuser"
20-
POSTGRES_DB: "mbtestdb"
10+
POSTGRES_USER: "mbtestuser"
11+
POSTGRES_DB: "mbtestdb"
2112

2213
mb3server:
2314
extends:
@@ -27,9 +18,7 @@ services:
2718
depends_on:
2819
testpostgres:
2920
condition: service_healthy
30-
testmongo:
31-
condition: service_healthy
32-
21+
3322
mb3test:
3423
build:
3524
context: ..
@@ -39,5 +28,3 @@ services:
3928
depends_on:
4029
testpostgres:
4130
condition: service_healthy
42-
testmongo:
43-
condition: service_healthy

docker/env.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MB3_FRONTEND_BASE_URL=/massbank3/
3030
# Database configuration
3131
# ----------------------
3232

33-
# The database type: "mongodb" or "postgres"
33+
# The database type: "postgres"
3434
DB_TYPE=postgres
3535

3636
# The port of the database

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require (
1111
github.com/lib/pq v1.10.7
1212
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de
1313
github.com/nullism/bqb v1.3.1
14-
go.mongodb.org/mongo-driver v1.11.6
1514
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
1615
)
1716

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgk
9696
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
9797
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
9898
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
99-
go.mongodb.org/mongo-driver v1.11.6 h1:XM7G6PjiGAO5betLF13BIa5TlLUUE3uJ/2Ox3Lz1K+o=
100-
go.mongodb.org/mongo-driver v1.11.6/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
10199
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
102100
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
103101
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=

pkg/config/config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func getDBConfig() database.DBConfig {
108108
log.Panicln(errors.New("Could not read port variable: DB_PORT=" + dbPortEnv))
109109
}
110110
c.DbPort = uint(dbPort)
111-
flag.StringVar(&databaseType, "db_type", databaseType, "Database type must be postgres or mongodb. Overwrites environment variable DB_TYPE")
111+
flag.StringVar(&databaseType, "db_type", databaseType, "Database type must be postgres (currently). Overwrites environment variable DB_TYPE")
112112
flag.StringVar(&c.DbUser, "db_user", c.DbUser, "database user name. Overwrites environment variable DB_USER")
113113
flag.StringVar(&c.DbPwd, "db_pwd", c.DbPwd, "database user password. Overwrites environment variable DB_PASSWORD")
114114
flag.StringVar(&c.DbHost, "db_host", c.DbHost, "database host. Overwrites environment variable DB_HOST")
@@ -118,10 +118,8 @@ func getDBConfig() database.DBConfig {
118118
flag.Parse()
119119
if databaseType == "postgres" {
120120
c.Database = database.Postgres
121-
} else if databaseType == "mongodb" {
122-
c.Database = database.MongoDB
123121
} else {
124-
panic("Database must be postgres or mongodb")
122+
panic("Database must be postgres (currently).")
125123
}
126124
if c.DbPort == 0 {
127125
if c.Database == database.Postgres {

pkg/database/db_interface.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ type DatabaseType int
3434

3535
// The list of supported databases
3636
const (
37-
MongoDB DatabaseType = 0
38-
Postgres = 1
37+
Postgres = 0
3938
)
4039

4140
// DBConfig is the abstract database configuration which should be used when working
@@ -223,12 +222,7 @@ var db MB3Database
223222
func InitDb(dbConfig DBConfig) (MB3Database, error) {
224223
if db == nil {
225224
var err error
226-
if dbConfig.Database == MongoDB {
227-
db, err = NewMongoDB(dbConfig)
228-
if err != nil {
229-
panic(err)
230-
}
231-
} else if dbConfig.Database == Postgres {
225+
if dbConfig.Database == Postgres {
232226
db, err = NewPostgresSQLDb(dbConfig)
233227
log.Println(dd.Dump(db))
234228
if err != nil {

0 commit comments

Comments
 (0)