Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/sqlc: Add SQLCTMPDIR environment variable #2189

Merged
merged 3 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/reference/environment-variables.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Environment variables

## SQLCCACHE

The `SQLCCACHE` environment variable dictates where `sqlc` will store cached
WASM-based plugins and modules. By default `sqlc` follows the [XDG Base
Directory
Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html).

## SQLCDEBUG

The `SQLCDEBUG` variable controls debugging variables within the runtime. It is
Expand Down Expand Up @@ -110,3 +117,18 @@ log showing the execution time for each package.
0.046042779 . 5148212 1 region writefiles started (duration: 1.718259ms)
0.047767781 . 1725002 1 task end
```

### processplugins

Setting this value to `0` disables process-based plugins. If a process-based
plugin is declared in the configuration file, running any `sqlc` command will
return an error.

`SQLCDEBUG=processplugins=0`

## SQLCTMPDIR

If specified, use the given directory as the base for temporary folders. Only
applies when using WASM-based codegen plugins. When not specified, this
defaults to passing an empty string to
[`os.MkdirTemp`](https://pkg.go.dev/os#MkdirTemp).
3 changes: 1 addition & 2 deletions internal/ext/wasm/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -236,7 +235,7 @@ func (r *Runner) Generate(ctx context.Context, req *plugin.CodeGenRequest) (*plu
return nil, err
}

dir, err := ioutil.TempDir("", "out")
dir, err := os.MkdirTemp(os.Getenv("SQLCTMPDIR"), "out")
if err != nil {
return nil, fmt.Errorf("temp dir: %w", err)
}
Expand Down