Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 591523a

Browse files
authored
chore: Move httpapi, httpmw, & database into coderd (#568)
* chore: Move httpmw to /coderd directory httpmw is specific to coderd and should be scoped under coderd * chore: Move httpapi to /coderd directory httpapi is specific to coderd and should be scoped under coderd * chore: Move database to /coderd directory database is specific to coderd and should be scoped under coderd * chore: Update codecov & gitattributes for generated files * chore: Update Makefile
1 parent 6be949a commit 591523a

File tree

98 files changed

+155
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+155
-155
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Generated files
2-
database/dump.sql linguist-generated=true
2+
coderd/database/dump.sql linguist-generated=true
33
peerbroker/proto/*.go linguist-generated=true
44
provisionerd/proto/*.go linguist-generated=true
55
provisionersdk/proto/*.go linguist-generated=true

Makefile

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ build: site/out bin
1010
.PHONY: build
1111

1212
# Runs migrations to output a dump of the database.
13-
database/dump.sql: $(wildcard database/migrations/*.sql)
14-
go run database/dump/main.go
13+
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
14+
go run coderd/database/dump/main.go
1515

1616
# Generates Go code for querying the database.
17-
database/generate: fmt/sql database/dump.sql database/query.sql
18-
cd database && sqlc generate && rm db_tmp.go
19-
cd database && gofmt -w -r 'Querier -> querier' *.go
20-
cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go
21-
.PHONY: database/generate
17+
coderd/database/generate: fmt/sql coderd/database/dump.sql coderd/database/query.sql
18+
cd coderd/database && sqlc generate && rm db_tmp.go
19+
cd coderd/database && gofmt -w -r 'Querier -> querier' *.go
20+
cd coderd/database && gofmt -w -r 'Queries -> sqlQuerier' *.go
21+
.PHONY: coderd/database/generate
2222

2323
fmt/prettier:
2424
@echo "--- prettier"
@@ -30,18 +30,18 @@ else
3030
endif
3131
.PHONY: fmt/prettier
3232

33-
fmt/sql: ./database/query.sql
33+
fmt/sql: ./coderd/database/query.sql
3434
npx sql-formatter \
3535
--language postgresql \
3636
--lines-between-queries 2 \
37-
./database/query.sql \
38-
--output ./database/query.sql
39-
sed -i 's/@ /@/g' ./database/query.sql
37+
./coderd/database/query.sql \
38+
--output ./coderd/database/query.sql
39+
sed -i 's/@ /@/g' ./coderd/database/query.sql
4040

4141
fmt: fmt/prettier fmt/sql
4242
.PHONY: fmt
4343

44-
gen: database/generate peerbroker/proto provisionersdk/proto provisionerd/proto
44+
gen: coderd/database/generate peerbroker/proto provisionersdk/proto provisionerd/proto
4545
.PHONY: gen
4646

4747
install: bin

cli/cliui/job.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"github.com/charmbracelet/lipgloss"
1111
"github.com/spf13/cobra"
1212

13+
"github.com/coder/coder/coderd/database"
1314
"github.com/coder/coder/codersdk"
14-
"github.com/coder/coder/database"
1515
)
1616

1717
type JobOptions struct {

cli/parametercreate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"github.com/spf13/cobra"
77
"golang.org/x/xerrors"
88

9+
"github.com/coder/coder/coderd/database"
910
"github.com/coder/coder/codersdk"
10-
"github.com/coder/coder/database"
1111
)
1212

1313
func parameterCreate() *cobra.Command {

cli/projectcreate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"golang.org/x/xerrors"
1616

1717
"github.com/coder/coder/cli/cliui"
18+
"github.com/coder/coder/coderd/database"
1819
"github.com/coder/coder/codersdk"
19-
"github.com/coder/coder/database"
2020
"github.com/coder/coder/provisionerd"
2121
"github.com/coder/coder/provisionersdk"
2222
)

cli/projectcreate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/coder/coder/cli/clitest"
99
"github.com/coder/coder/coderd/coderdtest"
10-
"github.com/coder/coder/database"
10+
"github.com/coder/coder/coderd/database"
1111
"github.com/coder/coder/provisioner/echo"
1212
"github.com/coder/coder/pty/ptytest"
1313
)

cli/projects.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/spf13/cobra"
99

1010
"github.com/coder/coder/cli/cliui"
11+
"github.com/coder/coder/coderd/database"
1112
"github.com/coder/coder/codersdk"
12-
"github.com/coder/coder/database"
1313
)
1414

1515
func projects() *cobra.Command {

cli/projectupdate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/spf13/cobra"
1010
"golang.org/x/xerrors"
1111

12+
"github.com/coder/coder/coderd/database"
1213
"github.com/coder/coder/codersdk"
13-
"github.com/coder/coder/database"
1414
"github.com/coder/coder/provisionersdk"
1515
)
1616

cli/ssh.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"golang.org/x/term"
99
"golang.org/x/xerrors"
1010

11+
"github.com/coder/coder/coderd/database"
1112
"github.com/coder/coder/codersdk"
12-
"github.com/coder/coder/database"
1313
)
1414

1515
func workspaceSSH() *cobra.Command {

cli/start.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import (
2828
"github.com/coder/coder/cli/cliui"
2929
"github.com/coder/coder/cli/config"
3030
"github.com/coder/coder/coderd"
31+
"github.com/coder/coder/coderd/database"
32+
"github.com/coder/coder/coderd/database/databasefake"
3133
"github.com/coder/coder/coderd/tunnel"
3234
"github.com/coder/coder/codersdk"
33-
"github.com/coder/coder/database"
34-
"github.com/coder/coder/database/databasefake"
3535
"github.com/coder/coder/provisioner/terraform"
3636
"github.com/coder/coder/provisionerd"
3737
"github.com/coder/coder/provisionersdk"

cli/start_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222

2323
"github.com/coder/coder/cli/clitest"
2424
"github.com/coder/coder/coderd/coderdtest"
25+
"github.com/coder/coder/coderd/database/postgres"
2526
"github.com/coder/coder/codersdk"
26-
"github.com/coder/coder/database/postgres"
2727
)
2828

2929
func TestStart(t *testing.T) {

cli/workspacecreate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"golang.org/x/xerrors"
1414

1515
"github.com/coder/coder/cli/cliui"
16+
"github.com/coder/coder/coderd/database"
1617
"github.com/coder/coder/codersdk"
17-
"github.com/coder/coder/database"
1818
)
1919

2020
func workspaceCreate() *cobra.Command {

cli/workspacedelete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"github.com/spf13/cobra"
77

88
"github.com/coder/coder/cli/cliui"
9+
"github.com/coder/coder/coderd/database"
910
"github.com/coder/coder/codersdk"
10-
"github.com/coder/coder/database"
1111
)
1212

1313
func workspaceDelete() *cobra.Command {

cli/workspacestart.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"github.com/spf13/cobra"
77

88
"github.com/coder/coder/cli/cliui"
9+
"github.com/coder/coder/coderd/database"
910
"github.com/coder/coder/codersdk"
10-
"github.com/coder/coder/database"
1111
)
1212

1313
func workspaceStart() *cobra.Command {

cli/workspacestop.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"github.com/spf13/cobra"
77

88
"github.com/coder/coder/cli/cliui"
9+
"github.com/coder/coder/coderd/database"
910
"github.com/coder/coder/codersdk"
10-
"github.com/coder/coder/database"
1111
)
1212

1313
func workspaceStop() *cobra.Command {

cmd/cliui/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"golang.org/x/xerrors"
1212

1313
"github.com/coder/coder/cli/cliui"
14+
"github.com/coder/coder/coderd/database"
1415
"github.com/coder/coder/codersdk"
15-
"github.com/coder/coder/database"
1616
)
1717

1818
func main() {

cmd/templater/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import (
1919
"cdr.dev/slog"
2020
"cdr.dev/slog/sloggers/sloghuman"
2121
"github.com/coder/coder/coderd"
22+
"github.com/coder/coder/coderd/database"
23+
"github.com/coder/coder/coderd/database/databasefake"
2224
"github.com/coder/coder/coderd/tunnel"
2325
"github.com/coder/coder/codersdk"
24-
"github.com/coder/coder/database"
25-
"github.com/coder/coder/database/databasefake"
2626
"github.com/coder/coder/provisioner/terraform"
2727
"github.com/coder/coder/provisionerd"
2828
"github.com/coder/coder/provisionersdk"

codecov.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ coverage:
2424

2525
ignore:
2626
# This is generated code.
27-
- database/models.go
28-
- database/query.sql.go
29-
- database/databasefake
27+
- coderd/database/models.go
28+
- coderd/database/query.sql.go
29+
- coderd/database/databasefake
3030
# These are generated or don't require tests.
3131
- cmd
3232
- coderd/tunnel
33-
- database/dump
34-
- database/postgres
33+
- coderd/database/dump
34+
- coderd/database/postgres
3535
- peerbroker/proto
3636
- provisionerd/proto
3737
- provisionersdk/proto

coderd/coderd.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"google.golang.org/api/idtoken"
1111

1212
"cdr.dev/slog"
13-
"github.com/coder/coder/database"
14-
"github.com/coder/coder/httpapi"
15-
"github.com/coder/coder/httpmw"
13+
"github.com/coder/coder/coderd/database"
14+
"github.com/coder/coder/coderd/httpapi"
15+
"github.com/coder/coder/coderd/httpmw"
1616
"github.com/coder/coder/site"
1717
)
1818

coderd/coderdtest/coderdtest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ import (
3131
"cdr.dev/slog"
3232
"cdr.dev/slog/sloggers/slogtest"
3333
"github.com/coder/coder/coderd"
34+
"github.com/coder/coder/coderd/database"
35+
"github.com/coder/coder/coderd/database/databasefake"
36+
"github.com/coder/coder/coderd/database/postgres"
3437
"github.com/coder/coder/codersdk"
3538
"github.com/coder/coder/cryptorand"
36-
"github.com/coder/coder/database"
37-
"github.com/coder/coder/database/databasefake"
38-
"github.com/coder/coder/database/postgres"
3939
"github.com/coder/coder/provisioner/echo"
4040
"github.com/coder/coder/provisionerd"
4141
"github.com/coder/coder/provisionersdk"

database/databasefake/databasefake.go renamed to coderd/database/databasefake/databasefake.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/google/uuid"
1010

11-
"github.com/coder/coder/database"
11+
"github.com/coder/coder/coderd/database"
1212
)
1313

1414
// New returns an in-memory fake of the database.

database/db.go renamed to coderd/database/db.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
//
55
// To modify the database schema:
66
// 1. Add a new migration using "create_migration.sh" in database/migrations/
7-
// 2. Run "make database/generate" in the root to generate models.
8-
// 3. Add/Edit queries in "query.sql" and run "make database/generate" to create Go code.
7+
// 2. Run "make coderd/database/generate" in the root to generate models.
8+
// 3. Add/Edit queries in "query.sql" and run "make coderd/database/generate" to create Go code.
99
package database
1010

1111
import (

database/dump.sql renamed to coderd/database/dump.sql

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

database/dump/main.go renamed to coderd/database/dump/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"path/filepath"
1111
"runtime"
1212

13-
"github.com/coder/coder/database"
14-
"github.com/coder/coder/database/postgres"
13+
"github.com/coder/coder/coderd/database"
14+
"github.com/coder/coder/coderd/database/postgres"
1515
)
1616

1717
func main() {
@@ -76,7 +76,7 @@ func main() {
7676
}
7777
}
7878

79-
dump := fmt.Sprintf("-- Code generated by 'make database/generate'. DO NOT EDIT.\n%s", output.Bytes())
79+
dump := fmt.Sprintf("-- Code generated by 'make coderd/database/generate'. DO NOT EDIT.\n%s", output.Bytes())
8080
_, mainPath, _, ok := runtime.Caller(0)
8181
if !ok {
8282
panic("couldn't get caller path")
File renamed without changes.

database/migrate_test.go renamed to coderd/database/migrate_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/stretchr/testify/require"
1010
"go.uber.org/goleak"
1111

12-
"github.com/coder/coder/database"
13-
"github.com/coder/coder/database/postgres"
12+
"github.com/coder/coder/coderd/database"
13+
"github.com/coder/coder/coderd/database/postgres"
1414
)
1515

1616
func TestMain(m *testing.M) {
File renamed without changes.
File renamed without changes.

database/postgres/postgres_test.go renamed to coderd/database/postgres/postgres_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/stretchr/testify/require"
1010
"go.uber.org/goleak"
1111

12-
"github.com/coder/coder/database/postgres"
12+
"github.com/coder/coder/coderd/database/postgres"
1313

1414
_ "github.com/lib/pq"
1515
)
File renamed without changes.
File renamed without changes.

database/pubsub_memory_test.go renamed to coderd/database/pubsub_memory_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/stretchr/testify/assert"
88
"github.com/stretchr/testify/require"
99

10-
"github.com/coder/coder/database"
10+
"github.com/coder/coder/coderd/database"
1111
)
1212

1313
func TestPubsubMemory(t *testing.T) {

database/pubsub_test.go renamed to coderd/database/pubsub_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
"github.com/stretchr/testify/require"
1212

13-
"github.com/coder/coder/database"
14-
"github.com/coder/coder/database/postgres"
13+
"github.com/coder/coder/coderd/database"
14+
"github.com/coder/coder/coderd/database/postgres"
1515
)
1616

1717
func TestPubsub(t *testing.T) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

coderd/files.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212
"github.com/go-chi/chi/v5"
1313
"github.com/go-chi/render"
1414

15+
"github.com/coder/coder/coderd/database"
16+
"github.com/coder/coder/coderd/httpapi"
17+
"github.com/coder/coder/coderd/httpmw"
1518
"github.com/coder/coder/codersdk"
16-
"github.com/coder/coder/database"
17-
"github.com/coder/coder/httpapi"
18-
"github.com/coder/coder/httpmw"
1919
)
2020

2121
func (api *api) postFile(rw http.ResponseWriter, r *http.Request) {
File renamed without changes.

httpapi/httpapi_test.go renamed to coderd/httpapi/httpapi_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"github.com/stretchr/testify/require"
1111

12-
"github.com/coder/coder/httpapi"
12+
"github.com/coder/coder/coderd/httpapi"
1313
)
1414

1515
func TestWrite(t *testing.T) {

httpmw/apikey.go renamed to coderd/httpmw/apikey.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313

1414
"golang.org/x/oauth2"
1515

16-
"github.com/coder/coder/database"
17-
"github.com/coder/coder/httpapi"
16+
"github.com/coder/coder/coderd/database"
17+
"github.com/coder/coder/coderd/httpapi"
1818
)
1919

2020
// AuthCookie represents the name of the cookie the API key is stored in.

httpmw/apikey_test.go renamed to coderd/httpmw/apikey_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212
"github.com/stretchr/testify/require"
1313
"golang.org/x/oauth2"
1414

15+
"github.com/coder/coder/coderd/database"
16+
"github.com/coder/coder/coderd/database/databasefake"
17+
"github.com/coder/coder/coderd/httpapi"
18+
"github.com/coder/coder/coderd/httpmw"
1519
"github.com/coder/coder/cryptorand"
16-
"github.com/coder/coder/database"
17-
"github.com/coder/coder/database/databasefake"
18-
"github.com/coder/coder/httpapi"
19-
"github.com/coder/coder/httpmw"
2020
)
2121

2222
func randomAPIKeyParts() (id string, secret string) {

0 commit comments

Comments
 (0)