This builds on top of #383, and allows for a custom PebbleDir to be passed to cli.Run() in RunOptions to make sure all parts of the codebase use the passed-in values and not fall back on environment variables.
The default behavior of cli.Run(nil) stays unchanged.
Multiple parts of the codebase currently use getEnvPaths() directly to access PEBBLE and PEBBLE_SOCKET:
cli.Run() for the default value of client.Config.Socket (ignores PEBBLE dir)
loadCLIState and saveCLIState in cli for the socket path (both ignore PEBBLE dir)
runDaemon in cmd_run.go, which accesses both pebbleDir and socketPath
With #383, it is possible to pick a different socket path by passing it into cli.Run()'s options. This socket path currently only applies to Pebble client, it does not apply to the daemon part started by pebble run (because of the separate getEnvPaths() in cmd_run.go's runDaemon).
For loadCLIState and saveCLIState (both used by pebble notices and its acknowledgement command pebble okay) this PR makes sure the passed-in socket path is used (otherwise it would default to the environment variable even when a non-nil options value is passed to cli.Run()).
While "Pebble as a server" (pebble run) and "Pebble as a client" can be seen as conceptually different things, both share cli.Run as entry point.
This doesn't affect uses of getEnvPaths (and its exported name GetEnvPaths) in the unit tests.
This builds on top of #383, and allows for a custom
PebbleDir
to be passed tocli.Run()
inRunOptions
to make sure all parts of the codebase use the passed-in values and not fall back on environment variables.The default behavior of
cli.Run(nil)
stays unchanged.Multiple parts of the codebase currently use
getEnvPaths()
directly to accessPEBBLE
andPEBBLE_SOCKET
:cli.Run()
for the default value ofclient.Config.Socket
(ignoresPEBBLE
dir)loadCLIState
andsaveCLIState
incli
for the socket path (both ignorePEBBLE
dir)runDaemon
incmd_run.go
, which accesses bothpebbleDir
andsocketPath
With #383, it is possible to pick a different socket path by passing it into
cli.Run()
's options. This socket path currently only applies to Pebble client, it does not apply to the daemon part started bypebble run
(because of the separategetEnvPaths()
incmd_run.go
'srunDaemon
).For
loadCLIState
andsaveCLIState
(both used bypebble notices
and its acknowledgement commandpebble okay
) this PR makes sure the passed-in socket path is used (otherwise it would default to the environment variable even when a non-nil
options value is passed tocli.Run()
).While "Pebble as a server" (
pebble run
) and "Pebble as a client" can be seen as conceptually different things, both sharecli.Run
as entry point.This doesn't affect uses of
getEnvPaths
(and its exported nameGetEnvPaths
) in the unit tests.