Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix config check
  • Loading branch information
frankli0324 committed Oct 30, 2025
commit 6947d668c1ea8b4387f38bd3cc3659a24deb593d
3 changes: 2 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ var ErrPluginExists = errors.New("a plugin with that name already exists")
var ErrPluginNotFound = errors.New("no plugin found")
var ErrPluginNoType = errors.New("plugin: field `process` or `wasm` required")
var ErrPluginBothTypes = errors.New("plugin: `process` and `wasm` cannot both be defined")
var ErrPluginProcessNoCmd = errors.New("plugin: missing process command")
var ErrPluginProcessTooManyCmd = errors.New("plugin: only one of `cmd` or `go_package` is allowed for process plugin")
var ErrPluginProcessNoCmd = errors.New("plugin: missing `cmd` or `go_package` for process plugin")

var ErrInvalidDatabase = errors.New("database must be managed or have a non-empty URI")
var ErrManagedDatabaseNoProject = errors.New(`managed databases require a cloud project
Expand Down
7 changes: 5 additions & 2 deletions internal/config/v_two.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ func v2ParseConfig(rd io.Reader) (Config, error) {
if conf.Plugins[i].Process != nil && conf.Plugins[i].WASM != nil {
return conf, ErrPluginBothTypes
}
if conf.Plugins[i].Process != nil {
if conf.Plugins[i].Process.Cmd == "" {
if r := conf.Plugins[i].Process; r != nil {
switch {
case r.Cmd != "" && r.GoPkg != "":
return conf, ErrPluginProcessTooManyCmd
case r.Cmd == "" && r.GoPkg == "":
return conf, ErrPluginProcessNoCmd
}
}
Expand Down
8 changes: 2 additions & 6 deletions internal/ext/process/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,21 @@ func (r *Runner) Invoke(ctx context.Context, method string, args any, reply any,

var cmd *exec.Cmd
switch {
case r.Cmd != "" && r.GoPkg == "":
case r.Cmd != "":
// Check if the output plugin exists
path, err := exec.LookPath(r.Cmd)
if err != nil {
return fmt.Errorf("process: %s not found", r.Cmd)
}
cmd = exec.CommandContext(ctx, path, method)
case r.Cmd == "" && r.GoPkg != "":
case r.GoPkg != "":
// Check if the go binary exists
path, err := exec.LookPath("go")
if err != nil {
return fmt.Errorf("go binary required to run go package %s", r.GoPkg)
}
cmd = exec.CommandContext(ctx, path, method)
cmd.Args = []string{"run", r.GoPkg}
case r.Cmd != "" && r.GoPkg != "":
return fmt.Errorf("only one of cmd or go_package is allowed")
default:
return fmt.Errorf("cmd and go_package cannot both be empty for process plugin")
}

cmd.Stdin = bytes.NewReader(stdin)
Expand Down
Loading