{-# LANGUAGE NoImplicitPrelude  #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}

-- | Docker types.


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 (..) )

-- | Type representing exceptions thrown by functions exported by the

-- "Stack.Docker" module.

data DockerException
  = DockerMustBeEnabledException
    -- ^ Docker must be enabled to use the command.

  | OnlyOnHostException
    -- ^ Command must be run on host OS (not in a container).

  | InspectFailedException String
    -- ^ @docker inspect@ failed.

  | NotPulledException String
    -- ^ Image does not exist.

  | InvalidImagesOutputException String
    -- ^ Invalid output from @docker images@.

  | InvalidPSOutputException String
    -- ^ Invalid output from @docker ps@.

  | InvalidInspectOutputException String
    -- ^ Invalid output from @docker inspect@.

  | PullFailedException String
    -- ^ Could not pull a Docker image.

  | DockerTooOldException Version Version
    -- ^ Installed version of @docker@ below minimum version.

  | DockerVersionProhibitedException [Version] Version
    -- ^ Installed version of @docker@ is prohibited.

  | BadDockerVersionException VersionRange Version
    -- ^ Installed version of @docker@ is out of range specified in config file.

  | InvalidVersionOutputException
    -- ^ Invalid output from @docker --version@.

  | HostStackTooOldException Version (Maybe Version)
    -- ^ Version of @stack@ on host is too old for version in image.

  | ContainerStackTooOldException Version Version
    -- ^ Version of @stack@ in container/image is too old for version on host.

  | CannotDetermineProjectRootException
    -- ^ Can't determine the project root (where to put docker sandbox).

  | DockerNotInstalledException
    -- ^ @docker --version@ failed.

  | UnsupportedStackExeHostPlatformException
    -- ^ Using host stack-exe on unsupported platform.

  | DockerStackExeParseException String
    -- ^ @stack-exe@ option fails to parse.

  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."
    ]

-- | Docker configuration.

