static path for appmgr and other feedback

This commit is contained in:
Lucy Cifferello
2020-10-07 16:47:05 -06:00
parent 0e1e77f4b6
commit 846b1d7754
6 changed files with 12 additions and 15 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 - requires query param ?appmgr=<appmgr_version>
/apps/#S9PK/#Text/config AppConfigR GET -- get app config from appmgr - requires query param ?appmgr=<appmgr_version>
/apps/#S9PK/#Text/manifest AppManifestR GET -- get app manifest from appmgr
/apps/#S9PK/#Text/config AppConfigR GET -- get app config from appmgr
/version VersionR GET

View File

@@ -32,6 +32,7 @@ resources-path: "_env:RESOURCES_PATH:/var/www/html/resources"
ssl-path: "_env:SSL_PATH:/var/ssl"
registry-hostname: "_env:REGISTRY_HOSTNAME:registry.start9labs.com"
tor-port: "_env:TOR_PORT:447"
static-bin-dir: "_env:STATIC_BIN:/usr/local/bin/"
database:
database: "_env:PG_DATABASE:start9_registry"

View File

@@ -2,15 +2,15 @@ name: start9-registry
version: 0.1.0
default-extensions:
- NoImplicitPrelude
- FlexibleInstances
- GeneralizedNewtypeDeriving
- LambdaCase
- MultiWayIf
- NamedFieldPuns
- NoImplicitPrelude
- NumericUnderscores
- OverloadedStrings
- StandaloneDeriving
- FlexibleInstances
dependencies:
- base >=4.12 && <5
@@ -36,10 +36,12 @@ dependencies:
- persistent-template
- process
- protolude
- shakespeare
- template-haskell
- text
- time
- transformers
- typed-process
- unordered-containers
- unix
- wai
@@ -51,8 +53,6 @@ dependencies:
- yesod
- yesod-core
- yesod-persistent
- shakespeare
- typed-process
library:
source-dirs: src

View File

@@ -88,20 +88,14 @@ getSysR e = do
getAppManifestR :: Extension "s9pk" -> Text -> Handler TypedContent
getAppManifestR e@(Extension appId) v = do
appmgrVersion <- lookupGetParam "appmgr" >>= \case
Nothing -> sendResponseStatus status400 ("Appmgr version required" :: Text)
Just a -> pure $ toS a
appMgrDir <- (<> "/") . (</> appmgrVersion) . (</> "appmgr") . (</> "sys") . resourcesDir . appSettings <$> getYesod
appMgrDir <- (<> "/") . staticBinDir . appSettings <$> getYesod
appDir <- (<> "/") . (</> toS v) . (</> appId) . (</> "apps") . resourcesDir . appSettings <$> getYesod
manifest <- handleS9ErrT $ getManifest appMgrDir appDir e
pure $ TypedContent "application/json" (toContent manifest)
getAppConfigR :: Extension "s9pk" -> Text -> Handler TypedContent
getAppConfigR e@(Extension appId) v = do
appmgrVersion <- lookupGetParam "appmgr" >>= \case
Nothing -> sendResponseStatus status400 ("Appmgr version required" :: Text)
Just a -> pure $ toS a
appMgrDir <- (<> "/") . (</> appmgrVersion) . (</> "appmgr") . (</> "sys") . resourcesDir . appSettings <$> getYesod
appMgrDir <- (<> "/") . staticBinDir . appSettings <$> getYesod
appDir <- (<> "/") . (</> toS v) . (</> appId) . (</> "apps") . resourcesDir . appSettings <$> getYesod
config <- handleS9ErrT $ getConfig appMgrDir appDir e
pure $ TypedContent "application/json" (toContent config)

View File

@@ -50,6 +50,7 @@ data AppSettings = AppSettings
, sslCsrLocation :: FilePath
, sslCertLocation :: FilePath
, torPort :: AppPort
, staticBinDir :: FilePath
}
instance FromJSON AppSettings where
@@ -64,6 +65,7 @@ instance FromJSON AppSettings where
sslPath <- o .: "ssl-path"
registryHostname <- o .: "registry-hostname"
torPort <- o .: "tor-port"
staticBinDir <- o .: "static-bin-dir"
let sslKeyLocation = sslPath </> "key.pem"
let sslCsrLocation = sslPath </> "certificate.csr"

View File

@@ -76,6 +76,6 @@ spec = do
withApp $ it "gets bitcoin manifest" $ do
request $ do
setMethod "GET"
setUrl ("/apps/bitcoind.s9pk/0.2.5/manifest?appmgr=0.2.5" :: Text)
setUrl ("/apps/bitcoind.s9pk/0.2.5/manifest" :: Text)
statusIs 200
bodyContains "{\"id\":\"bitcoind\",\"version\":\"0.20.1\",\"title\":\"Bitcoin Core\",\"description\":{\"short\":\"Bitcoin Full Node by Bitcoin Core\",\"long\":\"Bitcoin is an innovative payment network and a new kind of money. Bitcoin uses peer-to-peer technology to operate with no central authority or banks; managing transactions and the issuing of bitcoins is carried out collectively by the network. Bitcoin is open-source; its design is public, nobody owns or controls Bitcoin and everyone can take part. Through many of its unique properties, Bitcoin allows exciting uses that could not be covered by any previous payment system.\"},\"release-notes\":\"https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.20.1.md\",\"has-instructions\":true,\"os-version-required\":\">=0.2.4\",\"os-version-recommended\":\">=0.2.4\",\"ports\":[{\"internal\":8332,\"tor\":8332},{\"internal\":8333,\"tor\":8333}],\"image\":{\"type\":\"tar\"},\"mount\":\"/root/.bitcoin\",\"assets\":[{\"src\":\"bitcoin.conf.template\",\"dst\":\".\",\"overwrite\":true}],\"hidden-service-version\":\"v2\",\"dependencies\":{}}"