Skip to content

Commit 435a1e4

Browse files
fredbiclaude
andauthored
refactor: decouple mongodb driver from root module (#222)
* refactor: decouple mongodb driver from root module * fixes #91 * relates to #191 Drop go.mongodb.org/mongo-driver/v2 from the root go.mod by introducing an internal minimal BSON codec (bsonlite) that is wire-compatible with mongo-driver v2.5.0. Users who want the real driver can opt in with a blank import: `import _ "github.com/go-openapi/strfmt/enable/mongodb"`. - internal/bsonlite: minimal BSON encoder/decoder for string, DateTime, ObjectID document types (no external dependencies) - enable/mongodb: separate Go module that replaces the lite codec with the real mongo-driver via init() - ObjectId type changed from bsonprim.ObjectID to [12]byte (same underlying type, backward compatible) - All BSON marshal/unmarshal methods rewritten to use bsonlite.C interface - Convert to mono-repo: go.work, CI workflows switched to monorepo variants (ci-workflows v0.2.13), dependabot scans all modules - Integration tests verify both codec paths against real MongoDB Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com> * fix(ci): use stable Go for integration tests The go.mod directive (go 1.24) causes setup-go to install go1.24.0, which triggers a panic in testify/v2 goroutine leak detector init(). Use go-version: stable (go1.26) until testify is patched. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com> --------- Signed-off-by: Frederic BIDON <fredbi@yahoo.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7304ce1 commit 435a1e4

32 files changed

+1148
-788
lines changed

.github/dependabot.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
version: 2
22
updates:
33
- package-ecosystem: "github-actions"
4-
directory: "/"
4+
directories:
5+
- "**/*"
56
schedule:
67
interval: "weekly"
78
day: "friday"
@@ -27,7 +28,8 @@ updates:
2728
# 2. golang.org-dependencies are auto-merged
2829
# 3. go-openapi patch updates are auto-merged. Minor/major version updates require a manual merge.
2930
# 4. other dependencies require a manual merge
30-
directory: "/"
31+
directories:
32+
- "**/*"
3133
schedule:
3234
interval: "weekly"
3335
day: "friday"

.github/workflows/auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jobs:
1111
permissions:
1212
contents: write
1313
pull-requests: write
14-
uses: go-openapi/ci-workflows/.github/workflows/auto-merge.yml@435746a4b72b06b6b6989c309fd2ad8150dbae5a # v0.2.11
14+
uses: go-openapi/ci-workflows/.github/workflows/auto-merge.yml@34a5baa33361844b1d2c70cd4548e3cea83529d9 # v0.2.13
1515
secrets: inherit

.github/workflows/bump-release.yml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@ permissions:
66
on:
77
workflow_dispatch:
88
inputs:
9-
bump-patch:
10-
description: Bump a patch version release
11-
type: boolean
9+
bump-type:
10+
description: Type of bump (patch, minor, major)
11+
type: choice
12+
options:
13+
- patch
14+
- minor
15+
- major
16+
default: patch
1217
required: false
13-
default: true
14-
bump-minor:
15-
description: Bump a minor version release
16-
type: boolean
17-
required: false
18-
default: false
19-
bump-major:
20-
description: Bump a major version release
21-
type: boolean
22-
required: false
23-
default: false
2418
tag-message-title:
2519
description: Tag message title to prepend to the release notes
2620
required: false
@@ -36,11 +30,10 @@ jobs:
3630
bump-release:
3731
permissions:
3832
contents: write
39-
uses: go-openapi/ci-workflows/.github/workflows/bump-release.yml@435746a4b72b06b6b6989c309fd2ad8150dbae5a # v0.2.11
33+
pull-requests: write
34+
uses: go-openapi/ci-workflows/.github/workflows/bump-release-monorepo.yml@34a5baa33361844b1d2c70cd4548e3cea83529d9 # v0.2.13
4035
with:
41-
bump-patch: ${{ inputs.bump-patch }}
42-
bump-minor: ${{ inputs.bump-minor }}
43-
bump-major: ${{ inputs.bump-major }}
36+
bump-type: ${{ inputs.bump-type }}
4437
tag-message-title: ${{ inputs.tag-message-title }}
4538
tag-message-body: ${{ inputs.tag-message-body }}
4639
secrets: inherit

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
permissions:
1919
contents: read
2020
security-events: write
21-
uses: go-openapi/ci-workflows/.github/workflows/codeql.yml@435746a4b72b06b6b6989c309fd2ad8150dbae5a # v0.2.11
21+
uses: go-openapi/ci-workflows/.github/workflows/codeql.yml@34a5baa33361844b1d2c70cd4548e3cea83529d9 # v0.2.13
2222
secrets: inherit

.github/workflows/contributors.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
permissions:
1515
pull-requests: write
1616
contents: write
17-
uses: go-openapi/ci-workflows/.github/workflows/contributors.yml@435746a4b72b06b6b6989c309fd2ad8150dbae5a # v0.2.11
17+
uses: go-openapi/ci-workflows/.github/workflows/contributors.yml@34a5baa33361844b1d2c70cd4548e3cea83529d9 # v0.2.13
1818
secrets: inherit

.github/workflows/go-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ on:
1313

1414
jobs:
1515
test:
16-
uses: go-openapi/ci-workflows/.github/workflows/go-test.yml@435746a4b72b06b6b6989c309fd2ad8150dbae5a # v0.2.11
16+
uses: go-openapi/ci-workflows/.github/workflows/go-test-monorepo.yml@34a5baa33361844b1d2c70cd4548e3cea83529d9 # v0.2.13
1717
secrets: inherit

.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353

5454
- uses: actions/setup-go@v5
5555
with:
56-
go-version-file: go.mod
56+
go-version: stable
5757

5858
- name: Run integration tests
5959
working-directory: internal/testintegration

.github/workflows/scanner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ jobs:
1515
permissions:
1616
contents: read
1717
security-events: write
18-
uses: go-openapi/ci-workflows/.github/workflows/scanner.yml@435746a4b72b06b6b6989c309fd2ad8150dbae5a # V0.2.11
18+
uses: go-openapi/ci-workflows/.github/workflows/scanner.yml@34a5baa33361844b1d2c70cd4548e3cea83529d9 # v0.2.13
1919
secrets: inherit

.github/workflows/tag-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
name: Create release
1414
permissions:
1515
contents: write
16-
uses: go-openapi/ci-workflows/.github/workflows/release.yml@435746a4b72b06b6b6989c309fd2ad8150dbae5a # v0.2.11
16+
uses: go-openapi/ci-workflows/.github/workflows/release.yml@34a5baa33361844b1d2c70cd4548e3cea83529d9 # v0.2.13
1717
with:
1818
tag: ${{ github.ref_name }}
19+
is-monorepo: true
1920
secrets: inherit

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ You may join the discord community by clicking the invite link on the discord ba
2424

2525
Or join our Slack channel: [![Slack Channel][slack-logo]![slack-badge]][slack-url]
2626

27+
* **2026-03-07** : v0.26.0 **dropped dependency to the mongodb driver**
28+
* mongodb users can still use this package without any change
29+
* however, we have frozen the back-compatible support for mongodb driver at v2.5.0
30+
* users who want to keep-up with future evolutions (possibly incompatible) of this driver
31+
can do so by adding a blank import in their program: `import _ "github.com/go-openapi/strfmt/enable/mongodb"`.
32+
This will switch the behavior to the actual driver, which remains regularly updated as an independent module.
33+
2734
## Status
2835

2936
API is stable.
@@ -132,8 +139,9 @@ List of defined types:
132139
All format types implement the `database/sql` interfaces `sql.Scanner` and `driver.Valuer`,
133140
so they work out of the box with Go's standard `database/sql` package and any SQL driver.
134141

135-
All format types also implement BSON marshaling/unmarshaling for use with MongoDB
136-
(via [`go.mongodb.org/mongo-driver/v2`](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2)).
142+
All format types also implement BSON marshaling/unmarshaling for use with MongoDB.
143+
By default, a built-in minimal codec is used (compatible with mongo-driver v2.5.0).
144+
For full driver support, add `import _ "github.com/go-openapi/strfmt/enable/mongodb"`.
137145

138146
> **MySQL / MariaDB caveat for `DateTime`:**
139147
> The `go-sql-driver/mysql` driver has hard-coded handling for `time.Time` but does not

0 commit comments

Comments
 (0)