module Ecluse.Core.Server.Upstream (
MirrorServePlan (..),
MountUpstreams,
mountUpstreams,
upstreamPrivateBaseUrl,
upstreamPublicBaseUrl,
upstreamMirror,
upstreamTarballHostGate,
) where
import Ecluse.Core.Security (TarballHostGate, tarballHostGate)
import Ecluse.Core.Security.Egress (RegistryUrl, registryUrlText)
data MirrorServePlan
=
MirrorOnAdmit RegistryUrl
|
NoMirrorWrite
deriving stock (MirrorServePlan -> MirrorServePlan -> Bool
(MirrorServePlan -> MirrorServePlan -> Bool)
-> (MirrorServePlan -> MirrorServePlan -> Bool)
-> Eq MirrorServePlan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MirrorServePlan -> MirrorServePlan -> Bool
== :: MirrorServePlan -> MirrorServePlan -> Bool
$c/= :: MirrorServePlan -> MirrorServePlan -> Bool
/= :: MirrorServePlan -> MirrorServePlan -> Bool
Eq, Int -> MirrorServePlan -> ShowS
[MirrorServePlan] -> ShowS
MirrorServePlan -> String
(Int -> MirrorServePlan -> ShowS)
-> (MirrorServePlan -> String)
-> ([MirrorServePlan] -> ShowS)
-> Show MirrorServePlan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MirrorServePlan -> ShowS
showsPrec :: Int -> MirrorServePlan -> ShowS
$cshow :: MirrorServePlan -> String
show :: MirrorServePlan -> String
$cshowList :: [MirrorServePlan] -> ShowS
showList :: [MirrorServePlan] -> ShowS
Show)
data MountUpstreams = MountUpstreams
{ MountUpstreams -> Maybe RegistryUrl
muPrivateBaseUrl :: Maybe RegistryUrl
, MountUpstreams -> RegistryUrl
muPublicBaseUrl :: RegistryUrl
, MountUpstreams -> MirrorServePlan
muMirror :: MirrorServePlan
, MountUpstreams -> TarballHostGate
muTarballHostGate :: TarballHostGate
}
deriving stock (MountUpstreams -> MountUpstreams -> Bool
(MountUpstreams -> MountUpstreams -> Bool)
-> (MountUpstreams -> MountUpstreams -> Bool) -> Eq MountUpstreams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MountUpstreams -> MountUpstreams -> Bool
== :: MountUpstreams -> MountUpstreams -> Bool
$c/= :: MountUpstreams -> MountUpstreams -> Bool
/= :: MountUpstreams -> MountUpstreams -> Bool
Eq, Int -> MountUpstreams -> ShowS
[MountUpstreams] -> ShowS
MountUpstreams -> String
(Int -> MountUpstreams -> ShowS)
-> (MountUpstreams -> String)
-> ([MountUpstreams] -> ShowS)
-> Show MountUpstreams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MountUpstreams -> ShowS
showsPrec :: Int -> MountUpstreams -> ShowS
$cshow :: MountUpstreams -> String
show :: MountUpstreams -> String
$cshowList :: [MountUpstreams] -> ShowS
showList :: [MountUpstreams] -> ShowS
Show)
mountUpstreams :: [Text] -> Maybe RegistryUrl -> RegistryUrl -> MirrorServePlan -> MountUpstreams
mountUpstreams :: [Text]
-> Maybe RegistryUrl
-> RegistryUrl
-> MirrorServePlan
-> MountUpstreams
mountUpstreams [Text]
ecosystemHostUrls Maybe RegistryUrl
privateBaseUrl RegistryUrl
publicBaseUrl MirrorServePlan
mirror =
MountUpstreams
{ muPrivateBaseUrl :: Maybe RegistryUrl
muPrivateBaseUrl = Maybe RegistryUrl
privateBaseUrl
, muPublicBaseUrl :: RegistryUrl
muPublicBaseUrl = RegistryUrl
publicBaseUrl
, muMirror :: MirrorServePlan
muMirror = MirrorServePlan
mirror
,
muTarballHostGate :: TarballHostGate
muTarballHostGate =
[Text] -> Maybe Text -> Text -> Maybe Text -> TarballHostGate
tarballHostGate
[Text]
ecosystemHostUrls
(RegistryUrl -> Text
registryUrlText (RegistryUrl -> Text) -> Maybe RegistryUrl -> Maybe Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe RegistryUrl
privateBaseUrl)
(RegistryUrl -> Text
registryUrlText RegistryUrl
publicBaseUrl)
(RegistryUrl -> Text
registryUrlText (RegistryUrl -> Text) -> Maybe RegistryUrl -> Maybe Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MirrorServePlan -> Maybe RegistryUrl
mirrorTargetUrl MirrorServePlan
mirror)
}
mirrorTargetUrl :: MirrorServePlan -> Maybe RegistryUrl
mirrorTargetUrl :: MirrorServePlan -> Maybe RegistryUrl
mirrorTargetUrl = \case
MirrorOnAdmit RegistryUrl
url -> RegistryUrl -> Maybe RegistryUrl
forall a. a -> Maybe a
Just RegistryUrl
url
MirrorServePlan
NoMirrorWrite -> Maybe RegistryUrl
forall a. Maybe a
Nothing
upstreamPrivateBaseUrl :: MountUpstreams -> Maybe RegistryUrl
upstreamPrivateBaseUrl :: MountUpstreams -> Maybe RegistryUrl
upstreamPrivateBaseUrl = MountUpstreams -> Maybe RegistryUrl
muPrivateBaseUrl
upstreamPublicBaseUrl :: MountUpstreams -> RegistryUrl
upstreamPublicBaseUrl :: MountUpstreams -> RegistryUrl
upstreamPublicBaseUrl = MountUpstreams -> RegistryUrl
muPublicBaseUrl
upstreamMirror :: MountUpstreams -> MirrorServePlan
upstreamMirror :: MountUpstreams -> MirrorServePlan
upstreamMirror = MountUpstreams -> MirrorServePlan
muMirror
upstreamTarballHostGate :: MountUpstreams -> TarballHostGate
upstreamTarballHostGate :: MountUpstreams -> TarballHostGate
upstreamTarballHostGate = MountUpstreams -> TarballHostGate
muTarballHostGate