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

Introduce CachePrefix #83

Merged
merged 1 commit into from Jul 10, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rome.cabal
@@ -1,5 +1,5 @@
name: Rome
version: 0.11.1.28
version: 0.12.0.29
synopsis: An S3 cache for Carthage
description: Please see README.md
homepage: https://github.com/blender/Rome
Expand Down
2 changes: 1 addition & 1 deletion app/Main.hs
Expand Up @@ -9,7 +9,7 @@ import System.Exit


romeVersion :: RomeVersion
romeVersion = (0, 11, 1, 28)
romeVersion = (0, 12, 0, 29)



Expand Down
8 changes: 5 additions & 3 deletions src/CommandParsers.hs
Expand Up @@ -19,9 +19,11 @@ import Types.Commands
-- verifyParser :: Parser VerifyFlag
-- verifyParser = VerifyFlag <$> Opts.switch ( Opts.long "verify" <> Opts.help "Verify that the framework has the same hash as specified in the Cartfile.resolved.")

cachePrefixParser :: Parser String
cachePrefixParser = Opts.strOption (Opts.value "" <> Opts.metavar "PREFIX" <> Opts.long "cache-prefix" <> Opts.help "A prefix appended to the top level directories inside the caches. Usefull to separate artifacts between Swift versions.")

skipLocalCacheParser :: Parser SkipLocalCacheFlag
skipLocalCacheParser = SkipLocalCacheFlag <$> Opts.switch ( Opts.long "skip-local-cache" <> Opts.help "Ignore the local cache when performing the operation.")
skipLocalCacheParser = SkipLocalCacheFlag <$> Opts.switch (Opts.long "skip-local-cache" <> Opts.help "Ignore the local cache when performing the operation.")

reposParser :: Opts.Parser [GitRepoName]
reposParser = Opts.many (Opts.argument (GitRepoName <$> str) (Opts.metavar "FRAMEWORKS..." <> Opts.help "Zero or more framework names. If zero, all frameworks and dSYMs are uploaded."))
Expand All @@ -35,7 +37,7 @@ platformsParser = (nub . concat <$> Opts.some (Opts.option (eitherReader platfor
platformListOrError s = mapM platformOrError $ splitPlatforms s

udcPayloadParser :: Opts.Parser RomeUDCPayload
udcPayloadParser = RomeUDCPayload <$> reposParser <*> platformsParser {- <*> verifyParser-} <*> skipLocalCacheParser
udcPayloadParser = RomeUDCPayload <$> reposParser <*> platformsParser <*> cachePrefixParser <*> skipLocalCacheParser

uploadParser :: Opts.Parser RomeCommand
uploadParser = pure Upload <*> udcPayloadParser
Expand All @@ -51,7 +53,7 @@ listModeParser = (
<|> Opts.flag All All (Opts.help "Reports missing or present status of frameworks in the cache. Ignores dSYMs.")

listPayloadParser :: Opts.Parser RomeListPayload
listPayloadParser = RomeListPayload <$> listModeParser <*> platformsParser
listPayloadParser = RomeListPayload <$> listModeParser <*> platformsParser <*> cachePrefixParser

listParser :: Opts.Parser RomeCommand
listParser = List <$> listPayloadParser
Expand Down
356 changes: 221 additions & 135 deletions src/Lib.hs

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/Types.hs
Expand Up @@ -11,7 +11,8 @@ import Types.Commands



type UDCEnv = (AWS.Env,{-, VerifyFlag-}SkipLocalCacheFlag, Bool)
type UploadDownloadCmdEnv = (AWS.Env, CachePrefix, SkipLocalCacheFlag, Bool)
type UploadDownloadEnv = (AWS.Env, CachePrefix, Bool)
type RomeMonad = ExceptT String IO
type RepositoryMap = M.Map GitRepoName [FrameworkName]
type InvertedRepositoryMap = M.Map FrameworkName GitRepoName
Expand All @@ -20,6 +21,11 @@ type RomeVersion = (Int, Int, Int, Int)

type GitRepoNameAndVersion = (GitRepoName, Version)

-- | A wrapper around `String` used to specify what prefix to user
-- | when determining remote paths of artifacts

newtype CachePrefix = CachePrefix { _unCachePrefix :: String }
deriving (Show, Eq)

-- | Represents the name of a framework together with its version
data FrameworkVersion = FrameworkVersion { _frameworkName :: FrameworkName
Expand Down
6 changes: 4 additions & 2 deletions src/Types/Commands.hs
Expand Up @@ -10,6 +10,7 @@ data RomeCommand = Upload RomeUDCPayload

data RomeUDCPayload = RomeUDCPayload { _payload :: [GitRepoName]
, _udcPlatforms :: [TargetPlatform]
, _cachePrefix :: String
-- , _verifyFlag :: VerifyFlag
, _skipLocalCacheFlag :: SkipLocalCacheFlag
}
Expand All @@ -20,8 +21,9 @@ data RomeUDCPayload = RomeUDCPayload { _payload :: [GitRepoName]
newtype SkipLocalCacheFlag = SkipLocalCacheFlag { _skipLocalCache :: Bool }
deriving (Show, Eq)

data RomeListPayload = RomeListPayload { _listMode :: ListMode
, _listPlatforms :: [TargetPlatform]
data RomeListPayload = RomeListPayload { _listMode :: ListMode
, _listPlatforms :: [TargetPlatform]
, _listCachePrefix :: String
}
deriving (Show, Eq)

Expand Down
3 changes: 3 additions & 0 deletions src/Utils.hs
Expand Up @@ -373,3 +373,6 @@ greenControlSequence = "\ESC[0;32m"

noColorControlSequence :: String
noColorControlSequence = "\ESC[0m"

third :: (a, b, c) -> c
third (_, _, c) = c