convert configParser to Annex action and add passthrough option

Needed so Remote.External can query the external program for its
configs. When the external program does not support the query,
the passthrough option will make all input fields be available.
This commit is contained in:
Joey Hess 2020-01-14 13:18:15 -04:00
parent 8f142a9279
commit c498269a88
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
16 changed files with 70 additions and 47 deletions

View file

@ -77,9 +77,10 @@ adjustExportImportRemoteType rt = rt
, configParser = configparser
}
where
configparser = configParser rt ++ exportImportConfigParser
configparser = addRemoteConfigParser exportImportConfigParsers
<$> configParser rt
setup' st mu cp c gc = do
pc <- either giveup return $ parseRemoteConfig c configparser
pc <- either giveup return . parseRemoteConfig c =<< configparser
let checkconfig supported configured configfield cont =
ifM (supported rt pc gc)
( case st of
@ -87,9 +88,9 @@ adjustExportImportRemoteType rt = rt
| configured pc && isEncrypted pc ->
giveup $ "cannot enable both encryption and " ++ fromProposedAccepted configfield
| otherwise -> cont
Enable oldc ->
let oldpc = either mempty id $ parseRemoteConfig oldc configparser
in if configured pc /= configured oldpc
Enable oldc -> do
oldpc <- either mempty id . parseRemoteConfig oldc <$> configparser
if configured pc /= configured oldpc
then giveup $ "cannot change " ++ fromProposedAccepted configfield ++ " of existing special remote"
else cont
, if configured pc
@ -102,8 +103,8 @@ adjustExportImportRemoteType rt = rt
then giveup "cannot enable importtree=yes without also enabling exporttree=yes"
else setup rt st mu cp c gc
exportImportConfigParser :: [RemoteConfigParser]
exportImportConfigParser =
exportImportConfigParsers :: [RemoteConfigFieldParser]
exportImportConfigParsers =
[ yesNoParser exportTreeField False
, yesNoParser importTreeField False
]