Merged in bugfix/envvars (pull request #20)

Fix SQLc Env Vars

* init

* fixenvvar

* ignoredevbox

* queueurl
This commit is contained in:
Michael McGuinness
2025-01-14 13:28:25 +00:00
parent a7ad31a3f8
commit 9f9700a773
7 changed files with 33 additions and 4 deletions
+2
View File
@@ -70,3 +70,5 @@ Thumbs.db
*.mov *.mov
*.wmv *.wmv
# Devbox
.devbox/
+2
View File
@@ -2,3 +2,5 @@
extends: default extends: default
ignore: | ignore: |
vendor/ vendor/
.devbox/
out/
+1 -2
View File
@@ -8,9 +8,8 @@ Using the following project as a baseline: https://github.com/golang-standards/p
- Install devbox: `https://www.jetify.com/docs/devbox/installing_devbox` - Install devbox: `https://www.jetify.com/docs/devbox/installing_devbox`
- Ubuntu/MacOS: `curl -fsSL https://get.jetify.com/devbox | bash` - Ubuntu/MacOS: `curl -fsSL https://get.jetify.com/devbox | bash`
- Run `devbox run init` to create init dependencies
- Run `devbox shell` to enter the environment - Run `devbox shell` to enter the environment
- Create `.env` file to add environment variables
- Run `direnv allow` to ensure environment variables are populated
- Run `task deps:download` to download code dependencies - Run `task deps:download` to download code dependencies
- (IF NECESSARY) Ensure user in docker group and docker group is in sudo group - (IF NECESSARY) Ensure user in docker group and docker group is in sudo group
``` ```
+2 -2
View File
@@ -18,11 +18,11 @@
], ],
"shell": { "shell": {
"init_hook": [ "init_hook": [
"DB_URI=postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=disable", "export DB_URI=postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=disable",
"echo 'Welcome to the DoczyAI devbox!'" "echo 'Welcome to the DoczyAI devbox!'"
], ],
"scripts": { "scripts": {
"deps:download": [ "init": [
"task deps:download" "task deps:download"
] ]
} }
+2
View File
@@ -25,6 +25,8 @@ func TestNew(t *testing.T) {
return MockController{} return MockController{}
} }
t.Setenv("QUEUE_URL", "example_url")
queue.NewServer(ctx, &queue.ListenerConfig{ queue.NewServer(ctx, &queue.ListenerConfig{
Controller: controller, Controller: controller,
BasePath: "../..", BasePath: "../..",
+3
View File
@@ -28,6 +28,9 @@ includes:
taskfile: database.yml taskfile: database.yml
tasks: tasks:
init:
cmds:
- touch .env
fullsuite: fullsuite:
deps: deps:
- lint - lint
+21
View File
@@ -8,6 +8,12 @@ sql:
engine: "postgresql" engine: "postgresql"
queries: "database/queries/" queries: "database/queries/"
schema: "database/migrations" schema: "database/migrations"
rules:
- sqlc/db-prepare
- no-delete
- no-pg
- no-seq-scan
- too-costly
database: database:
managed: true managed: true
gen: gen:
@@ -15,3 +21,18 @@ sql:
package: "repository" package: "repository"
out: "internal/database/repository" out: "internal/database/repository"
sql_package: "pgx/v5" sql_package: "pgx/v5"
rules:
- name: no-pg
message: "invalid engine: not postgresql"
rule: |
config.engine != "postgresql"
- name: no-delete
message: "don't use delete statements"
rule: |
query.sql.contains("DELETE")
- name: too-costly
message: "Query cost estimate is too high"
rule: "postgresql.explain.plan.total_cost > 400.0"
- name: no-seq-scan
message: "Query plan results in a sequential scan"
rule: "postgresql.explain.plan.node_type == 'Seq Scan'"