Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
privatestoragemobile
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PrivateStorage
privatestoragemobile
Commits
cca6808e
Commit
cca6808e
authored
Jun 20, 2023
by
Jean-Paul Calderone
Browse files
Options
Downloads
Plain Diff
Merge branch 'grid-as-configuration' into 'main'
Read grid configuration using the Obelisk "Config" system Closes
#59
See merge request
!55
parents
f9d9fc9c
7ac19755
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!55
Read grid configuration using the Obelisk "Config" system
Pipeline
#4894
passed
Jun 20, 2023
Stage: lint
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
obelisk/config/common/servers.yaml
+8
-0
8 additions, 0 deletions
obelisk/config/common/servers.yaml
obelisk/frontend/src/App.hs
+2
-1
2 additions, 1 deletion
obelisk/frontend/src/App.hs
obelisk/frontend/src/MagicFolder.hs
+11
-21
11 additions, 21 deletions
obelisk/frontend/src/MagicFolder.hs
with
21 additions
and
22 deletions
obelisk/config/common/servers.yaml
0 → 100644
+
8
−
0
View file @
cca6808e
# The Private Storage staging grid configuration.
storage
:
v0-roiqkiw76qcj7gcilbbut52rsxofubqugqtgnap3rgncutdueoda
:
ann
:
anonymous-storage-FURL
:
pb://oykwjvglr5h7elum5zlfll7vgiayd2ey@tcp:storage001.privatestorage-staging.com:8899/u2urs2aqarw2euuxddby7dvxkdd2rsuc
nickname
:
storage001
anonymous-storage-NURLs
:
-
pb://oykwjvglr5h7elum5zlfll7vgiayd2ey@tcp:storage001.privatestorage-staging.com:8899/u2urs2aqarw2euuxddby7dvxkdd2rsuc
This diff is collapsed.
Click to expand it.
obelisk/frontend/src/App.hs
+
2
−
1
View file @
cca6808e
...
...
@@ -26,7 +26,7 @@ import Reflex
,
foldDyn
,
fmapMaybe
)
import
Obelisk.Configs
(
HasConfigs
)
import
Tahoe.Announcement
(
Announcements
)
import
MagicFolder
(
MagicFolder
,
loadGrid
,
loadMagicFolders
,
readMagicFolder
)
...
...
@@ -50,6 +50,7 @@ initialApp
,
PerformEvent
t
m
,
TriggerEvent
t
m
,
MonadIO
(
Performable
m
)
,
HasConfigs
(
Performable
m
)
)
=>
Event
t
()
-- ^ An event to trigger loading the state.
->
m
(
App
t
)
-- ^ The loaded application state.
...
...
This diff is collapsed.
Click to expand it.
obelisk/frontend/src/MagicFolder.hs
+
11
−
21
View file @
cca6808e
...
...
@@ -4,6 +4,7 @@
module
MagicFolder
where
import
Data.Bifunctor
(
first
)
import
Text.Megaparsec
(
parse
)
import
qualified
Data.Map.Strict
as
Map
import
qualified
Tahoe.Directory
as
Directory
...
...
@@ -12,9 +13,10 @@ import Text.RawString.QQ (r)
import
qualified
Data.Text
as
T
import
Data.Yaml
(
decodeEither'
)
import
Tahoe.Announcement
(
Announcements
(
..
))
import
Control.Monad.IO.Class
(
MonadIO
(
liftIO
)
)
import
Control.Monad.IO.Class
(
MonadIO
)
import
Control.Exception
(
SomeException
)
import
qualified
Tahoe.MagicFoldr
as
MF
import
Obelisk.Configs
(
HasConfigs
(
getConfig
))
data
MagicFolder
=
MagicFolder
...
...
@@ -29,27 +31,15 @@ newtype EntryName = EntryName { unEntryName :: T.Text } deriving (Eq, Ord, Show)
-- | Load the announcements for the grid to use for downloads.
--
-- This reads "servers.yaml" from the application-private files directory.
loadGrid
::
MonadIO
m
=>
m
(
Either
T
.
Text
Announcements
)
loadGrid
=
liftIO
$
do
loadGrid
::
HasConfigs
m
=>
m
(
Either
T
.
Text
Announcements
)
loadGrid
=
do
announcementsBytes
<-
getConfig
"common/servers.yaml"
case
announcementsBytes
of
Left
err
->
pure
$
Left
$
T
.
concat
[
"Could not read grid configuration: "
,
T
.
pack
$
show
(
err
::
SomeException
)]
Right
bytes
->
case
decodeEither'
bytes
of
Left
err
->
pure
$
Left
$
T
.
concat
[
"Could not parse grid configuration: "
,
T
.
pack
$
show
err
]
Right
ann
->
pure
$
Right
ann
Nothing
->
pure
.
Left
$
"Could not load grid configuration"
Just
bytes
->
pure
.
first
renderError
$
decodeEither'
bytes
where
-- TODO: Figure out how we can distribute this yaml in a separate file and
-- still be able to get at its contents, even on Android.
announcementsBytes
=
Right
[
r
|
storage:
v0-roiqkiw76qcj7gcilbbut52rsxofubqugqtgnap3rgncutdueoda:
ann:
anonymous-storage-FURL: pb://gnuer2axzoq3ggnn7gjoybmfqsjvaow3@tcp:magnon:46185/sxytycucj5eeunlx6modfazq5byp2hpb
nickname: storage001
anonymous-storage-NURLs:
- pb://4cD3anuFqhz81xiI2dtRj7eDJLsCFNXrHZZExUXotfE@magnon:46185/sxytycucj5eeunlx6modfazq5byp2hpb#v=1
|]
renderError
=
T
.
concat
.
(
"Could not parse grid configuration: "
:
)
.
(
:
[]
)
.
T
.
pack
.
show
-- | Load the configured magic-folder collective capabilities.
--
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment