25 lines
888 B
Haskell
25 lines
888 B
Haskell
|
|
module Main where
|
||
|
|
|
||
|
|
import MiniStatePlanner.Plan
|
||
|
|
( DeploymentRequest (DeploymentRequest)
|
||
|
|
, Environment (Production, Staging)
|
||
|
|
, PlannedDeployment (PlannedDeployment)
|
||
|
|
, parseRequest
|
||
|
|
, planDeployments
|
||
|
|
, renderPlan
|
||
|
|
)
|
||
|
|
import System.Exit (die)
|
||
|
|
|
||
|
|
main :: IO ()
|
||
|
|
main =
|
||
|
|
case traverse parseRequest ["api:production:3", "worker:staging:1", "cache:production:2"] of
|
||
|
|
Left err -> die err
|
||
|
|
Right requests ->
|
||
|
|
case planDeployments requests of
|
||
|
|
[ PlannedDeployment 1001 1 (DeploymentRequest "api" Production 3)
|
||
|
|
, PlannedDeployment 1002 1 (DeploymentRequest "worker" Staging 1)
|
||
|
|
, PlannedDeployment 1003 2 (DeploymentRequest "cache" Production 2)
|
||
|
|
] | "cache -> production, replicas 2, build 1003, wave 2" `elem` lines (renderPlan (planDeployments requests)) ->
|
||
|
|
putStrLn "test passed"
|
||
|
|
_ -> die "unexpected planning result"
|