data DockerOpts = DockerOpts
  { DockerOpts -> Bool
dockerEnable :: !Bool
     -- ^ Is using Docker enabled?

  , DockerOpts -> Either SomeException [Char]
dockerImage :: !(Either SomeException String)
     -- ^ Exact Docker image tag or ID.  Overrides docker-repo-*/tag.

  , DockerOpts -> Bool
dockerRegistryLogin :: !Bool
     -- ^ Does registry require login for pulls?

  , DockerOpts -> Maybe [Char]
dockerRegistryUsername :: !(Maybe String)
     -- ^ Optional username for Docker registry.

  , DockerOpts -> Maybe [Char]
dockerRegistryPassword :: !(Maybe String)
     -- ^ Optional password for Docker registry.

  , DockerOpts -> Bool
dockerAutoPull :: !Bool
     -- ^ Automatically pull new images.

  , DockerOpts -> Bool
dockerDetach :: !Bool
     -- ^ Whether to run a detached container

  , DockerOpts -> Bool
dockerPersist :: !Bool
     -- ^ Create a persistent container (don't remove it when finished). Implied

     -- by `dockerDetach`.

  , DockerOpts -> Maybe [Char]
dockerContainerName :: !(Maybe String)
     -- ^ Container name to use, only makes sense from command-line with

     -- `dockerPersist` or `dockerDetach`.

  , DockerOpts -> Maybe [Char]
dockerNetwork :: !(Maybe String)
    -- ^ The network docker uses.

  , DockerOpts -> [[Char]]
dockerRunArgs :: ![String]
     -- ^ Arguments to pass directly to @docker run@.

  , DockerOpts -> [Mount]
dockerMount :: ![Mount]
     -- ^ Volumes to mount in the container.

  , DockerOpts -> Maybe [Char]
dockerMountMode :: !(Maybe String)
     -- ^ Volume mount mode

  , DockerOpts -> [[Char]]
dockerEnv :: ![String]
     -- ^ Environment variables to set in the container.

  , DockerOpts -> Maybe DockerStackExe
dockerStackExe :: !(Maybe DockerStackExe)
     -- ^ Location of container-compatible Stack executable

  , DockerOpts -> Maybe Bool
dockerSetUser :: !(Maybe Bool)
    -- ^ Set in-container user to match host's

  , DockerOpts -> VersionRange
dockerRequireDockerVersion :: !VersionRange
    -- ^ Require a version of Docker within this range.

  }
  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

-- | An uninterpreted representation of docker options. Configurations may be

-- "cascaded" using mappend (left-biased).

data DockerOptsMonoid = DockerOptsMonoid
  { DockerOptsMonoid -> Any
dockerMonoidDefaultEnable :: !Any
    -- ^ Should Docker be defaulted to enabled (does @docker:@ section exist in

    -- the config)?

  , DockerOptsMonoid -> First Bool
dockerMonoidEnable :: !(First Bool)
    -- ^ Is using Docker enabled?

  , DockerOptsMonoid -> First DockerMonoidRepoOrImage
dockerMonoidRepoOrImage :: !(First DockerMonoidRepoOrImage)
    -- ^ Docker repository name (e.g. @fpco/stack-build@ or

    -- @fpco/stack-full:lts-2.8@)

  , DockerOptsMonoid -> First Bool
dockerMonoidRegistryLogin :: !(First Bool)
    -- ^ Does registry require login for pulls?

  , DockerOptsMonoid -> First [Char]
dockerMonoidRegistryUsername :: !(First String)
    -- ^ Optional username for Docker registry.

  , DockerOptsMonoid -> First [Char]
dockerMonoidRegistryPassword :: !(First String)
    -- ^ Optional password for Docker registry.

  , DockerOptsMonoid -> FirstTrue
dockerMonoidAutoPull :: !FirstTrue
    -- ^ Automatically pull new images.

  , DockerOptsMonoid -> FirstFalse
dockerMonoidDetach :: !FirstFalse
    -- ^ Whether to run a detached container

  , DockerOptsMonoid -> FirstFalse
dockerMonoidPersist :: !FirstFalse
    -- ^ Create a persistent container (don't remove it when finished). Implied

    -- by -- `dockerDetach`.

  , DockerOptsMonoid -> First [Char]
dockerMonoidContainerName :: !(First String)
    -- ^ Container name to use, only makes sense from command-line with

    -- `dockerPersist` or `dockerDetach`.

  , DockerOptsMonoid -> First [Char]
dockerMonoidNetwork :: !(First String)
    -- ^ See: 'dockerNetwork'

  , DockerOptsMonoid -> [[Char]]
dockerMonoidRunArgs :: ![String]
    -- ^ Arguments to pass directly to @docker run@

  , DockerOptsMonoid -> [Mount]
dockerMonoidMount :: ![Mount]
    -- ^ Volumes to mount in the container

  , DockerOptsMonoid -> First [Char]
dockerMonoidMountMode :: !(First String)
    -- ^ Volume mount mode

  , DockerOptsMonoid -> [[Char]]
dockerMonoidEnv :: ![String]
    -- ^ Environment variables to set in the container

  , DockerOptsMonoid -> First DockerStackExe
dockerMonoidStackExe :: !(First DockerStackExe)
    -- ^ Location of container-compatible Stack executable

  , DockerOptsMonoid -> First Bool
dockerMonoidSetUser :: !(First Bool)
    -- ^ Set in-container user to match host's

  , DockerOptsMonoid -> IntersectingVersionRange
dockerMonoidRequireDockerVersion :: !IntersectingVersionRange
    -- ^ See: 'dockerRequireDockerVersion'

  }
  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)

-- | Decode uninterpreted docker options from JSON/YAML.

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
..}
    )

-- | Left-biased combine Docker options

instance Semigroup DockerOptsMonoid where
  <> :: DockerOptsMonoid -> DockerOptsMonoid -> DockerOptsMonoid
(<>) = DockerOptsMonoid -> DockerOptsMonoid -> DockerOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault

-- | Left-biased combine Docker options

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
(<>)

-- | Where to get the `stack` executable to run in Docker containers

data DockerStackExe
  = DockerStackExeDownload  -- ^ Download from official bindist

  | DockerStackExeHost  -- ^ Host's `stack` (linux-x86_64 only)

  | DockerStackExeImage  -- ^ Docker image's `stack` (versions must match)

  | DockerStackExePath (Path Abs File) -- ^ Executable at given path

  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)

-- | Parse 'DockerStackExe'.

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)

-- | Docker volume mount.

data Mount = Mount String String

-- | For optparse-applicative.

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')"

-- | Show instance.

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]

-- | For YAML.

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

-- | Options for Docker repository or image.

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 for non-orphan FromJSON instance.

newtype VersionRangeJSON =
  VersionRangeJSON { VersionRangeJSON -> VersionRange
unVersionRangeJSON :: VersionRange }

-- | Parse 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)))

-- | Docker enable argument name.

dockerEnableArgName :: Text
dockerEnableArgName :: Text
dockerEnableArgName = Text
"enable"

