{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Stack.Types.Docker
( DockerException (..)
, DockerMonoidRepoOrImage (..)
, DockerOpts (..)
, DockerOptsMonoid (..)
, DockerStackExe (..)
, Mount (..)
, VersionRangeJSON (..)
, dockerAutoPullArgName
, dockerCmdName
, dockerContainerNameArgName
, dockerContainerPlatform
, dockerDetachArgName
, dockerEnableArgName
, dockerEntrypointArgName
, dockerEnvArgName
, dockerHelpOptName
, dockerImageArgName
, dockerMountArgName
, dockerMountModeArgName
, dockerNetworkArgName
, dockerPersistArgName
, dockerPullCmdName
, dockerRegistryLoginArgName
, dockerRegistryPasswordArgName
, dockerRegistryUsernameArgName
, dockerRepoArgName
, dockerRequireDockerVersionArgName
, dockerRunArgsArgName
, dockerSetUserArgName
, dockerStackExeArgName
, dockerStackExeDownloadVal
, dockerStackExeHostVal
, dockerStackExeImageVal
, parseDockerStackExe
, reExecArgName
) where
import Data.Aeson.Types ( FromJSON (..), withText )
import Data.Aeson.WarningParser
( WithJSONWarnings, (..:), (..:?), (..!=), withObjectWarnings
)
import Data.List ( intercalate )
import qualified Data.Text as T
import Distribution.System ( Arch (..), OS (..), Platform (..) )
import Distribution.Text ( display, simpleParse )
import Distribution.Version ( anyVersion )
import Generics.Deriving.Monoid ( mappenddefault, memptydefault )
import Path ( parseAbsFile )
import Stack.Constants ( stackProgName )
import Stack.Prelude hiding ( Display (..) )
import Stack.Types.Version
( IntersectingVersionRange (..), VersionRange
, versionRangeText
)
import Text.Read ( Read (..) )
data DockerException
= DockerMustBeEnabledException
| OnlyOnHostException
| InspectFailedException String
| NotPulledException String
| InvalidImagesOutputException String
| InvalidPSOutputException String
| InvalidInspectOutputException String
| PullFailedException String
| DockerTooOldException Version Version
| DockerVersionProhibitedException [Version] Version
| BadDockerVersionException VersionRange Version
| InvalidVersionOutputException
| HostStackTooOldException Version (Maybe Version)
| ContainerStackTooOldException Version Version
| CannotDetermineProjectRootException
| DockerNotInstalledException
| UnsupportedStackExeHostPlatformException
| DockerStackExeParseException String
deriving (Int -> DockerException -> ShowS
[DockerException] -> ShowS
DockerException -> [Char]
(Int -> DockerException -> ShowS)
-> (DockerException -> [Char])
-> ([DockerException] -> ShowS)
-> Show DockerException
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DockerException -> ShowS
showsPrec :: Int -> DockerException -> ShowS
$cshow :: DockerException -> [Char]
show :: DockerException -> [Char]
$cshowList :: [DockerException] -> ShowS
showList :: [DockerException] -> ShowS
Show, Typeable)
instance Exception DockerException where
displayException :: DockerException -> [Char]
displayException DockerException
DockerMustBeEnabledException =
[Char]
"Error: [S-3223]\n"
[Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
"Docker must be enabled in your configuration file to use this \
\command."
displayException DockerException
OnlyOnHostException =
[Char]
"Error: [S-9779]\n"
[Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
"This command must be run on host OS (not in a Docker container)."
displayException (InspectFailedException [Char]
image) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-9105]\n"
, [Char]
"'docker inspect' failed for image after pull: "
, [Char]
image
, [Char]
"."
]
displayException (NotPulledException [Char]
image) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-6626]\n"
, [Char]
"The Docker image referenced by your configuration file"
, [Char]
" has not\nbeen downloaded:\n "
, [Char]
image
, [Char]
"\n\nRun '"
, [[Char]] -> [Char]
unwords [[Char]
stackProgName, [Char]
dockerCmdName, [Char]
dockerPullCmdName]
, [Char]
"' to download it, then try again."
]
displayException (InvalidImagesOutputException [Char]
l) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-5841]\n"
, [Char]
"Invalid 'docker images' output line: '"
, [Char]
l
, [Char]
"'."
]
displayException (InvalidPSOutputException [Char]
l) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-9608]\n"
, [Char]
"Invalid 'docker ps' output line: '"
, [Char]
l
,[Char]
"'."
]
displayException (InvalidInspectOutputException [Char]
msg) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-2240]\n"
, [Char]
"Invalid 'docker inspect' output: "
, [Char]
msg
, [Char]
"."
]
displayException (PullFailedException [Char]
image) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-6092]\n"
, [Char]
"Could not pull Docker image:\n "
, [Char]
image
, [Char]
"\nThere may not be an image on the registry for your resolver's LTS \
\version in\n"
, [Char]
"your configuration file."
]
displayException (DockerTooOldException Version
minVersion Version
haveVersion) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-6281]\n"
, [Char]
"Minimum docker version '"
, Version -> [Char]
versionString Version
minVersion
, [Char]
"' is required by "
, [Char]
stackProgName
, [Char]
" (you have '"
, Version -> [Char]
versionString Version
haveVersion
, [Char]
"')."
]
displayException (DockerVersionProhibitedException [Version]
prohibitedVersions Version
haveVersion) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-8252]\n"
, [Char]
"These Docker versions are incompatible with "
, [Char]
stackProgName
, [Char]
" (you have '"
, Version -> [Char]
versionString Version
haveVersion
, [Char]
"'): "
, [Char] -> [[Char]] -> [Char]
forall a. [a] -> [[a]] -> [a]
intercalate [Char]
", " ((Version -> [Char]) -> [Version] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map Version -> [Char]
versionString [Version]
prohibitedVersions)
, [Char]
"."
]
displayException (BadDockerVersionException VersionRange
requiredRange Version
haveVersion) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-6170]\n"
, [Char]
"The version of 'docker' you are using ("
, Version -> [Char]
forall a. Show a => a -> [Char]
show Version
haveVersion
, [Char]
") is outside the required\n"
, [Char]
"version range specified in stack.yaml ("
, Text -> [Char]
T.unpack (VersionRange -> Text
versionRangeText VersionRange
requiredRange)
, [Char]
")."
]
displayException DockerException
InvalidVersionOutputException =
[Char]
"Error: [S-5827]\n"
[Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
"Cannot get Docker version (invalid 'docker --version' output)."
displayException (HostStackTooOldException Version
minVersion (Just Version
hostVersion)) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-7112]\n"
, [Char]
"The host's version of '"
, [Char]
stackProgName
, [Char]
"' is too old for this Docker image.\nVersion "
, Version -> [Char]
versionString Version
minVersion
, [Char]
" is required; you have "
, Version -> [Char]
versionString Version
hostVersion
, [Char]
"."
]
displayException (HostStackTooOldException Version
minVersion Maybe Version
Nothing) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-7112]\n"
, [Char]
"The host's version of '"
, [Char]
stackProgName
, [Char]
"' is too old.\nVersion "
, Version -> [Char]
versionString Version
minVersion
, [Char]
" is required."
]
displayException (ContainerStackTooOldException Version
requiredVersion Version
containerVersion) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-5832]\n"
, [Char]
"The Docker container's version of '"
, [Char]
stackProgName
, [Char]
"' is too old.\nVersion "
, Version -> [Char]
versionString Version
requiredVersion
, [Char]
" is required; the container has "
, Version -> [Char]
versionString Version
containerVersion
, [Char]
"."
]
displayException DockerException
CannotDetermineProjectRootException =
[Char]
"Error: [S-4078]\n"
[Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
"Cannot determine project root directory for Docker sandbox."
displayException DockerException
DockerNotInstalledException =
[Char]
"Error: [S-7058]\n"
[Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
"Cannot find 'docker' in PATH. Is Docker installed?"
displayException DockerException
UnsupportedStackExeHostPlatformException = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-6894]\n"
, [Char]
"Using host's "
, [Char]
stackProgName
, [Char]
" executable in Docker container is only supported on "
, Platform -> [Char]
forall a. Pretty a => a -> [Char]
display Platform
dockerContainerPlatform
, [Char]
" platform."
]
displayException (DockerStackExeParseException [Char]
s) = [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [Char]
"Error: [S-1512]\n"
, [Char]
"Failed to parse "
, ShowS
forall a. Show a => a -> [Char]
show [Char]
s
, [Char]
". Expected "
, ShowS
forall a. Show a => a -> [Char]
show [Char]
dockerStackExeDownloadVal
, [Char]
", "
, ShowS
forall a. Show a => a -> [Char]
show [Char]
dockerStackExeHostVal
, [Char]
", "
, ShowS
forall a. Show a => a -> [Char]
show [Char]
dockerStackExeImageVal
, [Char]
" or absolute path to executable."
]
data DockerOpts = DockerOpts
{ DockerOpts -> Bool
dockerEnable :: !Bool
, DockerOpts -> Either SomeException [Char]
dockerImage :: !(Either SomeException String)
, DockerOpts -> Bool
dockerRegistryLogin :: !Bool
, DockerOpts -> Maybe [Char]
dockerRegistryUsername :: !(Maybe String)
, DockerOpts -> Maybe [Char]
dockerRegistryPassword :: !(Maybe String)
, DockerOpts -> Bool
dockerAutoPull :: !Bool
, DockerOpts -> Bool
dockerDetach :: !Bool
, DockerOpts -> Bool
dockerPersist :: !Bool
, DockerOpts -> Maybe [Char]
dockerContainerName :: !(Maybe String)
, DockerOpts -> Maybe [Char]
dockerNetwork :: !(Maybe String)
, DockerOpts -> [[Char]]
dockerRunArgs :: ![String]
, DockerOpts -> [Mount]
dockerMount :: ![Mount]
, DockerOpts -> Maybe [Char]
dockerMountMode :: !(Maybe String)
, DockerOpts -> [[Char]]
dockerEnv :: ![String]
, DockerOpts -> Maybe DockerStackExe
dockerStackExe :: !(Maybe DockerStackExe)
, DockerOpts -> Maybe Bool
dockerSetUser :: !(Maybe Bool)
, DockerOpts -> VersionRange
dockerRequireDockerVersion :: !VersionRange
}
deriving Int -> DockerOpts -> ShowS
[DockerOpts] -> ShowS
DockerOpts -> [Char]
(Int -> DockerOpts -> ShowS)
-> (DockerOpts -> [Char])
-> ([DockerOpts] -> ShowS)
-> Show DockerOpts
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DockerOpts -> ShowS
showsPrec :: Int -> DockerOpts -> ShowS
$cshow :: DockerOpts -> [Char]
show :: DockerOpts -> [Char]
$cshowList :: [DockerOpts] -> ShowS
showList :: [DockerOpts] -> ShowS
Show
data DockerOptsMonoid = DockerOptsMonoid
{ DockerOptsMonoid -> Any
dockerMonoidDefaultEnable :: !Any
, DockerOptsMonoid -> First Bool
dockerMonoidEnable :: !(First Bool)
, DockerOptsMonoid -> First DockerMonoidRepoOrImage
dockerMonoidRepoOrImage :: !(First DockerMonoidRepoOrImage)
, DockerOptsMonoid -> First Bool
dockerMonoidRegistryLogin :: !(First Bool)
, DockerOptsMonoid -> First [Char]
dockerMonoidRegistryUsername :: !(First String)
, DockerOptsMonoid -> First [Char]
dockerMonoidRegistryPassword :: !(First String)
, DockerOptsMonoid -> FirstTrue
dockerMonoidAutoPull :: !FirstTrue
, DockerOptsMonoid -> FirstFalse
dockerMonoidDetach :: !FirstFalse
, DockerOptsMonoid -> FirstFalse
dockerMonoidPersist :: !FirstFalse
, DockerOptsMonoid -> First [Char]
dockerMonoidContainerName :: !(First String)
, DockerOptsMonoid -> First [Char]
dockerMonoidNetwork :: !(First String)
, DockerOptsMonoid -> [[Char]]
dockerMonoidRunArgs :: ![String]
, DockerOptsMonoid -> [Mount]
dockerMonoidMount :: ![Mount]
, DockerOptsMonoid -> First [Char]
dockerMonoidMountMode :: !(First String)
, DockerOptsMonoid -> [[Char]]
dockerMonoidEnv :: ![String]
, DockerOptsMonoid -> First DockerStackExe
dockerMonoidStackExe :: !(First DockerStackExe)
, DockerOptsMonoid -> First Bool
dockerMonoidSetUser :: !(First Bool)
, DockerOptsMonoid -> IntersectingVersionRange
dockerMonoidRequireDockerVersion :: !IntersectingVersionRange
}
deriving (Int -> DockerOptsMonoid -> ShowS
[DockerOptsMonoid] -> ShowS
DockerOptsMonoid -> [Char]
(Int -> DockerOptsMonoid -> ShowS)
-> (DockerOptsMonoid -> [Char])
-> ([DockerOptsMonoid] -> ShowS)
-> Show DockerOptsMonoid
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DockerOptsMonoid -> ShowS
showsPrec :: Int -> DockerOptsMonoid -> ShowS
$cshow :: DockerOptsMonoid -> [Char]
show :: DockerOptsMonoid -> [Char]
$cshowList :: [DockerOptsMonoid] -> ShowS
showList :: [DockerOptsMonoid] -> ShowS
Show, (forall x. DockerOptsMonoid -> Rep DockerOptsMonoid x)
-> (forall x. Rep DockerOptsMonoid x -> DockerOptsMonoid)
-> Generic DockerOptsMonoid
forall x. Rep DockerOptsMonoid x -> DockerOptsMonoid
forall x. DockerOptsMonoid -> Rep DockerOptsMonoid x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DockerOptsMonoid -> Rep DockerOptsMonoid x
from :: forall x. DockerOptsMonoid -> Rep DockerOptsMonoid x
$cto :: forall x. Rep DockerOptsMonoid x -> DockerOptsMonoid
to :: forall x. Rep DockerOptsMonoid x -> DockerOptsMonoid
Generic)
instance FromJSON (WithJSONWarnings DockerOptsMonoid) where
parseJSON :: Value -> Parser (WithJSONWarnings DockerOptsMonoid)
parseJSON = [Char]
-> (Object -> WarningParser DockerOptsMonoid)
-> Value
-> Parser (WithJSONWarnings DockerOptsMonoid)
forall a.
[Char]
-> (Object -> WarningParser a)
-> Value
-> Parser (WithJSONWarnings a)
withObjectWarnings [Char]
"DockerOptsMonoid"
( \Object
o -> do
let dockerMonoidDefaultEnable :: Any
dockerMonoidDefaultEnable = Bool -> Any
Any Bool
True
First Bool
dockerMonoidEnable <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerEnableArgName
First DockerMonoidRepoOrImage
dockerMonoidRepoOrImage <- Maybe DockerMonoidRepoOrImage -> First DockerMonoidRepoOrImage
forall a. Maybe a -> First a
First (Maybe DockerMonoidRepoOrImage -> First DockerMonoidRepoOrImage)
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
-> WriterT
WarningParserMonoid Parser (First DockerMonoidRepoOrImage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
( (DockerMonoidRepoOrImage -> Maybe DockerMonoidRepoOrImage
forall a. a -> Maybe a
Just (DockerMonoidRepoOrImage -> Maybe DockerMonoidRepoOrImage)
-> ([Char] -> DockerMonoidRepoOrImage)
-> [Char]
-> Maybe DockerMonoidRepoOrImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> DockerMonoidRepoOrImage
DockerMonoidImage ([Char] -> Maybe DockerMonoidRepoOrImage)
-> WriterT WarningParserMonoid Parser [Char]
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser [Char]
forall a. FromJSON a => Object -> Text -> WarningParser a
..: Text
dockerImageArgName)
WriterT WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
forall a.
WriterT WarningParserMonoid Parser a
-> WriterT WarningParserMonoid Parser a
-> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (DockerMonoidRepoOrImage -> Maybe DockerMonoidRepoOrImage
forall a. a -> Maybe a
Just (DockerMonoidRepoOrImage -> Maybe DockerMonoidRepoOrImage)
-> ([Char] -> DockerMonoidRepoOrImage)
-> [Char]
-> Maybe DockerMonoidRepoOrImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> DockerMonoidRepoOrImage
DockerMonoidRepo ([Char] -> Maybe DockerMonoidRepoOrImage)
-> WriterT WarningParserMonoid Parser [Char]
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser [Char]
forall a. FromJSON a => Object -> Text -> WarningParser a
..: Text
dockerRepoArgName)
WriterT WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
forall a.
WriterT WarningParserMonoid Parser a
-> WriterT WarningParserMonoid Parser a
-> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe DockerMonoidRepoOrImage
-> WriterT
WarningParserMonoid Parser (Maybe DockerMonoidRepoOrImage)
forall a. a -> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe DockerMonoidRepoOrImage
forall a. Maybe a
Nothing
)
First Bool
dockerMonoidRegistryLogin <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerRegistryLoginArgName
First [Char]
dockerMonoidRegistryUsername <-
Maybe [Char] -> First [Char]
forall a. Maybe a -> First a
First (Maybe [Char] -> First [Char])
-> WriterT WarningParserMonoid Parser (Maybe [Char])
-> WriterT WarningParserMonoid Parser (First [Char])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Char])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerRegistryUsernameArgName
First [Char]
dockerMonoidRegistryPassword <-
Maybe [Char] -> First [Char]
forall a. Maybe a -> First a
First (Maybe [Char] -> First [Char])
-> WriterT WarningParserMonoid Parser (Maybe [Char])
-> WriterT WarningParserMonoid Parser (First [Char])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Char])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerRegistryPasswordArgName
FirstTrue
dockerMonoidAutoPull <- Maybe Bool -> FirstTrue
FirstTrue (Maybe Bool -> FirstTrue)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstTrue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerAutoPullArgName
FirstFalse
dockerMonoidDetach <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerDetachArgName
FirstFalse
dockerMonoidPersist <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerPersistArgName
First [Char]
dockerMonoidContainerName <- Maybe [Char] -> First [Char]
forall a. Maybe a -> First a
First (Maybe [Char] -> First [Char])
-> WriterT WarningParserMonoid Parser (Maybe [Char])
-> WriterT WarningParserMonoid Parser (First [Char])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Char])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerContainerNameArgName
First [Char]
dockerMonoidNetwork <- Maybe [Char] -> First [Char]
forall a. Maybe a -> First a
First (Maybe [Char] -> First [Char])
-> WriterT WarningParserMonoid Parser (Maybe [Char])
-> WriterT WarningParserMonoid Parser (First [Char])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Char])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerNetworkArgName
[[Char]]
dockerMonoidRunArgs <- Object
o Object -> Text -> WarningParser (Maybe [[Char]])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerRunArgsArgName WarningParser (Maybe [[Char]])
-> [[Char]] -> WarningParser [[Char]]
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= []
[Mount]
dockerMonoidMount <- Object
o Object -> Text -> WarningParser (Maybe [Mount])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerMountArgName WarningParser (Maybe [Mount]) -> [Mount] -> WarningParser [Mount]
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= []
First [Char]
dockerMonoidMountMode <- Maybe [Char] -> First [Char]
forall a. Maybe a -> First a
First (Maybe [Char] -> First [Char])
-> WriterT WarningParserMonoid Parser (Maybe [Char])
-> WriterT WarningParserMonoid Parser (First [Char])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Char])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerMountModeArgName
[[Char]]
dockerMonoidEnv <- Object
o Object -> Text -> WarningParser (Maybe [[Char]])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerEnvArgName WarningParser (Maybe [[Char]])
-> [[Char]] -> WarningParser [[Char]]
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= []
First DockerStackExe
dockerMonoidStackExe <- Maybe DockerStackExe -> First DockerStackExe
forall a. Maybe a -> First a
First (Maybe DockerStackExe -> First DockerStackExe)
-> WriterT WarningParserMonoid Parser (Maybe DockerStackExe)
-> WriterT WarningParserMonoid Parser (First DockerStackExe)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object
-> Text
-> WriterT WarningParserMonoid Parser (Maybe DockerStackExe)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerStackExeArgName
First Bool
dockerMonoidSetUser <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerSetUserArgName
IntersectingVersionRange
dockerMonoidRequireDockerVersion <-
VersionRange -> IntersectingVersionRange
IntersectingVersionRange (VersionRange -> IntersectingVersionRange)
-> (VersionRangeJSON -> VersionRange)
-> VersionRangeJSON
-> IntersectingVersionRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VersionRangeJSON -> VersionRange
unVersionRangeJSON (VersionRangeJSON -> IntersectingVersionRange)
-> WriterT WarningParserMonoid Parser VersionRangeJSON
-> WriterT WarningParserMonoid Parser IntersectingVersionRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
( Object
o Object -> Text -> WarningParser (Maybe VersionRangeJSON)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
dockerRequireDockerVersionArgName
WarningParser (Maybe VersionRangeJSON)
-> VersionRangeJSON
-> WriterT WarningParserMonoid Parser VersionRangeJSON
forall a. WarningParser (Maybe a) -> a -> WarningParser a
..!= VersionRange -> VersionRangeJSON
VersionRangeJSON VersionRange
anyVersion
)
DockerOptsMonoid -> WarningParser DockerOptsMonoid
forall a. a -> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DockerOptsMonoid {[[Char]]
[Mount]
Any
First Bool
First [Char]
First DockerMonoidRepoOrImage
First DockerStackExe
FirstFalse
FirstTrue
IntersectingVersionRange
dockerMonoidDefaultEnable :: Any
dockerMonoidEnable :: First Bool
dockerMonoidRepoOrImage :: First DockerMonoidRepoOrImage
dockerMonoidRegistryLogin :: First Bool
dockerMonoidRegistryUsername :: First [Char]
dockerMonoidRegistryPassword :: First [Char]
dockerMonoidAutoPull :: FirstTrue
dockerMonoidDetach :: FirstFalse
dockerMonoidPersist :: FirstFalse
dockerMonoidContainerName :: First [Char]
dockerMonoidNetwork :: First [Char]
dockerMonoidRunArgs :: [[Char]]
dockerMonoidMount :: [Mount]
dockerMonoidMountMode :: First [Char]
dockerMonoidEnv :: [[Char]]
dockerMonoidStackExe :: First DockerStackExe
dockerMonoidSetUser :: First Bool
dockerMonoidRequireDockerVersion :: IntersectingVersionRange
dockerMonoidDefaultEnable :: Any
dockerMonoidEnable :: First Bool
dockerMonoidRepoOrImage :: First DockerMonoidRepoOrImage
dockerMonoidRegistryLogin :: First Bool
dockerMonoidRegistryUsername :: First [Char]
dockerMonoidRegistryPassword :: First [Char]
dockerMonoidAutoPull :: FirstTrue
dockerMonoidDetach :: FirstFalse
dockerMonoidPersist :: FirstFalse
dockerMonoidContainerName :: First [Char]
dockerMonoidNetwork :: First [Char]
dockerMonoidRunArgs :: [[Char]]
dockerMonoidMount :: [Mount]
dockerMonoidMountMode :: First [Char]
dockerMonoidEnv :: [[Char]]
dockerMonoidStackExe :: First DockerStackExe
dockerMonoidSetUser :: First Bool
dockerMonoidRequireDockerVersion :: IntersectingVersionRange
..}
)
instance Semigroup DockerOptsMonoid where
<> :: DockerOptsMonoid -> DockerOptsMonoid -> DockerOptsMonoid
(<>) = DockerOptsMonoid -> DockerOptsMonoid -> DockerOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault
instance Monoid DockerOptsMonoid where
mempty :: DockerOptsMonoid
mempty = DockerOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
mappend :: DockerOptsMonoid -> DockerOptsMonoid -> DockerOptsMonoid
mappend = DockerOptsMonoid -> DockerOptsMonoid -> DockerOptsMonoid
forall a. Semigroup a => a -> a -> a
(<>)
data DockerStackExe
= DockerStackExeDownload
| DockerStackExeHost
| DockerStackExeImage
| DockerStackExePath (Path Abs File)
deriving Int -> DockerStackExe -> ShowS
[DockerStackExe] -> ShowS
DockerStackExe -> [Char]
(Int -> DockerStackExe -> ShowS)
-> (DockerStackExe -> [Char])
-> ([DockerStackExe] -> ShowS)
-> Show DockerStackExe
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DockerStackExe -> ShowS
showsPrec :: Int -> DockerStackExe -> ShowS
$cshow :: DockerStackExe -> [Char]
show :: DockerStackExe -> [Char]
$cshowList :: [DockerStackExe] -> ShowS
showList :: [DockerStackExe] -> ShowS
Show
instance FromJSON DockerStackExe where
parseJSON :: Value -> Parser DockerStackExe
parseJSON Value
a = do
[Char]
s <- Value -> Parser [Char]
forall a. FromJSON a => Value -> Parser a
parseJSON Value
a
case [Char] -> Either SomeException DockerStackExe
forall (m :: * -> *). MonadThrow m => [Char] -> m DockerStackExe
parseDockerStackExe [Char]
s of
Right DockerStackExe
dse -> DockerStackExe -> Parser DockerStackExe
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DockerStackExe
dse
Left SomeException
e -> [Char] -> Parser DockerStackExe
forall a. [Char] -> Parser a
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail (SomeException -> [Char]
forall e. Exception e => e -> [Char]
displayException SomeException
e)
parseDockerStackExe :: (MonadThrow m) => String -> m DockerStackExe
parseDockerStackExe :: forall (m :: * -> *). MonadThrow m => [Char] -> m DockerStackExe
parseDockerStackExe [Char]
t
| [Char]
t [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
dockerStackExeDownloadVal = DockerStackExe -> m DockerStackExe
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DockerStackExe
DockerStackExeDownload
| [Char]
t [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
dockerStackExeHostVal = DockerStackExe -> m DockerStackExe
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DockerStackExe
DockerStackExeHost
| [Char]
t [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
dockerStackExeImageVal = DockerStackExe -> m DockerStackExe
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DockerStackExe
DockerStackExeImage
| Bool
otherwise = case [Char] -> Maybe (Path Abs File)
forall (m :: * -> *). MonadThrow m => [Char] -> m (Path Abs File)
parseAbsFile [Char]
t of
Just Path Abs File
p -> DockerStackExe -> m DockerStackExe
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Path Abs File -> DockerStackExe
DockerStackExePath Path Abs File
p)
Maybe (Path Abs File)
Nothing -> DockerException -> m DockerStackExe
forall e a. Exception e => e -> m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM ([Char] -> DockerException
DockerStackExeParseException [Char]
t)
data Mount = Mount String String
instance Read Mount where
readsPrec :: Int -> ReadS Mount
readsPrec Int
_ [Char]
s =
case (Char -> Bool) -> [Char] -> ([Char], [Char])
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
':') [Char]
s of
([Char]
a, Char
':':[Char]
b) -> [([Char] -> [Char] -> Mount
Mount [Char]
a [Char]
b, [Char]
"")]
([Char]
a, []) -> [([Char] -> [Char] -> Mount
Mount [Char]
a [Char]
a, [Char]
"")]
([Char], [Char])
_ -> ReadS Mount
forall a. [Char] -> [a]
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"Invalid value for Docker mount (expect '/host/path:/container/path')"
instance Show Mount where
show :: Mount -> [Char]
show (Mount [Char]
a [Char]
b) = if [Char]
a [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
b then [Char]
a else [[Char]] -> [Char]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Char]
a, [Char]
":", [Char]
b]
instance FromJSON Mount where
parseJSON :: Value -> Parser Mount
parseJSON Value
v = do
[Char]
s <- Value -> Parser [Char]
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
case [Char] -> Maybe Mount
forall a. Read a => [Char] -> Maybe a
readMaybe [Char]
s of
Maybe Mount
Nothing -> [Char] -> Parser Mount
forall a. [Char] -> Parser a
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail ([Char] -> Parser Mount) -> [Char] -> Parser Mount
forall a b. (a -> b) -> a -> b
$ [Char]
"Mount read failed: " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
s
Just Mount
x -> Mount -> Parser Mount
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Mount
x
data DockerMonoidRepoOrImage
= DockerMonoidRepo String
| DockerMonoidImage String
deriving Int -> DockerMonoidRepoOrImage -> ShowS
[DockerMonoidRepoOrImage] -> ShowS
DockerMonoidRepoOrImage -> [Char]
(Int -> DockerMonoidRepoOrImage -> ShowS)
-> (DockerMonoidRepoOrImage -> [Char])
-> ([DockerMonoidRepoOrImage] -> ShowS)
-> Show DockerMonoidRepoOrImage
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DockerMonoidRepoOrImage -> ShowS
showsPrec :: Int -> DockerMonoidRepoOrImage -> ShowS
$cshow :: DockerMonoidRepoOrImage -> [Char]
show :: DockerMonoidRepoOrImage -> [Char]
$cshowList :: [DockerMonoidRepoOrImage] -> ShowS
showList :: [DockerMonoidRepoOrImage] -> ShowS
Show
newtype VersionRangeJSON =
VersionRangeJSON { VersionRangeJSON -> VersionRange
unVersionRangeJSON :: VersionRange }
instance FromJSON VersionRangeJSON where
parseJSON :: Value -> Parser VersionRangeJSON
parseJSON = [Char]
-> (Text -> Parser VersionRangeJSON)
-> Value
-> Parser VersionRangeJSON
forall a. [Char] -> (Text -> Parser a) -> Value -> Parser a
withText [Char]
"VersionRange"
(\Text
s -> Parser VersionRangeJSON
-> (VersionRange -> Parser VersionRangeJSON)
-> Maybe VersionRange
-> Parser VersionRangeJSON
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([Char] -> Parser VersionRangeJSON
forall a. [Char] -> Parser a
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail ([Char]
"Invalid cabal-style VersionRange: " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> [Char]
T.unpack Text
s))
(VersionRangeJSON -> Parser VersionRangeJSON
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VersionRangeJSON -> Parser VersionRangeJSON)
-> (VersionRange -> VersionRangeJSON)
-> VersionRange
-> Parser VersionRangeJSON
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VersionRange -> VersionRangeJSON
VersionRangeJSON)
([Char] -> Maybe VersionRange
forall a. Parsec a => [Char] -> Maybe a
Distribution.Text.simpleParse (Text -> [Char]
T.unpack Text
s)))
dockerEnableArgName :: Text
dockerEnableArgName :: Text
dockerEnableArgName = Text
"enable"
dockerRepoArgName :: Text
dockerRepoArgName :: Text
dockerRepoArgName = Text
"repo"
dockerImageArgName :: Text
dockerImageArgName :: Text
dockerImageArgName = Text
"image"
dockerRegistryLoginArgName :: Text
dockerRegistryLoginArgName :: Text
dockerRegistryLoginArgName = Text
"registry-login"
dockerRegistryUsernameArgName :: Text
dockerRegistryUsernameArgName :: Text
dockerRegistryUsernameArgName = Text
"registry-username"
dockerRegistryPasswordArgName :: Text
dockerRegistryPasswordArgName :: Text
dockerRegistryPasswordArgName = Text
"registry-password"
dockerAutoPullArgName :: Text
dockerAutoPullArgName :: Text
dockerAutoPullArgName = Text
"auto-pull"
dockerDetachArgName :: Text
dockerDetachArgName :: Text
dockerDetachArgName = Text
"detach"
dockerRunArgsArgName :: Text
dockerRunArgsArgName :: Text
dockerRunArgsArgName = Text
"run-args"
dockerMountArgName :: Text
dockerMountArgName :: Text
dockerMountArgName = Text
"mount"
dockerMountModeArgName :: Text
dockerMountModeArgName :: Text
dockerMountModeArgName = Text
"mount-mode"
dockerEnvArgName :: Text
dockerEnvArgName :: Text
dockerEnvArgName = Text
"env"
dockerContainerNameArgName :: Text
dockerContainerNameArgName :: Text
dockerContainerNameArgName = Text
"container-name"
dockerNetworkArgName :: Text
dockerNetworkArgName :: Text
dockerNetworkArgName = Text
"network"
dockerPersistArgName :: Text
dockerPersistArgName :: Text
dockerPersistArgName = Text
"persist"
dockerStackExeArgName :: Text
dockerStackExeArgName :: Text
dockerStackExeArgName = Text
"stack-exe"
dockerStackExeDownloadVal :: String
dockerStackExeDownloadVal :: [Char]
dockerStackExeDownloadVal = [Char]
"download"
dockerStackExeHostVal :: String
dockerStackExeHostVal :: [Char]
dockerStackExeHostVal = [Char]
"host"
dockerStackExeImageVal :: String
dockerStackExeImageVal :: [Char]
dockerStackExeImageVal = [Char]
"image"
dockerSetUserArgName :: Text
dockerSetUserArgName :: Text
dockerSetUserArgName = Text
"set-user"
dockerRequireDockerVersionArgName :: Text
dockerRequireDockerVersionArgName :: Text
dockerRequireDockerVersionArgName = Text
"require-docker-version"
dockerEntrypointArgName :: String
dockerEntrypointArgName :: [Char]
dockerEntrypointArgName = [Char]
"internal-docker-entrypoint"
dockerCmdName :: String
dockerCmdName :: [Char]
dockerCmdName = [Char]
"docker"
dockerHelpOptName :: String
dockerHelpOptName :: [Char]
dockerHelpOptName = [Char]
dockerCmdName [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
"-help"
dockerPullCmdName :: String
dockerPullCmdName :: [Char]
dockerPullCmdName = [Char]
"pull"
reExecArgName :: String
reExecArgName :: [Char]
reExecArgName = [Char]
"internal-re-exec-version"
dockerContainerPlatform :: Platform
dockerContainerPlatform :: Platform
dockerContainerPlatform = Arch -> OS -> Platform
Platform Arch
X86_64 OS
Linux