toolsrv: use ToolsPath() for local ollie-remote bootstrap
Remove hardcoded ~/.config/ollie/tools path and XXX hack. Local ollie-remote now inherits OLLIE_TOOLS_PATH from the environment via os.Environ(), same as remote bootstrap sets it explicitly. ToolsPath() reads OLLIE_TOOLS_PATH with fallback to ~/.config/ollie/tools. Tools added to the directory are picked up immediately on next tool_load — no restart needed. Removed dead appendEnvVar helper.
This commit is contained in:
parent
8f09aa2060
commit
3f1e8bfd8b
|
|
@ -37,8 +37,8 @@ func localDial(ctx context.Context, cwd string, opts ...Option) (*transport, err
|
|||
return nil, fmt.Errorf("bootstrap: ollie-remote not found")
|
||||
}
|
||||
|
||||
// Bootstrap: verify tools directory.
|
||||
toolsDir := filepath.Join(os.Getenv("HOME"), ".config", "ollie", "tools")
|
||||
// Verify tools directory is accessible via ToolsPath().
|
||||
toolsDir := ToolsPath()
|
||||
if _, err := os.Stat(toolsDir); err != nil {
|
||||
return nil, fmt.Errorf("bootstrap: tools directory not found at %s", toolsDir)
|
||||
}
|
||||
|
|
@ -64,9 +64,10 @@ func localDial(ctx context.Context, cwd string, opts ...Option) (*transport, err
|
|||
Pdeathsig: syscall.SIGTERM,
|
||||
}
|
||||
|
||||
// XXX: set OLLIE_TOOLS_PATH explicitly until ToolsPath() default is updated.
|
||||
// Inherit environment — OLLIE_TOOLS_PATH flows through naturally.
|
||||
// ollie-remote reads it via ToolsPath() at runtime, picking up new
|
||||
// tools from disk without restart.
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = appendEnvVar(cmd.Env, "OLLIE_TOOLS_PATH", toolsDir)
|
||||
|
||||
// Watch stderr for readiness signal.
|
||||
stderrPipe, err := cmd.StderrPipe()
|
||||
|
|
@ -283,18 +284,6 @@ func shellEscape(s string) string {
|
|||
return "'" + strings.ReplaceAll(s, "'", "'\\''") + "'"
|
||||
}
|
||||
|
||||
// appendEnvVar replaces or appends a KEY=VALUE in an env slice.
|
||||
func appendEnvVar(env []string, key, value string) []string {
|
||||
prefix := key + "="
|
||||
for i, e := range env {
|
||||
if strings.HasPrefix(e, prefix) {
|
||||
env[i] = prefix + value
|
||||
return env
|
||||
}
|
||||
}
|
||||
return append(env, prefix+value)
|
||||
}
|
||||
|
||||
// runtimeDir returns XDG_RUNTIME_DIR or a fallback.
|
||||
func runtimeDir() string {
|
||||
if d := os.Getenv("XDG_RUNTIME_DIR"); d != "" {
|
||||
|
|
|
|||
Loading…
Reference in New Issue