@cryptotaxi247 / kubo / commits / 55587d8e4

feat!: make --empty-repo default (#9758)

Context: https://github.com/ipfs/kubo/pull/9758#pullrequestreview-1366898875

Henrique Dias committed Mar 31, 2023 at 15:06 UTC 55587d8e419078858ba16e4ed4e1b2ab6069398e
8 files changed +23 -22
cmd/ipfs/init.go
+2 -1
@@ -28,6 +28,7 @@ const (
28 algorithmDefault = options.Ed25519Key
29 algorithmOptionName = "algorithm"
30 bitsOptionName = "bits"
31 + emptyRepoDefault = true
32 emptyRepoOptionName = "empty-repo"
33 profileOptionName = "profile"
34 )
@@ -61,7 +62,7 @@ environment variable:
62 Options: []cmds.Option{
63 cmds.StringOption(algorithmOptionName, "a", "Cryptographic algorithm to use for key generation.").WithDefault(algorithmDefault),
64 cmds.IntOption(bitsOptionName, "b", "Number of bits to use in the generated RSA private key."),
64 - cmds.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage."),
65 + cmds.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage.").WithDefault(emptyRepoDefault),
66 cmds.StringOption(profileOptionName, "p", "Apply profile settings to config. Multiple profiles can be separated by ','"),
67
68 // TODO need to decide whether to expose the override as a file or a
test/cli/init_test.go
+9 -9
@@ -33,9 +33,7 @@ func testInitAlgo(t *testing.T, initFlags []string, expOutputName string, expPee
33 lines := []string{
34 fmt.Sprintf("generating %s keypair...done", expOutputName),
35 fmt.Sprintf("peer identity: %s", node.PeerID().String()),
36 - fmt.Sprintf("initializing IPFS node at %s", node.Dir),
37 - "to get started, enter:",
38 - fmt.Sprintf("\n\tipfs cat /ipfs/%s/readme\n\n", CIDWelcomeDocs),
36 + fmt.Sprintf("initializing IPFS node at %s\n", node.Dir),
37 }
38 expectedInitOutput := strings.Join(lines, "\n")
39 assert.Equal(t, expectedInitOutput, initRes.Stdout.String())
@@ -54,26 +52,28 @@ func testInitAlgo(t *testing.T, initFlags []string, expOutputName string, expPee
52 res := node.IPFS("config", "Mounts.IPFS")
53 assert.Equal(t, "/ipfs", res.Stdout.Trimmed())
54
57 - node.IPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
55 + catRes := node.RunIPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
56 + assert.NotEqual(t, 0, catRes.ExitErr.ExitCode(), "welcome readme doesn't exist")
57 })
58
60 - t.Run("init empty repo", func(t *testing.T) {
59 + t.Run("init without empty repo", func(t *testing.T) {
60 t.Parallel()
61 node := harness.NewT(t).NewNode()
63 - initRes := node.IPFS(StrCat("init", "--empty-repo", initFlags)...)
62 + initRes := node.IPFS(StrCat("init", "--empty-repo=false", initFlags)...)
63
64 validatePeerID(t, node.PeerID(), expPeerIDPubKeyErr, expPeerIDPubKeyType)
65
66 lines := []string{
67 fmt.Sprintf("generating %s keypair...done", expOutputName),
68 fmt.Sprintf("peer identity: %s", node.PeerID().String()),
70 - fmt.Sprintf("initializing IPFS node at %s\n", node.Dir),
69 + fmt.Sprintf("initializing IPFS node at %s", node.Dir),
70 + "to get started, enter:",
71 + fmt.Sprintf("\n\tipfs cat /ipfs/%s/readme\n\n", CIDWelcomeDocs),
72 }
73 expectedEmptyInitOutput := strings.Join(lines, "\n")
74 assert.Equal(t, expectedEmptyInitOutput, initRes.Stdout.String())
75
75 - catRes := node.RunIPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
76 - assert.NotEqual(t, 0, catRes.ExitErr.ExitCode(), "welcome readme doesn't exist")
76 + node.IPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
77
78 idRes := node.IPFS("id", "-f", "<aver>")
79 version := node.IPFS("version", "-n").Stdout.Trimmed()
test/sharness/lib/test-lib.sh
+2 -2
@@ -194,7 +194,7 @@ test_config_set() {
194 }
195
196 test_init_ipfs() {
197 -
197 + args=("$@")
198
199 # we set the Addresses.API config variable.
200 # the cli client knows to use it, so only need to set.
@@ -202,7 +202,7 @@ test_init_ipfs() {
202
203 test_expect_success "ipfs init succeeds" '
204 export IPFS_PATH="$(pwd)/.ipfs" &&
205 - ipfs init --profile=test > /dev/null
205 + ipfs init "${args[@]}" --profile=test > /dev/null
206 '
207
208 test_expect_success "prepare config -- mounting" '
test/sharness/t0025-datastores.sh
+2 -2
@@ -4,9 +4,9 @@ test_description="Test non-standard datastores"
4
5 . lib/test-lib.sh
6
7 -test_expect_success "'ipfs init --profile=badgerds' succeeds" '
7 +test_expect_success "'ipfs init --empty-repo=false --profile=badgerds' succeeds" '
8 BITS="2048" &&
9 - ipfs init --profile=badgerds
9 + ipfs init --empty-repo=false --profile=badgerds
10 '
11
12 test_expect_success "'ipfs pin ls' works" '
test/sharness/t0054-dag-car-import-export.sh
+1 -1
@@ -171,7 +171,7 @@ test_expect_success "shut down nodes" '
171
172
173 # We want to just init the repo, without using a daemon for stuff below
174 -test_init_ipfs
174 +test_init_ipfs --empty-repo=false
175
176
177 test_expect_success "basic offline export of 'getting started' dag works" '
test/sharness/t0080-repo.sh
+1 -1
@@ -8,7 +8,7 @@ test_description="Test ipfs repo operations"
8
9 . lib/test-lib.sh
10
11 -test_init_ipfs
11 +test_init_ipfs --empty-repo=false
12 test_launch_ipfs_daemon_without_network
13
14 test_expect_success "'ipfs repo gc' succeeds" '
test/sharness/t0100-name.sh
+5 -5
@@ -15,13 +15,13 @@ test_name_with_self() {
15 export IPFS_PATH="$(pwd)/.ipfs" &&
16 case $SELF_ALG in
17 default)
18 - ipfs init --profile=test > /dev/null
18 + ipfs init --empty-repo=false --profile=test > /dev/null
19 ;;
20 rsa)
21 - ipfs init --profile=test -a=rsa > /dev/null
21 + ipfs init --empty-repo=false --profile=test -a=rsa > /dev/null
22 ;;
23 ed25519)
24 - ipfs init --profile=test -a=ed25519 > /dev/null
24 + ipfs init --empty-repo=false --profile=test -a=ed25519 > /dev/null
25 ;;
26 esac &&
27 export PEERID=`ipfs key list --ipns-base=base36 -l | grep self | cut -d " " -f1` &&
@@ -273,7 +273,7 @@ test_name_with_key() {
273
274 test_expect_success "ipfs init (key variant $GEN_ALG)" '
275 export IPFS_PATH="$(pwd)/.ipfs" &&
276 - ipfs init --profile=test > /dev/null
276 + ipfs init --empty-repo=false --profile=test > /dev/null
277 '
278
279 test_expect_success "'prepare keys" '
@@ -317,7 +317,7 @@ test_name_with_key 'ed25519_b36'
317
318 # `ipfs name inspect --verify` using the wrong RSA key should not succeed
319
320 -test_init_ipfs
320 +test_init_ipfs --empty-repo=false
321 test_launch_ipfs_daemon
322
323 test_expect_success "prepare RSA keys" '
test/sharness/t0600-issues-and-regressions-online.sh
+1 -1
@@ -4,7 +4,7 @@ test_description="Tests for various fixed issues and regressions."
4
5 . lib/test-lib.sh
6
7 -test_init_ipfs
7 +test_init_ipfs --empty-repo=false
8
9 test_launch_ipfs_daemon
10