rename -f to --ipns-base
Petar Maymounkov committed
Aug 10, 2020 at 21:45 UTC
23a26c05d3d66d80113eee76201cb8fd0e00c280
7 files changed
+39
-39
core/commands/keystore.go
+10
-10
@@ -68,11 +68,11 @@ type KeyRenameOutput struct {
68
}
69
70
const (
71
- keyStoreAlgorithmDefault = options.RSAKey
72
- keyStoreTypeOptionName = "type"
73
- keyStoreSizeOptionName = "size"
74
- keyFormatOptionName = "format"
75
- oldKeyOptionName = "oldkey"
71
+ keyStoreAlgorithmDefault = options.RSAKey
72
+ keyStoreTypeOptionName = "type"
73
+ keyStoreSizeOptionName = "size"
74
+ keyFormatOptionName = "ipns-base"
75
+ oldKeyOptionName = "oldkey"
76
)
77
78
var keyGenCmd = &cmds.Command{
@@ -82,7 +82,7 @@ var keyGenCmd = &cmds.Command{
82
Options: []cmds.Option{
83
cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault(keyStoreAlgorithmDefault),
84
cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
85
- cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
85
+ cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
86
},
87
Arguments: []cmds.Argument{
88
cmds.StringArg("name", true, false, "name of key to create"),
@@ -223,7 +223,7 @@ var keyImportCmd = &cmds.Command{
223
Tagline: "Import a key and prints imported key id",
224
},
225
Options: []cmds.Option{
226
- cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"),
226
+ cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b58mh"),
227
},
228
Arguments: []cmds.Argument{
229
cmds.StringArg("name", true, false, "name to associate with key in keychain"),
@@ -298,7 +298,7 @@ var keyListCmd = &cmds.Command{
298
},
299
Options: []cmds.Option{
300
cmds.BoolOption("l", "Show extra information about keys."),
301
- cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
301
+ cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
302
},
303
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
304
if err := verifyIDFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil {
@@ -395,7 +395,7 @@ var keyRmCmd = &cmds.Command{
395
},
396
Options: []cmds.Option{
397
cmds.BoolOption("l", "Show extra information about keys."),
398
- cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
398
+ cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
399
},
400
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
401
api, err := cmdenv.GetApi(env, req)
@@ -417,7 +417,7 @@ var keyRmCmd = &cmds.Command{
417
418
list = append(list, KeyOutput{
419
Name: name,
420
- Id: formatID(key.ID(), req.Options[keyFormatOptionName].(string)), // key.ID().Pretty(),
420
+ Id: formatID(key.ID(), req.Options[keyFormatOptionName].(string)),
421
})
422
}
423
test/sharness/t0027-rotate.sh
+2
-2
@@ -56,8 +56,8 @@ test_rotate() {
56
test_expect_success "checking ID" '
57
ipfs config Identity.PeerID > expected-id &&
58
ipfs id -f "<id>\n" > actual-id &&
59
- ipfs key list -l -f=b58mh | grep self | cut -d " " -f1 > keystore-id &&
60
- ipfs key list -l -f=b58mh | grep oldkey | cut -d " " -f1 | tr -d "\n" > old-keystore-id &&
59
+ ipfs key list -l --ipns-base=b58mh | grep self | cut -d " " -f1 > keystore-id &&
60
+ ipfs key list -l --ipns-base=b58mh | grep oldkey | cut -d " " -f1 | tr -d "\n" > old-keystore-id &&
61
test_cmp expected-id actual-id &&
62
test_cmp expected-id keystore-id &&
63
test_cmp old-keystore-id first_id
test/sharness/t0100-name.sh
+8
-8
@@ -24,7 +24,7 @@ test_name_with_self() {
24
ipfs init --profile=test -a=ed25519 > /dev/null
25
;;
26
esac &&
27
- export PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
27
+ export PEERID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
28
test_check_peerid "${PEERID}"
29
'
30
@@ -109,8 +109,8 @@ test_name_with_self() {
109
# test publishing with B36CID and B58MH resolve to the same B36CID
110
111
test_expect_success "verify self key output" '
112
- B58MH_ID=`ipfs key list -f=b58mh -l | grep self | cut -d " " -f1` &&
113
- B36CID_ID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
112
+ B58MH_ID=`ipfs key list --ipns-base=b58mh -l | grep self | cut -d " " -f1` &&
113
+ B36CID_ID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
114
test_check_peerid "${B58MH_ID}" &&
115
test_check_peerid "${B36CID_ID}"
116
'
@@ -250,15 +250,15 @@ test_name_with_key() {
250
test_expect_success "'prepare keys" '
251
case $GEN_ALG in
252
rsa)
253
- export KEY=`ipfs key gen -f=b58mh --type=rsa --size=2048 key` &&
254
- export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
253
+ export KEY=`ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 key` &&
254
+ export KEY_B36CID=`ipfs key list --ipns-base=b36cid -l | grep key | cut -d " " -f1`
255
;;
256
ed25519_b58)
257
- export KEY=`ipfs key gen -f=b58mh --type=ed25519 key`
258
- export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
257
+ export KEY=`ipfs key gen --ipns-base=b58mh --type=ed25519 key`
258
+ export KEY_B36CID=`ipfs key list --ipns-base=b36cid -l | grep key | cut -d " " -f1`
259
;;
260
ed25519_b36)
261
- export KEY=`ipfs key gen -f=b36cid --type=ed25519 key`
261
+ export KEY=`ipfs key gen --ipns-base=b36cid --type=ed25519 key`
262
export KEY_B36CID=$KEY
263
;;
264
esac &&
test/sharness/t0114-gateway-subdomains.sh
+3
-3
@@ -113,7 +113,7 @@ test_expect_success "Add the test directory" '
113
'
114
115
test_expect_success "Publish test text file to IPNS using RSA keys" '
116
- RSA_KEY=$(ipfs key gen -f=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n")
116
+ RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n")
117
RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0)
118
RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --codec libp2p-key -b base36)
119
RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36)
@@ -125,9 +125,9 @@ test_expect_success "Publish test text file to IPNS using RSA keys" '
125
'
126
127
test_expect_success "Publish test text file to IPNS using ED25519 keys" '
128
- ED25519_KEY=$(ipfs key gen -f=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n")
128
+ ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n")
129
ED25519_IPNS_IDv0=$ED25519_KEY
130
- ED25519_IPNS_IDv1=$(ipfs key list -l -f b36cid | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n")
130
+ ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=b36cid | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n")
131
ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --codec protobuf)
132
test_check_peerid "${ED25519_KEY}" &&
133
ipfs name publish --key test_key_ed25519 --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out &&
test/sharness/t0160-resolve.sh
+2
-2
@@ -22,8 +22,8 @@ test_expect_success "resolve: prepare dag" '
22
'
23
24
test_expect_success "resolve: prepare keys" '
25
- self_hash=$(ipfs key list -f=b36cid -l | grep self | cut -d " " -f1) &&
26
- alt_hash=$(ipfs key gen -f=b36cid -t rsa alt)
25
+ self_hash=$(ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1) &&
26
+ alt_hash=$(ipfs key gen --ipns-base=b36cid -t rsa alt)
27
echo self_hash $self_hash
28
echo $(ipfs id -f="<id>")
29
'
test/sharness/t0165-keystore.sh
+13
-13
@@ -13,10 +13,10 @@ test_init_ipfs
13
test_key_cmd() {
14
# test key output format
15
test_expect_success "create an RSA key and test B58MH/B36CID output formats" '
16
-PEERID=$(ipfs key gen -f=b58mh --type=rsa --size=2048 key_rsa) &&
16
+PEERID=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 key_rsa) &&
17
test_check_rsa2048_b58mh_peerid $PEERID &&
18
ipfs key rm key_rsa &&
19
-PEERID=$(ipfs key gen -f=b36cid --type=rsa --size=2048 key_rsa) &&
19
+PEERID=$(ipfs key gen --ipns-base=b36cid --type=rsa --size=2048 key_rsa) &&
20
test_check_rsa2048_b36cid_peerid $PEERID
21
'
22
@@ -27,18 +27,18 @@ rm key_rsa.key
27
'
28
29
test_expect_success "test RSA key B58MH/B36CID multihash format" '
30
-PEERID=$(ipfs key list -f=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
30
+PEERID=$(ipfs key list --ipns-base=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
31
test_check_rsa2048_b58mh_peerid $PEERID &&
32
-PEERID=$(ipfs key list -f=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
32
+PEERID=$(ipfs key list --ipns-base=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
33
test_check_rsa2048_b36cid_peerid $PEERID &&
34
ipfs key rm key_rsa
35
'
36
37
test_expect_success "create an ED25519 key and test B58MH/B36CID output formats" '
38
-PEERID=$(ipfs key gen -f=b58mh --type=ed25519 key_ed25519) &&
38
+PEERID=$(ipfs key gen --ipns-base=b58mh --type=ed25519 key_ed25519) &&
39
test_check_ed25519_b58mh_peerid $PEERID &&
40
ipfs key rm key_ed25519 &&
41
-PEERID=$(ipfs key gen -f=b36cid --type=ed25519 key_ed25519) &&
41
+PEERID=$(ipfs key gen --ipns-base=b36cid --type=ed25519 key_ed25519) &&
42
test_check_ed25519_b36cid_peerid $PEERID
43
'
44
@@ -49,9 +49,9 @@ rm key_ed25519.key
49
'
50
51
test_expect_success "test ED25519 key B58MH/B36CID multihash format" '
52
-PEERID=$(ipfs key list -f=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
52
+PEERID=$(ipfs key list --ipns-base=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
53
test_check_ed25519_b58mh_peerid $PEERID &&
54
-PEERID=$(ipfs key list -f=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
54
+PEERID=$(ipfs key list --ipns-base=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
55
test_check_ed25519_b36cid_peerid $PEERID &&
56
ipfs key rm key_ed25519
57
'
@@ -59,12 +59,12 @@ ipfs key rm key_ed25519
59
60
61
test_expect_success "create a new rsa key" '
62
- rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048 -f=b58mh)
62
+ rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048 --ipns-base=b58mh)
63
echo $rsahash > rsa_key_id
64
'
65
66
test_expect_success "create a new ed25519 key" '
67
- edhash=$(ipfs key gen generated_ed25519_key --type=ed25519 -f=b58mh)
67
+ edhash=$(ipfs key gen generated_ed25519_key --type=ed25519 --ipns-base=b58mh)
68
echo $edhash > ed25519_key_id
69
'
70
@@ -119,13 +119,13 @@ ipfs key rm key_ed25519
119
'
120
121
test_expect_success "key hashes show up in long list output" '
122
- ipfs key list -l -f=b58mh | grep $edhash > /dev/null &&
123
- ipfs key list -l -f=b58mh | grep $rsahash > /dev/null
122
+ ipfs key list -l --ipns-base=b58mh | grep $edhash > /dev/null &&
123
+ ipfs key list -l --ipns-base=b58mh | grep $rsahash > /dev/null
124
'
125
126
test_expect_success "key list -l contains self key with peerID" '
127
PeerID="$(ipfs config Identity.PeerID)"
128
- ipfs key list -l -f=b58mh | grep "$PeerID\s\+self"
128
+ ipfs key list -l --ipns-base=b58mh | grep "$PeerID\s\+self"
129
'
130
131
test_expect_success "key rm remove a key" '
test/sharness/t0600-issues-and-regressions-online.sh
+1
-1
@@ -62,7 +62,7 @@ test_expect_success "ipfs daemon --offline --mount fails - #2995" '
62
test_launch_ipfs_daemon --offline
63
64
test_expect_success "'ipfs name resolve' succeeds after ipfs id when daemon offline" '
65
- PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
65
+ PEERID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
66
test_check_peerid "${PEERID}" &&
67
ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out
68
'