feat: add MongoDB NoSQL database backend#904
Open
madhavilosetty-intel wants to merge 1 commit intomainfrom
Open
feat: add MongoDB NoSQL database backend#904madhavilosetty-intel wants to merge 1 commit intomainfrom
madhavilosetty-intel wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
e9e284f to
3089193
Compare
abde129 to
a322ead
Compare
a322ead to
b7bab8c
Compare
904a8ae to
1c83fd3
Compare
1c83fd3 to
16fe6e9
Compare
There was a problem hiding this comment.
Pull request overview
Adds a MongoDB-backed repository implementation and introduces an explicit “DB provider” selection so the app can run against Postgres, embedded SQLite, or MongoDB, while keeping the same usecase layer.
Changes:
- Introduce
usecase.Reposbundle and refactor usecase wiring to be backend-agnostic (NewSQLRepos,NewMongoRepos). - Add MongoDB repository implementations (devices/domains/profiles/wifi/802.1x/CIRA) + wire-level unit tests.
- Add
DB_PROVIDERconfiguration + docker/CI workflow support to run API tests against MongoDB.
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/usecase/usecase_test.go | Updates usecase construction to use repo bundle (NewSQLRepos). |
| internal/usecase/usecase.go | Adds Repos bundle + SQL/Mongo repo constructors; refactors NewUseCases to accept repos. |
| internal/usecase/nosqldb/mongo/wificonfig_test.go | Unit tests for Mongo wireless config repo. |
| internal/usecase/nosqldb/mongo/wificonfig.go | Mongo wireless config repository implementation (incl. 802.1x “join” behavior). |
| internal/usecase/nosqldb/mongo/profilewificonfig_test.go | Unit tests for Mongo profile-wifi-configs repo. |
| internal/usecase/nosqldb/mongo/profilewificonfig.go | Mongo profile-wifi-configs repository implementation. |
| internal/usecase/nosqldb/mongo/profile_test.go | Unit tests for Mongo profiles repo. |
| internal/usecase/nosqldb/mongo/profile.go | Mongo profiles repository implementation (incl. 802.1x “join” behavior). |
| internal/usecase/nosqldb/mongo/mongo_test.go | Shared test helpers using mongo-driver wire-level mock deployment. |
| internal/usecase/nosqldb/mongo/ieee8021xconfig_test.go | Unit tests for Mongo IEEE8021x repo. |
| internal/usecase/nosqldb/mongo/ieee8021xconfig.go | Mongo IEEE8021x repository implementation. |
| internal/usecase/nosqldb/mongo/errors_test.go | Tests for duplicate-key detection wrapper. |
| internal/usecase/nosqldb/mongo/errors.go | Mongo repo error wrappers + duplicate-key helper. |
| internal/usecase/nosqldb/mongo/domain_test.go | Unit tests for Mongo domains repo. |
| internal/usecase/nosqldb/mongo/domain.go | Mongo domains repository implementation (case-insensitive name lookups). |
| internal/usecase/nosqldb/mongo/device_test.go | Unit tests for Mongo devices repo. |
| internal/usecase/nosqldb/mongo/device.go | Mongo devices repository implementation (tags search, updates, status timestamps). |
| internal/usecase/nosqldb/mongo/client_test.go | Tests Mongo Connect input validation. |
| internal/usecase/nosqldb/mongo/client.go | Mongo Connect + index creation logic. |
| internal/usecase/nosqldb/mongo/ciraconfig_test.go | Unit tests for Mongo CIRA configs repo. |
| internal/usecase/nosqldb/mongo/ciraconfig.go | Mongo CIRA configs repository implementation. |
| internal/app/repos.go | Adds provider-based repo construction (postgres/sqlite/mongo). |
| internal/app/app_test.go | Updates test setup to explicitly select Postgres provider. |
| internal/app/app.go | Refactors app startup/shutdown to use repo bundle + generic closer. |
| go.mod | Adds mongo-driver v2 and related indirect deps. |
| go.sum | Updates module sums for added/updated dependencies. |
| docker-compose.yml | Adds optional Mongo service (profile-gated) + DB_PROVIDER/DB_URL env wiring. |
| config/config.yml | Documents postgres.provider (backend selector) and defaults to sqlite. |
| config/config.go | Adds DB.Provider to configuration (env/yaml). |
| .github/workflows/api-test.yml | Adds a MongoDB-backed API test job and fixes artifact path. |
| .env.example | Adds DB_PROVIDER example env var. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a0e71a4 to
851bde8
Compare
851bde8 to
1ba867c
Compare
Adds a MongoDB backend implementing the same *.Repository interfaces as
the existing SQL backend (Postgres + embedded SQLite). Provider is
selected at startup via cfg.DB.Provider in {postgres, sqlite, mongo};
no existing backend is touched.
1ba867c to
79f9e16
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.