@cryptotaxi247 / kubo / commits / 2514c7475

config-patch: apply review suggestions

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Nov 25, 2017 at 03:16 UTC 2514c747505b034c488f529692418c9266135970
4 files changed +59 -9
core/commands/config.go
+3 -1
@@ -324,13 +324,14 @@ var configProfileApplyCmd = &cmds.Command{
324 res.SetError(err, cmdkit.ErrNormal)
325 return
326 }
327 + res.SetOutput(nil)
328 },
329 }
330
331 var configProfileRevertCmd = &cmds.Command{
332 Helptext: cmdkit.HelpText{
333 Tagline: "Revert profile changes.",
333 - ShortDescription: `Reverts profile-related changes to the config.
334 + ShortDescription: `Reverts profile-related changes to the default values.
335
336 Reverting some profiles may damage the configuration or not be possible.
337 Backing up the config before running this command is advised.`,
@@ -350,6 +351,7 @@ Backing up the config before running this command is advised.`,
351 res.SetError(err, cmdkit.ErrNormal)
352 return
353 }
354 + res.SetOutput(nil)
355 },
356 }
357
docs/config.md
+21 -8
@@ -9,14 +9,27 @@ Configuration profiles allow to tweak configuration quickly. Profiles can be
9 applied with `--profile` flag to `ipfs init` or with `ipfs config profile apply`
10 command.
11
12 -- `server` profile
13 -Recommended for nodes with public IPv4 address, disables host and content
14 -discovery in local networks.
15 -
16 -- `test` profile
17 -Reduces external interference, useful for running ipfs in test environments.
18 -Note that with these settings node won't be able to talk to the rest of the
19 -network without manual bootstrap.
12 +Available profiles:
13 +- `server`
14 +
15 + Recommended for nodes with public IPv4 address, disables host and content
16 + discovery in local networks.
17 +
18 +- `test`
19 +
20 + Reduces external interference, useful for running ipfs in test environments.
21 + Note that with these settings node won't be able to talk to the rest of the
22 + network without manual bootstrap.
23 +
24 +- `badgerds`
25 +
26 + Replaces default datastore configuration with experimental badger datastore.
27 + If you apply this profile after `ipfs init`, you will need to convert your
28 + datastore to the new configuration. You can do this using [ipfs-ds-convert](https://github.com/ipfs/ipfs-ds-convert)
29 +
30 + WARNING: badger datastore is experimantal. Make sure to backup your data
31 + frequently
32 +
33
34 ## Table of Contents
35
repo/config/profile.go
+1
@@ -64,6 +64,7 @@ var Profiles = map[string]*Profile{
64 c.Addresses = addressesConfig()
65
66 c.Swarm.DisableNatPortMap = false
67 + c.Discovery.MDNS.Enabled = true
68 return nil
69 },
70 },
test/sharness/t0021-config.sh
+34
@@ -48,6 +48,32 @@ CONFIG_SET_JSON_TEST='{
48 }
49 }'
50
51 +test_profile_apply_revert() {
52 + profile=$1
53 +
54 + test_expect_success "save expected config" '
55 + ipfs config show >expected
56 + '
57 +
58 + test_expect_success "'ipfs config profile apply ${profile}' works" '
59 + ipfs config profile apply '${profile}'
60 + '
61 +
62 + test_expect_success "profile ${profile} changed something" '
63 + ipfs config show >actual &&
64 + test_must_fail test_cmp expected actual
65 + '
66 +
67 + test_expect_success "'ipfs config profile revert ${profile}' works" '
68 + ipfs config profile revert '${profile}'
69 + '
70 +
71 + test_expect_success "config is back to previous state after ${profile} revert" '
72 + ipfs config show >actual &&
73 + test_cmp expected actual
74 + '
75 +}
76 +
77 test_config_cmd() {
78 test_config_cmd_set "beep" "boop"
79 test_config_cmd_set "beep1" "boop2"
@@ -175,6 +201,14 @@ test_config_cmd() {
201 test $(cat actual_config | wc -l) = 1
202 '
203
204 + test_profile_apply_revert server
205 +
206 + # won't work as we already have this profile applied
207 + # test_profile_apply_revert test
208 +
209 + # won't work as it changes datastore definition, which makes ipfs not launch
210 + # without converting first
211 + # test_profile_apply_revert badgerds
212 }
213
214 test_init_ipfs