add LISTCONFIGS to external special remote protocol
Special remote programs that use GETCONFIG/SETCONFIG are recommended to implement it. The description is not yet used, but will be useful later when adding a way to make initremote list all accepted configs. configParser now takes a RemoteConfig parameter. Normally, that's not needed, because configParser returns a parter, it does not parse it itself. But, it's needed to look at externaltype and work out what external remote program to run for LISTCONFIGS. Note that, while externalUUID is changed to a Maybe UUID, checkExportSupported used to use NoUUID. The code that now checks for Nothing used to behave in some undefined way if the external program made requests that triggered it. Also, note that in externalSetup, once it generates external, it parses the RemoteConfig strictly. That generates a ParsedRemoteConfig, which is thrown away. The reason it's ok to throw that away, is that, if the strict parse succeeded, the result must be the same as the earlier, lenient parse. initremote of an external special remote now runs the program three times. First for LISTCONFIGS, then EXPORTSUPPORTED, and again LISTCONFIGS+INITREMOTE. It would not be hard to eliminate at least one of those, and it should be possible to only run the program once.
This commit is contained in:
parent
1ce722d86f
commit
99cb3e75f1
20 changed files with 158 additions and 76 deletions
10
Remote/S3.hs
10
Remote/S3.hs
|
@ -73,7 +73,7 @@ remote = specialRemoteType $ RemoteType
|
|||
{ typename = "S3"
|
||||
, enumerate = const (findSpecialRemotes "s3")
|
||||
, generate = gen
|
||||
, configParser = pure $ RemoteConfigParser
|
||||
, configParser = const $ pure $ RemoteConfigParser
|
||||
{ remoteConfigFieldParsers =
|
||||
[ optionalStringParser bucketField
|
||||
, optionalStringParser hostField
|
||||
|
@ -230,7 +230,8 @@ s3Setup' ss u mcreds c gc
|
|||
(c', encsetup) <- encryptionSetup c gc
|
||||
c'' <- setRemoteCredPair encsetup c' gc (AWS.creds u) mcreds
|
||||
let fullconfig = c'' `M.union` defaults
|
||||
pc <- either giveup return . parseRemoteConfig fullconfig =<< configParser remote
|
||||
pc <- either giveup return . parseRemoteConfig fullconfig
|
||||
=<< configParser remote fullconfig
|
||||
info <- extractS3Info pc
|
||||
checkexportimportsafe pc info
|
||||
case ss of
|
||||
|
@ -255,7 +256,8 @@ s3Setup' ss u mcreds c gc
|
|||
M.union c' $
|
||||
-- special constraints on key names
|
||||
M.insert mungekeysField (Proposed "ia") defaults
|
||||
pc <- either giveup return . parseRemoteConfig archiveconfig =<< configParser remote
|
||||
pc <- either giveup return . parseRemoteConfig archiveconfig
|
||||
=<< configParser remote archiveconfig
|
||||
info <- extractS3Info pc
|
||||
checkexportimportsafe pc info
|
||||
hdl <- mkS3HandleVar pc gc u
|
||||
|
@ -1234,7 +1236,7 @@ enableBucketVersioning ss info _ _ _ = do
|
|||
Enable oldc -> do
|
||||
oldpc <- either (const mempty) id
|
||||
. parseRemoteConfig oldc
|
||||
<$> configParser remote
|
||||
<$> configParser remote oldc
|
||||
oldinfo <- extractS3Info oldpc
|
||||
when (versioning info /= versioning oldinfo) $
|
||||
giveup "Cannot change versioning= of existing S3 remote."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue