Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/149 env variables #150

Merged
merged 2 commits into from
Sep 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rome.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Rome
version: 0.17.1.49
version: 0.17.2.50
synopsis: A cache for Carthage
description: Please see README.md
homepage: https://github.com/blender/Rome
Expand Down
2 changes: 1 addition & 1 deletion Rome.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Rome'
s.version = '0.17.1.49'
s.version = '0.17.2.50'
s.summary = 'A cache tool for Carthage'
s.homepage = 'https://github.com/blender/Rome'
s.source = { :http => "#{s.homepage}/releases/download/v#{s.version}/rome.zip" }
Expand Down
2 changes: 1 addition & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import System.Exit


romeVersion :: RomeVersion
romeVersion = (0, 17, 1, 49)
romeVersion = (0, 17, 2, 50)



Expand Down
31 changes: 21 additions & 10 deletions src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ runRomeWithOptions
runRomeWithOptions (RomeOptions options romefilePath verbose) romeVersion = do
absoluteRomefilePath <- liftIO $ absolutizePath romefilePath
case options of
Utils utilsPayload -> runUtilsCommand options absoluteRomefilePath verbose romeVersion
otherCommad -> runUDCCommand options absoluteRomefilePath verbose romeVersion
Utils utilsPayload ->
runUtilsCommand options absoluteRomefilePath verbose romeVersion
otherCommad ->
runUDCCommand options absoluteRomefilePath verbose romeVersion

runUtilsCommand :: RomeCommand -> FilePath -> Bool -> RomeVersion -> RomeMonad ()
runUtilsCommand
:: RomeCommand -> FilePath -> Bool -> RomeVersion -> RomeMonad ()
runUtilsCommand command absoluteRomefilePath verbose romeVersion =
case command of
Utils _ -> do
Expand Down Expand Up @@ -1075,15 +1078,18 @@ filterAccordingToListMode Commands.Present = filter _isAvailable
-- | then if not found the region is read via `Configuration.getS3ConfigFile`
-- | looking at the _AWS_PROFILE_ environment variable
-- | or falling back to _default_ profile.
discoverRegion :: MonadIO m => ExceptT String m AWS.Region
discoverRegion :: (MonadIO m, MonadCatch m) => ExceptT String m AWS.Region
discoverRegion = do
envRegion <-
liftIO $ maybeToEither "No env variable AWS_REGION found. " <$> lookupEnv
"AWS_REGION"
f <- getS3ConfigFile
profile <- liftIO $ lookupEnv "AWS_PROFILE"
let eitherText = ExceptT . return $ envRegion >>= AWS.fromText . T.pack
eitherText <|> getRegionFromFile f (fromMaybe "default" profile)
let eitherEnvRegion = ExceptT . return $ envRegion >>= AWS.fromText . T.pack
let
eitherFileRegion =
(getS3ConfigFile >>= flip getRegionFromFile (fromMaybe "default" profile))
`catch` \(e :: IOError) -> ExceptT . return . Left . show $ e
eitherEnvRegion <|> eitherFileRegion



Expand All @@ -1103,17 +1109,22 @@ getRegionFromFile f profile = fromFile f $ \file -> ExceptT . return $ do
-- | then if not found the endpoint is read via `Configuration.getS3ConfigFile`
-- | looking at the _AWS_PROFILE_ environment variable
-- | or falling back to _default_ profile.
discoverEndpoint :: MonadIO m => ExceptT String m URL
discoverEndpoint :: (MonadIO m, MonadCatch m) => ExceptT String m URL
discoverEndpoint = do
maybeString <- liftIO $ lookupEnv "AWS_ENDPOINT"
let envEndpointURL =
maybeToEither "No env variable AWS_ENDPOINT found. "
$ maybeString
>>= importURL
profile <- liftIO $ lookupEnv "AWS_PROFILE"
let fileEndpointURL = liftIO getS3ConfigFile
let
fileEndPointURL =
( getS3ConfigFile
>>= flip getEndpointFromFile (fromMaybe "default" profile)
(ExceptT . return $ envEndpointURL) <|> fileEndpointURL
)
`catch` \(e :: IOError) -> ExceptT . return . Left . show $ e
(ExceptT . return $ envEndpointURL) <|> fileEndPointURL




Expand Down