2019-10-10 16:48:26 +00:00
|
|
|
{- git-annex special remote configuration
|
|
|
|
-
|
|
|
|
- Copyright 2019 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Annex.SpecialRemote.Config where
|
|
|
|
|
|
|
|
import Common
|
2019-10-10 19:31:10 +00:00
|
|
|
import Types.Remote (RemoteConfigField, RemoteConfig)
|
2019-10-10 16:48:26 +00:00
|
|
|
|
|
|
|
import qualified Data.Map as M
|
2019-10-10 19:46:12 +00:00
|
|
|
import qualified Data.Set as S
|
2019-10-10 16:48:26 +00:00
|
|
|
|
|
|
|
{- The name of a configured remote is stored in its config using this key. -}
|
2019-10-10 19:31:10 +00:00
|
|
|
nameField :: RemoteConfigField
|
|
|
|
nameField = "name"
|
2019-10-10 16:48:26 +00:00
|
|
|
|
|
|
|
{- The name of a sameas remote is stored using this key instead.
|
|
|
|
- This prevents old versions of git-annex getting confused. -}
|
2019-10-10 19:31:10 +00:00
|
|
|
sameasNameField :: RemoteConfigField
|
|
|
|
sameasNameField = "sameas-name"
|
2019-10-10 16:48:26 +00:00
|
|
|
|
|
|
|
lookupName :: RemoteConfig -> Maybe String
|
2019-10-10 19:31:10 +00:00
|
|
|
lookupName c = M.lookup nameField c <|> M.lookup sameasNameField c
|
2019-10-10 16:48:26 +00:00
|
|
|
|
|
|
|
{- The uuid that a sameas remote is the same as is stored in this key. -}
|
2019-10-10 19:31:10 +00:00
|
|
|
sameasUUIDField :: RemoteConfigField
|
|
|
|
sameasUUIDField = "sameas-uuid"
|
2019-10-10 16:48:26 +00:00
|
|
|
|
|
|
|
{- The type of a remote is stored in its config using this key. -}
|
2019-10-10 19:31:10 +00:00
|
|
|
typeField :: RemoteConfigField
|
|
|
|
typeField = "type"
|
2019-10-10 16:48:26 +00:00
|
|
|
|
2019-10-10 19:31:10 +00:00
|
|
|
autoEnableField :: RemoteConfigField
|
|
|
|
autoEnableField = "autoenable"
|
2019-10-10 16:48:26 +00:00
|
|
|
|
2019-10-10 19:46:12 +00:00
|
|
|
encryptionField :: RemoteConfigField
|
|
|
|
encryptionField = "encryption"
|
|
|
|
|
|
|
|
{- A remote with sameas-uuid set will inherit these values from the config
|
|
|
|
- of that uuid. These values cannot be overridden. -}
|
|
|
|
sameasInherits :: S.Set RemoteConfigField
|
|
|
|
sameasInherits = S.fromList
|
|
|
|
[ encryptionField
|
|
|
|
-- TODO more encryption related fields
|
|
|
|
]
|