mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-30 03:41:57 +00:00
rename appmgr calls to be more descriptive of the API
This commit is contained in:
@@ -33,7 +33,6 @@ import Yesod.Persist.Core
|
|||||||
|
|
||||||
import Database.Queries
|
import Database.Queries
|
||||||
import Foundation
|
import Foundation
|
||||||
import Lib.Error
|
|
||||||
import Lib.External.AppMgr
|
import Lib.External.AppMgr
|
||||||
import Lib.Registry
|
import Lib.Registry
|
||||||
import Lib.Types.AppIndex
|
import Lib.Types.AppIndex
|
||||||
@@ -79,10 +78,10 @@ getAppManifestR appId = do
|
|||||||
Just v -> pure v
|
Just v -> pure v
|
||||||
let appDir = (<> "/") . (</> show av) . (</> show appId) $ appsDir
|
let appDir = (<> "/") . (</> show av) . (</> show appId) $ appsDir
|
||||||
addPackageHeader appMgrDir appDir appExt
|
addPackageHeader appMgrDir appDir appExt
|
||||||
getManifest appMgrDir
|
sourceManifest appMgrDir
|
||||||
appDir
|
appDir
|
||||||
appExt
|
appExt
|
||||||
(\bsSource -> respondSource "application/json" (bsSource .| awaitForever sendChunkBS))
|
(\bsSource -> respondSource "application/json" (bsSource .| awaitForever sendChunkBS))
|
||||||
where appExt = Extension (show appId) :: Extension "s9pk"
|
where appExt = Extension (show appId) :: Extension "s9pk"
|
||||||
|
|
||||||
getAppConfigR :: AppIdentifier -> Handler TypedContent
|
getAppConfigR :: AppIdentifier -> Handler TypedContent
|
||||||
@@ -95,7 +94,10 @@ getAppConfigR appId = do
|
|||||||
Just v -> pure v
|
Just v -> pure v
|
||||||
let appDir = (<> "/") . (</> show av) . (</> show appId) $ appsDir
|
let appDir = (<> "/") . (</> show av) . (</> show appId) $ appsDir
|
||||||
addPackageHeader appMgrDir appDir appExt
|
addPackageHeader appMgrDir appDir appExt
|
||||||
config <- getConfig appMgrDir appDir appExt (\bsSource -> _)
|
config <- sourceConfig appMgrDir
|
||||||
|
appDir
|
||||||
|
appExt
|
||||||
|
(\bsSource -> respondSource "application/json" (bsSource .| awaitForever sendChunkBS))
|
||||||
pure $ TypedContent "application/json" (toContent config)
|
pure $ TypedContent "application/json" (toContent config)
|
||||||
where appExt = Extension (show appId) :: Extension "s9pk"
|
where appExt = Extension (show appId) :: Extension "s9pk"
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import Data.Conduit ( (.|)
|
|||||||
)
|
)
|
||||||
import qualified Data.Conduit.List as CL
|
import qualified Data.Conduit.List as CL
|
||||||
import Foundation
|
import Foundation
|
||||||
import Lib.Error
|
|
||||||
import Lib.External.AppMgr
|
import Lib.External.AppMgr
|
||||||
import Lib.Registry
|
import Lib.Registry
|
||||||
import Lib.Types.AppIndex
|
import Lib.Types.AppIndex
|
||||||
@@ -45,7 +44,7 @@ getIconsR appId = do
|
|||||||
Nothing -> sendResponseStatus status404 ("Specified App Version Not Found" :: Text)
|
Nothing -> sendResponseStatus status404 ("Specified App Version Not Found" :: Text)
|
||||||
Just v -> pure v
|
Just v -> pure v
|
||||||
let appDir = (<> "/") . (</> show spec) . (</> show appId) $ appsDir
|
let appDir = (<> "/") . (</> show spec) . (</> show appId) $ appsDir
|
||||||
manifest' <- getManifest appMgrDir appDir ext (\bsSource -> runConduit $ bsSource .| CL.foldMap BS.fromStrict)
|
manifest' <- sourceManifest appMgrDir appDir ext (\bsSource -> runConduit $ bsSource .| CL.foldMap BS.fromStrict)
|
||||||
manifest <- case eitherDecode manifest' of
|
manifest <- case eitherDecode manifest' of
|
||||||
Left e -> do
|
Left e -> do
|
||||||
$logError "could not parse service manifest!"
|
$logError "could not parse service manifest!"
|
||||||
@@ -66,10 +65,10 @@ getIconsR appId = do
|
|||||||
SVG -> pure typeSvg
|
SVG -> pure typeSvg
|
||||||
JPG -> pure typeJpeg
|
JPG -> pure typeJpeg
|
||||||
JPEG -> pure typeJpeg
|
JPEG -> pure typeJpeg
|
||||||
getIcon appMgrDir
|
sourceIcon appMgrDir
|
||||||
(appDir </> show ext)
|
(appDir </> show ext)
|
||||||
ext
|
ext
|
||||||
(\bsSource -> respondSource mimeType (bsSource .| awaitForever sendChunkBS))
|
(\bsSource -> respondSource mimeType (bsSource .| awaitForever sendChunkBS))
|
||||||
where ext = Extension (show appId) :: Extension "s9pk"
|
where ext = Extension (show appId) :: Extension "s9pk"
|
||||||
|
|
||||||
getLicenseR :: AppIdentifier -> Handler TypedContent
|
getLicenseR :: AppIdentifier -> Handler TypedContent
|
||||||
@@ -82,7 +81,7 @@ getLicenseR appId = do
|
|||||||
case servicePath of
|
case servicePath of
|
||||||
Nothing -> notFound
|
Nothing -> notFound
|
||||||
Just p ->
|
Just p ->
|
||||||
getLicense appMgrDir p ext (\bsSource -> respondSource typePlain (bsSource .| awaitForever sendChunkBS))
|
sourceLicense appMgrDir p ext (\bsSource -> respondSource typePlain (bsSource .| awaitForever sendChunkBS))
|
||||||
where ext = Extension (show appId) :: Extension "s9pk"
|
where ext = Extension (show appId) :: Extension "s9pk"
|
||||||
|
|
||||||
getInstructionsR :: AppIdentifier -> Handler TypedContent
|
getInstructionsR :: AppIdentifier -> Handler TypedContent
|
||||||
@@ -94,8 +93,8 @@ getInstructionsR appId = do
|
|||||||
servicePath <- liftIO $ getVersionedFileFromDir appsDir ext spec
|
servicePath <- liftIO $ getVersionedFileFromDir appsDir ext spec
|
||||||
case servicePath of
|
case servicePath of
|
||||||
Nothing -> notFound
|
Nothing -> notFound
|
||||||
Just p -> getInstructions appMgrDir
|
Just p -> sourceInstructions appMgrDir
|
||||||
p
|
p
|
||||||
ext
|
ext
|
||||||
(\bsSource -> respondSource typePlain (bsSource .| awaitForever sendChunkBS))
|
(\bsSource -> respondSource typePlain (bsSource .| awaitForever sendChunkBS))
|
||||||
where ext = Extension (show appId) :: Extension "s9pk"
|
where ext = Extension (show appId) :: Extension "s9pk"
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ getServiceDetails settings metadata maybeVersion appId = do
|
|||||||
Just v -> pure v
|
Just v -> pure v
|
||||||
let appDir = (<> "/") . (</> show version) . (</> show appId) $ appsDir
|
let appDir = (<> "/") . (</> show version) . (</> show appId) $ appsDir
|
||||||
let appExt = Extension (show appId) :: Extension "s9pk"
|
let appExt = Extension (show appId) :: Extension "s9pk"
|
||||||
manifest' <- getManifest appMgrDir appDir appExt (\bs -> sinkMem (bs .| mapC BS.fromStrict))
|
manifest' <- sourceManifest appMgrDir appDir appExt (\bs -> sinkMem (bs .| mapC BS.fromStrict))
|
||||||
case eitherDecode $ manifest' of
|
case eitherDecode $ manifest' of
|
||||||
Left e -> pure $ Left $ "Could not parse service manifest for " <> show appId <> ": " <> show e
|
Left e -> pure $ Left $ "Could not parse service manifest for " <> show appId <> ": " <> show e
|
||||||
Right m -> do
|
Right m -> do
|
||||||
@@ -467,7 +467,7 @@ decodeInstructions :: (MonadUnliftIO m, MonadHandler m, KnownSymbol a, MonadThro
|
|||||||
-> Extension a
|
-> Extension a
|
||||||
-> m Text
|
-> m Text
|
||||||
decodeInstructions appmgrPath depPath package = do
|
decodeInstructions appmgrPath depPath package = do
|
||||||
getInstructions appmgrPath depPath package (\bs -> sinkMem (bs .| CT.decode CT.utf8))
|
sourceInstructions appmgrPath depPath package (\bs -> sinkMem (bs .| CT.decode CT.utf8))
|
||||||
|
|
||||||
decodeLicense :: (MonadUnliftIO m, MonadThrow m, MonadHandler m, KnownSymbol a)
|
decodeLicense :: (MonadUnliftIO m, MonadThrow m, MonadHandler m, KnownSymbol a)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
@@ -475,7 +475,7 @@ decodeLicense :: (MonadUnliftIO m, MonadThrow m, MonadHandler m, KnownSymbol a)
|
|||||||
-> Extension a
|
-> Extension a
|
||||||
-> m Text
|
-> m Text
|
||||||
decodeLicense appmgrPath depPath package =
|
decodeLicense appmgrPath depPath package =
|
||||||
getLicense appmgrPath depPath package (\bs -> sinkMem (bs .| CT.decode CT.utf8))
|
sourceLicense appmgrPath depPath package (\bs -> sinkMem (bs .| CT.decode CT.utf8))
|
||||||
|
|
||||||
fetchAllAppVersions :: Key SApp -> HandlerFor RegistryCtx ([VersionInfo], ReleaseNotes)
|
fetchAllAppVersions :: Key SApp -> HandlerFor RegistryCtx ([VersionInfo], ReleaseNotes)
|
||||||
fetchAllAppVersions appId = do
|
fetchAllAppVersions appId = do
|
||||||
|
|||||||
70
src/Lib/External/AppMgr.hs
vendored
70
src/Lib/External/AppMgr.hs
vendored
@@ -57,36 +57,36 @@ readProcessInheritStderr a b c sink = do
|
|||||||
$ System.Process.Typed.proc a b
|
$ System.Process.Typed.proc a b
|
||||||
withProcessTerm_ pc $ \p -> sink (getStdout p)
|
withProcessTerm_ pc $ \p -> sink (getStdout p)
|
||||||
|
|
||||||
getConfig :: (MonadUnliftIO m, MonadThrow m, KnownSymbol a)
|
sourceConfig :: (MonadUnliftIO m, MonadThrow m, KnownSymbol a)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> FilePath
|
-> FilePath
|
||||||
-> Extension a
|
-> Extension a
|
||||||
-> (ConduitT () ByteString m () -> m r)
|
-> (ConduitT () ByteString m () -> m r)
|
||||||
-> m r
|
-> m r
|
||||||
getConfig appmgrPath appPath e@(Extension appId) sink = do
|
sourceConfig appmgrPath appPath e@(Extension appId) sink = do
|
||||||
let
|
let
|
||||||
appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk")
|
appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk")
|
||||||
["inspect", "config", appPath </> show e, "--json"]
|
["inspect", "config", appPath </> show e, "--json"]
|
||||||
""
|
""
|
||||||
appmgr sink `catch` \ece -> throwIO (AppMgrE [i|inspect config #{appId} \--json|] (eceExitCode ece))
|
appmgr sink `catch` \ece -> throwIO (AppMgrE [i|inspect config #{appId} \--json|] (eceExitCode ece))
|
||||||
|
|
||||||
getManifest :: (MonadUnliftIO m, KnownSymbol a)
|
sourceManifest :: (MonadUnliftIO m, KnownSymbol a)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> FilePath
|
-> FilePath
|
||||||
-> Extension a
|
-> Extension a
|
||||||
-> (ConduitT () ByteString m () -> m r)
|
-> (ConduitT () ByteString m () -> m r)
|
||||||
-> m r
|
-> m r
|
||||||
getManifest appmgrPath appPath e@(Extension appId) sink = do
|
sourceManifest appmgrPath appPath e@(Extension appId) sink = do
|
||||||
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "manifest", appPath </> show e] ""
|
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "manifest", appPath </> show e] ""
|
||||||
appmgr sink `catch` \ece -> throwIO (AppMgrE [i|embassy-sdk inspect manifest #{appId}|] (eceExitCode ece))
|
appmgr sink `catch` \ece -> throwIO (AppMgrE [i|embassy-sdk inspect manifest #{appId}|] (eceExitCode ece))
|
||||||
|
|
||||||
getIcon :: (MonadUnliftIO m, KnownSymbol a)
|
sourceIcon :: (MonadUnliftIO m, KnownSymbol a)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> FilePath
|
-> FilePath
|
||||||
-> Extension a
|
-> Extension a
|
||||||
-> (ConduitT () ByteString m () -> m r)
|
-> (ConduitT () ByteString m () -> m r)
|
||||||
-> m r
|
-> m r
|
||||||
getIcon appmgrPath appPath (Extension icon) sink = do
|
sourceIcon appmgrPath appPath (Extension icon) sink = do
|
||||||
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "icon", appPath] ""
|
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "icon", appPath] ""
|
||||||
appmgr sink `catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect icon #{icon}|] (eceExitCode ece)
|
appmgr sink `catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect icon #{icon}|] (eceExitCode ece)
|
||||||
|
|
||||||
@@ -96,23 +96,23 @@ getPackageHash appmgrPath appPath e@(Extension appId) = do
|
|||||||
appmgr (\bsSource -> runConduit $ bsSource .| CL.foldMap id)
|
appmgr (\bsSource -> runConduit $ bsSource .| CL.foldMap id)
|
||||||
`catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect hash #{appId}|] (eceExitCode ece)
|
`catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect hash #{appId}|] (eceExitCode ece)
|
||||||
|
|
||||||
getInstructions :: (MonadUnliftIO m, KnownSymbol a)
|
sourceInstructions :: (MonadUnliftIO m, KnownSymbol a)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> FilePath
|
-> FilePath
|
||||||
-> Extension a
|
-> Extension a
|
||||||
-> (ConduitT () ByteString m () -> m r)
|
-> (ConduitT () ByteString m () -> m r)
|
||||||
-> m r
|
-> m r
|
||||||
getInstructions appmgrPath appPath (Extension appId) sink = do
|
sourceInstructions appmgrPath appPath (Extension appId) sink = do
|
||||||
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "instructions", appPath] ""
|
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "instructions", appPath] ""
|
||||||
appmgr sink `catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect instructions #{appId}|] (eceExitCode ece)
|
appmgr sink `catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect instructions #{appId}|] (eceExitCode ece)
|
||||||
|
|
||||||
getLicense :: (MonadUnliftIO m, KnownSymbol a)
|
sourceLicense :: (MonadUnliftIO m, KnownSymbol a)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> FilePath
|
-> FilePath
|
||||||
-> Extension a
|
-> Extension a
|
||||||
-> (ConduitT () ByteString m () -> m r)
|
-> (ConduitT () ByteString m () -> m r)
|
||||||
-> m r
|
-> m r
|
||||||
getLicense appmgrPath appPath (Extension appId) sink = do
|
sourceLicense appmgrPath appPath (Extension appId) sink = do
|
||||||
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "license", appPath] ""
|
let appmgr = readProcessInheritStderr (appmgrPath <> "embassy-sdk") ["inspect", "license", appPath] ""
|
||||||
appmgr sink `catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect license #{appId}|] (eceExitCode ece)
|
appmgr sink `catch` \ece -> throwIO $ AppMgrE [i|embassy-sdk inspect license #{appId}|] (eceExitCode ece)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user