You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor config to multi-target CUE pattern and update dependencies
Consolidate local.cue and staging.cue into a single config.cue with
multi-target support using snake_case naming. Restructure CUE schema
accordingly and move Taskfile out of dbt/ subdirectory. Add top-level
config.json for ff JSON config parser. Refactor cmd package to extract
flags validation and add printFlags helper. Comment out Genesis and GCP
deploy code pending rework. Make SQL migration constraints idempotent.
Update Go to 1.24.11 and upgrade all dependencies. Document config
values as example/placeholder only.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+33-15Lines changed: 33 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,31 +82,29 @@ The `movieAdmin` role is set up to grant access to all resources. It's a demo...
82
82
83
83
--------
84
84
85
-
### Step 3 - Prepare Environment (2 options)
85
+
### Step 2 - Prepare Environment (2 options)
86
86
87
-
All Mage programs in this project which take an environment (env) parameter (e.g., `func DBUp(env string)`), must have certain environment variables set. These environment variables can be set independently [option 1](#option-1---set-your-environment-independently) or based on a configuration file [option 2](#option-2---set-your-environment-through-a-config-file). Depending on which environment method you choose, the values to pass to the env parameter when running Mage programs in this project are as follows:
| LOG_LEVEL_MIN | sets the minimum accepted logging level |
102
-
| LOG_ERROR_STACK | If true, log error stacktrace using github.com/pkg/errors, else just log error (includes op stack) |
103
91
| DB_HOST | The host name of the database server. |
104
92
| DB_PORT | The port number the database server is listening on. |
105
93
| DB_NAME | The database name. |
106
94
| DB_USER | PostgreSQL™ user name to connect as. |
107
95
| DB_PASSWORD | Password to be used if the server demands password authentication. |
108
96
| DB_SEARCH_PATH | Schema Search Path |
109
-
| ENCRYPT_KEY | Encryption Key |
97
+
98
+
These environment variables can be set independently [option 1](#option-1---set-your-environment-independently) or based on a configuration file [option 2](#option-2---set-your-environment-through-a-config-file). Depending on which environment method you choose, the values to pass to the env parameter when running Mage programs in this project are as follows:
| current | N/A | Uses the current session environment. Environment will not be overriden from a config file |
104
+
| local | ./config/local.json | Uses the `local.json` config file to set the environment |
105
+
| staging | ./config/staging.json | Uses the `staging.json` config file to set the environment in [Google Cloud Run](https://cloud.google.com/run)|
106
+
107
+
The base environment variables to be set are:
110
108
111
109
> The same environment variables are used when running the web server, but are not mandatory. When running the web server, if you prefer, you can bypass environment variables and instead send command line flags (more about that later).
112
110
@@ -505,6 +503,26 @@ The above image is a high-level view of an example request that is processed by
505
503
506
504
> `diygoapi` package layout is based on several projects, but the primary source of inspiration is the [WTF Dial app repo](https://github.com/benbjohnson/wtf) and [accompanying blog](https://www.gobeyond.dev/) from [Ben Johnson](https://github.com/benbjohnson). It's really a wonderful resource and I encourage everyone to read it.
507
505
506
+
### Environment Variables
507
+
508
+
The following environment variables are used to configure the web server:
| LOG_LEVEL_MIN | sets the minimum accepted logging level |
515
+
| LOG_ERROR_STACK | If true, log error stacktrace using github.com/pkg/errors, else just log error (includes op stack) |
516
+
| DB_HOST | The host name of the database server. |
517
+
| DB_PORT | The port number the database server is listening on. |
518
+
| DB_NAME | The database name. |
519
+
| DB_USER | PostgreSQL™ user name to connect as. |
520
+
| DB_PASSWORD | Password to be used if the server demands password authentication. |
521
+
| DB_SEARCH_PATH | Schema Search Path |
522
+
| ENCRYPT_KEY | Encryption Key |
523
+
524
+
> Note: If an environment variable is not set, the default is used
525
+
508
526
### Errors
509
527
510
528
Handling errors is really important in Go. Errors are first class citizens and there are many different approaches for handling them. I have based my error handling on a [blog post from Rob Pike](https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html) and have modified it to meet my needs. The post is many years old now, but I find the lessons there still hold true at least for my requirements.
logErrorStack=fs.Bool("log-error-stack", false, fmt.Sprintf("if true, log full error stacktrace using github.com/pkg/errors, else just log error, (also via %s)", logErrorStackEnv))
91
-
port=fs.Int("port", 8080, fmt.Sprintf("listen port for server (also via %s)", portEnv))
92
-
dbhost=fs.String("db-host", "", fmt.Sprintf("postgresql database host (also via %s)", sqldb.DBHostEnv))
93
-
dbport=fs.Int("db-port", 5432, fmt.Sprintf("postgresql database port (also via %s)", sqldb.DBPortEnv))
94
-
dbname=fs.String("db-name", "", fmt.Sprintf("postgresql database name (also via %s)", sqldb.DBNameEnv))
95
-
dbuser=fs.String("db-user", "", fmt.Sprintf("postgresql database user (also via %s)", sqldb.DBUserEnv))
96
-
dbpassword=fs.String("db-password", "", fmt.Sprintf("postgresql database password (also via %s)", sqldb.DBPasswordEnv))
97
-
dbsearchpath=fs.String("db-search-path", "", fmt.Sprintf("postgresql database search path (also via %s)", sqldb.DBSearchPathEnv))
98
-
encryptkey=fs.String("encrypt-key", "", fmt.Sprintf("encryption key (also via %s)", encryptKeyEnv))
99
-
)
100
-
101
-
// Parse the command line flags from above
102
-
err:=ff.Parse(fs, args[1:], ff.WithEnvVars())
103
-
iferr!=nil {
104
-
returnflags{}, errs.E(op, err)
105
-
}
106
-
107
-
returnflags{
108
-
loglvl: *loglvl,
109
-
logLvlMin: *logLvlMin,
110
-
logErrorStack: *logErrorStack,
111
-
port: *port,
112
-
dbhost: *dbhost,
113
-
dbport: *dbport,
114
-
dbname: *dbname,
115
-
dbuser: *dbuser,
116
-
dbpassword: *dbpassword,
117
-
dbsearchpath: *dbsearchpath,
118
-
encryptkey: *encryptkey,
119
-
}, nil
120
-
}
121
-
122
22
// Run parses command line flags and starts the server
0 commit comments