-- | Implementation of an execution environment that uses /podman/.
module B9.Podman
  ( Podman (..),
  )
where

import B9.B9Config
  ( getB9Config,
    podmanConfigs,
  )
import B9.B9Config.Podman as X
import B9.Container
import B9.DiskImages
import B9.ShellScript
import Control.Lens (view)

newtype Podman = Podman PodmanConfig

instance Backend Podman where
  getBackendConfig :: proxy Podman -> Eff e (Maybe Podman)
getBackendConfig proxy Podman
_ =
    (PodmanConfig -> Podman) -> Maybe PodmanConfig -> Maybe Podman
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PodmanConfig -> Podman
Podman (Maybe PodmanConfig -> Maybe Podman)
-> (B9Config -> Maybe PodmanConfig) -> B9Config -> Maybe Podman
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Maybe PodmanConfig) B9Config (Maybe PodmanConfig)
-> B9Config -> Maybe PodmanConfig
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (Maybe PodmanConfig) B9Config (Maybe PodmanConfig)
Lens' B9Config (Maybe PodmanConfig)
podmanConfigs (B9Config -> Maybe Podman)
-> Eff e B9Config -> Eff e (Maybe Podman)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Eff e B9Config
forall (e :: [* -> *]). Member B9ConfigReader e => Eff e B9Config
getB9Config

  -- supportedImageTypes :: proxy config -> [ImageType]
  supportedImageTypes :: proxy Podman -> [ImageType]
supportedImageTypes proxy Podman
_ = [ImageType
Raw]

  -- runInEnvironment ::
  --   forall e.
  --   (Member BuildInfoReader e, CommandIO e) =>
  --   config ->
  --   ExecEnv ->
  --   Script ->
  --   Eff e Bool
  runInEnvironment :: Podman -> ExecEnv -> Script -> Eff e Bool
runInEnvironment (Podman PodmanConfig
_dcfg) ExecEnv
_env Script
scriptIn = do
    if Script -> Bool
emptyScript Script
scriptIn
      then Bool -> Eff e Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
      else do [Char] -> Eff e Bool
forall a. HasCallStack => [Char] -> a
error [Char]
"TODO"