@@ -15,32 +15,20 @@ top-level `plugins` map. The `options` are serialized to a string and passed on
15
15
to the plugin itself.
16
16
17
17
18
- ``` json
19
- {
20
- "version" : " 2" ,
21
- "plugins" : [
22
- {
23
- "name" : " greeter" ,
24
- "wasm" : {
25
- "url" : " https://github.com/sqlc-dev/sqlc-gen-greeter/releases/download/v0.1.0/sqlc-gen-greeter.wasm" ,
26
- "sha256" : " afc486dac2068d741d7a4110146559d12a013fd0286f42a2fc7dcd802424ad07"
27
- }
28
- }
29
- ],
30
- "sql" : [
31
- {
32
- "schema" : " schema.sql" ,
33
- "queries" : " query.sql" ,
34
- "engine" : " postgresql" ,
35
- "codegen" : [
36
- {
37
- "out" : " gen" ,
38
- "plugin" : " greeter"
39
- }
40
- ]
41
- }
42
- ]
43
- }
18
+ ``` yaml
19
+ version : ' 2'
20
+ plugins :
21
+ - name : greeter
22
+ wasm :
23
+ url : https://github.com/sqlc-dev/sqlc-gen-greeter/releases/download/v0.1.0/sqlc-gen-greeter.wasm
24
+ sha256 : afc486dac2068d741d7a4110146559d12a013fd0286f42a2fc7dcd802424ad07
25
+ sql :
26
+ - schema : schema.sql
27
+ queries : query.sql
28
+ engine : postgresql
29
+ codegen :
30
+ - out : gen
31
+ plugin : greeter
44
32
` ` `
45
33
46
34
For a complete working example see the following files:
@@ -59,39 +47,51 @@ the new files. The `plugin` key must reference a plugin defined in the
59
47
top-level `plugins` map. The `options` are serialized to a string and passed on
60
48
to the plugin itself.
61
49
62
- ``` json
63
- {
64
- "version" : " 2" ,
65
- "plugins" : [
66
- {
67
- "name" : " jsonb" ,
68
- "process" : {
69
- "cmd" : " sqlc-gen-json"
70
- }
71
- }
72
- ],
73
- "sql" : [
74
- {
75
- "schema" : " schema.sql" ,
76
- "queries" : " query.sql" ,
77
- "engine" : " postgresql" ,
78
- "codegen" : [
79
- {
80
- "out" : " gen" ,
81
- "plugin" : " jsonb" ,
82
- "options" : {
83
- "indent" : " " ,
84
- "filename" : " codegen.json"
85
- }
86
- }
87
- ]
88
- }
89
- ]
90
- }
50
+ ` ` ` yaml
51
+ version: '2'
52
+ plugins:
53
+ - name: jsonb
54
+ process:
55
+ cmd: sqlc-gen-json
56
+ sql:
57
+ - schema: schema.sql
58
+ queries: query.sql
59
+ engine: postgresql
60
+ codegen:
61
+ - out: gen
62
+ plugin: jsonb
63
+ options:
64
+ indent: " "
65
+ filename: codegen.json
91
66
` ` `
92
67
93
68
For a complete working example see the following files :
94
69
- [sqlc-gen-json](https://github.com/sqlc-dev/sqlc/tree/main/cmd/sqlc-gen-json)
95
70
- A process-based plugin that serializes the CodeGenRequest to JSON
96
71
- [process_plugin_sqlc_gen_json](https://github.com/sqlc-dev/sqlc/tree/main/internal/endtoend/testdata/process_plugin_sqlc_gen_json)
97
72
- An example project showing how to use a process-based plugin
73
+
74
+ # # Environment variables
75
+
76
+ By default, plugins do not inherit access to environment variables. Instead,
77
+ access can be configured on a per-variable basis. For example, if your plugin
78
+ needs the `PATH` environment variable, add the `PATH` to the `env` option in the
79
+ ` plugins` collection.
80
+
81
+ ` ` ` yaml
82
+ version: '2'
83
+ sql:
84
+ - schema: schema.sql
85
+ queries: query.sql
86
+ engine: postgresql
87
+ codegen:
88
+ - out: gen
89
+ plugin: test
90
+ plugins:
91
+ - name: test
92
+ env:
93
+ - PATH
94
+ wasm:
95
+ url: https://github.com/sqlc-dev/sqlc-gen-test/releases/download/v0.1.0/sqlc-gen-test.wasm
96
+ sha256: 138220eae508d4b65a5a8cea555edd155eb2290daf576b7a8b96949acfeb3790
97
+ ` ` `
0 commit comments