refactor config/manifest endpoint path with appId

This commit is contained in:
Lucy Cifferello
2020-10-09 14:16:57 -06:00
parent 1017d5a363
commit f7482cbc76
6 changed files with 19 additions and 60 deletions

View File

@@ -1,8 +1,8 @@
/apps AppsManifestR GET -- get current apps listing
/apps/#S9PK/#Text/manifest AppManifestR GET -- get app manifest from appmgr
/apps/#S9PK/#Text/config AppConfigR GET -- get app config from appmgr
/apps/#AppIdentifier/#Text/manifest AppManifestR GET -- get app manifest from appmgr
/apps/#AppIdentifier/#Text/config AppConfigR GET -- get app config from appmgr
/version VersionR GET

View File

@@ -1,16 +0,0 @@
-----BEGIN CERTIFICATE-----
MIICljCCAX4CCQCUVP/RJvKF1DANBgkqhkiG9w0BAQUFADANMQswCQYDVQQGEwJV
UzAeFw0xOTEyMjEyMDM1MDBaFw0yMDAxMjAyMDM1MDBaMA0xCzAJBgNVBAYTAlVT
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0jmDTPSdmEt5WvBvAnhg
CTfuwhX+gukkjqy6FudTSPIRDkdgEdgZ47M2+VBRFRotFgFJSL2p5iqgksj+5LNp
MveuMY5BzjvgpAwMXd+lXsYCcKkWrrD54BMmvJ8r0lZd7qIkm9jZF/cNFNDu838F
MraySN+JtRCSHPgdtnnRump0SzyiftRl22+7XZfzqgh/RMwMVepeqkySCA2OZ2oZ
MfRhDzF6L98wYO+o526XK7hNDfvIVmAsi1HTwobC1Z9+a7JqRty0TeUShsdYDYD3
KtaOBDVvFigfUDDHxO74c4qFhcGsBu1qkRSmNkenPf+aN2QwbNjyztKWTS47oeq2
XwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQCTwhvM7g7SWI8XIOJRa3FKHq+IXCi5
YQQkXqZH4v82UQNhhR6dNLBKu66ZGEflr0HnaqXl8iZnuUxI3iBTLUUOEK2xVggt
YBVkf7/nnGl0Y6RqUz8lPhJ5ySloR99FvBuN4k3ldO3pjKdJ+h9r9heVbVcurLxN
f/pU6J1Y4soVG7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KgPbbjOTlN6a3ourfnYLKpiN3y8O5X/+NEqfZw+akS+fRUCgYEA3Z+2
CrH8ekR+tIfwSYpKwKvdQi7FT0gc5o/XBlipVtztuEvElMzFWR1aeKfZ9PoEsuvv
XWECSNEgeu8/d0aILpiEZSnIDqq05DemYA1gM4dtjgjT9ip+Wur8JFMLpjty2ymA
GoQZkiye5cjrhJnwwXUXWywFFqrDC53qlFLVSqMCgYAQWQFSUp3/TS4aXc7SlHOr
yT+rh+yDsYCbXK1/Rq70ykU6PZSWIchc13BQvF46gdgX2tl5lKpyaNr4WDBIQoRU
kdkXVdbLOGqC+x3WWpkBjcyc/JCFuj8Ej8Tcvl/2M2o2fMaGx1/qdGNIGxXOi/no
umEBset1mL8/jZE2HkKksQKBgALLEoZL+/ymhFpOJE8o+Qw4nk9JO59mL0cQpQsl
buzzV+OswMuHUS1wW0WOCAc4Z3rB0oCAyoCUci5aeZhNQUYlEfYccrMMn78InIY1
ZPMBT/YsUk+V9YW71HW4vjrYIPh2K3EqHRBkk5Qd1ioTrp8hlKvHgEDq4g5xbRV1
fc61AoGBALfH4KqPqDcJNRvomHE4LQagn63nYyt7R3rIdA+AsvxRKF/uP8w8dTeB
lMDM7S/UzGwsxNU/bCAyrazoNGd/zQ1N7Da5cl54fJ08yV8t68v5Y0kVzmweMyya
tFCnAJF0BTnqHx2MApsipgPvY6Z/oWXsLGdCTY+ILmR7Ej1PWyUA
-----END RSA PRIVATE KEY-----

View File

