Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sbshah97 committed Mar 18, 2024
2 parents 413d262 + 419f9a0 commit d3a8f91
Show file tree
Hide file tree
Showing 173 changed files with 4,444 additions and 4,739 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
!.gitignore

# additional files for Docker images
!build/docker
!build/ferretdb
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ updates:
time: "01:42"

- package-ecosystem: "docker"
directory: "/build/docker"
directory: "/build/ferretdb"
labels: ["deps", "not ready"]
assignees: [AlekSi]
open-pull-requests-limit: 20
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ vendor/
website/build/

**/testdata/fuzz/

build/trivy-ignore.yml
1 change: 1 addition & 0 deletions .golangci-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ linters:
- lll
- misspell
- nolintlint
- sloglint
- unused
- whitespace

Expand Down
30 changes: 17 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,24 @@ linters-settings:
desc: use `github.com/jackc/pgx/v5` package instead
- pkg: github.com/jackc/pgx/v4
desc: use `github.com/jackc/pgx/v5` package instead
fjson:
oldbson:
files:
- $all
- "!**/internal/bson/*_test.go"
- "!**/internal/util/testutil/*.go"
- "!**/internal/wire/*.go"
- "!**/internal/bson/bson_test.go"
deny:
- pkg: github.com/FerretDB/FerretDB/internal/types/fjson
- pkg: github.com/FerretDB/FerretDB/internal/bson/oldbson$
bson:
files:
- $all
- "!**/internal/bson2/*_test.go"
deny:
- pkg: github.com/FerretDB/FerretDB/internal/bson$
bson2:
files:
- $all
- "!**/internal/bson/*_test.go"
- "!**/internal/util/testutil/*.go"
- "!**/internal/wire/*.go"
deny:
- pkg: github.com/FerretDB/FerretDB/internal/bson2
- pkg: github.com/FerretDB/FerretDB/internal/bson
bsonproto:
files:
- $all
- "!**/internal/bson2/*.go"
- "!**/internal/bson/*.go"
deny:
- pkg: github.com/cristalhq/bson
- pkg: github.com/cristalhq/bson/bsonproto
Expand Down Expand Up @@ -209,6 +203,15 @@ linters-settings:
ignore-generated-header: true
severity: error
rules: []
sloglint:
no-mixed-args: true
kv-only: false
attr-only: true
context-only: false # https://github.com/go-simpler/sloglint/issues/29
static-msg: false # TODO https://github.com/FerretDB/FerretDB/issues/3421
no-raw-keys: false # TODO https://github.com/FerretDB/FerretDB/issues/3421
key-naming-case: snake
args-on-sep-lines: false
staticcheck:
checks:
- all
Expand Down Expand Up @@ -241,6 +244,7 @@ linters:
- misspell
- nolintlint
- revive
- sloglint
- staticcheck
- unused
- whitespace
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ The `internal` subpackages contain most of the FerretDB code:

- `types` package provides Go types matching BSON types that don't have built-in Go equivalents:
we use `int32` for BSON's int32, but `types.ObjectID` for BSON's ObjectId.
- `types/fjson` provides converters from/to FJSON for built-in and `types` types.
It is used for logging of BSON values and wire protocol messages.
- `bson` package provides converters from/to BSON for built-in and `types` types.
- `wire` package provides wire protocol implementation.
- `clientconn` package provides client connection implementation.
Expand All @@ -183,7 +181,8 @@ you can run those with `task test-unit` after starting the environment as descri

We also have a set of "integration" tests in the `integration` directory.
They use the Go MongoDB driver like a regular user application.
They could test any MongoDB-compatible database (such as FerretDB or MongoDB itself) via a regular TCP or TLS port or Unix socket.
They could test any MongoDB-compatible database (such as FerretDB or MongoDB itself) via a regular TCP or TLS port
or Unix domain socket.
They also could test in-process FerretDB instances
(meaning that integration tests start and stop them themselves) with a given backend.
Finally, some integration tests (so-called compatibility or "compat" tests) connect to two systems
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ See [there](https://pkg.go.dev/github.com/FerretDB/FerretDB/build/version) for m

- [Civo](https://www.civo.com/marketplace/FerretDB)
- [Scaleway](https://www.scaleway.com/en/managed-document-database/)
- [Tembo](https://tembo.io/docs/tembo-stacks/mongo-alternative)
- [Vultr](https://www.vultr.com/products/managed-databases/ferretdb/)

## Documentation
Expand Down
42 changes: 21 additions & 21 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@ tasks:
-coverpkg=../...
-coverprofile=integration-mongodb.txt
./...
-target-url='mongodb://127.0.0.1:47017/'
-target-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem&replicaSet=rs0'
-target-backend=mongodb
bench-unit:
desc: "Run unit benchmarks"
cmds:
- go test -list='Benchmark.*' ./...
- go test -count=10 -bench=BenchmarkDocument -benchtime={{.BENCH_TIME}} ./internal/bson2/ | tee -a new.txt
- go test -count=10 -bench=BenchmarkDocument -benchtime={{.BENCH_TIME}} ./internal/bson/ | tee -a new.txt
- bin/benchstat{{exeExt}} old.txt new.txt

# That's not quite correct: https://github.com/golang/go/issues/15513
Expand All @@ -338,7 +338,7 @@ tasks:
desc: "Fuzz for about 1 minute (with default FUZZ_TIME)"
cmds:
- go test -list='Fuzz.*' ./...
- go test -run=XXX -fuzz=FuzzDocument -fuzztime={{.FUZZ_TIME}} ./internal/bson2/
- go test -run=XXX -fuzz=FuzzDocument -fuzztime={{.FUZZ_TIME}} ./internal/bson/
- go test -run=XXX -fuzz=FuzzMsg -fuzztime={{.FUZZ_TIME}} ./internal/wire/
- go test -run=XXX -fuzz=FuzzQuery -fuzztime={{.FUZZ_TIME}} ./internal/wire/
- go test -run=XXX -fuzz=FuzzReply -fuzztime={{.FUZZ_TIME}} ./internal/wire/
Expand Down Expand Up @@ -492,23 +492,23 @@ tasks:
desc: "Run security scanners"
cmds:
# don't run them in parallel via `deps` because that breaks terminal output
- task: security-trivy
- task: security-govulncheck
- task: security-trivy

security-govulncheck:
cmds:
- bin/govulncheck{{exeExt}} -test ./...
- bin/task{{exeExt}} -d integration integration-security

security-trivy:
cmds:
- >
docker compose run --rm trivy filesystem .
--secret-config=./build/trivy-secret.yml
--ignorefile=./build/.trivyignore
--ignorefile=./build/trivy-ignore.yml
--cache-dir=./tmp/trivy
--exit-code=1
security-govulncheck:
cmds:
- bin/govulncheck{{exeExt}} -test ./...
- bin/task{{exeExt}} -d integration integration-security

godocs:
desc: "Serve Go code documentation"
cmds:
Expand Down Expand Up @@ -562,7 +562,7 @@ tasks:
--name=ferretdb
--bootstrap=true
--use=false
--config=./build/docker/buildkitd.toml
--config=./build/buildkitd.toml
--driver=docker-container
--driver-opt network=host
--driver-opt env.JAEGER_TRACE=127.0.0.1:6831
Expand All @@ -586,7 +586,7 @@ tasks:
cmds:
- >
docker buildx build --builder=ferretdb
--file=build/docker/{{.FILE}}.Dockerfile
--file=build/{{.FILE}}.Dockerfile
--build-arg=LABEL_VERSION={{.VERSION}}
--build-arg=LABEL_COMMIT={{.COMMIT}}
--target={{.TARGET}}
Expand Down Expand Up @@ -619,7 +619,7 @@ tasks:
- bin/envtool{{exeExt}} shell mkdir tmp/bin-dev
- task: docker-build
vars:
FILE: development
FILE: ferretdb/development
TARGET: development-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
Expand All @@ -639,7 +639,7 @@ tasks:
- bin/envtool{{exeExt}} shell mkdir tmp/bin
- task: docker-build
vars:
FILE: production
FILE: ferretdb/production
TARGET: production-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
Expand Down Expand Up @@ -669,7 +669,7 @@ tasks:
- echo 'docker-all-in-one' > build/version/package.txt
- task: docker-build
vars:
FILE: all-in-one
FILE: ferretdb/all-in-one
TARGET: all-in-one
PLATFORM: linux/amd64,linux/arm64 # no mongosh for arm/v6 and arm/v7
OUTPUT: type=image,push=true
Expand All @@ -682,7 +682,7 @@ tasks:
- echo 'docker-development' > build/version/package.txt
- task: docker-build
vars:
FILE: development
FILE: ferretdb/development
TARGET: development
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=image,push=true
Expand All @@ -695,7 +695,7 @@ tasks:
- echo 'docker' > build/version/package.txt
- task: docker-build
vars:
FILE: production
FILE: ferretdb/production
TARGET: production
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=image,push=true
Expand Down Expand Up @@ -744,7 +744,7 @@ tasks:
- bin/envtool{{exeExt}} shell mkdir tmp/debs
- task: docker-build
vars:
FILE: development
FILE: ferretdb/development
TARGET: development-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
Expand Down Expand Up @@ -772,7 +772,7 @@ tasks:
- bin/envtool{{exeExt}} shell mkdir tmp/debs
- task: docker-build
vars:
FILE: production
FILE: ferretdb/production
TARGET: production-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
Expand Down Expand Up @@ -812,7 +812,7 @@ tasks:
- bin/envtool{{exeExt}} shell mkdir tmp/rpms
- task: docker-build
vars:
FILE: development
FILE: ferretdb/development
TARGET: development-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
Expand Down Expand Up @@ -840,7 +840,7 @@ tasks:
- bin/envtool{{exeExt}} shell mkdir tmp/rpms
- task: docker-build
vars:
FILE: production
FILE: ferretdb/production
TARGET: production-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ RUN mkdir /tmp/cover

# all-in-one hacks start there

COPY --from=all-in-one-build /src/build/docker/all-in-one/ferretdb.sh /etc/service/ferretdb/run
COPY --from=all-in-one-build /src/build/docker/all-in-one/postgresql.sh /etc/service/postgresql/run
COPY --from=all-in-one-build /src/build/docker/all-in-one/entrypoint.sh /entrypoint.sh
COPY --from=all-in-one-build /src/build/ferretdb/all-in-one/ferretdb.sh /etc/service/ferretdb/run
COPY --from=all-in-one-build /src/build/ferretdb/all-in-one/postgresql.sh /etc/service/postgresql/run
COPY --from=all-in-one-build /src/build/ferretdb/all-in-one/entrypoint.sh /entrypoint.sh

RUN --mount=type=cache,sharing=locked,target=/var/cache/apt <<EOF
set -ex
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ FROM scratch AS production
COPY --from=production-build /src/bin/ferretdb /ferretdb

# TODO https://github.com/FerretDB/FerretDB/issues/3992
# COPY build/docker/passwd /etc/passwd
# COPY build/docker/group /etc/group
# COPY build/ferretdb/passwd /etc/passwd
# COPY build/ferretdb/group /etc/group
# USER ferretdb:ferretdb

ENTRYPOINT [ "/ferretdb" ]
Expand Down
8 changes: 8 additions & 0 deletions build/trivy-ignore.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Copy to trivy-ignore.yml if you use direnv / .envrc for managing local development environment.
# https://aquasecurity.github.io/trivy/latest/docs/configuration/filtering/#trivyignoreyaml

secrets:
- id: github-pat
paths:
- .envrc
2 changes: 1 addition & 1 deletion ferretdb/ferretdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (f *FerretDB) MongoDBURI() string {
Path: "/",
}
case f.config.Listener.Unix != "":
// MongoDB really wants Unix socket path in the host part of the URI
// MongoDB really wants Unix domain socket path in the host part of the URI
u = &url.URL{
Scheme: "mongodb",
Host: f.l.UnixAddr().String(),
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/google/uuid v1.6.0
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa
github.com/jackc/pgx-zap v0.0.0-20221202020421-94b1cb2f889f
github.com/jackc/pgx/v5 v5.5.3
github.com/jackc/pgx/v5 v5.5.5
github.com/neilotoole/slogt v1.1.0
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/client_golang v1.18.0
Expand Down Expand Up @@ -68,11 +68,11 @@ require (
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.18.0 // indirect
golang.org/x/tools v0.18.0 // indirect; https://github.com/golang/go/issues/66259
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/grpc v1.61.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx-zap v0.0.0-20221202020421-94b1cb2f889f h1:ahoGnXfh4wiCisojvzq1PzgxzFwJEUHMI26pUY6oluk=
github.com/jackc/pgx-zap v0.0.0-20221202020421-94b1cb2f889f/go.mod h1:m9tCxmy1PSUQa5o0aL4rQTowmJD1BK2Zc7dgnK/IrXc=
github.com/jackc/pgx/v5 v5.5.3 h1:Ces6/M3wbDXYpM8JyyPD57ivTtJACFZJd885pdIaV2s=
github.com/jackc/pgx/v5 v5.5.3/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
Expand Down Expand Up @@ -183,8 +183,8 @@ google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
1 change: 1 addition & 0 deletions integration/.golangci-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ linters:
- lll
- misspell
- nolintlint
- sloglint
- unused
- whitespace

Expand Down
10 changes: 10 additions & 0 deletions integration/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ linters-settings:
ignore-generated-header: true
severity: error
rules: []
sloglint:
no-mixed-args: true
kv-only: false
attr-only: true
context-only: true
static-msg: true
no-raw-keys: false # TODO https://github.com/FerretDB/FerretDB/issues/3421
key-naming-case: snake
args-on-sep-lines: false
staticcheck:
checks:
- all
Expand Down Expand Up @@ -138,6 +147,7 @@ linters:
- misspell
- nolintlint
- revive
- sloglint
- staticcheck
- unused
- whitespace
Expand Down
Loading

0 comments on commit d3a8f91

Please sign in to comment.