Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2/app: allow dbs to be defined outside svcs #822

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 1 addition & 8 deletions v2/app/testdata/sqldb_outside_svc.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
! parse
err 'cannot define SQL Database resource in non-service package'
parse

-- svc/migrations/1_dummy.up.sql --
-- svc/svc.go --
Expand All @@ -19,9 +18,3 @@ import (
)

var Moo = sqldb.Named("svc")

-- want: errors --

── Resource defined outside of service ────────────────────────────────────────────────────[E9999]──

Resources can only be defined within a service.
4 changes: 4 additions & 0 deletions v2/app/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encr.dev/v2/parser/apis/middleware"
"encr.dev/v2/parser/infra/pubsub"
"encr.dev/v2/parser/infra/secrets"
"encr.dev/v2/parser/infra/sqldb"
)

// validate checks that the application is in a valid state across all services and compilation units.
Expand Down Expand Up @@ -46,6 +47,9 @@ func (d *Desc) validate(pc *parsectx.Context, result *parser.Result) {
case *secrets.Secrets:
// Secrets are allowed anywhere
continue
case *sqldb.Database:
// Databases are allowed anywhere
continue

default:
_, ok := d.ServiceForPath(b.Package().FSPath)
Expand Down