-
Notifications
You must be signed in to change notification settings - Fork 879
feat(codegen): Allow plugins to access environment variables #2669
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
Conversation
Currently untested, but environment variable access must be configured in sqlc.yaml.
So the idea here is that the user can decide which variables go in the allow list, via sqlc.conf? |
Exactly. This is very similar to how wasmtime allows environment variables to be accessed. version: '2'
plugins:
- name: py
env:
- PATH
wasm:
url: https://github.com/sqlc-dev/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm
sha256: 428476c7408fd4c032da4ec74e8a7344f4fa75e0f98a5a3302f238283b9b95f2
sql:
- schema: "schema.sql"
queries: "query.sql"
engine: postgresql
codegen:
- out: src/authors
plugin: py
options:
package: authors
emit_sync_querier: true
emit_async_querier: true
query_parameter_limit: 5 |
@@ -316,6 +316,8 @@ Each mapping in the `plugins` collection has the following keys: | |||
|
|||
- `name`: | |||
- The name of this plugin. Required | |||
- `env` | |||
- A list of environment variables to pass to the plugin. By default, no environment variables are passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the SQLC_VERSION
var which is added (not from the actual shell environment though). That should be documented somewhere, but probably not here.
Allow plugins, both process-based and WASM-based, to read environment variables from the host, configured via a per-variable allowlist. Plugins can not declare the environment variables they have access to outside of the sqlc.yaml configuration file.
Closes #2661