Added the build git commit sha to ping endpoint (#110)

* Added the build git commit sha to ping endpoint

* Fixed CI
This commit is contained in:
iko 2021-09-26 19:36:10 +03:00 committed by GitHub
parent 071d58d0d2
commit 9440cb66a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 13 deletions

View File

@ -32,7 +32,23 @@ let
dontStrip = false;
dontPatchELF = false;
enableDeadCodeElimination = true;
packages.octopod-backend = addLocalOptions { src = ./octopod-backend; };
packages.octopod-backend = addLocalOptions (
if prod
then {
src = pkgs.runCommand "octopod-backend-src" { }
''
mkdir -p $out
cp -r ${./octopod-backend}/* $out
cp -r ${builtins.path { path = ./.git; name = "dot-git"; }}/ $out/.git/
'';
components.exes.octopod-exe = {
build-tools =
pkgs.lib.mkForce [ pkgs.buildPackages.buildPackages.gitReallyMinimal ];
extraSrcFiles = [ ".git/**/*" ];
};
}
else { src = ./octopod-backend; }
);
packages.octo-cli = addLocalOptions { src = ./octo-cli; };
packages.octopod-api = addLocalOptions { src = ./octopod-api; };
packages.octopod-frontend = addLocalOptions { src = ./octopod-frontend; };

View File

@ -42,7 +42,7 @@ type DefaultApplicationOverrides =
:> ReqBody '[JSON] (Config 'DeploymentLevel)
:> Post '[JSON] (DefaultConfig 'ApplicationLevel)
type PingEndpoint = "ping" :> GetNoContent
type PingEndpoint = "ping" :> Get '[PlainText] Text
type ProjectNameEndpoint =
"project_name" :> Get '[JSON] ProjectName

View File

@ -1,6 +1,10 @@
{-# LANGUAGE TemplateHaskell #-}
module Main (main) where
import qualified Data.Text as T
import Development.GitRev
import Octopod.Server
main :: IO ()
main = runOctopodServer
main = runOctopodServer (T.pack $gitHash)

View File

@ -137,4 +137,6 @@ executable octopod-exe
build-depends:
base >=4.7 && <5
, octopod-backend
, gitrev
, text
default-language: Haskell2010

View File

@ -130,6 +130,7 @@ data AppState = AppState
, depOverrideKeysCache :: CacheMap ServerError AppM' () [Text]
, appOverridesCache :: CacheMap ServerError AppM' (Config 'DeploymentLevel) (DefaultConfig 'ApplicationLevel)
, appOverrideKeysCache :: CacheMap ServerError AppM' (Config 'DeploymentLevel) [Text]
, gitSha :: Text
}
deriving stock (Generic)
@ -154,8 +155,11 @@ data FullInfoListType
| FullInfoOnlyForOne DeploymentName
deriving stock (Show)
runOctopodServer :: IO ()
runOctopodServer = do
runOctopodServer ::
-- | The git SHA
Text ->
IO ()
runOctopodServer sha = do
logger' <- newLogger
logInfo logger' "started"
bgWorkersC <- newIORef 0
@ -257,6 +261,7 @@ runOctopodServer = do
, depOverrideKeysCache = depOverrideKeysCache'
, appOverridesCache = appOverridesCache'
, appOverrideKeysCache = appOverrideKeysCache'
, gitSha = sha
}
app' = app appSt
@ -885,10 +890,10 @@ getInfo dName = do
}
-- | Handles the 'ping' request.
pingH :: AppM NoContent
pingH :: AppM Text
pingH = do
_ <- runStatement $ select $ pure $ litExpr True
pure NoContent
asks gitSha
-- | Handles the 'project_name' request.
projectNameH :: AppM ProjectName

View File

@ -21,7 +21,6 @@ module Frontend.API
fullInfoEndpoint,
statusEndpoint,
restoreEndpoint,
pingEndpoint,
projectName,
commandResponse,
wsPath,
@ -127,10 +126,6 @@ restoreEndpoint ::
Dynamic t (Either Text DeploymentName) ->
Event t () ->
m (Event t (ReqResult () CommandResponse))
pingEndpoint ::
MonadWidget t m =>
Event t () ->
m (Event t (ReqResult () NoContent))
projectName ::
MonadWidget t m =>
Event t () ->
@ -148,7 +143,7 @@ deploymentOverrideKeys
:<|> statusEndpoint
:<|> restoreEndpoint
)
:<|> pingEndpoint
:<|> _pingEndpoint
:<|> projectName = apiClients
-- | Parser of kubectl command responses.