Skip to content

Commit

Permalink
Merge pull request #501 from alphagov/remove-mongo-db
Browse files Browse the repository at this point in the history
Remove ability to load routes from MongoDB
  • Loading branch information
theseanything authored Dec 9, 2024
2 parents 0d33284 + 041b6f3 commit 2936a7d
Show file tree
Hide file tree
Showing 78 changed files with 30 additions and 21,871 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
- run: make unit_tests
- run: make integration_tests
timeout-minutes: 15
env:
ROUTER_MONGO_URL: 127.0.0.1
golangci-lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -35,4 +33,4 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
11 changes: 2 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean build test lint unit_tests integration_tests start_mongo stop_mongo update_deps
.PHONY: all clean build test lint unit_tests integration_tests update_deps
.NOTPARALLEL:

TARGET_MODULE := router
Expand Down Expand Up @@ -27,15 +27,8 @@ lint:
unit_tests:
go test -race $$(go list ./... | grep -v integration_tests)

integration_tests: build start_mongo
go test -race -v ./integration_tests
integration_tests: build
go test -race -v ./cs_integration_tests

start_mongo:
./mongo.sh start

stop_mongo:
./mongo.sh stop

update_deps:
go get -t -u ./... && go mod tidy && go mod vendor
2 changes: 0 additions & 2 deletions cs_integration_tests/router_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ func startRouter(port, apiPort int, extraEnv []string) error {
}
cmd := exec.Command(bin)

cmd.Env = append(cmd.Environ(), "ROUTER_MONGO_DB=router_test")
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_PUBADDR=%s", pubAddr))
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_APIADDR=%s", apiAddr))
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_ERROR_LOG=%s", tempLogfile.Name()))
cmd.Env = append(cmd.Env, "CSMUX_SAMPLE_RATE=1.0")
cmd.Env = append(cmd.Env, "CONTENT_STORE_DATABASE_URL="+postgresContainer.MustConnectionString(context.Background()))
cmd.Env = append(cmd.Env, extraEnv...)

Expand Down
27 changes: 6 additions & 21 deletions docs/data-structure.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Data structure

The Router requires two MongoDB collections: `routes` and `backends`.

## Routes

The `routes` collection uses the following data structure:
The `routes` uses the following data structure:

```json
{
"_id" : ObjectId(),
"route_type" : ["prefix","exact"],
"incoming_path" : "/url-path/here",
"handler" : ["backend", "redirect", "gone"],
"route_type": ["prefix", "exact"],
"incoming_path": "/url-path/here",
"handler": ["backend", "redirect", "gone"]
}
```

Expand All @@ -28,7 +25,7 @@ The `backend` handler causes the Router to reverse proxy to a named

```json
{
"backend_id" : "backend-id-corresponding-to-backends-collection"
"backend_id": "backend-id-corresponding-to-backends-collection"
}
```

Expand All @@ -40,22 +37,10 @@ extra fields are supported:

```json
{
"redirect_to" : "/target-of-redirect"
"redirect_to": "/target-of-redirect"
}
```

### `gone` handler

The `gone` handler causes the Router to return a 410 response.

## Backends

The `backends` collection uses the following data structure:

```json
{
"_id" : ObjectId(),
"backend_id" : "arbitrary-slug-or-name",
"backend_url" : "https://example.com:port/"
}
```
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.22.5

require (
github.com/getsentry/sentry-go v0.30.0
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
github.com/jackc/pgx/v5 v5.7.1
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.36.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo=
github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down
99 changes: 0 additions & 99 deletions integration_tests/backend_helpers.go

This file was deleted.

50 changes: 0 additions & 50 deletions integration_tests/error_handling_test.go

This file was deleted.

35 changes: 0 additions & 35 deletions integration_tests/gone_test.go

This file was deleted.

83 changes: 0 additions & 83 deletions integration_tests/http_request_helpers.go

This file was deleted.

Loading

0 comments on commit 2936a7d

Please sign in to comment.