be stricter about rejecting invalid configurations for remotes
This is a first step toward that goal, using the ProposedAccepted type in RemoteConfig lets initremote/enableremote reject bad parameters that were passed in a remote's configuration, while avoiding enableremote rejecting bad parameters that have already been stored in remote.log This does not eliminate every place where a remote config is parsed and a default value is used if the parse false. But, I did fix several things that expected foo=yes/no and so confusingly accepted foo=true but treated it like foo=no. There are still some fields that are parsed with yesNo but not not checked when initializing a remote, and there are other fields that are parsed in other ways and not checked when initializing a remote. This also lays groundwork for rejecting unknown/typoed config keys.
This commit is contained in:
parent
ea3f206fd1
commit
71ecfbfccf
45 changed files with 395 additions and 224 deletions
|
@ -46,6 +46,8 @@ import Config
|
|||
import Config.GitConfig
|
||||
import Config.DynamicConfig
|
||||
import Types.Group
|
||||
import Types.ProposedAccepted
|
||||
import Annex.SpecialRemote.Config
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Map as M
|
||||
|
@ -125,7 +127,7 @@ setRepoConfig uuid mremote oldc newc = do
|
|||
case M.lookup uuid m of
|
||||
Nothing -> noop
|
||||
Just remoteconfig -> configSet uuid $
|
||||
M.insert "preferreddir" dir remoteconfig
|
||||
M.insert (Proposed "preferreddir") (Proposed dir) remoteconfig
|
||||
when groupChanged $ do
|
||||
liftAnnex $ case repoGroup newc of
|
||||
RepoGroupStandard g -> setStandardGroup uuid g
|
||||
|
@ -243,7 +245,7 @@ checkAssociatedDirectory cfg (Just r) = do
|
|||
_ -> noop
|
||||
|
||||
getRepoInfo :: Maybe Remote.Remote -> Maybe Remote.RemoteConfig -> Widget
|
||||
getRepoInfo (Just r) (Just c) = case M.lookup "type" c of
|
||||
getRepoInfo (Just r) (Just c) = case fromProposedAccepted <$> M.lookup typeField c of
|
||||
Just "S3"
|
||||
#ifdef WITH_S3
|
||||
| S3.configIA c -> IA.getRepoInfo c
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue