Skip to content

Commit 5dc3d28

Browse files
authored
plugins(wasm): Change the SHA-256 config key (#1710)
* plugins(wasm): Change the SHA-256 config key Use sha256 to match Bazel's http_file directive
1 parent 167e414 commit 5dc3d28

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

internal/cmd/generate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ func codegen(ctx context.Context, combo config.CombinedSettings, sql outPair, re
328328
}
329329
case plug.WASM != nil:
330330
handler = &wasm.Runner{
331-
URL: plug.WASM.URL,
332-
Checksum: plug.WASM.Checksum,
331+
URL: plug.WASM.URL,
332+
SHA256: plug.WASM.SHA256,
333333
}
334334
default:
335335
return "", nil, fmt.Errorf("unsupported plugin type")

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ type Plugin struct {
8888
Cmd string `json:"cmd" yaml:"cmd"`
8989
} `json:"process" yaml:"process"`
9090
WASM *struct {
91-
URL string `json:"url" yaml:"url"`
92-
Checksum string `json:"checksum" yaml:"checksum"`
91+
URL string `json:"url" yaml:"url"`
92+
SHA256 string `json:"sha256" yaml:"sha256"`
9393
} `json:"wasm" yaml:"wasm"`
9494
}
9595

internal/endtoend/testdata/wasm_plugin_sqlc_gen_greeter/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"name": "greeter",
1919
"wasm": {
2020
"url": "https://github.com/kyleconroy/sqlc-gen-greeter/releases/download/v0.1.0/sqlc-gen-greeter.wasm",
21-
"checksum": "sha256/afc486dac2068d741d7a4110146559d12a013fd0286f42a2fc7dcd802424ad07"
21+
"sha256": "afc486dac2068d741d7a4110146559d12a013fd0286f42a2fc7dcd802424ad07"
2222
}
2323
}
2424
]

internal/ext/wasm/wasm.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,16 @@ func cacheDir() (string, error) {
4141
}
4242

4343
type Runner struct {
44-
URL string
45-
Checksum string
44+
URL string
45+
SHA256 string
4646
}
4747

4848
// Verify the provided sha256 is valid.
4949
func (r *Runner) parseChecksum() (string, error) {
50-
if r.Checksum == "" {
51-
return "", fmt.Errorf("missing checksum")
50+
if r.SHA256 == "" {
51+
return "", fmt.Errorf("missing SHA-256 checksum")
5252
}
53-
if !strings.HasPrefix(r.Checksum, "sha256/") {
54-
return "", fmt.Errorf("invalid checksum algo: %s", r.Checksum)
55-
}
56-
return strings.TrimPrefix(r.Checksum, "sha256/"), nil
53+
return r.SHA256, nil
5754
}
5855

5956
func (r *Runner) loadModule(ctx context.Context, engine *wasmtime.Engine) (*wasmtime.Module, error) {

0 commit comments

Comments
 (0)