mirror of
https://github.com/snoyberg/keter.git
synced 2024-12-12 14:06:10 +03:00
Merge branch 'forward-env-vars' of https://github.com/mulby/keter
This commit is contained in:
commit
0a4a9a6cda
@ -44,6 +44,7 @@ import Keter.PortPool (PortPool, getPort, releasePort)
|
||||
import Keter.Types
|
||||
import qualified Network
|
||||
import Prelude hiding (FilePath)
|
||||
import System.Environment (getEnvironment)
|
||||
import System.IO (hClose)
|
||||
import System.Posix.Files (fileAccess)
|
||||
import System.Posix.Types (EpochTime)
|
||||
@ -267,6 +268,7 @@ launchWebApp :: AppStartConfig
|
||||
-> IO a
|
||||
launchWebApp AppStartConfig {..} aid BundleConfig {..} mdir rlog WebAppConfig {..} f = do
|
||||
otherEnv <- pluginsGetEnv ascPlugins name bconfigPlugins
|
||||
systemEnv <- getEnvironment
|
||||
let httpPort = kconfigExternalHttpPort ascKeterConfig
|
||||
httpsPort = kconfigExternalHttpsPort ascKeterConfig
|
||||
(scheme, extport) =
|
||||
@ -277,6 +279,7 @@ launchWebApp AppStartConfig {..} aid BundleConfig {..} mdir rlog WebAppConfig {.
|
||||
-- Ordering chosen specifically to precedence rules: app specific,
|
||||
-- plugins, global, and then auto-set Keter variables.
|
||||
[ waconfigEnvironment
|
||||
, Map.filterWithKey (\k _ -> Set.member k waconfigForwardEnv) $ Map.fromList $ map (\x -> (pack (fst x), pack (snd x))) systemEnv
|
||||
, Map.fromList otherEnv
|
||||
, kconfigEnvironment ascKeterConfig
|
||||
, Map.singleton "PORT" $ pack $ show waconfigPort
|
||||
|
@ -327,6 +327,7 @@ data WebAppConfig port = WebAppConfig
|
||||
, waconfigHosts :: !(Set Host) -- ^ all hosts, not including the approot host
|
||||
, waconfigSsl :: !Bool
|
||||
, waconfigPort :: !port
|
||||
, waconfigForwardEnv :: !(Set Text)
|
||||
}
|
||||
deriving Show
|
||||
|
||||
@ -340,6 +341,7 @@ instance ToCurrent (WebAppConfig ()) where
|
||||
, waconfigHosts = Set.map CI.mk hosts
|
||||
, waconfigSsl = ssl
|
||||
, waconfigPort = ()
|
||||
, waconfigForwardEnv = Set.empty
|
||||
}
|
||||
|
||||
instance ParseYamlFile (WebAppConfig ()) where
|
||||
@ -361,6 +363,7 @@ instance ParseYamlFile (WebAppConfig ()) where
|
||||
<*> return hosts
|
||||
<*> o .:? "ssl" .!= False
|
||||
<*> return ()
|
||||
<*> o .:? "forward-env" .!= Set.empty
|
||||
|
||||
instance ToJSON (WebAppConfig ()) where
|
||||
toJSON WebAppConfig {..} = object
|
||||
@ -369,6 +372,7 @@ instance ToJSON (WebAppConfig ()) where
|
||||
, "env" .= waconfigEnvironment
|
||||
, "hosts" .= map CI.original (waconfigApprootHost : Set.toList waconfigHosts)
|
||||
, "ssl" .= waconfigSsl
|
||||
, "forward-env" .= waconfigForwardEnv
|
||||
]
|
||||
|
||||
data AppInput = AIBundle !FilePath !EpochTime
|
||||
|
@ -5,6 +5,9 @@ stanzas:
|
||||
- Hello World 2
|
||||
env:
|
||||
FROM_KETER_CONFIG: foo bar baz
|
||||
forward-env:
|
||||
- FROM_SYSTEM_ENV
|
||||
- ANOTHER_ENV_VAR
|
||||
hosts:
|
||||
- keter1_0
|
||||
- pong1_0
|
||||
|
Loading…
Reference in New Issue
Block a user