feat(codegen): Allow plugins to access environment variables#2669
Merged
kyleconroy merged 7 commits intomainfrom Aug 29, 2023
Merged
feat(codegen): Allow plugins to access environment variables#2669kyleconroy merged 7 commits intomainfrom
kyleconroy merged 7 commits intomainfrom
Conversation
Currently untested, but environment variable access must be configured in sqlc.yaml.
Collaborator
|
So the idea here is that the user can decide which variables go in the allow list, via sqlc.conf? |
Collaborator
Author
|
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 |
| - `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. |
Collaborator
There was a problem hiding this comment.
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.
alfonsodev
pushed a commit
to ExponentiaTeam/sqlc
that referenced
this pull request
Oct 13, 2025
…v#2669) 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. ```yaml 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 ``` * Add SQLC_VERSION to docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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