summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkfine <>2018-01-17 23:45:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-01-17 23:45:00 (GMT)
commit0be36a09312da235650daf316995408efefe3e0d (patch)
treee128f5c0253d2881fcf3213b3cfa16d1796c92ee
parent611a300c9a4347e5f411f9dd584853c3af14e3e6 (diff)
version 0.3.400.3.40
-rw-r--r--main/actor.hs3
-rw-r--r--src/Network/AWS/Wolf/Act.hs29
-rw-r--r--src/Network/AWS/Wolf/Prelude.hs6
-rw-r--r--wolf.cabal2
4 files changed, 26 insertions, 14 deletions
diff --git a/main/actor.hs b/main/actor.hs
index ed4d438..6708f4d 100644
--- a/main/actor.hs
+++ b/main/actor.hs
@@ -30,6 +30,8 @@ data Args = Args
-- ^ Copy working directory.
, local :: Bool
-- ^ Run locally, not in a temp directory.
+ , include :: [FilePath]
+ -- ^ Optional artifacts to filter.
, command :: String
-- ^ Command to run.
} deriving (Show, Generic)
@@ -51,4 +53,5 @@ main = do
(fromMaybe 1 $ num args)
(nocopy args)
(local args)
+ (include args)
(command args)
diff --git a/src/Network/AWS/Wolf/Act.hs b/src/Network/AWS/Wolf/Act.hs
index 750da95..913b04f 100644
--- a/src/Network/AWS/Wolf/Act.hs
+++ b/src/Network/AWS/Wolf/Act.hs
@@ -22,8 +22,8 @@ import System.Process
-- | S3 copy call.
--
-cp :: MonadIO m => FilePath -> FilePath -> m ()
-cp f t = liftIO $ callProcess "aws" [ "s3", "cp", "--quiet", "--recursive", f, t ]
+cp :: MonadIO m => [FilePath] -> m ()
+cp = liftIO . callProcess "aws" . (["s3", "cp", "--quiet", "--recursive"] <>)
-- | Key to download and upload objects from.
--
@@ -35,17 +35,20 @@ key = do
-- | Download artifacts to the store input directory.
--
-download :: MonadAmazonStore c m => FilePath -> m ()
-download dir = do
- traceInfo "download" [ "dir" .= dir ]
- flip cp dir =<< key
+download :: MonadAmazonStore c m => FilePath -> [FilePath] -> m ()
+download dir includes = do
+ traceInfo "download" [ "dir" .= dir, "includes" .= includes ]
+ let includes' = bool ([ "--exclude", "*" ] <> interleave (repeat "--include") includes) mempty $ null includes
+ k <- key
+ cp $ includes' <> [ k, dir ]
-- | Upload artifacts from the store output directory.
--
upload :: MonadAmazonStore c m => FilePath -> m ()
upload dir = do
traceInfo "upload" [ "dir" .= dir ]
- cp dir =<< key
+ k <- key
+ cp [ dir, k ]
-- | callCommand wrapper that maybe returns an exception.
--
@@ -72,8 +75,8 @@ check = maybe (pure False) (liftIO . doesFileExist)
-- | Actor logic - poll for work, download artifacts, run command, upload artifacts.
--
-act :: MonadConf c m => Text -> Bool -> Bool -> String -> m ()
-act queue nocopy local command =
+act :: MonadConf c m => Text -> Bool -> Bool -> [FilePath] -> String -> m ()
+act queue nocopy local includes command =
preConfCtx [ "label" .= LabelAct ] $
runAmazonWorkCtx queue $ do
traceInfo "poll" mempty
@@ -94,7 +97,7 @@ act queue nocopy local command =
osd <- outputDirectory sd
writeJson (dd </> "control.json") (Control uid')
writeText (dd </> "input.json") input
- download isd
+ download isd includes
e <- run command
upload osd
output <- readText (dd </> "output.json")
@@ -107,8 +110,8 @@ act queue nocopy local command =
-- | Run actor from main with config file.
--
-actMain :: MonadControl m => FilePath -> Maybe FilePath -> Maybe Text -> Maybe Text -> Maybe Text -> Text -> Int -> Bool -> Bool -> String -> m ()
-actMain cf quiesce domain bucket prefix queue num nocopy local command =
+actMain :: MonadControl m => FilePath -> Maybe FilePath -> Maybe Text -> Maybe Text -> Maybe Text -> Text -> Int -> Bool -> Bool -> [FilePath] -> String -> m ()
+actMain cf quiesce domain bucket prefix queue num nocopy local includes command =
runCtx $ runTop $ do
conf <- readYaml cf
let conf' = override cPrefix prefix $ override cBucket bucket $ override cDomain domain conf
@@ -117,4 +120,4 @@ actMain cf quiesce domain bucket prefix queue num nocopy local command =
ok <- check quiesce
when ok $
liftIO exitSuccess
- act queue nocopy local command
+ act queue nocopy local includes command
diff --git a/src/Network/AWS/Wolf/Prelude.hs b/src/Network/AWS/Wolf/Prelude.hs
index 09abf45..82fadbd 100644
--- a/src/Network/AWS/Wolf/Prelude.hs
+++ b/src/Network/AWS/Wolf/Prelude.hs
@@ -8,6 +8,7 @@ module Network.AWS.Wolf.Prelude
( module Exports
, runConcurrent
, override
+ , interleave
) where
import Control.Concurrent.Async.Lifted
@@ -22,3 +23,8 @@ runConcurrent = void . runConcurrently . traverse Concurrently
--
override :: ASetter s s a b -> Maybe b -> s -> s
override k v c = maybe c (flip (set k) c) v
+
+-- | Interleave arrays.
+--
+interleave :: [a] -> [a] -> [a]
+interleave xs ys = concat $ zipWith (\x y -> [x, y]) xs ys
diff --git a/wolf.cabal b/wolf.cabal
index 2704616..b69ef63 100644
--- a/wolf.cabal
+++ b/wolf.cabal
@@ -1,5 +1,5 @@
name: wolf
-version: 0.3.39
+version: 0.3.40
synopsis: Amazon Simple Workflow Service Wrapper.
description: Wolf is a wrapper around Amazon Simple Workflow Service.
homepage: https://github.com/swift-nav/wolf