@@ -17,6 +17,8 @@ import qualified Yesod.Core.Unsafe as Unsafe
import Settings
import Yesod.Persist.Core
import Lib.Types.AppIndex
import Lib.Types.Semver
-- | The foundation datatype for your application. This can be a good place to
-- keep settings and values requiring initialization before your application

View File

@@ -86,18 +86,18 @@ getSysR e = do
sysResourceDir <- (</> "sys") . resourcesDir . appSettings <$> getYesod
getApp sysResourceDir e
getAppManifestR :: Extension "s9pk" -> Text -> Handler TypedContent
getAppManifestR e@(Extension appId) v = do
getAppManifestR :: AppIdentifier -> Text -> Handler TypedContent
getAppManifestR appId v = do
appMgrDir <- (<> "/") . staticBinDir . appSettings <$> getYesod
appDir <- (<> "/") . (</> toS v) . (</> appId) . (</> "apps") . resourcesDir . appSettings <$> getYesod
manifest <- handleS9ErrT $ getManifest appMgrDir appDir e
appDir <- (<> "/") . (</> toS v) . (</> toS appId) . (</> "apps") . resourcesDir . appSettings <$> getYesod
manifest <- handleS9ErrT $ getManifest appMgrDir appDir appId
pure $ TypedContent "application/json" (toContent manifest)
getAppConfigR :: Extension "s9pk" -> Text -> Handler TypedContent
getAppConfigR e@(Extension appId) v = do
getAppConfigR :: AppIdentifier -> Text -> Handler TypedContent
getAppConfigR appId v = do
appMgrDir <- (<> "/") . staticBinDir . appSettings <$> getYesod
appDir <- (<> "/") . (</> toS v) . (</> appId) . (</> "apps") . resourcesDir . appSettings <$> getYesod
config <- handleS9ErrT $ getConfig appMgrDir appDir e
appDir <- (<> "/") . (</> toS v) . (</> toS appId) . (</> "apps") . resourcesDir . appSettings <$> getYesod
config <- handleS9ErrT $ getConfig appMgrDir appDir appId
pure $ TypedContent "application/json" (toContent config)
getAppR :: Extension "s9pk" -> Handler TypedContent

View File

@@ -16,7 +16,7 @@ import Data.String.Interpolate.IsString
import System.Process.Typed hiding ( createPipe )
import Lib.Error
import Lib.Registry
import Lib.Types.AppIndex
readProcessWithExitCode' :: MonadIO m => String -> [String] -> ByteString -> m (ExitCode, ByteString, ByteString)
readProcessWithExitCode' a b c = liftIO $ do
@@ -42,16 +42,16 @@ readProcessInheritStderr a b c = liftIO $ do
withProcessWait pc
$ \process -> atomically $ liftA2 (,) (waitExitCodeSTM process) (fmap LBS.toStrict $ getStdout process)
getConfig :: (MonadIO m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> S9ErrT m Text
getConfig appmgrPath appPath e@(Extension appId) = fmap decodeUtf8 $ do
(ec, out) <- readProcessInheritStderr (appmgrPath <> "appmgr") ["inspect", "info", appPath <> show e, "-C", "--json"] ""
getConfig :: MonadIO m => FilePath -> FilePath -> AppIdentifier -> S9ErrT m Text
getConfig appmgrPath appPath appId = fmap decodeUtf8 $ do
(ec, out) <- readProcessInheritStderr (appmgrPath <> "appmgr") ["inspect", "info", appPath <> (toS $ appId <> ".s9pk"), "-C", "--json"] ""
case ec of
ExitSuccess -> pure out
ExitFailure n -> throwE $ AppMgrE [i|info #{appId} -C \--json|] n
getManifest :: (MonadIO m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> S9ErrT m ByteString
getManifest appmgrPath appPath e@(Extension appId) = do
(ec, bs) <- readProcessInheritStderr (appmgrPath <> "appmgr") ["inspect", "info", appPath <> show e, "-M", "--json"] ""
getManifest :: MonadIO m => FilePath -> FilePath -> AppIdentifier -> S9ErrT m ByteString
getManifest appmgrPath appPath appId = do
(ec, bs) <- readProcessInheritStderr (appmgrPath <> "appmgr") ["inspect", "info", appPath <> (toS $ appId <> ".s9pk"), "-M", "--json"] ""
case ec of
ExitSuccess -> pure bs
ExitFailure n -> throwE $ AppMgrE [i|info -M #{appId} \--json|] n