Skip to content

Commit e13d256

Browse files
authored
Merge pull request #99 from input-output-hk/clr/paths
Honor KES_AGENT_CONTROL_PATH , add tests.
2 parents ac88b37 + a3f532d commit e13d256

3 files changed

Lines changed: 388 additions & 5 deletions

File tree

kes-agent/cli/AgentMain.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pNormalModeOptions =
233233
<> metavar "PATH"
234234
<> help
235235
( "Socket address for 'control' connections (empty to disable). "
236-
<> "($KES_AGENT_SERVICE_PATH)"
236+
<> "($KES_AGENT_CONTROL_PATH)"
237237
)
238238
)
239239
<*> ( Set.fromList

kes-agent/cli/ControlMain.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,16 @@ instance Semigroup CommonOptions where
6565
(re1 <|> re2)
6666
(ra1 <|> ra2)
6767

68+
-- | The control socket the client connects to when neither @--control-address@
69+
-- nor @KES_AGENT_CONTROL_PATH@ is supplied. Applied as the final fallback in
70+
-- 'mkControlClientOptions', consistent with how the other option defaults are
71+
-- resolved at the point of use.
72+
defaultControlSocketPath :: FilePath
73+
defaultControlSocketPath = "/tmp/kes-agent-control.socket"
74+
6875
defCommonOptions :: CommonOptions =
6976
CommonOptions
70-
{ optControlPath = Just "/tmp/kes-agent-control.socket"
77+
{ optControlPath = Nothing
7178
, optVerbosity = Just 0
7279
, optRetryDelay = Nothing
7380
, optRetryExponential = Nothing
@@ -373,7 +380,7 @@ formatReason RecvErrorUnknown = "unknown error"
373380

374381
mkControlClientOptions :: CommonOptions -> IOManager -> IO (ControlClientOptions IO Socket SockAddr)
375382
mkControlClientOptions opts ioManager = do
376-
controlPath <- maybe (error "No control address") return (optControlPath opts)
383+
let controlPath = fromMaybe defaultControlSocketPath (optControlPath opts)
377384

378385
let retryDelay = fromMaybe 1000 $ optRetryDelay opts
379386
let retryExponential = fromMaybe False $ optRetryExponential opts
@@ -522,7 +529,7 @@ runGetInfo opt' = withIOManager $ \ioManager -> do
522529
let cPutStrLn = hcPutStrLn cmode stdout
523530
cPutStrLn (bold defaultColor) $ printf "--- Agent ---"
524531
printf "Agent version: %s\n" $ fromMaybe "<unknown>" (agentInfoProgramVersion info)
525-
printf "Connected via: %s\n" $ fromMaybe "<unknown>" (optControlPath opt')
532+
printf "Connected via: %s\n" $ fromMaybe defaultControlSocketPath (optControlPath opt)
526533
printf "Current time: %s\n" $ show (agentInfoCurrentTime info)
527534
printf "Current KES period: %u\n" (unKESPeriod $ agentInfoCurrentKESPeriod info)
528535
printf "Current KES period started: %s\n" $

0 commit comments

Comments
 (0)