mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
feat!: make --empty-repo default (#9758)
Context: https://github.com/ipfs/kubo/pull/9758#pullrequestreview-1366898875
This commit is contained in:
parent
c81d2da871
commit
55587d8e41
@ -28,6 +28,7 @@ const (
|
||||
algorithmDefault = options.Ed25519Key
|
||||
algorithmOptionName = "algorithm"
|
||||
bitsOptionName = "bits"
|
||||
emptyRepoDefault = true
|
||||
emptyRepoOptionName = "empty-repo"
|
||||
profileOptionName = "profile"
|
||||
)
|
||||
@ -61,7 +62,7 @@ environment variable:
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption(algorithmOptionName, "a", "Cryptographic algorithm to use for key generation.").WithDefault(algorithmDefault),
|
||||
cmds.IntOption(bitsOptionName, "b", "Number of bits to use in the generated RSA private key."),
|
||||
cmds.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage."),
|
||||
cmds.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage.").WithDefault(emptyRepoDefault),
|
||||
cmds.StringOption(profileOptionName, "p", "Apply profile settings to config. Multiple profiles can be separated by ','"),
|
||||
|
||||
// TODO need to decide whether to expose the override as a file or a
|
||||
|
||||
@ -33,9 +33,7 @@ func testInitAlgo(t *testing.T, initFlags []string, expOutputName string, expPee
|
||||
lines := []string{
|
||||
fmt.Sprintf("generating %s keypair...done", expOutputName),
|
||||
fmt.Sprintf("peer identity: %s", node.PeerID().String()),
|
||||
fmt.Sprintf("initializing IPFS node at %s", node.Dir),
|
||||
"to get started, enter:",
|
||||
fmt.Sprintf("\n\tipfs cat /ipfs/%s/readme\n\n", CIDWelcomeDocs),
|
||||
fmt.Sprintf("initializing IPFS node at %s\n", node.Dir),
|
||||
}
|
||||
expectedInitOutput := strings.Join(lines, "\n")
|
||||
assert.Equal(t, expectedInitOutput, initRes.Stdout.String())
|
||||
@ -54,26 +52,28 @@ func testInitAlgo(t *testing.T, initFlags []string, expOutputName string, expPee
|
||||
res := node.IPFS("config", "Mounts.IPFS")
|
||||
assert.Equal(t, "/ipfs", res.Stdout.Trimmed())
|
||||
|
||||
node.IPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
|
||||
catRes := node.RunIPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
|
||||
assert.NotEqual(t, 0, catRes.ExitErr.ExitCode(), "welcome readme doesn't exist")
|
||||
})
|
||||
|
||||
t.Run("init empty repo", func(t *testing.T) {
|
||||
t.Run("init without empty repo", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
node := harness.NewT(t).NewNode()
|
||||
initRes := node.IPFS(StrCat("init", "--empty-repo", initFlags)...)
|
||||
initRes := node.IPFS(StrCat("init", "--empty-repo=false", initFlags)...)
|
||||
|
||||
validatePeerID(t, node.PeerID(), expPeerIDPubKeyErr, expPeerIDPubKeyType)
|
||||
|
||||
lines := []string{
|
||||
fmt.Sprintf("generating %s keypair...done", expOutputName),
|
||||
fmt.Sprintf("peer identity: %s", node.PeerID().String()),
|
||||
fmt.Sprintf("initializing IPFS node at %s\n", node.Dir),
|
||||
fmt.Sprintf("initializing IPFS node at %s", node.Dir),
|
||||
"to get started, enter:",
|
||||
fmt.Sprintf("\n\tipfs cat /ipfs/%s/readme\n\n", CIDWelcomeDocs),
|
||||
}
|
||||
expectedEmptyInitOutput := strings.Join(lines, "\n")
|
||||
assert.Equal(t, expectedEmptyInitOutput, initRes.Stdout.String())
|
||||
|
||||
catRes := node.RunIPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
|
||||
assert.NotEqual(t, 0, catRes.ExitErr.ExitCode(), "welcome readme doesn't exist")
|
||||
node.IPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs))
|
||||
|
||||
idRes := node.IPFS("id", "-f", "<aver>")
|
||||
version := node.IPFS("version", "-n").Stdout.Trimmed()
|
||||
|
||||
@ -194,7 +194,7 @@ test_config_set() {
|
||||
}
|
||||
|
||||
test_init_ipfs() {
|
||||
|
||||
args=("$@")
|
||||
|
||||
# we set the Addresses.API config variable.
|
||||
# the cli client knows to use it, so only need to set.
|
||||
@ -202,7 +202,7 @@ test_init_ipfs() {
|
||||
|
||||
test_expect_success "ipfs init succeeds" '
|
||||
export IPFS_PATH="$(pwd)/.ipfs" &&
|
||||
ipfs init --profile=test > /dev/null
|
||||
ipfs init "${args[@]}" --profile=test > /dev/null
|
||||
'
|
||||
|
||||
test_expect_success "prepare config -- mounting" '
|
||||
|
||||
@ -4,9 +4,9 @@ test_description="Test non-standard datastores"
|
||||
|
||||
. lib/test-lib.sh
|
||||
|
||||
test_expect_success "'ipfs init --profile=badgerds' succeeds" '
|
||||
test_expect_success "'ipfs init --empty-repo=false --profile=badgerds' succeeds" '
|
||||
BITS="2048" &&
|
||||
ipfs init --profile=badgerds
|
||||
ipfs init --empty-repo=false --profile=badgerds
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs pin ls' works" '
|
||||
|
||||
@ -171,7 +171,7 @@ test_expect_success "shut down nodes" '
|
||||
|
||||
|
||||
# We want to just init the repo, without using a daemon for stuff below
|
||||
test_init_ipfs
|
||||
test_init_ipfs --empty-repo=false
|
||||
|
||||
|
||||
test_expect_success "basic offline export of 'getting started' dag works" '
|
||||
|
||||
@ -8,7 +8,7 @@ test_description="Test ipfs repo operations"
|
||||
|
||||
. lib/test-lib.sh
|
||||
|
||||
test_init_ipfs
|
||||
test_init_ipfs --empty-repo=false
|
||||
test_launch_ipfs_daemon_without_network
|
||||
|
||||
test_expect_success "'ipfs repo gc' succeeds" '
|
||||
|
||||
@ -15,13 +15,13 @@ test_name_with_self() {
|
||||
export IPFS_PATH="$(pwd)/.ipfs" &&
|
||||
case $SELF_ALG in
|
||||
default)
|
||||
ipfs init --profile=test > /dev/null
|
||||
ipfs init --empty-repo=false --profile=test > /dev/null
|
||||
;;
|
||||
rsa)
|
||||
ipfs init --profile=test -a=rsa > /dev/null
|
||||
ipfs init --empty-repo=false --profile=test -a=rsa > /dev/null
|
||||
;;
|
||||
ed25519)
|
||||
ipfs init --profile=test -a=ed25519 > /dev/null
|
||||
ipfs init --empty-repo=false --profile=test -a=ed25519 > /dev/null
|
||||
;;
|
||||
esac &&
|
||||
export PEERID=`ipfs key list --ipns-base=base36 -l | grep self | cut -d " " -f1` &&
|
||||
@ -273,7 +273,7 @@ test_name_with_key() {
|
||||
|
||||
test_expect_success "ipfs init (key variant $GEN_ALG)" '
|
||||
export IPFS_PATH="$(pwd)/.ipfs" &&
|
||||
ipfs init --profile=test > /dev/null
|
||||
ipfs init --empty-repo=false --profile=test > /dev/null
|
||||
'
|
||||
|
||||
test_expect_success "'prepare keys" '
|
||||
@ -317,7 +317,7 @@ test_name_with_key 'ed25519_b36'
|
||||
|
||||
# `ipfs name inspect --verify` using the wrong RSA key should not succeed
|
||||
|
||||
test_init_ipfs
|
||||
test_init_ipfs --empty-repo=false
|
||||
test_launch_ipfs_daemon
|
||||
|
||||
test_expect_success "prepare RSA keys" '
|
||||
|
||||
@ -4,7 +4,7 @@ test_description="Tests for various fixed issues and regressions."
|
||||
|
||||
. lib/test-lib.sh
|
||||
|
||||
test_init_ipfs
|
||||
test_init_ipfs --empty-repo=false
|
||||
|
||||
test_launch_ipfs_daemon
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user