Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
INSTALL_DIR=$(shell go env GOPATH)/bin
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
DATABASE_DIR=coderd/database

bin:
goreleaser build --snapshot --rm-dist
Expand All @@ -10,14 +11,14 @@ build: site/out bin
.PHONY: build

# Runs migrations to output a dump of the database.
database/dump.sql: $(wildcard database/migrations/*.sql)
go run database/dump/main.go
$(DATABASE_DIR)/dump.sql: $(wildcard database/migrations/*.sql)
go run $(DATABASE_DIR)/dump/main.go

# Generates Go code for querying the database.
database/generate: fmt/sql database/dump.sql database/query.sql
cd database && sqlc generate && rm db_tmp.go
cd database && gofmt -w -r 'Querier -> querier' *.go
cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go
database/generate: fmt/sql $(DATABASE_DIR)/dump.sql $(DATABASE_DIR)/query.sql
cd $(DATABASE_DIR) && sqlc generate && rm db_tmp.go
cd $(DATABASE_DIR) && gofmt -w -r 'Querier -> querier' *.go
cd $(DATABASE_DIR) && gofmt -w -r 'Queries -> sqlQuerier' *.go
.PHONY: database/generate

fmt/prettier:
Expand All @@ -30,13 +31,13 @@ else
endif
.PHONY: fmt/prettier

fmt/sql: ./database/query.sql
fmt/sql: ./$(DATABASE_DIR)/query.sql
npx sql-formatter \
--language postgresql \
--lines-between-queries 2 \
./database/query.sql \
--output ./database/query.sql
sed -i 's/@ /@/g' ./database/query.sql
./$(DATABASE_DIR)/query.sql \
--output ./$(DATABASE_DIR)/query.sql
sed -i 's/@ /@/g' ./$(DATABASE_DIR)/query.sql

fmt: fmt/prettier fmt/sql
.PHONY: fmt
Expand Down
2 changes: 1 addition & 1 deletion cli/cliui/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/spf13/cobra"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

type JobOptions struct {
Expand Down
2 changes: 1 addition & 1 deletion cli/parametercreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra"
"golang.org/x/xerrors"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func parameterCreate() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cli/projectcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"golang.org/x/xerrors"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
"github.com/coder/coder/provisionerd"
"github.com/coder/coder/provisionersdk"
)
Expand Down
2 changes: 1 addition & 1 deletion cli/projectcreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/database"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/pty/ptytest"
)
Expand Down
2 changes: 1 addition & 1 deletion cli/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/spf13/cobra"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func projects() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cli/projectupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/spf13/cobra"
"golang.org/x/xerrors"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
"github.com/coder/coder/provisionersdk"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"golang.org/x/term"
"golang.org/x/xerrors"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func workspaceSSH() *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/cli/config"
"github.com/coder/coder/coderd"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/databasefake"
"github.com/coder/coder/coderd/tunnel"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
"github.com/coder/coder/database/databasefake"
"github.com/coder/coder/provisioner/terraform"
"github.com/coder/coder/provisionerd"
"github.com/coder/coder/provisionersdk"
Expand Down
2 changes: 1 addition & 1 deletion cli/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/coderd/database/postgres"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database/postgres"
)

func TestStart(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cli/workspacecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"golang.org/x/xerrors"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func workspaceCreate() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cli/workspacedelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func workspaceDelete() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cli/workspacestart.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func workspaceStart() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cli/workspacestop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func workspaceStop() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cliui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"golang.org/x/xerrors"

"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/templater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
"cdr.dev/slog"
"cdr.dev/slog/sloggers/sloghuman"
"github.com/coder/coder/coderd"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/databasefake"
"github.com/coder/coder/coderd/tunnel"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
"github.com/coder/coder/database/databasefake"
"github.com/coder/coder/provisioner/terraform"
"github.com/coder/coder/provisionerd"
"github.com/coder/coder/provisionersdk"
Expand Down
6 changes: 3 additions & 3 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"google.golang.org/api/idtoken"

"cdr.dev/slog"
"github.com/coder/coder/database"
"github.com/coder/coder/httpapi"
"github.com/coder/coder/httpmw"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/coderd/httpmw"
"github.com/coder/coder/site"
)

Expand Down
6 changes: 3 additions & 3 deletions coderd/coderdtest/coderdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
"cdr.dev/slog"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/coderd"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/databasefake"
"github.com/coder/coder/coderd/database/postgres"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/cryptorand"
"github.com/coder/coder/database"
"github.com/coder/coder/database/databasefake"
"github.com/coder/coder/database/postgres"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionerd"
"github.com/coder/coder/provisionersdk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/google/uuid"

"github.com/coder/coder/database"
"github.com/coder/coder/coderd/database"
)

// New returns an in-memory fake of the database.
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions database/dump/main.go → coderd/database/dump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"path/filepath"
"runtime"

"github.com/coder/coder/database"
"github.com/coder/coder/database/postgres"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/postgres"
)

func main() {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions database/migrate_test.go → coderd/database/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/coder/coder/database"
"github.com/coder/coder/database/postgres"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/postgres"
)

func TestMain(m *testing.M) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/coder/coder/database/postgres"
"github.com/coder/coder/coderd/database/postgres"

_ "github.com/lib/pq"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/coder/coder/database"
"github.com/coder/coder/coderd/database"
)

func TestPubsubMemory(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions database/pubsub_test.go → coderd/database/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/coder/coder/database"
"github.com/coder/coder/database/postgres"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/postgres"
)

func TestPubsub(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions coderd/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/coderd/httpmw"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/database"
"github.com/coder/coder/httpapi"
"github.com/coder/coder/httpmw"
)

func (api *api) postFile(rw http.ResponseWriter, r *http.Request) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion httpapi/httpapi_test.go → coderd/httpapi/httpapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/coder/coder/httpapi"
"github.com/coder/coder/coderd/httpapi"
)

func TestWrite(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions httpmw/apikey.go → coderd/httpmw/apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"golang.org/x/oauth2"

"github.com/coder/coder/database"
"github.com/coder/coder/httpapi"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/httpapi"
)

// AuthCookie represents the name of the cookie the API key is stored in.
Expand Down
8 changes: 4 additions & 4 deletions httpmw/apikey_test.go → coderd/httpmw/apikey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/oauth2"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/databasefake"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/coderd/httpmw"
"github.com/coder/coder/cryptorand"
"github.com/coder/coder/database"
"github.com/coder/coder/database/databasefake"
"github.com/coder/coder/httpapi"
"github.com/coder/coder/httpmw"
)

func randomAPIKeyParts() (id string, secret string) {
Expand Down
2 changes: 1 addition & 1 deletion httpmw/httpmw.go → coderd/httpmw/httpmw.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/go-chi/chi/v5"
"github.com/google/uuid"

"github.com/coder/coder/httpapi"
"github.com/coder/coder/coderd/httpapi"
)

// parseUUID consumes a url parameter and parses it as a UUID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/go-chi/chi/v5"

"github.com/coder/coder/database"
"github.com/coder/coder/httpapi"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/httpapi"
)

type organizationParamContextKey struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/require"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/databasefake"
"github.com/coder/coder/coderd/httpmw"
"github.com/coder/coder/cryptorand"
"github.com/coder/coder/database"
"github.com/coder/coder/database/databasefake"
"github.com/coder/coder/httpmw"
)

func TestOrganizationParam(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions httpmw/projectparam.go → coderd/httpmw/projectparam.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/go-chi/chi/v5"

"github.com/coder/coder/database"
"github.com/coder/coder/httpapi"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/httpapi"
)

type projectParamContextKey struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/require"

"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/database/databasefake"
"github.com/coder/coder/coderd/httpmw"
"github.com/coder/coder/cryptorand"
"github.com/coder/coder/database"
"github.com/coder/coder/database/databasefake"
"github.com/coder/coder/httpmw"
)

func TestProjectParam(t *testing.T) {
Expand Down
Loading