-- | Docker repo arg argument name.

dockerRepoArgName :: Text
dockerRepoArgName :: Text
dockerRepoArgName = Text
"repo"

-- | Docker image argument name.

dockerImageArgName :: Text
dockerImageArgName :: Text
dockerImageArgName = Text
"image"

-- | Docker registry login argument name.

dockerRegistryLoginArgName :: Text
dockerRegistryLoginArgName :: Text
dockerRegistryLoginArgName = Text
"registry-login"

-- | Docker registry username argument name.

dockerRegistryUsernameArgName :: Text
dockerRegistryUsernameArgName :: Text
dockerRegistryUsernameArgName = Text
"registry-username"

-- | Docker registry password argument name.

dockerRegistryPasswordArgName :: Text
dockerRegistryPasswordArgName :: Text
dockerRegistryPasswordArgName = Text
"registry-password"

-- | Docker auto-pull argument name.

dockerAutoPullArgName :: Text
dockerAutoPullArgName :: Text
dockerAutoPullArgName = Text
"auto-pull"

-- | Docker detach argument name.

dockerDetachArgName :: Text
dockerDetachArgName :: Text
dockerDetachArgName = Text
"detach"

-- | Docker run args argument name.

dockerRunArgsArgName :: Text
dockerRunArgsArgName :: Text
dockerRunArgsArgName = Text
"run-args"

-- | Docker mount argument name.

dockerMountArgName :: Text
dockerMountArgName :: Text
dockerMountArgName = Text
"mount"

-- | Docker mount mode argument name.

dockerMountModeArgName :: Text
dockerMountModeArgName :: Text
dockerMountModeArgName = Text
"mount-mode"

-- | Docker environment variable argument name.

dockerEnvArgName :: Text
dockerEnvArgName :: Text
dockerEnvArgName = Text
"env"

-- | Docker container name argument name.

dockerContainerNameArgName :: Text
dockerContainerNameArgName :: Text
dockerContainerNameArgName = Text
"container-name"
--

-- | Docker container name argument name.

dockerNetworkArgName :: Text
dockerNetworkArgName :: Text
dockerNetworkArgName = Text
"network"

-- | Docker persist argument name.

dockerPersistArgName :: Text
dockerPersistArgName :: Text
dockerPersistArgName = Text
"persist"

-- | Docker Stack executable argument name.

dockerStackExeArgName :: Text
dockerStackExeArgName :: Text
dockerStackExeArgName = Text
"stack-exe"

-- | Value for @--docker-stack-exe=download@

dockerStackExeDownloadVal :: String
dockerStackExeDownloadVal :: [Char]
dockerStackExeDownloadVal = [Char]
"download"

-- | Value for @--docker-stack-exe=host@

dockerStackExeHostVal :: String
dockerStackExeHostVal :: [Char]
dockerStackExeHostVal = [Char]
"host"

-- | Value for @--docker-stack-exe=image@

dockerStackExeImageVal :: String
dockerStackExeImageVal :: [Char]
dockerStackExeImageVal = [Char]
"image"

-- | Docker @set-user@ argument name

dockerSetUserArgName :: Text
dockerSetUserArgName :: Text
dockerSetUserArgName = Text
"set-user"

-- | Docker @require-version@ argument name

dockerRequireDockerVersionArgName :: Text
dockerRequireDockerVersionArgName :: Text
dockerRequireDockerVersionArgName = Text
"require-docker-version"

-- | Argument name used to pass docker entrypoint data (only used internally)

dockerEntrypointArgName :: String
dockerEntrypointArgName :: [Char]
dockerEntrypointArgName = [Char]
"internal-docker-entrypoint"

-- | Command-line argument for "docker"

dockerCmdName :: String
dockerCmdName :: [Char]
dockerCmdName = [Char]
"docker"

dockerHelpOptName :: String
dockerHelpOptName :: [Char]
dockerHelpOptName = [Char]
dockerCmdName [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
"-help"

-- | Command-line argument for @docker pull@.

dockerPullCmdName :: String
dockerPullCmdName :: [Char]
dockerPullCmdName = [Char]
"pull"

-- | Command-line option for @--internal-re-exec-version@.

reExecArgName :: String
reExecArgName :: [Char]
reExecArgName = [Char]
"internal-re-exec-version"

-- | Platform that Docker containers run

dockerContainerPlatform :: Platform
dockerContainerPlatform :: Platform
dockerContainerPlatform = Arch -> OS -> Platform
Platform Arch
X86_64 OS
Linux