Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
0ff9b24a
Commit
0ff9b24a
authored
Dec 15, 2017
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config-patch: backup config
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
2514c747
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
0 deletions
+48
-0
core/commands/config.go
core/commands/config.go
+5
-0
repo/fsrepo/fsrepo.go
repo/fsrepo/fsrepo.go
+26
-0
repo/mock.go
repo/mock.go
+4
-0
repo/repo.go
repo/repo.go
+1
-0
test/sharness/t0021-config.sh
test/sharness/t0021-config.sh
+12
-0
No files found.
core/commands/config.go
View file @
0ff9b24a
...
...
@@ -372,6 +372,11 @@ func transformConfig(configRoot string, transformer config.Transformer) error {
return
err
}
_
,
err
=
r
.
BackupConfig
(
"profile-"
)
if
err
!=
nil
{
return
err
}
return
r
.
SetConfig
(
cfg
)
}
...
...
repo/fsrepo/fsrepo.go
View file @
0ff9b24a
...
...
@@ -480,6 +480,32 @@ func (r *FSRepo) FileManager() *filestore.FileManager {
return
r
.
filemgr
}
func
(
r
*
FSRepo
)
BackupConfig
(
prefix
string
)
(
string
,
error
)
{
temp
,
err
:=
ioutil
.
TempFile
(
r
.
path
,
"config-"
+
prefix
)
if
err
!=
nil
{
return
""
,
err
}
defer
temp
.
Close
()
configFilename
,
err
:=
config
.
Filename
(
r
.
path
)
if
err
!=
nil
{
return
""
,
err
}
orig
,
err
:=
os
.
OpenFile
(
configFilename
,
os
.
O_RDONLY
,
0600
)
if
err
!=
nil
{
return
""
,
err
}
defer
orig
.
Close
()
_
,
err
=
io
.
Copy
(
temp
,
orig
)
if
err
!=
nil
{
return
""
,
err
}
return
orig
.
Name
(),
nil
}
// setConfigUnsynced is for private use.
func
(
r
*
FSRepo
)
setConfigUnsynced
(
updated
*
config
.
Config
)
error
{
configFilename
,
err
:=
config
.
Filename
(
r
.
path
)
...
...
repo/mock.go
View file @
0ff9b24a
...
...
@@ -28,6 +28,10 @@ func (m *Mock) SetConfig(updated *config.Config) error {
return
nil
}
func
(
m
*
Mock
)
BackupConfig
(
prefix
string
)
(
string
,
error
)
{
return
""
,
errTODO
}
func
(
m
*
Mock
)
SetConfigKey
(
key
string
,
value
interface
{})
error
{
return
errTODO
}
...
...
repo/repo.go
View file @
0ff9b24a
...
...
@@ -18,6 +18,7 @@ var (
type
Repo
interface
{
Config
()
(
*
config
.
Config
,
error
)
BackupConfig
(
prefix
string
)
(
string
,
error
)
SetConfig
(
*
config
.
Config
)
error
SetConfigKey
(
key
string
,
value
interface
{})
error
...
...
test/sharness/t0021-config.sh
View file @
0ff9b24a
...
...
@@ -183,10 +183,18 @@ test_config_cmd() {
test $(cat actual_config | wc -l) = 1
'
test_expect_success
"copy ipfs config"
'
cp "$IPFS_PATH/config" before_patch
'
test_expect_success
"'ipfs config profile apply server' works"
'
ipfs config profile apply server
'
test_expect_success
"backup was created and looks good"
'
test_cmp "$(find "$IPFS_PATH" -name "config-profile*")" before_patch
'
test_expect_success
"'ipfs config Swarm.AddrFilters' looks good with server profile"
'
ipfs config Swarm.AddrFilters > actual_config &&
test $(cat actual_config | wc -l) = 17
...
...
@@ -209,6 +217,10 @@ test_config_cmd() {
# won't work as it changes datastore definition, which makes ipfs not launch
# without converting first
# test_profile_apply_revert badgerds
test_expect_success
"cleanup config backups"
'
find "$IPFS_PATH" -name "config-profile*" -exec rm {} \;
'
}
test_init_ipfs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment