Skip to content

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

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

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

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.

1 participant