From 1293a5eea4d9544ef9c2dc58e910509bff1b81a0 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Wed, 28 Dec 2022 21:20:02 +0400 Subject: [PATCH] Update building documentation (#1713) Closes #735. Closes #1447. --- .github/RELEASE_CHECKLIST.md | 4 +- .github/workflows/packages.yml | 11 ++ CONTRIBUTING.md | 5 + README.md | 16 ++ Taskfile.yml | 49 ++--- build/deps/cockroach.Dockerfile | 2 +- build/nfpm.yaml | 2 +- build/version/debug_off.go | 22 +++ build/version/debug_on.go | 22 +++ {internal/util => build}/version/generate.go | 11 +- .../version/gen => build/version}/mongodb.txt | 0 build/version/version.go | 181 ++++++++++++++++++ .../util => build}/version/version_test.go | 9 +- cmd/envtool/envtool.go | 12 +- cmd/ferretdb/main.go | 25 ++- ferretdb/ferretdb.go | 12 +- go.mod | 2 +- go.sum | 4 +- integration/commands_administration_test.go | 3 - integration/go.mod | 2 +- integration/go.sum | 4 +- internal/clientconn/listener.go | 7 +- internal/handlers/common/msg_buildinfo.go | 8 +- internal/handlers/common/serverstatus.go | 4 +- internal/handlers/pg/msg_explain.go | 4 +- internal/handlers/pg/msg_getlog.go | 2 +- internal/handlers/tigris/msg_explain.go | 4 +- internal/handlers/tigris/msg_getlog.go | 2 +- internal/util/logging/logging.go | 8 +- internal/util/state/metrics.go | 4 +- internal/util/state/metrics_test.go | 6 +- internal/util/telemetry/reporter.go | 4 +- internal/util/version/version.go | 146 -------------- tools/go.mod | 4 +- tools/go.sum | 8 +- website/docs/contributing.md | 2 +- website/docs/diff.md | 2 +- website/docs/reference/supported_commands.md | 6 +- website/docs/understanding_ferretdb.md | 6 +- 39 files changed, 379 insertions(+), 246 deletions(-) create mode 100644 build/version/debug_off.go create mode 100644 build/version/debug_on.go rename {internal/util => build}/version/generate.go (83%) rename {internal/util/version/gen => build/version}/mongodb.txt (100%) create mode 100644 build/version/version.go rename {internal/util => build}/version/version_test.go (84%) delete mode 100644 internal/util/version/version.go diff --git a/.github/RELEASE_CHECKLIST.md b/.github/RELEASE_CHECKLIST.md index 47df7595668a..c95d8a0d54be 100644 --- a/.github/RELEASE_CHECKLIST.md +++ b/.github/RELEASE_CHECKLIST.md @@ -30,7 +30,9 @@ ## Release -1. Upload .deb and .rpm packages [from the CI build for the tag](https://github.com/FerretDB/FerretDB/actions/workflows/packages.yml?query=event%3Apush) to the draft release. +1. Upload the binary and .deb and .rpm packages + [from the CI build for the tag](https://github.com/FerretDB/FerretDB/actions/workflows/packages.yml?query=event%3Apush) + to the draft release. 2. Close milestone in issues. 3. Publish release on GitHub. 4. Announce it on Slack. diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 3da0020be64c..1a69ec923006 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -47,9 +47,20 @@ jobs: - name: Run init run: bin/task init + - name: Build release binary + run: bin/task build-release + - name: Build packages run: bin/task packages + - name: Upload ferretdb + uses: actions/upload-artifact@v3 + with: + name: ferretdb + path: bin/ferretdb + retention-days: 14 + if-no-files-found: error + - name: Upload ferretdb.deb uses: actions/upload-artifact@v3 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 886b9b99fade..e52d27f471da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,6 +66,11 @@ you can reset the environment with `task env-reset`. You can see all available `task` tasks with `task -l`. +### Building release binary + +To build a release binary, run `task build-release`. +The result will be saved as `bin/ferretdb`. + ## Contributing code ### Commands for contributing code diff --git a/README.md b/README.md index d050246a2e4b..f0d4fb858b51 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,22 @@ They are not suitable for most production use-cases because they keep all data i You can also install with FerretDB with the `.deb` and `.rpm` packages provided for each [release](https://github.com/FerretDB/FerretDB/releases). +## Building and packaging + +We strongly advise users not to build FerretDB themselves. +Instead, use Docker images or .deb and .rpm packages provided by us. +If you want to package FerretDB for your operating system or distribution, +the recommended way is to use the `build-release` task; +see our [instructions for contributors](CONTRIBUTING.md) for more details. +FerretDB could also be built as any other Go program, +but a few generated files and build tags could affect it. +See [there](https://pkg.go.dev/github.com/FerretDB/FerretDB/build/version) for more details. + +## Documentation + +* [Documentation for users](https://docs.ferretdb.io/). +* [Documentation for Go developers about embeddable FerretDB](https://pkg.go.dev/github.com/FerretDB/FerretDB/ferretdb). + ## Community * Website and blog: [https://ferretdb.io](https://ferretdb.io/). diff --git a/Taskfile.yml b/Taskfile.yml index c71cfd44857e..327f4219dd51 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -9,7 +9,7 @@ vars: FUZZTIME: 15s FUZZCORPUS: ../fuzz-corpus RACEFLAG: -race={{and (ne OS "windows") (ne ARCH "arm")}} - BUILDTAGS: ferretdb_tigris + BUILDTAGS: ferretdb_debug,ferretdb_tigris SERVICES: postgres tigris mongodb tasks: @@ -30,7 +30,23 @@ tasks: gen-version: run: once cmds: - - go generate -x ./internal/util/version + - go generate -x ./build/version + + # do not change that target much; see "Building and packaging" in README.md + build-release: + desc: "Build bin/ferretdb{{exeExt}} (release build)" + deps: [gen-version] + cmds: + - go build -o=bin/ferretdb{{exeExt}} -trimpath -tags=ferretdb_tigris ./cmd/ferretdb + env: + CGO_ENABLED: 0 + + build-testcover: + desc: "Build bin/ferretdb-testcover{{exeExt}}" + run: once + deps: [gen-version] + cmds: + - go test -c -o=bin/ferretdb-testcover{{exeExt}} -trimpath {{.RACEFLAG}} -tags=ferretdb_testcover,{{.BUILDTAGS}} -coverpkg=./... ./cmd/ferretdb init-tools: dir: tools @@ -52,10 +68,6 @@ tasks: - go mod tidy - go mod verify - # deprecated alias - init-clean: - deps: [env-reset] - env-reset: desc: "Clean ALL Go and Docker data (caches, images, volumes), and reset environment" cmds: @@ -233,13 +245,6 @@ tasks: - go run {{.RACEFLAG}} ./cmd/fuzztool corpus seed {{.FUZZCORPUS}} - go run {{.RACEFLAG}} ./cmd/fuzztool corpus {{.FUZZCORPUS}} generated - build-testcover: - desc: "Build bin/ferretdb-testcover" - run: once - deps: [gen-version] - cmds: - - go test -c -o=bin/ferretdb-testcover{{exeExt}} -trimpath {{.RACEFLAG}} -tags=ferretdb_testcover,{{.BUILDTAGS}} -coverpkg=./... ./cmd/ferretdb - run: desc: "Run FerretDB" deps: [build-testcover] @@ -283,7 +288,7 @@ tasks: cmds: - bin/golangci-lint{{exeExt}} run --config=.golangci.yml - bin/golangci-lint{{exeExt}} run --config=.golangci-new.yml - - bin/go-consistent{{exeExt}} -pedantic ./cmd/... ./internal/... ./ferretdb/... + - bin/go-consistent{{exeExt}} -pedantic ./cmd/... ./internal/... ./build/... ./ferretdb/... - bin/go-sumtype{{exeExt}} ./... - go vet -vettool=./bin/checkswitch{{exeExt}} ./... - bin/task{{exeExt}} -d integration integration-lint @@ -365,9 +370,9 @@ tasks: --load . vars: VERSION: - sh: cat internal/util/version/gen/version.txt + sh: cat build/version/version.txt COMMIT: - sh: cat internal/util/version/gen/commit.txt + sh: cat build/version/commit.txt docker-push: deps: [gen-version] @@ -382,9 +387,9 @@ tasks: --push . vars: VERSION: - sh: cat internal/util/version/gen/version.txt + sh: cat build/version/version.txt COMMIT: - sh: cat internal/util/version/gen/commit.txt + sh: cat build/version/commit.txt docker-push-release: cmds: @@ -397,7 +402,7 @@ tasks: ghcr.io/ferretdb/ferretdb:{{trimPrefix "v" .VERSION}} vars: VERSION: - sh: cat internal/util/version/gen/version.txt + sh: cat build/version/version.txt packages: cmds: @@ -405,7 +410,6 @@ tasks: - task: packages-rpm packages-deb: - deps: [build-testcover] dir: build cmds: - ../bin/nfpm{{exeExt}} package --packager=deb --target=deb/ferretdb.deb @@ -414,12 +418,11 @@ tasks: 'dpkg -i /deb/ferretdb.deb && ferretdb --version' env: VERSION: - sh: cat ../internal/util/version/gen/version.txt + sh: cat ../build/version/version.txt GOARCH: sh: go env GOARCH packages-rpm: - deps: [build-testcover] dir: build cmds: - ../bin/nfpm{{exeExt}} package --packager=rpm --target=rpm/ferretdb.rpm @@ -428,7 +431,7 @@ tasks: 'rpm -i /rpm/ferretdb.rpm && ferretdb --version' env: VERSION: - sh: cat ../internal/util/version/gen/version.txt + sh: cat ../build/version/version.txt GOARCH: sh: go env GOARCH diff --git a/build/deps/cockroach.Dockerfile b/build/deps/cockroach.Dockerfile index 600ee6d0bc68..6e5231f6e95e 100644 --- a/build/deps/cockroach.Dockerfile +++ b/build/deps/cockroach.Dockerfile @@ -1 +1 @@ -FROM cockroachdb/cockroach:v22.2.0 +FROM cockroachdb/cockroach:v22.2.1 diff --git a/build/nfpm.yaml b/build/nfpm.yaml index 5561f2171e68..d0512fb68ec0 100644 --- a/build/nfpm.yaml +++ b/build/nfpm.yaml @@ -12,5 +12,5 @@ description: > homepage: https://ferretdb.io license: Apache License 2.0 contents: - - src: ../bin/ferretdb-testcover + - src: ../bin/ferretdb dst: /usr/bin/ferretdb diff --git a/build/version/debug_off.go b/build/version/debug_off.go new file mode 100644 index 000000000000..79bb3c695a50 --- /dev/null +++ b/build/version/debug_off.go @@ -0,0 +1,22 @@ +// Copyright 2021 FerretDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !(ferretdb_debug || ferretdb_testcover || race) + +package version + +// debugBuild is false if that's not a debug build. +// +// See package documentation for more details. +const debugBuild = false diff --git a/build/version/debug_on.go b/build/version/debug_on.go new file mode 100644 index 000000000000..47c308f9d0c3 --- /dev/null +++ b/build/version/debug_on.go @@ -0,0 +1,22 @@ +// Copyright 2021 FerretDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build ferretdb_debug || ferretdb_testcover || race + +package version + +// debugBuild is true if that's a debug build. +// +// See package documentation for more details. +const debugBuild = true diff --git a/internal/util/version/generate.go b/build/version/generate.go similarity index 83% rename from internal/util/version/generate.go rename to build/version/generate.go index 4a78106ccd06..bb02232d1888 100644 --- a/internal/util/version/generate.go +++ b/build/version/generate.go @@ -21,7 +21,6 @@ import ( "log" "os" "os/exec" - "path/filepath" "strings" "sync" @@ -44,7 +43,7 @@ func runGit(args ...string) []byte { // saveFile stores the given bytes in the given file with logging. func saveFile(b []byte, filename string) { log.Printf("%s: %s", filename, b) - must.NoError(os.WriteFile(filepath.Join("gen", filename), b, 0o666)) + must.NoError(os.WriteFile(filename, b, 0o666)) } func main() { @@ -52,15 +51,15 @@ func main() { var wg sync.WaitGroup - // git describe --tags --dirty > gen/version.txt + // git describe --dirty > version.txt wg.Add(1) go func() { defer wg.Done() - saveFile(runGit("describe", "--tags", "--dirty"), "version.txt") + saveFile(runGit("describe", "--dirty"), "version.txt") }() - // git rev-parse HEAD > gen/commit.txt + // git rev-parse HEAD > commit.txt wg.Add(1) go func() { defer wg.Done() @@ -68,7 +67,7 @@ func main() { saveFile(runGit("rev-parse", "HEAD"), "commit.txt") }() - // git branch --show-current > gen/branch.txt + // git branch --show-current > branch.txt wg.Add(1) go func() { defer wg.Done() diff --git a/internal/util/version/gen/mongodb.txt b/build/version/mongodb.txt similarity index 100% rename from internal/util/version/gen/mongodb.txt rename to build/version/mongodb.txt diff --git a/build/version/version.go b/build/version/version.go new file mode 100644 index 000000000000..b9e2e02e61ba --- /dev/null +++ b/build/version/version.go @@ -0,0 +1,181 @@ +// Copyright 2021 FerretDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package version provides information about FerretDB version and build configuration. +// +// # Required files +// +// The following generated text files may be present in this (build/version) directory during building: +// - version.txt (required) contains information about the FerretDB version in a format +// similar to `git describe` output: `v..`. +// - commit.txt (optional) contains information about the source git commit. +// - branch.txt (optional) contains information about the source git branch. +// +// # Go build tags +// +// The following Go build tags (also known as build constraints) affect all builds of FerretDB, +// including embedded usage: +// +// ferretdb_debug - enables debug build (see below; implied by ferretdb_testcover tag and builds with race detector) +// ferretdb_testcover - enables test coverage instrumentation +// ferretdb_tigris - enables Tigris backend +// +// # Debug builds +// +// Debug builds of FerretDB behave differently in a few aspects: +// - The default logging level is set to debug. +// - Some internal errors cause crashes instead of being handled more gracefully. +package version + +import ( + "embed" + "fmt" + "regexp" + "runtime/debug" + "strconv" + "strings" + + "github.com/FerretDB/FerretDB/internal/types" + "github.com/FerretDB/FerretDB/internal/util/must" +) + +// Each pattern in a //go:embed line must match at least one file or non-empty directory, +// but most files are generated and are not present when embeddable FerretDB package is used. +// As a workaround, mongodb.txt is always present. + +//go:generate go run ./generate.go + +//go:embed *.txt +var gen embed.FS + +// Info provides details about the current build. +// +//nolint:vet // for readability +type Info struct { + Version string + Commit string + Branch string + Dirty bool + DebugBuild bool + BuildEnvironment *types.Document + + // MongoDBVersion is fake MongoDB version for clients that check major.minor to adjust their behavior. + MongoDBVersion string + + // MongoDBVersionArray is MongoDBVersion, but as an array. + MongoDBVersionArray *types.Array +} + +// info singleton instance set by init(). +var info *Info + +// unknown is a placeholder for unknown version, commit, and branch values. +const unknown = "unknown" + +// Get returns current build's info. +func Get() *Info { + return info +} + +func init() { + versionRe := regexp.MustCompile(`^([0-9]+)\.([0-9]+)\.([0-9]+)$`) + + parts := versionRe.FindStringSubmatch(strings.TrimSpace(string(must.NotFail(gen.ReadFile("mongodb.txt"))))) + if len(parts) != 4 { + panic("invalid mongodb.txt") + } + major := must.NotFail(strconv.Atoi(parts[1])) + minor := must.NotFail(strconv.Atoi(parts[2])) + patch := must.NotFail(strconv.Atoi(parts[3])) + mongoDBVersion := fmt.Sprintf("%d.%d.%d", major, minor, patch) + mongoDBVersionArray := must.NotFail(types.NewArray(int32(major), int32(minor), int32(patch), int32(0))) + + info = &Info{ + Version: unknown, + Commit: unknown, + Branch: unknown, + Dirty: false, + DebugBuild: debugBuild, + BuildEnvironment: must.NotFail(types.NewDocument()), + MongoDBVersion: mongoDBVersion, + MongoDBVersionArray: mongoDBVersionArray, + } + + // do not expose extra information when embeddable FerretDB package is used + // (and some of it is most likely absent anyway) + + buildInfo, ok := debug.ReadBuildInfo() + if !ok { + return + } + + if buildInfo.Main.Path != "github.com/FerretDB/FerretDB" { + return + } + + if b, _ := gen.ReadFile("version.txt"); len(b) > 0 { + info.Version = strings.TrimSpace(string(b)) + } + + if !strings.HasPrefix(info.Version, "v") { + msg := "Invalid build/version/version.txt file content. Please run `bin/task gen-version`.\n" + msg += "Alternatively, create this file manually with a content similar to\n" + msg += "the output of `git describe`: `v..`.\n" + msg += "See https://pkg.go.dev/github.com/FerretDB/FerretDB/build/version" + panic(msg) + } + + if b, _ := gen.ReadFile("commit.txt"); len(b) > 0 { + info.Commit = strings.TrimSpace(string(b)) + } + + if b, _ := gen.ReadFile("branch.txt"); len(b) > 0 { + info.Branch = strings.TrimSpace(string(b)) + } + + for _, s := range buildInfo.Settings { + switch s.Key { + case "vcs.revision": + if s.Value != info.Commit { + // for non-official builds + if info.Commit == unknown { + info.Commit = s.Value + continue + } + + panic(fmt.Sprintf("commit.txt value %q != vcs.revision value %q\n"+ + "Please run `bin/task gen-version`", info.Commit, s.Value, + )) + } + + case "vcs.modified": + info.Dirty = must.NotFail(strconv.ParseBool(s.Value)) + + case "-compiler": + info.BuildEnvironment.Set("compiler", s.Value) + + case "-race": + info.BuildEnvironment.Set("race", s.Value) + + case "-tags": + info.BuildEnvironment.Set("buildtags", s.Value) + + case "-trimpath": + info.BuildEnvironment.Set("trimpath", s.Value) + + default: + info.BuildEnvironment.Set(s.Key, s.Value) + } + } +} diff --git a/internal/util/version/version_test.go b/build/version/version_test.go similarity index 84% rename from internal/util/version/version_test.go rename to build/version/version_test.go index 43e2f8b6443d..51053878a381 100644 --- a/internal/util/version/version_test.go +++ b/build/version/version_test.go @@ -26,8 +26,9 @@ import ( func TestGet(t *testing.T) { v := Get() - assert.NotEqual(t, "", v.Version) - assert.NotEqual(t, unknown, v.Version) - assert.Equal(t, "6.0.42", MongoDBVersion) - testutil.AssertEqual(t, must.NotFail(types.NewArray(int32(6), int32(0), int32(42), int32(0))), MongoDBVersionArray) + + assert.NotEmpty(t, v.Version) + + assert.Equal(t, "6.0.42", v.MongoDBVersion) + testutil.AssertEqual(t, must.NotFail(types.NewArray(int32(6), int32(0), int32(42), int32(0))), v.MongoDBVersionArray) } diff --git a/cmd/envtool/envtool.go b/cmd/envtool/envtool.go index 3890dd490d53..bf3472331b1a 100644 --- a/cmd/envtool/envtool.go +++ b/cmd/envtool/envtool.go @@ -36,11 +36,11 @@ import ( "github.com/tigrisdata/tigris-client-go/driver" "go.uber.org/zap" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/handlers/pg/pgdb" "github.com/FerretDB/FerretDB/internal/util/debug" "github.com/FerretDB/FerretDB/internal/util/logging" "github.com/FerretDB/FerretDB/internal/util/state" - "github.com/FerretDB/FerretDB/internal/util/version" ) var ( @@ -209,11 +209,11 @@ func printDiagnosticData(setupError error, logger *zap.SugaredLogger) { "GOOS": runtime.GOOS, "GOARCH": runtime.GOARCH, - "Version": info.Version, - "Commit": info.Commit, - "Branch": info.Branch, - "Dirty": info.Dirty, - "Debug": info.Debug, + "Version": info.Version, + "Commit": info.Commit, + "Branch": info.Branch, + "Dirty": info.Dirty, + "DebugBuild": info.DebugBuild, "GoVersion": runtime.Version(), "GitVersion": strings.TrimSpace(gitVersion), diff --git a/cmd/ferretdb/main.go b/cmd/ferretdb/main.go index abe6c7911ece..52a4c8087c36 100644 --- a/cmd/ferretdb/main.go +++ b/cmd/ferretdb/main.go @@ -31,6 +31,7 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/clientconn" "github.com/FerretDB/FerretDB/internal/clientconn/connmetrics" "github.com/FerretDB/FerretDB/internal/handlers/registry" @@ -38,7 +39,6 @@ import ( "github.com/FerretDB/FerretDB/internal/util/logging" "github.com/FerretDB/FerretDB/internal/util/state" "github.com/FerretDB/FerretDB/internal/util/telemetry" - "github.com/FerretDB/FerretDB/internal/util/version" ) // The cli struct represents all command-line commands, fields and flags. @@ -107,17 +107,14 @@ var ( kongOptions = []kong.Option{ kong.Vars{ - "default_log_level": zap.DebugLevel.String(), + "default_log_level": defaultLogLevel().String(), "default_mode": clientconn.AllModes[0], "default_postgresql_url": "postgres://postgres@127.0.0.1:5432/ferretdb", "help_debug_addr": "Debug address for /debug/metrics, /debug/pprof, and similar HTTP handlers.", - "help_log_level": fmt.Sprintf( - "Log level: '%s'. Debug level also enables development mode.", - strings.Join(logLevels, "', '"), - ), - "help_mode": fmt.Sprintf("Operation mode: '%s'.", strings.Join(clientconn.AllModes, "', '")), - "help_handler": fmt.Sprintf("Backend handler: '%s'.", strings.Join(registry.Handlers(), "', '")), + "help_log_level": fmt.Sprintf("Log level: '%s'.", strings.Join(logLevels, "', '")), + "help_mode": fmt.Sprintf("Operation mode: '%s'.", strings.Join(clientconn.AllModes, "', '")), + "help_handler": fmt.Sprintf("Backend handler: '%s'.", strings.Join(registry.Handlers(), "', '")), "enum_mode": strings.Join(clientconn.AllModes, ","), }, @@ -131,6 +128,15 @@ func main() { run() } +// defaultLogLevel returns the default log level. +func defaultLogLevel() zapcore.Level { + if version.Get().DebugBuild { + return zap.DebugLevel + } + + return zap.InfoLevel +} + // setupState setups state provider. func setupState() *state.Provider { f, err := filepath.Abs(filepath.Join(cli.StateDir, "state.json")) @@ -175,7 +181,7 @@ func setupLogger(stateProvider *state.Provider) *zap.Logger { zap.String("commit", info.Commit), zap.String("branch", info.Branch), zap.Bool("dirty", info.Dirty), - zap.Bool("debug", info.Debug), + zap.Bool("debugBuild", info.DebugBuild), zap.Any("buildEnvironment", info.BuildEnvironment.Map()), } logUUID := stateProvider.Get().UUID @@ -218,6 +224,7 @@ func run() { fmt.Fprintln(os.Stdout, "commit:", info.Commit) fmt.Fprintln(os.Stdout, "branch:", info.Branch) fmt.Fprintln(os.Stdout, "dirty:", info.Dirty) + fmt.Fprintln(os.Stdout, "debugBuild:", info.DebugBuild) return } diff --git a/ferretdb/ferretdb.go b/ferretdb/ferretdb.go index d74baec1cdff..3ebfb9d56809 100644 --- a/ferretdb/ferretdb.go +++ b/ferretdb/ferretdb.go @@ -13,6 +13,10 @@ // limitations under the License. // Package ferretdb provides embeddable FerretDB implementation. +// +// See [build/version package documentation] for information about Go build tags that affect this package. +// +// [build/version package documentation]: https://pkg.go.dev/github.com/FerretDB/FerretDB/build/version package ferretdb import ( @@ -23,6 +27,7 @@ import ( "go.uber.org/zap" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/clientconn" "github.com/FerretDB/FerretDB/internal/clientconn/connmetrics" "github.com/FerretDB/FerretDB/internal/handlers/registry" @@ -192,6 +197,11 @@ var logger *zap.Logger // Initialize the global logger there to avoid creating too many issues for zap users that initialize it in their // `main()` functions. It is still not a full solution; eventually, we should remove the usage of the global logger. func init() { - logging.Setup(zap.ErrorLevel, "") + l := zap.ErrorLevel + if version.Get().DebugBuild { + l = zap.DebugLevel + } + + logging.Setup(l, "") logger = zap.L() } diff --git a/go.mod b/go.mod index 389fb1995e95..78cb92620e02 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/tigrisdata/tigris-client-go v1.0.0-beta.18 go.uber.org/zap v1.24.0 golang.org/x/crypto v0.4.0 // indirect; always use @latest - golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 + golang.org/x/exp v0.0.0-20221227203929-1b447090c38c golang.org/x/sys v0.3.0 ) diff --git a/go.sum b/go.sum index 2cd14b5d28a3..2a1df5c2c1b6 100644 --- a/go.sum +++ b/go.sum @@ -479,8 +479,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 h1:5oN1Pz/eDhCpbMbLstvIPa0b/BEQo6g6nwV3pLjfM6w= -golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20221227203929-1b447090c38c h1:Govq2W3bnHJimHT2ium65kXcI7ZzTniZHcFATnLJM0Q= +golang.org/x/exp v0.0.0-20221227203929-1b447090c38c/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/integration/commands_administration_test.go b/integration/commands_administration_test.go index f15a816fa28c..b2f7fd96c8c8 100644 --- a/integration/commands_administration_test.go +++ b/integration/commands_administration_test.go @@ -559,8 +559,6 @@ func TestCommandsAdministrationGetParameter(t *testing.T) { } func TestCommandsAdministrationBuildInfo(t *testing.T) { - setup.SkipForTigris(t) - t.Parallel() ctx, collection := setup.Setup(t) @@ -586,7 +584,6 @@ func TestCommandsAdministrationBuildInfo(t *testing.T) { assert.Equal(t, int32(0), must.NotFail(versionArray.Get(1))) assert.Equal(t, int32(strconv.IntSize), must.NotFail(doc.Get("bits"))) - assert.False(t, must.NotFail(doc.Get("debug")).(bool)) assert.Equal(t, int32(16777216), must.NotFail(doc.Get("maxBsonObjectSize"))) _, ok = must.NotFail(doc.Get("buildEnvironment")).(*types.Document) diff --git a/integration/go.mod b/integration/go.mod index cd72b09b9e70..cc5dd90387f7 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -11,7 +11,7 @@ require ( github.com/stretchr/testify v1.8.1 go.mongodb.org/mongo-driver v1.10.4 go.uber.org/zap v1.24.0 - golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 + golang.org/x/exp v0.0.0-20221227203929-1b447090c38c ) require ( diff --git a/integration/go.sum b/integration/go.sum index cb1e20f559af..c8b5f91906e5 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -493,8 +493,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 h1:5oN1Pz/eDhCpbMbLstvIPa0b/BEQo6g6nwV3pLjfM6w= -golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20221227203929-1b447090c38c h1:Govq2W3bnHJimHT2ium65kXcI7ZzTniZHcFATnLJM0Q= +golang.org/x/exp v0.0.0-20221227203929-1b447090c38c/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/internal/clientconn/listener.go b/internal/clientconn/listener.go index fb20c02357a4..629ba125f4e5 100644 --- a/internal/clientconn/listener.go +++ b/internal/clientconn/listener.go @@ -202,7 +202,12 @@ func setupTLSListener(addr, certFile, keyFile string) (net.Listener, error) { return nil, lazyerrors.Error(err) } - config := tls.Config{Certificates: []tls.Certificate{cer}} + config := tls.Config{ + // TODO ClientAuth, ClientCAs, maybe something else + // https://github.com/FerretDB/FerretDB/issues/1707 + + Certificates: []tls.Certificate{cer}, + } listener, err := tls.Listen("tcp", addr, &config) if err != nil { diff --git a/internal/handlers/common/msg_buildinfo.go b/internal/handlers/common/msg_buildinfo.go index 4225aad3033d..a75d2b135bcf 100644 --- a/internal/handlers/common/msg_buildinfo.go +++ b/internal/handlers/common/msg_buildinfo.go @@ -18,9 +18,9 @@ import ( "context" "strconv" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/version" "github.com/FerretDB/FerretDB/internal/wire" ) @@ -29,13 +29,13 @@ func MsgBuildInfo(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) { var reply wire.OpMsg must.NoError(reply.SetSections(wire.OpMsgSection{ Documents: []*types.Document{must.NotFail(types.NewDocument( - "version", version.MongoDBVersion, + "version", version.Get().MongoDBVersion, "gitVersion", version.Get().Commit, "modules", must.NotFail(types.NewArray()), "sysInfo", "deprecated", - "versionArray", version.MongoDBVersionArray, + "versionArray", version.Get().MongoDBVersionArray, "bits", int32(strconv.IntSize), - "debug", version.Get().Debug, + "debug", version.Get().DebugBuild, "maxBsonObjectSize", int32(types.MaxDocumentLen), "buildEnvironment", version.Get().BuildEnvironment, diff --git a/internal/handlers/common/serverstatus.go b/internal/handlers/common/serverstatus.go index 7c9d9cffcb87..c0d2e00d9d88 100644 --- a/internal/handlers/common/serverstatus.go +++ b/internal/handlers/common/serverstatus.go @@ -21,12 +21,12 @@ import ( "github.com/AlekSi/pointer" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/clientconn/connmetrics" "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" "github.com/FerretDB/FerretDB/internal/util/state" - "github.com/FerretDB/FerretDB/internal/util/version" ) // ServerStatus returns a common part of serverStatus command response. @@ -73,7 +73,7 @@ func ServerStatus(state *state.State, cm *connmetrics.ConnMetrics) (*types.Docum res := must.NotFail(types.NewDocument( "host", host, - "version", version.MongoDBVersion, + "version", version.Get().MongoDBVersion, "process", filepath.Base(exec), "pid", int64(os.Getpid()), "uptime", uptime.Seconds(), diff --git a/internal/handlers/pg/msg_explain.go b/internal/handlers/pg/msg_explain.go index fd75daef671e..bf698f091d1a 100644 --- a/internal/handlers/pg/msg_explain.go +++ b/internal/handlers/pg/msg_explain.go @@ -21,13 +21,13 @@ import ( "github.com/jackc/pgx/v4" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/clientconn/conninfo" "github.com/FerretDB/FerretDB/internal/handlers/common" "github.com/FerretDB/FerretDB/internal/handlers/pg/pgdb" "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/version" "github.com/FerretDB/FerretDB/internal/wire" ) @@ -92,7 +92,7 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, serverInfo := must.NotFail(types.NewDocument( "host", hostname, "port", port, - "version", version.MongoDBVersion, + "version", version.Get().MongoDBVersion, "gitVersion", version.Get().Commit, "ferretdbVersion", version.Get().Version, )) diff --git a/internal/handlers/pg/msg_getlog.go b/internal/handlers/pg/msg_getlog.go index fcb08299b64f..fe7d19aeaff8 100644 --- a/internal/handlers/pg/msg_getlog.go +++ b/internal/handlers/pg/msg_getlog.go @@ -23,12 +23,12 @@ import ( "go.uber.org/zap" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/handlers/common" "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/logging" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/version" "github.com/FerretDB/FerretDB/internal/wire" ) diff --git a/internal/handlers/tigris/msg_explain.go b/internal/handlers/tigris/msg_explain.go index dbcbca6beb54..c7d2b3bcdbef 100644 --- a/internal/handlers/tigris/msg_explain.go +++ b/internal/handlers/tigris/msg_explain.go @@ -19,12 +19,12 @@ import ( "net" "os" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/clientconn/conninfo" "github.com/FerretDB/FerretDB/internal/handlers/common" "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/version" "github.com/FerretDB/FerretDB/internal/wire" ) @@ -76,7 +76,7 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, serverInfo := must.NotFail(types.NewDocument( "host", hostname, "port", port, - "version", version.MongoDBVersion, + "version", version.Get().MongoDBVersion, "gitVersion", version.Get().Commit, "ferretdbVersion", version.Get().Version, )) diff --git a/internal/handlers/tigris/msg_getlog.go b/internal/handlers/tigris/msg_getlog.go index 83e1da644619..9bc219745462 100644 --- a/internal/handlers/tigris/msg_getlog.go +++ b/internal/handlers/tigris/msg_getlog.go @@ -22,12 +22,12 @@ import ( "go.uber.org/zap" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/handlers/common" "github.com/FerretDB/FerretDB/internal/types" "github.com/FerretDB/FerretDB/internal/util/lazyerrors" "github.com/FerretDB/FerretDB/internal/util/logging" "github.com/FerretDB/FerretDB/internal/util/must" - "github.com/FerretDB/FerretDB/internal/util/version" "github.com/FerretDB/FerretDB/internal/wire" ) diff --git a/internal/util/logging/logging.go b/internal/util/logging/logging.go index 08b025586f79..f58a256cdc31 100644 --- a/internal/util/logging/logging.go +++ b/internal/util/logging/logging.go @@ -20,13 +20,15 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" + + "github.com/FerretDB/FerretDB/build/version" ) // Setup initializes logging with a given level. func Setup(level zapcore.Level, uuid string) { config := zap.Config{ Level: zap.NewAtomicLevelAt(level), - Development: false, + Development: version.Get().DebugBuild, DisableCaller: false, DisableStacktrace: false, Sampling: nil, @@ -50,10 +52,6 @@ func Setup(level zapcore.Level, uuid string) { InitialFields: nil, } - if level == zap.DebugLevel { - config.Development = true - } - if uuid != "" { config.InitialFields = map[string]any{"uuid": uuid} } diff --git a/internal/util/state/metrics.go b/internal/util/state/metrics.go index 88ce60d14767..aa88a1e03b1d 100644 --- a/internal/util/state/metrics.go +++ b/internal/util/state/metrics.go @@ -19,7 +19,7 @@ import ( "github.com/prometheus/client_golang/prometheus" - "github.com/FerretDB/FerretDB/internal/util/version" + "github.com/FerretDB/FerretDB/build/version" ) const ( @@ -56,7 +56,7 @@ func (mc *metricsCollector) Collect(ch chan<- prometheus.Metric) { "commit": v.Commit, "branch": v.Branch, "dirty": strconv.FormatBool(v.Dirty), - "debug": strconv.FormatBool(v.Debug), + "debug": strconv.FormatBool(v.DebugBuild), } s := mc.p.Get() diff --git a/internal/util/state/metrics_test.go b/internal/util/state/metrics_test.go index 60c43c6504c4..3b3bdea976b3 100644 --- a/internal/util/state/metrics_test.go +++ b/internal/util/state/metrics_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/FerretDB/FerretDB/internal/util/version" + "github.com/FerretDB/FerretDB/build/version" ) func TestMetrics(t *testing.T) { @@ -52,7 +52,7 @@ func TestMetrics(t *testing.T) { # TYPE ferretdb_up gauge ferretdb_up{branch=%q,commit=%q,debug="%t",dirty="%t",telemetry="undecided",uuid=%q,version=%q} 1 `, - v.Branch, v.Commit, v.Debug, v.Dirty, uuid, v.Version, + v.Branch, v.Commit, v.DebugBuild, v.Dirty, uuid, v.Version, ) assert.NoError(t, testutil.CollectAndCompare(mc, strings.NewReader(expected))) }) @@ -71,7 +71,7 @@ func TestMetrics(t *testing.T) { # TYPE ferretdb_up gauge ferretdb_up{branch=%q,commit=%q,debug="%t",dirty="%t",telemetry="undecided",version=%q} 1 `, - v.Branch, v.Commit, v.Debug, v.Dirty, v.Version, + v.Branch, v.Commit, v.DebugBuild, v.Dirty, v.Version, ) assert.NoError(t, testutil.CollectAndCompare(mc, strings.NewReader(expected))) }) diff --git a/internal/util/telemetry/reporter.go b/internal/util/telemetry/reporter.go index 9aab7115b84e..30c654517772 100644 --- a/internal/util/telemetry/reporter.go +++ b/internal/util/telemetry/reporter.go @@ -26,10 +26,10 @@ import ( "github.com/AlekSi/pointer" "go.uber.org/zap" + "github.com/FerretDB/FerretDB/build/version" "github.com/FerretDB/FerretDB/internal/clientconn/connmetrics" "github.com/FerretDB/FerretDB/internal/util/ctxutil" "github.com/FerretDB/FerretDB/internal/util/state" - "github.com/FerretDB/FerretDB/internal/util/version" ) // request represents telemetry request. @@ -189,7 +189,7 @@ func makeRequest(s *state.State, m *connmetrics.ConnMetrics) *request { Commit: v.Commit, Branch: v.Branch, Dirty: v.Dirty, - Debug: v.Debug, + Debug: v.DebugBuild, BuildEnvironment: v.BuildEnvironment.Map(), OS: runtime.GOOS, Arch: runtime.GOARCH, diff --git a/internal/util/version/version.go b/internal/util/version/version.go deleted file mode 100644 index 69b7263bbf44..000000000000 --- a/internal/util/version/version.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2021 FerretDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package version - -import ( - "embed" - "fmt" - "regexp" - "runtime/debug" - "strconv" - "strings" - - "golang.org/x/exp/slices" - - "github.com/FerretDB/FerretDB/internal/types" - "github.com/FerretDB/FerretDB/internal/util/must" -) - -// Each pattern in a //go:embed line must match at least one file or non-empty directory, -// but most files in gen/ are generated and are not present when FerretDB is used as library package. -// As a workaround, gen/mongodb.txt is always present. - -//go:generate go run ./generate.go - -//go:embed gen -var gen embed.FS - -// Info provides details about the current build. -type Info struct { - Version string - Commit string - Branch string - Dirty bool - Debug bool // -tags=ferretdb_testcover or -race - BuildEnvironment *types.Document -} - -var ( - // MongoDBVersion is a fake MongoDB version for clients that check major.minor to adjust their behavior. - MongoDBVersion string - - // MongoDBVersionArray is MongoDBVersion, but as an array. - MongoDBVersionArray *types.Array - - info *Info -) - -// unknown is a placeholder for unknown version, commit, and branch values. -const unknown = "unknown" - -// Get returns current build's info. -func Get() *Info { - return info -} - -func init() { - b := must.NotFail(gen.ReadFile("gen/mongodb.txt")) - parts := regexp.MustCompile(`^([0-9]+)\.([0-9]+)\.([0-9]+)$`).FindStringSubmatch(strings.TrimSpace(string(b))) - if len(parts) != 4 { - panic("invalid gen/mongodb.txt") - } - major := must.NotFail(strconv.Atoi(parts[1])) - minor := must.NotFail(strconv.Atoi(parts[2])) - patch := must.NotFail(strconv.Atoi(parts[3])) - MongoDBVersion = fmt.Sprintf("%d.%d.%d", major, minor, patch) - MongoDBVersionArray = must.NotFail(types.NewArray(int32(major), int32(minor), int32(patch), int32(0))) - - // those files are not present when FerretDB is used as library package - version := unknown - if b, _ := gen.ReadFile("gen/version.txt"); len(b) > 0 { - version = strings.TrimSpace(string(b)) - } - commit := unknown - if b, _ := gen.ReadFile("gen/commit.txt"); len(b) > 0 { - commit = strings.TrimSpace(string(b)) - } - branch := unknown - if b, _ := gen.ReadFile("gen/branch.txt"); len(b) > 0 { - branch = strings.TrimSpace(string(b)) - } - - info = &Info{ - Version: version, - Commit: commit, - Branch: branch, - BuildEnvironment: must.NotFail(types.NewDocument()), - } - - // do not expose extra information when FerretDB is used as library package - buildInfo, ok := debug.ReadBuildInfo() - if !ok { - return - } - if buildInfo.Main.Path != "github.com/FerretDB/FerretDB" { - return - } - - for _, s := range buildInfo.Settings { - switch s.Key { - case "vcs.revision": - if s.Value != info.Commit { - panic(fmt.Sprintf("commit.txt value %q != vcs.revision value %q\n"+ - "Please run `bin/task gen-version`", info.Commit, s.Value, - )) - } - - case "vcs.modified": - info.Dirty = must.NotFail(strconv.ParseBool(s.Value)) - - case "-compiler": - info.BuildEnvironment.Set("compiler", s.Value) - - case "-race": - info.BuildEnvironment.Set("race", s.Value) - - if must.NotFail(strconv.ParseBool(s.Value)) { - info.Debug = true - } - - case "-tags": - info.BuildEnvironment.Set("buildtags", s.Value) - - if slices.Contains(strings.Split(s.Value, ","), "ferretdb_testcover") { - info.Debug = true - } - - case "-trimpath": - info.BuildEnvironment.Set("trimpath", s.Value) - - default: - info.BuildEnvironment.Set(s.Key, s.Value) - } - } -} diff --git a/tools/go.mod b/tools/go.mod index e2d2335d22ea..aef61a2d5087 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -9,9 +9,9 @@ require ( github.com/goreleaser/nfpm/v2 v2.22.2 github.com/quasilyte/go-consistent v0.0.0-20220429160651-4e46040fbc82 github.com/reviewdog/reviewdog v0.14.1 - golang.org/x/perf v0.0.0-20220920022801-e8d778a60d07 + golang.org/x/perf v0.0.0-20221222172245-91a04616dc65 golang.org/x/tools v0.4.1-0.20221217013628-b4dfc36097e2 - golang.org/x/vuln v0.0.0-20221217143601-785badac1c32 + golang.org/x/vuln v0.0.0-20221222221150-61d83dad62c1 mvdan.cc/gofumpt v0.4.0 ) diff --git a/tools/go.sum b/tools/go.sum index cfdd5ef67c24..1cfd7b24ba64 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -992,8 +992,8 @@ golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= -golang.org/x/perf v0.0.0-20220920022801-e8d778a60d07 h1:LhnzFL4oipoFsDvxTy2IJRHgOlnGzB2dE5l7C4PN7bg= -golang.org/x/perf v0.0.0-20220920022801-e8d778a60d07/go.mod h1:UBKtEnL8aqnd+0JHqZ+2qoMDwtuy6cYhhKNoHLBiTQc= +golang.org/x/perf v0.0.0-20221222172245-91a04616dc65 h1:XSw0XBmN5N/9uRzwaBd5zUZHFvlbtIbjJgflDq/kfJ0= +golang.org/x/perf v0.0.0-20221222172245-91a04616dc65/go.mod h1:UBKtEnL8aqnd+0JHqZ+2qoMDwtuy6cYhhKNoHLBiTQc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1197,8 +1197,8 @@ golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.4.1-0.20221217013628-b4dfc36097e2 h1:xJW6CltANFz/N/OyFltaf/kJs6Mnaq9Etj8aSBvx7MQ= golang.org/x/tools v0.4.1-0.20221217013628-b4dfc36097e2/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= -golang.org/x/vuln v0.0.0-20221217143601-785badac1c32 h1:lSPVY+9RODR7rLeo1q0HuaHAF8ozIDPg17Js8snq0Rg= -golang.org/x/vuln v0.0.0-20221217143601-785badac1c32/go.mod h1:XJiVExZgoZfrrxoTeVsFYrSSk1snhfpOEC95JL+A4T0= +golang.org/x/vuln v0.0.0-20221222221150-61d83dad62c1 h1:OzHTNJjk1zc9gW1fKPoSilTVgWkmozp4UcWwWEDV/pY= +golang.org/x/vuln v0.0.0-20221222221150-61d83dad62c1/go.mod h1:XJiVExZgoZfrrxoTeVsFYrSSk1snhfpOEC95JL+A4T0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/website/docs/contributing.md b/website/docs/contributing.md index 6cbc6dd894c9..80dbca3b1f9a 100644 --- a/website/docs/contributing.md +++ b/website/docs/contributing.md @@ -19,7 +19,7 @@ Please take a look at this post on [how to contribute to open source software](h ## Get Started You don’t have to be a developer to contribute to FerretDB projects, you can even get started by helping us improve this documentation. -If you have any questions or suggestions on how we can improve, kindly join our [Slack chat](https://docs.ferretdb.io/intro/#community) or [GitHub discussions](https://github.com/FerretDB/FerretDB/discussions). +If you have any questions or suggestions on how we can improve, kindly join our [Slack chat](/intro/#community) or [GitHub discussions](https://github.com/FerretDB/FerretDB/discussions). We appreciate your feedback. ## Contributing to this documentation diff --git a/website/docs/diff.md b/website/docs/diff.md index 76baf185b3dc..f7da319402ab 100644 --- a/website/docs/diff.md +++ b/website/docs/diff.md @@ -30,4 +30,4 @@ slug: /diff/ The value must be a JSON string representing JSON schema in [Tigris format](https://docs.tigrisdata.com/overview/schema). If you encounter some other difference in behavior, -please [join our community](https://github.com/FerretDB/FerretDB#community) to report a problem. +please [join our community](/intro/#community) to report a problem. diff --git a/website/docs/reference/supported_commands.md b/website/docs/reference/supported_commands.md index c715a6f72e44..c492e87265c3 100644 --- a/website/docs/reference/supported_commands.md +++ b/website/docs/reference/supported_commands.md @@ -150,9 +150,9 @@ Related epic - [Issue](https://github.com/FerretDB/FerretDB/issues/78). | Command | Argument | Status | Comments | |----------------------------|--------------------------------------|--------|-------------------------------------------------------------------------------| -| `setFreeMonitoring` | | ✅ | [Telemetry reporting](https://docs.ferretdb.io/telemetry/) | -| | `action: "enable"` | ✅ | [`--telemetry=enable`](https://docs.ferretdb.io/telemetry/#enable-telemetry) | -| | `action: "disable"` | ✅ | [`--telemetry=disable`](https://docs.ferretdb.io/telemetry/#disable-telemetry)| +| `setFreeMonitoring` | | ✅ | [Telemetry reporting](/telemetry/) | +| | `action: "enable"` | ✅ | [`--telemetry=enable`](/telemetry/#enable-telemetry) | +| | `action: "disable"` | ✅ | [`--telemetry=disable`](/telemetry/#disable-telemetry)| | `getFreeMonitoringStatus` | | ✅ | | ## Database Operations diff --git a/website/docs/understanding_ferretdb.md b/website/docs/understanding_ferretdb.md index 952bedbe204b..6bead5c5c8dd 100644 --- a/website/docs/understanding_ferretdb.md +++ b/website/docs/understanding_ferretdb.md @@ -16,7 +16,7 @@ That makes it ideal for applications and workloads requiring flexible schemas, s :::note For Tigris, FerretDB requires you to declare a JSON schema in [Tigris format](https://docs.tigrisdata.com/overview/schema). -Get more information on the key differences [here](https://docs.ferretdb.io/diff/). +Get more information on the key differences [here](/diff/). ::: ## Documents @@ -38,7 +38,7 @@ The above data is stored in a single document. :::note FerretDB follows almost the same naming conventions as MongoDB. -However, there are a few restrictions, which you can find [here](https://docs.ferretdb.io/diff/). +However, there are a few restrictions, which you can find [here](/diff/). ::: For complex documents, you can nest objects (subdocuments) inside a document. @@ -160,7 +160,7 @@ Read more on [jsonb in PostgreSQL](https://www.postgresql.org/docs/current/datat In Tigris case, we convert MongoDB BSON to Tigris data based on the [Tigris model](https://docs.tigrisdata.com/documents/datamodel). There are a few differences in how data is stored in PostgreSQL and Tigris. -Please [check here](https://docs.ferretdb.io/diff/) for more details on the differences. +Please [check here](/diff/) for more details on the differences. :::caution FerretDB is still under development and not currently suitable for production-ready environments.