mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
Integration/0.2.13 (#324)
* updates to 8.10.4, adjusts dependencies, adds license info feature * add toJSON * add licesne info to services * remove mocks * adds license info to available show * prepare upgrade messaging * better welcome message * update backend versioning to 0.2.13 * add version migration file * update ui build scripts * update eos image * update eos image with embassy * add migration files * update welcome page * explicity add migration files Co-authored-by: Keagan McClelland <keagan.mcclelland@gmail.com> Co-authored-by: Lucy Cifferello <12953208+elvece@users.noreply.github.com>
This commit is contained in:
@@ -33,5 +33,5 @@ database:
|
||||
database: "start9_agent.sqlite3"
|
||||
poolsize: "_env:YESOD_SQLITE_POOLSIZE:10"
|
||||
|
||||
app-mgr-version-spec: "=0.2.12"
|
||||
app-mgr-version-spec: "=0.2.13"
|
||||
#analytics: UA-YOURCODE
|
||||
|
||||
1
agent/migrations/0.2.12::0.2.13
Normal file
1
agent/migrations/0.2.12::0.2.13
Normal file
@@ -0,0 +1 @@
|
||||
SELECT TRUE;
|
||||
@@ -1,5 +1,5 @@
|
||||
name: ambassador-agent
|
||||
version: 0.2.12
|
||||
version: 0.2.13
|
||||
|
||||
default-extensions:
|
||||
- NoImplicitPrelude
|
||||
@@ -182,3 +182,4 @@ executables:
|
||||
condition: flag(library-only)
|
||||
- condition: false
|
||||
other-modules: Paths_ambassador_agent
|
||||
extra-source-files: ./migrations/*
|
||||
@@ -154,8 +154,7 @@ getAvailableAppsLogic :: ( Has (Reader AgentCtx) sig m
|
||||
getAvailableAppsLogic = do
|
||||
jobCache <- asks appBackgroundJobs >>= liftIO . readTVarIO
|
||||
let installCache = inspect SInstalling jobCache
|
||||
(Reg.AppManifestRes apps, serverApps) <- LAsync.concurrently Reg.getAppManifest
|
||||
(AppMgr2.list [AppMgr2.flags|-s -d|])
|
||||
(Reg.AppIndexRes apps, serverApps) <- LAsync.concurrently Reg.getAppIndex (AppMgr2.list [AppMgr2.flags|-s -d|])
|
||||
let remapped = remapAppMgrInfo jobCache serverApps
|
||||
pure $ foreach apps $ \app@StoreApp { storeAppId } ->
|
||||
let installing =
|
||||
@@ -183,8 +182,9 @@ getAvailableAppByIdLogic appId = do
|
||||
let storeAppId' = storeAppId
|
||||
jobCache <- asks appBackgroundJobs >>= liftIO . readTVarIO
|
||||
let installCache = inspect SInstalling jobCache
|
||||
(Reg.AppManifestRes storeApps, serverApps) <- LAsync.concurrently Reg.getAppManifest
|
||||
(AppMgr2.list [AppMgr2.flags|-s -d|])
|
||||
((Reg.AppIndexRes storeApps, serverApps), AppManifest.AppManifest { appManifestLicenseName, appManifestLicenseLink }) <-
|
||||
LAsync.concurrently (LAsync.concurrently Reg.getAppIndex (AppMgr2.list [AppMgr2.flags|-s -d|]))
|
||||
(Reg.getAppManifest appId)
|
||||
StoreApp {..} <- pure (find ((== appId) . storeAppId) storeApps) `orThrowM` NotFoundE "appId" (show appId)
|
||||
let remapped = remapAppMgrInfo jobCache serverApps
|
||||
let installingInfo =
|
||||
@@ -213,6 +213,8 @@ getAvailableAppByIdLogic appId = do
|
||||
appId
|
||||
storeAppTitle
|
||||
(storeIconUrl appId (storeAppVersionInfoVersion $ extract storeAppVersions))
|
||||
, appAvailableFullLicenseName = appManifestLicenseName
|
||||
, appAvailableFullLicenseLink = appManifestLicenseLink
|
||||
, appAvailableFullInstallInfo = installingInfo
|
||||
, appAvailableFullVersionLatest = storeAppVersionInfoVersion latest
|
||||
, appAvailableFullDescriptionShort = storeAppDescriptionShort
|
||||
@@ -303,6 +305,8 @@ getInstalledAppByIdLogic appId = do
|
||||
backupTime <- lift $ LAsync.wait backupTime'
|
||||
hoistMaybe $ HM.lookup appId installCache <&> \(StoreApp {..}, StoreAppVersionInfo {..}) -> AppInstalledFull
|
||||
{ appInstalledFullBase = AppBase appId storeAppTitle (iconUrl appId storeAppVersionInfoVersion)
|
||||
, appInstalledFullLicenseName = Nothing
|
||||
, appInstalledFullLicenseLink = Nothing
|
||||
, appInstalledFullStatus = AppStatusTmp Installing
|
||||
, appInstalledFullVersionInstalled = storeAppVersionInfoVersion
|
||||
, appInstalledFullInstructions = Nothing
|
||||
@@ -319,7 +323,7 @@ getInstalledAppByIdLogic appId = do
|
||||
}
|
||||
serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|]
|
||||
let remapped = remapAppMgrInfo jobCache serverApps
|
||||
appManifestFetchCached <- cached Reg.getAppManifest
|
||||
appManifestFetchCached <- cached Reg.getAppIndex
|
||||
let
|
||||
installed = do
|
||||
(status, version, AppMgr2.InfoRes {..}) <- hoistMaybe (HM.lookup appId remapped)
|
||||
@@ -333,7 +337,7 @@ getInstalledAppByIdLogic appId = do
|
||||
fromInstalled = (AppMgr2.infoResTitle &&& AppMgr2.infoResVersion)
|
||||
<$> hoistMaybe (HM.lookup depId serverApps)
|
||||
let fromStore = do
|
||||
Reg.AppManifestRes res <- lift appManifestFetchCached
|
||||
Reg.AppIndexRes res <- lift appManifestFetchCached
|
||||
(storeAppTitle &&& storeAppVersionInfoVersion . extract . storeAppVersions)
|
||||
<$> hoistMaybe (find ((== depId) . storeAppId) res)
|
||||
(title, v) <- fromInstalled <|> fromStore
|
||||
@@ -354,6 +358,8 @@ getInstalledAppByIdLogic appId = do
|
||||
guard (not . null $ lanConfs)
|
||||
pure $ LanAddress . (".onion" `Text.replace` ".local") . unTorAddress $ addrBase
|
||||
pure AppInstalledFull { appInstalledFullBase = AppBase appId infoResTitle (iconUrl appId version)
|
||||
, appInstalledFullLicenseName = AppManifest.appManifestLicenseName manifest
|
||||
, appInstalledFullLicenseLink = AppManifest.appManifestLicenseLink manifest
|
||||
, appInstalledFullStatus = status
|
||||
, appInstalledFullVersionInstalled = version
|
||||
, appInstalledFullInstructions = instructions
|
||||
@@ -674,8 +680,8 @@ getAvailableAppVersionInfoLogic :: ( Has (Reader AgentCtx) sig m
|
||||
-> VersionRange
|
||||
-> m AppVersionInfo
|
||||
getAvailableAppVersionInfoLogic appId appVersionSpec = do
|
||||
jobCache <- asks appBackgroundJobs >>= liftIO . readTVarIO
|
||||
Reg.AppManifestRes storeApps <- Reg.getAppManifest
|
||||
jobCache <- asks appBackgroundJobs >>= liftIO . readTVarIO
|
||||
Reg.AppIndexRes storeApps <- Reg.getAppIndex
|
||||
let titles =
|
||||
(storeAppTitle &&& storeAppVersionInfoVersion . extract . storeAppVersions) <$> indexBy storeAppId storeApps
|
||||
StoreApp {..} <- find ((== appId) . storeAppId) storeApps `orThrowPure` NotFoundE "appId" (show appId)
|
||||
|
||||
@@ -14,6 +14,13 @@ import Network.HTTP.Simple
|
||||
import System.FilePath.Posix
|
||||
import Yesod.Core
|
||||
|
||||
import Control.Carrier.Reader hiding ( asks )
|
||||
import Control.Concurrent.STM ( modifyTVar
|
||||
, readTVarIO
|
||||
)
|
||||
import Control.Effect.Labelled ( runLabelled )
|
||||
import Crypto.Hash.Conduit ( hashFile )
|
||||
import qualified Data.HashMap.Strict as HM
|
||||
import Foundation
|
||||
import Lib.Algebra.State.RegistryUrl
|
||||
import Lib.Error
|
||||
@@ -21,16 +28,9 @@ import qualified Lib.External.Registry as Reg
|
||||
import Lib.IconCache
|
||||
import Lib.SystemPaths hiding ( (</>) )
|
||||
import Lib.Types.Core
|
||||
import Lib.Types.Emver
|
||||
import Lib.Types.ServerApp
|
||||
import Settings
|
||||
import Control.Carrier.Reader hiding ( asks )
|
||||
import Control.Effect.Labelled ( runLabelled )
|
||||
import qualified Data.HashMap.Strict as HM
|
||||
import Control.Concurrent.STM ( modifyTVar
|
||||
, readTVarIO
|
||||
)
|
||||
import Crypto.Hash.Conduit ( hashFile )
|
||||
import Lib.Types.Emver
|
||||
|
||||
iconUrl :: AppId -> Version -> Text
|
||||
iconUrl appId version = (foldMap (T.cons '/') . fst . renderRoute . AppIconR $ appId) <> "?" <> show version
|
||||
@@ -63,7 +63,7 @@ getAppIconR appId = handleS9ErrT $ do
|
||||
lift $ respondSource (parseContentType path) $ CB.sourceFile path .| awaitForever sendChunkBS
|
||||
where
|
||||
fetchIcon = do
|
||||
url <- find ((== appId) . storeAppId) . Reg.storeApps <$> Reg.getAppManifest >>= \case
|
||||
url <- find ((== appId) . storeAppId) . Reg.storeApps <$> Reg.getAppIndex >>= \case
|
||||
Nothing -> throwError $ NotFoundE "icon" (show appId)
|
||||
Just x -> pure . toS $ storeAppIconUrl x
|
||||
bp <- getAbsoluteLocationFor iconBasePath
|
||||
@@ -84,7 +84,7 @@ getAvailableAppIconR :: AppId -> Handler TypedContent
|
||||
getAvailableAppIconR appId = handleS9ErrT $ do
|
||||
s <- getsYesod appSettings
|
||||
url <- do
|
||||
find ((== appId) . storeAppId) . Reg.storeApps <$> interp s Reg.getAppManifest >>= \case
|
||||
find ((== appId) . storeAppId) . Reg.storeApps <$> interp s Reg.getAppIndex >>= \case
|
||||
Nothing -> throwE $ NotFoundE "icon" (show appId)
|
||||
Just x -> pure . toS $ storeAppIconUrl x
|
||||
req <- case parseRequest url of
|
||||
|
||||
@@ -74,6 +74,8 @@ instance FromJSON InstallNewAppReq where
|
||||
|
||||
data AppAvailableFull = AppAvailableFull
|
||||
{ appAvailableFullBase :: AppBase
|
||||
, appAvailableFullLicenseName :: Maybe Text
|
||||
, appAvailableFullLicenseLink :: Maybe Text
|
||||
, appAvailableFullInstallInfo :: Maybe (Version, AppStatus)
|
||||
, appAvailableFullVersionLatest :: Version
|
||||
, appAvailableFullDescriptionShort :: Text
|
||||
@@ -88,7 +90,9 @@ instance ToJSON AppAvailableFull where
|
||||
toJSON AppAvailableFull {..} = mergeTo
|
||||
(toJSON appAvailableFullBase)
|
||||
(object
|
||||
[ "versionInstalled" .= fmap fst appAvailableFullInstallInfo
|
||||
[ "licenseName" .= appAvailableFullLicenseName
|
||||
, "licenseLink" .= appAvailableFullLicenseLink
|
||||
, "versionInstalled" .= fmap fst appAvailableFullInstallInfo
|
||||
, "status" .= fmap snd appAvailableFullInstallInfo
|
||||
, "versionLatest" .= appAvailableFullVersionLatest
|
||||
, "descriptionShort" .= appAvailableFullDescriptionShort
|
||||
@@ -131,6 +135,8 @@ instance ToJSON (AppDependencyRequirement Keep) where
|
||||
-- mute violations downstream of version for installing apps
|
||||
data AppInstalledFull = AppInstalledFull
|
||||
{ appInstalledFullBase :: AppBase
|
||||
, appInstalledFullLicenseName :: Maybe Text
|
||||
, appInstalledFullLicenseLink :: Maybe Text
|
||||
, appInstalledFullStatus :: AppStatus
|
||||
, appInstalledFullVersionInstalled :: Version
|
||||
, appInstalledFullTorAddress :: Maybe TorAddress
|
||||
@@ -156,6 +162,8 @@ instance ToJSON AppInstalledFull where
|
||||
, "lanUi" .= appInstalledFullLanUi
|
||||
, "id" .= appBaseId appInstalledFullBase
|
||||
, "title" .= appBaseTitle appInstalledFullBase
|
||||
, "licenseName" .= appInstalledFullLicenseName
|
||||
, "licenseLink" .= appInstalledFullLicenseLink
|
||||
, "iconURL" .= appBaseIconUrl appInstalledFullBase
|
||||
, "versionInstalled" .= appInstalledFullVersionInstalled
|
||||
, "status" .= appInstalledFullStatus
|
||||
|
||||
4
agent/src/Lib/External/AppManifest.hs
vendored
4
agent/src/Lib/External/AppManifest.hs
vendored
@@ -78,6 +78,8 @@ data AppManifest where
|
||||
AppManifest ::{ appManifestId :: AppId
|
||||
, appManifestVersion :: Version
|
||||
, appManifestTitle :: Text
|
||||
, appManifestLicenseName :: Maybe Text
|
||||
, appManifestLicenseLink :: Maybe Text
|
||||
, appManifestDescShort :: Text
|
||||
, appManifestDescLong :: Text
|
||||
, appManifestReleaseNotes :: Text
|
||||
@@ -109,6 +111,8 @@ instance FromJSON AppManifest where
|
||||
appManifestId <- o .: "id"
|
||||
appManifestVersion <- o .: "version"
|
||||
appManifestTitle <- o .: "title"
|
||||
appManifestLicenseName <- o .:? "license-info" >>= traverse (.: "license")
|
||||
appManifestLicenseLink <- o .:? "license-info" >>= traverse (.: "url")
|
||||
appManifestDescShort <- o .: "description" >>= (.: "short")
|
||||
appManifestDescLong <- o .: "description" >>= (.: "long")
|
||||
appManifestReleaseNotes <- o .: "release-notes"
|
||||
|
||||
27
agent/src/Lib/External/Registry.hs
vendored
27
agent/src/Lib/External/Registry.hs
vendored
@@ -13,8 +13,8 @@ import Startlude.ByteStream hiding ( count )
|
||||
|
||||
import Conduit
|
||||
import Control.Algebra
|
||||
import Control.Effect.Lift
|
||||
import Control.Effect.Error
|
||||
import Control.Effect.Lift
|
||||
import Control.Effect.Reader.Labelled
|
||||
import Control.Monad.Fail ( fail )
|
||||
import Control.Monad.Trans.Resource
|
||||
@@ -30,15 +30,17 @@ import System.Directory
|
||||
import System.Process
|
||||
|
||||
import Constants
|
||||
import qualified Data.Aeson.Types ( parseEither )
|
||||
import Data.Time.ISO8601 ( parseISO8601 )
|
||||
import Lib.Algebra.State.RegistryUrl
|
||||
import Lib.Error
|
||||
import Lib.External.AppManifest
|
||||
import Lib.SystemPaths
|
||||
import Lib.Types.Core
|
||||
import Lib.Types.Emver
|
||||
import Lib.Types.ServerApp
|
||||
import Data.Time.ISO8601 ( parseISO8601 )
|
||||
|
||||
newtype AppManifestRes = AppManifestRes
|
||||
newtype AppIndexRes = AppIndexRes
|
||||
{ storeApps :: [StoreApp] } deriving (Eq, Show)
|
||||
|
||||
newtype RegistryVersionForSpecRes = RegistryVersionForSpecRes
|
||||
@@ -85,8 +87,8 @@ getLifelineBinary avs = do
|
||||
liftIO $ runConduitRes $ httpSource request getResponseBody .| sinkFile (toS lifelineTarget)
|
||||
liftIO $ void $ readProcessWithExitCode "chmod" ["700", toS lifelineTarget] ""
|
||||
|
||||
getAppManifest :: (MonadIO m, Has (Error S9Error) sig m, Has RegistryUrl sig m) => m AppManifestRes
|
||||
getAppManifest = do
|
||||
getAppIndex :: (MonadIO m, Has (Error S9Error) sig m, Has RegistryUrl sig m) => m AppIndexRes
|
||||
getAppIndex = do
|
||||
manifestPath <- registryManifestUrl
|
||||
req <- liftIO $ fmap setUserAgent . parseRequestThrow $ toS manifestPath
|
||||
val <- (liftIO . try @SomeException) (httpBS req) >>= \case
|
||||
@@ -96,22 +98,29 @@ getAppManifest = do
|
||||
Left e -> throwError $ RegistryParseE manifestPath . toS $ e
|
||||
Right a -> pure a
|
||||
|
||||
getAppManifest :: (MonadIO m, Has (Error S9Error) sig m, Has RegistryUrl sig m) => AppId -> m AppManifest
|
||||
getAppManifest appId = do
|
||||
let path = "/apps/manifest/" <> unAppId appId
|
||||
v <- registryRequest path
|
||||
case Data.Aeson.Types.parseEither parseJSON v of
|
||||
Left e -> throwError $ RegistryParseE path . toS $ e
|
||||
Right a -> pure a
|
||||
|
||||
getStoreAppInfo :: (MonadIO m, Has RegistryUrl sig m, Has (Error S9Error) sig m) => AppId -> m (Maybe StoreApp)
|
||||
getStoreAppInfo name = find ((== name) . storeAppId) . storeApps <$> getAppManifest
|
||||
getStoreAppInfo name = find ((== name) . storeAppId) . storeApps <$> getAppIndex
|
||||
|
||||
parseBsManifest :: Has RegistryUrl sig m => ByteString -> m (Either String AppManifestRes)
|
||||
parseBsManifest :: Has RegistryUrl sig m => ByteString -> m (Either String AppIndexRes)
|
||||
parseBsManifest bs = do
|
||||
parseRegistryRes' <- parseRegistryRes
|
||||
pure $ parseEither parseRegistryRes' . fromJust . decodeThrow $ bs
|
||||
|
||||
parseRegistryRes :: Has RegistryUrl sig m => m (Value -> Parser AppManifestRes)
|
||||
parseRegistryRes :: Has RegistryUrl sig m => m (Value -> Parser AppIndexRes)
|
||||
parseRegistryRes = do
|
||||
parseAppData' <- parseAppData
|
||||
pure $ withObject "app registry response" $ \obj -> do
|
||||
let keyVals = HM.toList obj
|
||||
let mManifestApps = fmap (\(k, v) -> parseMaybe (parseAppData' (AppId k)) v) keyVals
|
||||
pure . AppManifestRes . catMaybes $ mManifestApps
|
||||
pure . AppIndexRes . catMaybes $ mManifestApps
|
||||
|
||||
registryUrl :: (Has RegistryUrl sig m) => m Text
|
||||
registryUrl = maybe "https://registry.start9labs.com:443" show <$> getRegistryUrl
|
||||
|
||||
@@ -98,12 +98,12 @@ parseKernelVersion = do
|
||||
pure $ KernelVersion (Version (major', minor', patch', 0)) arch
|
||||
|
||||
synchronizer :: Synchronizer
|
||||
synchronizer = sync_0_2_12
|
||||
synchronizer = sync_0_2_13
|
||||
{-# INLINE synchronizer #-}
|
||||
|
||||
sync_0_2_12 :: Synchronizer
|
||||
sync_0_2_12 = Synchronizer
|
||||
"0.2.12"
|
||||
sync_0_2_13 :: Synchronizer
|
||||
sync_0_2_13 = Synchronizer
|
||||
"0.2.13"
|
||||
[ syncCreateAgentTmp
|
||||
, syncCreateSshDir
|
||||
, syncRemoveAvahiSystemdDependency
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
-- {-# OPTIONS_GHC -fno-warn-unused-imports #-}
|
||||
module Startlude.ByteStream
|
||||
( module Startlude.ByteStream
|
||||
, module BS
|
||||
)
|
||||
where
|
||||
( module BS
|
||||
) where
|
||||
|
||||
import Data.ByteString.Streaming as BS
|
||||
import Streaming.ByteString as BS
|
||||
hiding ( ByteString )
|
||||
import Data.ByteString.Streaming as X
|
||||
( ByteString )
|
||||
|
||||
type ByteStream m = X.ByteString m
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
module Startlude.ByteStream.Char8
|
||||
( module X
|
||||
)
|
||||
where
|
||||
) where
|
||||
|
||||
import Data.ByteString.Streaming.Char8
|
||||
as X
|
||||
import Streaming.ByteString.Char8 as X
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
resolver: nightly-2020-09-29
|
||||
resolver: lts-17.10
|
||||
|
||||
packages:
|
||||
- .
|
||||
- .
|
||||
|
||||
extra-deps:
|
||||
- aeson-1.4.7.1
|
||||
# - aeson-1.4.7.1
|
||||
- aeson-flatten-0.1.0.2
|
||||
- exinst-0.8
|
||||
- fused-effects-1.1.0.0
|
||||
@@ -12,13 +12,14 @@ extra-deps:
|
||||
- git-embed-0.1.0
|
||||
- json-stream-0.4.2.4
|
||||
- protolude-0.3.0
|
||||
- streaming-bytestring-0.1.7
|
||||
- streaming-conduit-0.1.2.2
|
||||
- streaming-utils-0.2.0.0
|
||||
# to avoid the ridiculous bug where stat64 is not found (only affects development)
|
||||
- git: https://github.com/ProofOfKeags/persistent.git
|
||||
commit: 3b52b13d9ce79cdef14bb1c37cc527657a529462
|
||||
subdirs:
|
||||
- persistent-sqlite
|
||||
# - git: https://github.com/ProofOfKeags/persistent.git
|
||||
# commit: 3b52b13d9ce79cdef14bb1c37cc527657a529462
|
||||
# subdirs:
|
||||
# - persistent-sqlite
|
||||
|
||||
ghc-options:
|
||||
"$locals": -fwrite-ide-info
|
||||
|
||||
Reference in New Issue
Block a user