1module Docker.Types where
3import Control.Monad.Except (ExceptT, runExceptT)
4import Control.Monad.Reader (ReaderT, runReaderT)
5import Data.Aeson (FromJSON, ToJSON, genericParseJSON,
6 genericToJSON, parseJSON, toJSON)
7import Data.Aeson.Types (defaultOptions, fieldLabelModifier)
8import qualified Data.ByteString.Lazy as BL
9import Data.Char (toUpper)
10import Data.Text (Text)
11import qualified Data.Text as T
12import GHC.Generics (Generic)
13import qualified Network.HTTP.Client as HTTP
19type Request = HTTP.Request
20type Response = HTTP.Response BL.ByteString
22data DockerClientOpts m = DockerClientOpts {
23 http :: Request -> m Response
24 , apiVersion :: ApiVersion
28type DockerT m a = ReaderT (DockerClientOpts m) (ExceptT String m) a
30runDockerT :: (Monad m) => DockerClientOpts m -> DockerT m a -> m (Either String a)
31runDockerT opts a = runExceptT $ runReaderT a opts
32-- runDockerT opts a = (runExceptT .) . flip runReaderT opts a
34data ListOpts = ListOpts
36 } deriving (Eq, Show, Generic)
38instance ToJSON ListOpts
39instance FromJSON ListOpts
41defaultClientOpts :: DockerClientOpts IO
42defaultClientOpts = DockerClientOpts
44 , apiVersion = "v1.22"
45 , baseUrl = "http://127.0.0.1:2375/"
48data DockerVersion = DockerVersion
53 , kernelVersion :: Text
54 } deriving (Show, Eq, Generic)
57instance ToJSON DockerVersion where
58 toJSON = genericToJSON defaultOptions {
59 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
61instance FromJSON DockerVersion where
62 parseJSON = genericParseJSON defaultOptions {
63 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
66data Container = Container
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list