You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
services: collapse duplicated client and process-manager code #3116
internal/services/client.go and manager.go contain copy-pasted functions, unused parameters and dead state. About 100 lines can go, and doing this fixes #3108 as a side effect.
client.go
StartServices, StopServices and RestartServices differ only in verb and HTTP method. Collapse them into one helper.
Use http.NewRequestWithContext in clientRequest, so ctx is finally used, and use io.ReadAll instead of a bytes.Buffer.
Remove the unused w from ListServices.
Make the argument order consistent: w is first in some functions and last in others.
manager.go
Shared config preamble. "Open, lock, read, defer close" of the global process-compose config appears 6 times. Extract withGlobalConfig(func(cfg, file) error) error.
Dead state.globalProcessComposeConfig.Path is written and never read. Pass *os.File explicitly instead of keeping config.File.
Start path.
StartProcessManager builds exec.Command twice.
The foreground and background paths both build and write instance{Pid, Port}. Do that once.
Slice aliasing.append(requestedServices, flags...) can alias the caller's slice. Build args := append([]string{"up"}, requested...) instead.
Unused parameters.
ctx is unused in StopProcessManager, StopAllProcessManagers and AttachToProcessManager.
w is unused in StopAllProcessManagers and AttachToProcessManager.
Activity