@cryptotaxi247 / kubo / commits / d7376cdab

config: profile tests, docs

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

Łukasz Magiera committed Sep 6, 2017 at 13:54 UTC d7376cdab054b5f62a17da3909449c0b89104d40
3 files changed +51 -12
docs/config.md
+15
@@ -17,6 +17,7 @@ on a running daemon do not read the config file at runtime.
17 - [`Mounts`](#mounts)
18 - [`Reprovider`](#reprovider)
19 - [`Swarm`](#swarm)
20 +- [`Profiles`](#profiles)
21
22 ## `Addresses`
23 Contains information about various listener addresses to be used by this node.
@@ -287,3 +288,17 @@ LowWater is the minimum number of connections to maintain.
288 HighWater is the number of connections that, when exceeded, will trigger a connection GC operation.
289 - `GracePeriod`
290 GracePeriod is a time duration that new connections are immune from being closed by the connection manager.
291 +
292 +## Profiles
293 +Configuration profiles allow to tweak configuration quickly. Profiles can be
294 +applied with `--profile` flag to `ipfs init` or with `ipfs config profile apply`
295 +command.
296 +
297 +- `server` profile
298 +Recommended for nodes with public IPv4 address, disables host and content
299 +discovery in local networks.
300 +
301 +- `test` profile
302 +Reduces external interference, useful for running ipfs in test environments.
303 +Note that with these settings node won't be able to talk to the rest of the
304 +network without manual bootstrap.
repo/config/profile.go
+12 -12
@@ -7,7 +7,7 @@ type Profile struct {
7 Unapply Transformer
8 }
9
10 -// Profiles is a map holding configuration transformers
10 +// Profiles is a map holding configuration transformers. Docs are in docs/config.md
11 var Profiles = map[string]*Profile{
12 "server": {
13 Apply: func(c *Config) error {
@@ -65,17 +65,17 @@ var Profiles = map[string]*Profile{
65 },
66 "badgerds": {
67 Apply: func(c *Config) error {
68 - c.Datastore.Spec = map[string]interface{}{
69 - "type": "measure",
70 - "prefix": "badger.datastore",
71 - "child": map[string]interface{}{
72 - "type": "badgerds",
73 - "path": "badgerds",
74 - "syncWrites": true,
75 - },
76 - }
77 - return nil
78 - },
68 + c.Datastore.Spec = map[string]interface{}{
69 + "type": "measure",
70 + "prefix": "badger.datastore",
71 + "child": map[string]interface{}{
72 + "type": "badgerds",
73 + "path": "badgerds",
74 + "syncWrites": true,
75 + },
76 + }
77 + return nil
78 + },
79 Unapply: func(c *Config) error {
80 c.Datastore.Spec = DefaultDatastoreConfig().Spec
81 return nil
test/sharness/t0021-config.sh
+24
@@ -151,6 +151,30 @@ test_config_cmd() {
151 echo "Error: setting private key with API is not supported" > replace_expected
152 test_cmp replace_out replace_expected
153 '
154 +
155 + test_expect_success "'ipfs config Swarm.AddrFilters' looks good" '
156 + ipfs config Swarm.AddrFilters > actual_config &&
157 + test $(cat actual_config | wc -l) = 1
158 + '
159 +
160 + test_expect_success "'ipfs config profile apply server' works" '
161 + ipfs config profile apply server
162 + '
163 +
164 + test_expect_success "'ipfs config Swarm.AddrFilters' looks good with server profile" '
165 + ipfs config Swarm.AddrFilters > actual_config &&
166 + test $(cat actual_config | wc -l) = 17
167 + '
168 +
169 + test_expect_success "'ipfs config profile revert server' works" '
170 + ipfs config profile revert server
171 + '
172 +
173 + test_expect_success "'ipfs config Swarm.AddrFilters' looks good with reverted server profile" '
174 + ipfs config Swarm.AddrFilters > actual_config &&
175 + test $(cat actual_config | wc -l) = 1
176 + '
177 +
178 }
179
180 test_init_ipfs