aboutsummaryrefslogtreecommitdiff
path: root/Creds.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-06-05 16:23:35 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-06-05 16:23:35 -0400
commitbc5a042b5bfb1999f8450657d5b0721235fbb84c (patch)
tree3a1af4e743ad048045ca53a4a59d4eb8b6f3bd61 /Creds.hs
parente9ab4e21fd215048e63f37d458e69f3f848ed5cb (diff)
S3: Publically accessible buckets can be used without creds.
Diffstat (limited to 'Creds.hs')
-rw-r--r--Creds.hs32
1 files changed, 19 insertions, 13 deletions
diff --git a/Creds.hs b/Creds.hs
index a4074c5c1..68bd1940c 100644
--- a/Creds.hs
+++ b/Creds.hs
@@ -9,8 +9,9 @@ module Creds (
module Types.Creds,
CredPairStorage(..),
setRemoteCredPair,
- getRemoteCredPairFor,
getRemoteCredPair,
+ getRemoteCredPairFor,
+ warnMissingCredPairFor,
getEnvCredPair,
writeCacheCreds,
readCacheCreds,
@@ -74,18 +75,6 @@ setRemoteCredPair _ c storage (Just creds)
{- Gets a remote's credpair, from the environment if set, otherwise
- from the cache in gitAnnexCredsDir, or failing that, from the
- value in RemoteConfig. -}
-getRemoteCredPairFor :: String -> RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
-getRemoteCredPairFor this c storage = maybe missing (return . Just) =<< getRemoteCredPair c storage
- where
- (loginvar, passwordvar) = credPairEnvironment storage
- missing = do
- warning $ unwords
- [ "Set both", loginvar
- , "and", passwordvar
- , "to use", this
- ]
- return Nothing
-
getRemoteCredPair :: RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
getRemoteCredPair c storage = maybe fromcache (return . Just) =<< fromenv
where
@@ -122,6 +111,23 @@ getRemoteCredPair c storage = maybe fromcache (return . Just) =<< fromenv
return $ Just credpair
_ -> error "bad creds"
+getRemoteCredPairFor :: String -> RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
+getRemoteCredPairFor this c storage = go =<< getRemoteCredPair c storage
+ where
+ go Nothing = do
+ warnMissingCredPairFor this storage
+ return Nothing
+ go (Just credpair) = return $ Just credpair
+
+warnMissingCredPairFor :: String -> CredPairStorage -> Annex ()
+warnMissingCredPairFor this storage = warning $ unwords
+ [ "Set both", loginvar
+ , "and", passwordvar
+ , "to use", this
+ ]
+ where
+ (loginvar, passwordvar) = credPairEnvironment storage
+
{- Gets a CredPair from the environment. -}
getEnvCredPair :: CredPairStorage -> IO (Maybe CredPair)
getEnvCredPair storage = liftM2 (,)