Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions internal/cmd/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func pluginSettings(r *compiler.Result, cs config.CombinedSettings) *plugin.Sett
Overrides: over,
Rename: cs.Rename,
Codegen: pluginCodegen(cs.Codegen),
Plugin: pluginPlugin(cs),
}
}

Expand All @@ -73,6 +74,39 @@ func pluginCodegen(s config.Codegen) *plugin.Codegen {
}
}

func pluginProcess(p config.Plugin) *plugin.Plugin_Process {
if p.Process != nil {
return &plugin.Plugin_Process{
Cmd: p.Process.Cmd,
}
}
return nil
}

func pluginWASM(p config.Plugin) *plugin.Plugin_WASM {
if p.WASM != nil {
return &plugin.Plugin_WASM{
Url: p.WASM.URL,
Sha256: p.WASM.SHA256,
}
}
return nil
}

func pluginPlugin(cs config.CombinedSettings) *plugin.Plugin {
for _, p := range cs.Global.Plugins {
if p.Name == cs.Codegen.Plugin {
return &plugin.Plugin{
Name: p.Name,
Env: p.Env,
Process: pluginProcess(p),
Wasm: pluginWASM(p),
}
}
}
return nil
}

func pluginGoType(o config.Override) *plugin.ParsedGoType {
// Note that there is a slight mismatch between this and the
// proto api. The GoType on the override is the unparsed type,
Expand Down
3 changes: 2 additions & 1 deletion internal/endtoend/testdata/codegen_json/gen/codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"out": "",
"plugin": "",
"options": ""
}
},
"plugin": null
},
"catalog": {
"comment": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
"out": "gen",
"plugin": "jsonb",
"options": "eyJmaWxlbmFtZSI6ImNvZGVnZW4uanNvbiIsImluZGVudCI6IiAgIn0="
},
"plugin": {
"name": "jsonb",
"env": [],
"process": {
"cmd": "sqlc-gen-json"
},
"wasm": null
}
},
"catalog": {
Expand Down
Loading