Revert "Implements repository initialization with default config"
See #2748 This reverts commit 6989686b8beb0b0381e9c3df766cae1d3e232214. License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
Lars Gierth committed
May 20, 2016 at 01:04 UTC
77ef3913d9f5682c5a0dedbba5488e794e9da1b5
2 files changed
+7
-85
cmd/ipfs/init.go
+7
-30
@@ -1,7 +1,6 @@
1
package main
2
3
import (
4
- "encoding/json"
4
"errors"
5
"fmt"
6
"io"
@@ -33,9 +32,7 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
32
export IPFS_PATH=/path/to/ipfsrepo
33
`,
34
},
36
- Arguments: []cmds.Argument{
37
- cmds.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
38
- },
35
+
36
Options: []cmds.Option{
37
cmds.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").Default(nBitsForKeypairDefault),
38
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage.").Default(false),
@@ -78,24 +75,7 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
75
return
76
}
77
81
- var conf *config.Config
82
-
83
- f := req.Files()
84
- if f != nil {
85
- confFile, err := f.NextFile()
86
- if err != nil {
87
- res.SetError(err, cmds.ErrNormal)
88
- return
89
- }
90
-
91
- conf = &config.Config{}
92
- if err := json.NewDecoder(confFile).Decode(conf); err != nil {
93
- res.SetError(err, cmds.ErrNormal)
94
- return
95
- }
96
- }
97
-
98
- if err := doInit(os.Stdout, req.InvocContext().ConfigRoot, empty, nBitsForKeypair, conf); err != nil {
78
+ if err := doInit(os.Stdout, req.InvocContext().ConfigRoot, empty, nBitsForKeypair); err != nil {
79
res.SetError(err, cmds.ErrNormal)
80
return
81
}
@@ -107,10 +87,10 @@ Reinitializing would overwrite your keys.
87
`)
88
89
func initWithDefaults(out io.Writer, repoRoot string) error {
110
- return doInit(out, repoRoot, false, nBitsForKeypairDefault, nil)
90
+ return doInit(out, repoRoot, false, nBitsForKeypairDefault)
91
}
92
113
-func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, conf *config.Config) error {
93
+func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int) error {
94
if _, err := fmt.Fprintf(out, "initializing ipfs node at %s\n", repoRoot); err != nil {
95
return err
96
}
@@ -123,12 +103,9 @@ func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, con
103
return errRepoExists
104
}
105
126
- if conf == nil {
127
- var err error
128
- conf, err = config.Init(out, nBitsForKeypair)
129
- if err != nil {
130
- return err
131
- }
106
+ conf, err := config.Init(out, nBitsForKeypair)
107
+ if err != nil {
108
+ return err
109
}
110
111
if err := fsrepo.Init(repoRoot, conf); err != nil {
test/sharness/t0022-init-default.sh
deleted
-55
@@ -1,55 +0,0 @@
1
-#!/bin/sh
2
-#
3
-# Copyright (c) 2014 Christian Couder
4
-# MIT Licensed; see the LICENSE file in this repository.
5
-#
6
-
7
-test_description="Test init command with default config"
8
-
9
-. lib/test-lib.sh
10
-
11
-cfg_key="Addresses.API"
12
-cfg_val="/ip4/0.0.0.0/tcp/5001"
13
-
14
-# test that init succeeds
15
-test_expect_success "ipfs init succeeds" '
16
- export IPFS_PATH="$(pwd)/.ipfs" &&
17
- echo "IPFS_PATH: \"$IPFS_PATH\"" &&
18
- BITS="2048" &&
19
- ipfs init --bits="$BITS" >actual_init ||
20
- test_fsh cat actual_init
21
-'
22
-
23
-test_expect_success ".ipfs/config has been created" '
24
- test -f "$IPFS_PATH"/config ||
25
- test_fsh ls -al .ipfs
26
-'
27
-
28
-test_expect_success "ipfs config succeeds" '
29
- ipfs config $cfg_flags "$cfg_key" "$cfg_val"
30
-'
31
-
32
-test_expect_success "ipfs read config succeeds" '
33
- IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config)
34
-'
35
-
36
-test_expect_success "clean up ipfs dir" '
37
- rm -rf "$IPFS_PATH"
38
-'
39
-
40
-test_expect_success "ipfs init default config succeeds" '
41
- echo $IPFS_DEFAULT_CONFIG | ipfs init >actual_init ||
42
- test_fsh cat actual_init
43
-'
44
-
45
-test_expect_success "ipfs config output looks good" '
46
- echo "$cfg_val" >expected &&
47
- ipfs config "$cfg_key" >actual &&
48
- test_cmp expected actual
49
-'
50
-
51
-test_launch_ipfs_daemon
52
-
53
-test_kill_ipfs_daemon
54
-
55
-test_done