Skip to content

Commit 1326fdb

Browse files
committed
[cli] feat: add ANTI_SECRETS_FILE setting
1 parent a39bfd9 commit 1326fdb

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

cli/anti.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ library
196196
, monad-control
197197
, old-time
198198
, opt-env-conf
199+
, path
199200
, plutus-tx
200201
, process
201202
, purebred-email

cli/src/Options.hs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ module Options
1212
, optionsParser
1313
, parseArgs
1414
, githubAuthOption
15+
, secretsFileOption
1516
) where
1617

1718
import Cli (Command (..))
1819
import Control.Applicative (optional)
20+
import Control.Arrow (left)
1921
import Core.Options
2022
( outputReferenceParser
2123
, tokenIdOption
@@ -34,11 +36,13 @@ import Lib.Options.Secrets (secretsParser)
3436
import OptEnvConf
3537
( Alternative (..)
3638
, Parser
39+
, checkEither
3740
, command
3841
, commands
3942
, env
4043
, help
4144
, long
45+
, mapIO
4246
, metavar
4347
, option
4448
, reader
@@ -47,9 +51,20 @@ import OptEnvConf
4751
, str
4852
, switch
4953
, value
54+
, withYamlConfig
5055
, (<|>)
5156
)
5257
import Oracle.Options (oracleCommandParser)
58+
import Path
59+
( Abs
60+
, File
61+
, Path
62+
, SomeBase (Abs, Rel)
63+
, parseAbsFile
64+
, parseSomeFile
65+
, toFilePath
66+
)
67+
import System.Directory (makeAbsolute)
5368
import User.Agent.Options (agentCommandParser, testRunIdOption)
5469
import User.Agent.Types (TestRunId)
5570
import User.Requester.Options
@@ -221,11 +236,28 @@ parseArgs version =
221236
runParser
222237
version
223238
intro
224-
optionsParser
239+
$ withYamlConfig secretsFileOption optionsParser
225240

226241
retractRequestOptions :: Parser (Box Command)
227242
retractRequestOptions =
228243
fmap (fmap Box) . RetractRequest
229244
<$> mpfsClientOption
230245
<*> walletOption
231246
<*> outputReferenceParser
247+
248+
secretsFileOption :: Parser (Maybe (Path Abs File))
249+
secretsFileOption =
250+
optional
251+
$ parsePath
252+
$ setting
253+
[ long "secrets-file"
254+
, metavar "FILEPATH"
255+
, help "The file path to a YAML file containing secrets"
256+
, reader str
257+
, option
258+
, env "ANTI_SECRETS_FILE"
259+
]
260+
where
261+
parsePath = mapIO absolutize . checkEither (left show . parseSomeFile)
262+
absolutize (Abs fp) = pure fp
263+
absolutize (Rel fp) = makeAbsolute (toFilePath fp) >>= parseAbsFile

cli/src/Oracle/Process.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Data.String.QQ (s)
2727
import GitHub (Auth)
2828
import MPFS.API (mpfsClient)
2929
import OptEnvConf
30-
import Options (githubAuthOption)
30+
import Options (githubAuthOption, secretsFileOption)
3131
import Oracle.Token.Cli
3232
( TokenCommand (..)
3333
, TokenUpdateFailure
@@ -67,7 +67,9 @@ parseArgs =
6767
runParser
6868
version
6969
intro
70-
processOptionsParser
70+
$ withYamlConfig
71+
secretsFileOption
72+
processOptionsParser
7173

7274
data ProcessOptions = ProcessOptions
7375
{ poAuth :: Auth

0 commit comments

Comments
 (0)