Documentation
¶
Overview ¶
Package pluginpdk provides helpers for honey WASM plugins built with the Extism Go PDK.
Recipe KV (stepkv) is optional per plugin and per recipe run:
- plugin.yaml: allow_kv: true
- recipe step or defaults: kv_tunnel: true
Without both, KV* functions return an error from the host (e.g. "kv not available for this call"). RemoteExec/RemoteUpload/RemoteStat require allow_remote_exec / allow_sftp in plugin.yaml. PostgresQuery/PostgresExec require allow_postgres in plugin.yaml. Keys are shared with remote command/script steps that use HONEY_KV_URL on the same cue-exec run.
Build plugins for WASI:
GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o plugin.wasm .
Example recipe: examples/recipe/echo_plugin_kv_demo.cue Reference plugin: examples/plugins/echo/
Index ¶
- func KVDelete(key string) error
- func KVGet(key string) (value string, found bool, err error)
- func KVPut(key, value string) error
- func ReadConfig[T any](config []byte) (T, error)
- type PostgresMigrateInput
- type PostgresOutput
- type PostgresSQLInput
- type RemoteDownloadOutput
- type RemoteExecOutput
- type RemoteStatOutput
- type RemoteUploadOutput
- type TemplateRenderOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KVGet ¶
KVGet reads a key from the recipe stepkv store. Missing keys return found=false and a nil error.
func ReadConfig ¶ added in v0.3.0
ReadConfig unmarshals plugin step config JSON into T.
Types ¶
type PostgresMigrateInput ¶ added in v0.3.0
type PostgresMigrateInput struct {
DSNSecret string `json:"dsn_secret"`
MigrationsDir string `json:"migrations_dir,omitempty"`
Files []string `json:"files,omitempty"`
TimeoutMS int `json:"timeout_ms"`
Readonly *bool `json:"readonly,omitempty"`
KVKey string `json:"kv_key,omitempty"`
KVKeyPerHost bool `json:"kv_key_per_host,omitempty"`
Extract map[string]string `json:"extract,omitempty"`
}
type PostgresOutput ¶ added in v0.3.0
type PostgresOutput struct {
Changed bool `json:"changed,omitempty"`
Failed bool `json:"failed,omitempty"`
Rows []map[string]any `json:"rows,omitempty"`
RowsAffected int64 `json:"rows_affected,omitempty"`
Stdout string `json:"stdout,omitempty"`
Error string `json:"error,omitempty"`
}
func PostgresExec ¶ added in v0.3.0
func PostgresExec(in PostgresSQLInput) (PostgresOutput, error)
PostgresExec runs a write SQL statement via the host.
func PostgresMigrate ¶ added in v0.3.0
func PostgresMigrate(in PostgresMigrateInput) (PostgresOutput, error)
PostgresMigrate applies SQL migration files via the host.
func PostgresQuery ¶ added in v0.3.0
func PostgresQuery(in PostgresSQLInput) (PostgresOutput, error)
PostgresQuery runs a read-only SQL query via the host.
type PostgresSQLInput ¶ added in v0.3.0
type PostgresSQLInput struct {
DSNSecret string `json:"dsn_secret"`
SQL string `json:"sql"`
Params json.RawMessage `json:"params,omitempty"`
TimeoutMS int `json:"timeout_ms"`
Readonly *bool `json:"readonly,omitempty"`
KVKey string `json:"kv_key,omitempty"`
KVKeyPerHost bool `json:"kv_key_per_host,omitempty"`
Extract map[string]string `json:"extract,omitempty"`
Host string `json:"host,omitempty"`
Port string `json:"port,omitempty"`
TunnelStep string `json:"tunnel_step,omitempty"`
}
type RemoteDownloadOutput ¶ added in v0.3.0
type RemoteDownloadOutput struct {
Content string `json:"content,omitempty"`
Size int64 `json:"size,omitempty"`
Changed bool `json:"changed,omitempty"`
Failed bool `json:"failed,omitempty"`
Error string `json:"error,omitempty"`
}
func RemoteDownload ¶ added in v0.3.0
func RemoteDownload(remotePath string, maxBytes int64) (RemoteDownloadOutput, error)
RemoteDownload reads a remote file (size-capped by the host).
type RemoteExecOutput ¶ added in v0.3.0
type RemoteExecOutput struct {
ExitCode int `json:"exit_code,omitempty"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
Changed bool `json:"changed,omitempty"`
Failed bool `json:"failed,omitempty"`
Error string `json:"error,omitempty"`
}
func RemoteExec ¶ added in v0.3.0
func RemoteExec(shell, script string) (RemoteExecOutput, error)
RemoteExec runs a script on the remote host via the remote_exec host function.
type RemoteStatOutput ¶ added in v0.3.0
type RemoteStatOutput struct {
Exists bool `json:"exists,omitempty"`
IsDir bool `json:"is_dir,omitempty"`
Mode string `json:"mode,omitempty"`
Size int64 `json:"size,omitempty"`
MTime string `json:"mtime,omitempty"`
Changed bool `json:"changed,omitempty"`
Failed bool `json:"failed,omitempty"`
Error string `json:"error,omitempty"`
}
func RemoteStat ¶ added in v0.3.0
func RemoteStat(path string) (RemoteStatOutput, error)
RemoteStat returns metadata for a remote path.
type RemoteUploadOutput ¶ added in v0.3.0
type RemoteUploadOutput struct {
Changed bool `json:"changed,omitempty"`
Failed bool `json:"failed,omitempty"`
Error string `json:"error,omitempty"`
}
func RemoteUpload ¶ added in v0.3.0
func RemoteUpload(localPath, remotePath, mode string) (RemoteUploadOutput, error)
RemoteUpload uploads a local file to the remote host.
func RemoteUploadContent ¶ added in v0.3.0
func RemoteUploadContent(remotePath, content, mode string) (RemoteUploadOutput, error)
RemoteUploadContent uploads in-memory content to a remote path.
type TemplateRenderOutput ¶ added in v0.3.0
type TemplateRenderOutput struct {
Content string `json:"content,omitempty"`
Failed bool `json:"failed,omitempty"`
Error string `json:"error,omitempty"`
}
func TemplateRender ¶ added in v0.3.0
func TemplateRender(template string, data map[string]any) (TemplateRenderOutput, error)
TemplateRender evaluates a Go text/template on the host.