Remove workspace-root configuration and use client run directories

This commit is contained in:
2026-10-09 00:32:00 +01:00
parent 4697bb4465
commit c5a5521015
17 changed files with 97 additions and 116 deletions
+7 -26
View File
@@ -162,7 +162,7 @@ func ServerExecutable(executable string) (string, error) {
// ServiceCommand uses the OS service manager directly, without a second supervisor.
func ServiceCommand(ctx context.Context, executable string, args []string, out, stderr io.Writer) error {
help := "Usage: pipelines service enable --workspace-root DIR [--workspace-root DIR] [--db FILE] [--addr HOST:PORT] [--print]\n pipelines service disable | status\nAutostart is per-user, at login. enable starts the server now; --print only previews.\n"
help := "Usage: pipelines service enable [--db FILE] [--addr HOST:PORT] [--print]\n pipelines service disable | status\nAutostart is per-user, at login. enable starts the server now; --print only previews.\nRuns use the directory you invoke pipelines run from.\n"
if len(args) == 0 || args[0] == "--help" || args[0] == "help" {
_, err := io.WriteString(out, help)
return err
@@ -192,34 +192,14 @@ func ServiceCommand(ctx context.Context, executable string, args []string, out,
}
db := f.String("db", defaultDB, "SQLite database file")
addr := f.String("addr", "127.0.0.1:8080", "Server listen address")
var roots []string
f.Func("workspace-root", "Trusted repository root (required; repeatable)", func(value string) error {
path, err := filepath.Abs(value)
if err != nil {
return err
}
path, err = filepath.EvalSymlinks(path)
if err != nil {
return err
}
info, err := os.Stat(path)
if err != nil {
return err
}
if !info.IsDir() {
return fmt.Errorf("workspace root must be a directory")
}
roots = append(roots, path)
return nil
})
if err := f.Parse(args[1:]); err != nil {
if err == flag.ErrHelp {
return nil
}
return err
}
if len(f.Args()) != 0 || len(roots) == 0 {
return fmt.Errorf("service enable requires --workspace-root DIR; no positional arguments")
if len(f.Args()) != 0 {
return fmt.Errorf("service enable takes no positional arguments")
}
if os.Getenv("PIPELINES_NTFY_TOKEN") != "" {
return fmt.Errorf("use PIPELINES_NTFY_TOKEN_FILE for autostart; inline tokens are not saved")
@@ -232,10 +212,11 @@ func ServiceCommand(ctx context.Context, executable string, args []string, out,
if err != nil {
return err
}
d := serviceDefinition{Binary: binary, Directory: roots[0], Args: []string{"-db", database, "-addr", *addr}, Environment: map[string]string{}}
for _, root := range roots {
d.Args = append(d.Args, "-workspace-root", root)
home, err := os.UserHomeDir()
if err != nil {
return err
}
d := serviceDefinition{Binary: binary, Directory: home, Args: []string{"-db", database, "-addr", *addr}, Environment: map[string]string{}}
for _, key := range serviceEnvironmentKeys {
if value, ok := os.LookupEnv(key); ok {
d.Environment[key] = value
+3 -7
View File
@@ -13,7 +13,7 @@ import (
)
func TestServiceDefinitionsQuotePathsAndKeepEnvironmentLimited(t *testing.T) {
d := serviceDefinition{Binary: `/some bin/server`, Directory: `/repo "quoted" 100% $USER`, Args: []string{"-workspace-root", `/repo "quoted" 100% $USER`}, Environment: map[string]string{"PATH": "/usr/bin:/custom bin", "PIPELINES_NTFY_TOKEN_FILE": "/secret & token", "PROVIDER_SECRET": "must-not-export"}}
d := serviceDefinition{Binary: `/some bin/server`, Directory: `/repo "quoted" 100% $USER`, Args: []string{"-db", `/repo "quoted" 100% $USER/data.db`}, Environment: map[string]string{"PATH": "/usr/bin:/custom bin", "PIPELINES_NTFY_TOKEN_FILE": "/secret & token", "PROVIDER_SECRET": "must-not-export"}}
for _, platform := range []string{"linux", "darwin"} {
text, err := d.render(platform)
if err != nil {
@@ -86,8 +86,7 @@ func TestServiceConfigurationPreviewAndLifecycleWithMockOSManager(t *testing.T)
}
home := t.TempDir()
bin := filepath.Join(home, "bin")
root := filepath.Join(home, "repo with spaces")
for _, dir := range []string{bin, root} {
for _, dir := range []string{bin} {
if err := os.MkdirAll(dir, 0700); err != nil {
t.Fatal(err)
}
@@ -115,10 +114,7 @@ func TestServiceConfigurationPreviewAndLifecycleWithMockOSManager(t *testing.T)
if err != nil {
t.Fatal(err)
}
if err := ServiceCommand(ctx, server, []string{"enable"}, &out, &out); err == nil {
t.Fatal("workspace scope must be explicit")
}
args := []string{"enable", "--workspace-root", root}
args := []string{"enable"}
if err := ServiceCommand(ctx, server, append(args, "--print"), &out, &out); err != nil {
t.Fatal(err)
}