40 lines
1.5 KiB
Haskell

module Main where
import MiniResolution.Plan
( Environment (Production, Staging)
, ReleaseTrack (Candidate, Stable)
, ResolvedDeployment (ResolvedDeployment)
, catalog
, parseRequest
, renderPlan
, resolveRequests
)
import System.Exit (die)
main :: IO ()
main =
case traverse parseRequest ["api:production:stable", "worker:staging:candidate", "auth:production:stable"] of
Left err -> die err
Right requests ->
case
( resolveRequests catalog requests
, traverse parseRequest ["worker:production:stable"] >>= resolveRequests catalog
) of
( Right
[ ResolvedDeployment "api" Production "registry.example/api:2026.04.1" 3 False
, ResolvedDeployment "worker" Staging "registry.example/worker:2026.05-beta2" 2 False
, ResolvedDeployment "auth" Production "registry.example/auth:2026.04.3" 4 False
]
, Left _
) | "auth -> production, image registry.example/auth:2026.04.3, replicas 4, approval not-required"
`elem`
lines
( renderPlan
[ ResolvedDeployment "api" Production "registry.example/api:2026.04.1" 3 False
, ResolvedDeployment "worker" Staging "registry.example/worker:2026.05-beta2" 2 False
, ResolvedDeployment "auth" Production "registry.example/auth:2026.04.3" 4 False
]
) ->
putStrLn "test passed"
_ -> die "unexpected traverse resolution result"