Skip to content

Commit

Permalink
config-patch: apply review suggestions
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed Nov 25, 2017
1 parent 1687d4c commit 81579d6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
4 changes: 3 additions & 1 deletion core/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,14 @@ var configProfileApplyCmd = &cmds.Command{
res.SetError(err, cmdkit.ErrNormal)
return
}
res.SetOutput(nil)
},
}

var configProfileRevertCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Revert profile changes.",
ShortDescription: `Reverts profile-related changes to the config.
ShortDescription: `Reverts profile-related changes to the default values.
Reverting some profiles may damage the configuration or not be possible.
Backing up the config before running this command is advised.`,
Expand All @@ -350,6 +351,7 @@ Backing up the config before running this command is advised.`,
res.SetError(err, cmdkit.ErrNormal)
return
}
res.SetOutput(nil)
},
}

Expand Down
29 changes: 21 additions & 8 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@ Configuration profiles allow to tweak configuration quickly. Profiles can be
applied with `--profile` flag to `ipfs init` or with `ipfs config profile apply`
command.

- `server` profile
Recommended for nodes with public IPv4 address, disables host and content
discovery in local networks.

- `test` profile
Reduces external interference, useful for running ipfs in test environments.
Note that with these settings node won't be able to talk to the rest of the
network without manual bootstrap.
Available profiles:
- `server`

Recommended for nodes with public IPv4 address, disables host and content
discovery in local networks.

- `test`

Reduces external interference, useful for running ipfs in test environments.
Note that with these settings node won't be able to talk to the rest of the
network without manual bootstrap.

- `badgerds`

Replaces default datastore configuration with experimental badger datastore.
If you apply this profile after `ipfs init`, you will need to convert your
datastore to the new configuration. You can do this using [ipfs-ds-convert](https://github.com/ipfs/ipfs-ds-convert)

WARNING: badger datastore is experimantal. Make sure to backup your data
frequently


## Table of Contents

Expand Down
1 change: 1 addition & 0 deletions repo/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var Profiles = map[string]*Profile{
c.Addresses = addressesConfig()

c.Swarm.DisableNatPortMap = false
c.Discovery.MDNS.Enabled = true
return nil
},
},
Expand Down
34 changes: 34 additions & 0 deletions test/sharness/t0021-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ CONFIG_SET_JSON_TEST='{
}
}'

test_profile_apply_revert() {
profile=$1

test_expect_success "save expected config" '
ipfs config show >expected
'

test_expect_success "'ipfs config profile apply ${profile}' works" '
ipfs config profile apply '${profile}'
'

test_expect_success "profile ${profile} changed something" '
ipfs config show >actual &&
test_must_fail test_cmp expected actual
'

test_expect_success "'ipfs config profile revert ${profile}' works" '
ipfs config profile revert '${profile}'
'

test_expect_success "config is back to previous state after ${profile} revert" '
ipfs config show >actual &&
test_cmp expected actual
'
}

test_config_cmd() {
test_config_cmd_set "beep" "boop"
test_config_cmd_set "beep1" "boop2"
Expand Down Expand Up @@ -175,6 +201,14 @@ test_config_cmd() {
test $(cat actual_config | wc -l) = 1
'

test_profile_apply_revert server

# won't work as we already have this profile applied
# test_profile_apply_revert test

# won't work as it changes datastore definition, which makes ipfs not launch
# without converting first
# test_profile_apply_revert badgerds
}

test_init_ipfs
Expand Down

0 comments on commit 81579d6

Please sign in to comment.