module Ecluse.Composition.BootError (
BootError (..),
renderBootError,
mountEnvKey,
) where
import Data.Text qualified as T
import Ecluse.Config (
PolicyError,
renderPolicyError,
)
import Ecluse.Config.Resolve qualified as Resolve
import Ecluse.Core.Ecosystem (Ecosystem, ecosystemName)
data BootError
=
PolicyBootError PolicyError
|
MissingAdapter Ecosystem
|
UnresolvedCredential Ecosystem
|
QueueProviderUnavailable Text
|
QueueRegionMissing
|
QueueUrlUnrecognised Text
|
QueueEndpointMalformed Text
|
CodeArtifactMintFailed Text
|
PublishAllowMissing Ecosystem
|
PublishStaticCredentialNeedsEdge Ecosystem
|
MemoryPlanOverrideUnsafe [Text]
deriving stock (BootError -> BootError -> Bool
(BootError -> BootError -> Bool)
-> (BootError -> BootError -> Bool) -> Eq BootError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BootError -> BootError -> Bool
== :: BootError -> BootError -> Bool
$c/= :: BootError -> BootError -> Bool
/= :: BootError -> BootError -> Bool
Eq, Int -> BootError -> ShowS
[BootError] -> ShowS
BootError -> String
(Int -> BootError -> ShowS)
-> (BootError -> String)
-> ([BootError] -> ShowS)
-> Show BootError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BootError -> ShowS
showsPrec :: Int -> BootError -> ShowS
$cshow :: BootError -> String
show :: BootError -> String
$cshowList :: [BootError] -> ShowS
showList :: [BootError] -> ShowS
Show)
renderBootError :: BootError -> Text
renderBootError :: BootError -> Text
renderBootError = \case
PolicyBootError PolicyError
err -> PolicyError -> Text
renderPolicyError PolicyError
err
MissingAdapter Ecosystem
eco ->
Text
"mount " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Ecosystem -> Text
ecosystemName Ecosystem
eco Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" has no adapter wired in this build"
UnresolvedCredential Ecosystem
eco ->
Text
"mount "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Ecosystem -> Text
ecosystemName Ecosystem
eco
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" has no initialised mirror-write credential in this build"
QueueProviderUnavailable Text
provider ->
Text
"mirror queue provider "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
provider
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" (named by the ECLUSE_QUEUE__URL shape) is not available in this build"
BootError
QueueRegionMissing ->
Text
"the SQS endpoint override (AWS_ENDPOINT_URL_SQS) is set but AWS_REGION is not: an emulator or VPC endpoint does not carry its region, so AWS_REGION must scope it"
QueueUrlUnrecognised Text
url ->
Text
"ECLUSE_QUEUE__URL names no queue backend this build knows: "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
url
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" (expected an SQS queue URL, https://sqs.{region}.amazonaws.com/{account}/{queue}, or a Pub/Sub topic resource, projects/{project}/topics/{topic}; unset it to run the bounded in-memory queue)"
QueueEndpointMalformed Text
url ->
Text
"the SQS endpoint override (AWS_ENDPOINT_URL_SQS) is not a valid endpoint URL: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
url
CodeArtifactMintFailed Text
detail ->
Text
"mirror-target credential provider codeartifact failed to mint an initial token at boot: "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
detail
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" (a transient AWS error may clear on retry; a permanent one -- bad domain/region or missing permission -- must be fixed)"
PublishAllowMissing Ecosystem
eco ->
Ecosystem -> Text -> Text
mountEnvKey Ecosystem
eco Text
"PUBLICATION_TARGET" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" is set but " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Ecosystem -> Text -> Text
mountEnvKey Ecosystem
eco Text
"PUBLISH_ALLOW" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" is empty: a publication target needs a publish allow-list (for npm, scopes such as @acme) for the anti-shadowing guard."
PublishStaticCredentialNeedsEdge Ecosystem
eco ->
Ecosystem -> Text -> Text
mountEnvKey Ecosystem
eco Text
"PUBLICATION_TARGET_TOKEN" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" is set but ECLUSE_SERVER__AUTH_TOKEN is not: a static publish credential needs a verifiable inbound edge."
MemoryPlanOverrideUnsafe [Text]
details ->
Text
"memory plan refused: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> [Text] -> Text
T.intercalate Text
"; " [Text]
details
mountEnvKey :: Ecosystem -> Text -> Text
mountEnvKey :: Ecosystem -> Text -> Text
mountEnvKey Ecosystem
eco = Text -> Text -> Text
Resolve.mountEnvKey (Ecosystem -> Text
ecosystemName Ecosystem
eco)