Skip to content

feat(wasm): add support for OCI urls - #4649

Closed
bobdoah wants to merge 1 commit into
sqlc-dev:mainfrom
bobdoah:main
Closed

bobdoah wants to merge 1 commit into
sqlc-dev:mainfrom
bobdoah:main

Conversation

@bobdoah

@bobdoah bobdoah commented Oct 18, 2026

Copy link
Copy Markdown

This change adds OCI support for WASM plugin URLs. The OCI artifact is checked against the CNCF Wasm OCI artifact layout.

An example of building and using the sqlc-gen-go plugin via OCI:

  1. Build the plugin
git clone https://github.com/sqlc-dev/sqlc-gen-go.git
cd sqlc-gen-go
make bin/sqlc-gen-go.wasm
cd bin
  1. Create the OCI config
WASM_SHA256=$(sha256sum sqlc-gen-go.wasm | awk '{print $1}')

cat > config.json <<EOF
{
  "architecture": "wasm",
  "os": "wasip1",
  "layerDigests": ["sha256:${WASM_SHA256}"]
}
EOF
  1. Authenticate and push
IMAGE=ghcr.io/bobdoah/sqlc-gen-go

oras login ghcr.io

oras push "${IMAGE}:v1" \
  --config config.json:application/vnd.wasm.config.v0+json \
  sqlc-gen-go.wasm:application/wasm

The config is uploaded as the manifest’s config blob; the WASM file is its only layer.

  1. Configure sqlc
cat > examples/authors/oci-sqlc.yaml << EOF
version: "2"
plugins:
  - name: golang
    wasm:
      url: oci://${IMAGE}:v1@$(oras resolve "${IMAGE}:v1")
      sha256: $WASM_SHA256

sql:
- engine: sqlite
  schema: sqlite/schema.sql
  queries: sqlite/query.sql
  codegen:
  - plugin: golang
    out: gen
    options:
      package: authors
EOF
  1. Run the example
make sqlc-dev
~/bin/sqlc-dev generate -f examples/authors/oci-sqlc.yaml

@kyleconroy

Copy link
Copy Markdown
Collaborator

As I said in #4480, I'm not looking to add OCI support for wasm plugins. If HTTPS support doesn't work, please add a comment to that issue.

@kyleconroy kyleconroy closed this Oct 19, 2026
@bobdoah

bobdoah commented Oct 19, 2026 •

Copy link
Copy Markdown
Author

Apologies, I searched the open issues, very briefly and didn't spot it. I've also failed to provide any kind of use-case, which I do genuinely have. I was too focused on solving my problem and providing a workable example. I've added a comment to that issue, hopefully, explaining why I opened this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants