Fix t0063-daemon-init.sh by adding test profile to daemon
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Mar 15, 2018 at 01:06 UTC
6b67125139667b19fd761fcfaed7fb4dfee77463
3 files changed
+13
-4
cmd/ipfs/daemon.go
+5
-1
@@ -34,6 +34,7 @@ const (
34
adjustFDLimitKwd = "manage-fdlimit"
35
enableGCKwd = "enable-gc"
36
initOptionKwd = "init"
37
+ initProfileOptionKwd = "init-profile"
38
ipfsMountKwd = "mount-ipfs"
39
ipnsMountKwd = "mount-ipns"
40
migrateKwd = "migrate"
@@ -148,6 +149,7 @@ Headers.
149
150
Options: []cmdkit.Option{
151
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
152
+ cmdkit.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
153
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("dht"),
154
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
155
cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
@@ -222,7 +224,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
224
225
cfg := cctx.ConfigRoot
226
if !fsrepo.IsInitialized(cfg) {
225
- err := initWithDefaults(os.Stdout, cfg)
227
+ profiles, _ := req.Options[initProfileOptionKwd].(string)
228
+
229
+ err := initWithDefaults(os.Stdout, cfg, profiles)
230
if err != nil {
231
re.SetError(err, cmdkit.ErrNormal)
232
return
cmd/ipfs/init.go
+7
-2
@@ -134,8 +134,13 @@ var errRepoExists = errors.New(`ipfs configuration file already exists!
134
Reinitializing would overwrite your keys.
135
`)
136
137
-func initWithDefaults(out io.Writer, repoRoot string) error {
138
- return doInit(out, repoRoot, false, nBitsForKeypairDefault, nil, nil)
137
+func initWithDefaults(out io.Writer, repoRoot string, profile string) error {
138
+ var profiles []string
139
+ if profile != "" {
140
+ profiles = strings.Split(profile, ",")
141
+ }
142
+
143
+ return doInit(out, repoRoot, false, nBitsForKeypairDefault, profiles, nil)
144
}
145
146
func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, confProfiles []string, conf *config.Config) error {
test/sharness/t0063-daemon-init.sh
+1
-1
@@ -26,7 +26,7 @@ test_ipfs_daemon_init() {
26
# server.
27
28
test_expect_success "'ipfs daemon --init' succeeds" '
29
- ipfs daemon --init >actual_daemon 2>daemon_err &
29
+ ipfs daemon --init --init-profile=test >actual_daemon 2>daemon_err &
30
IPFS_PID=$!
31
sleep 2 &&
32
if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi