Skip to content

Commit

Permalink
rename -f to --ipns-base
Browse files Browse the repository at this point in the history
  • Loading branch information
petar committed Aug 17, 2020
1 parent 39155b5 commit 08e0e08
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
20 changes: 10 additions & 10 deletions core/commands/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ type KeyRenameOutput struct {
}

const (
keyStoreAlgorithmDefault = options.RSAKey
keyStoreTypeOptionName = "type"
keyStoreSizeOptionName = "size"
keyFormatOptionName = "format"
oldKeyOptionName = "oldkey"
keyStoreAlgorithmDefault = options.RSAKey
keyStoreTypeOptionName = "type"
keyStoreSizeOptionName = "size"
keyFormatOptionName = "ipns-base"
oldKeyOptionName = "oldkey"
)

var keyGenCmd = &cmds.Command{
Expand All @@ -82,7 +82,7 @@ var keyGenCmd = &cmds.Command{
Options: []cmds.Option{
cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault(keyStoreAlgorithmDefault),
cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
},
Arguments: []cmds.Argument{
cmds.StringArg("name", true, false, "name of key to create"),
Expand Down Expand Up @@ -223,7 +223,7 @@ var keyImportCmd = &cmds.Command{
Tagline: "Import a key and prints imported key id",
},
Options: []cmds.Option{
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"),
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b58mh"),
},
Arguments: []cmds.Argument{
cmds.StringArg("name", true, false, "name to associate with key in keychain"),
Expand Down Expand Up @@ -298,7 +298,7 @@ var keyListCmd = &cmds.Command{
},
Options: []cmds.Option{
cmds.BoolOption("l", "Show extra information about keys."),
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
if err := verifyIDFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil {
Expand Down Expand Up @@ -395,7 +395,7 @@ var keyRmCmd = &cmds.Command{
},
Options: []cmds.Option{
cmds.BoolOption("l", "Show extra information about keys."),
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
api, err := cmdenv.GetApi(env, req)
Expand All @@ -417,7 +417,7 @@ var keyRmCmd = &cmds.Command{

list = append(list, KeyOutput{
Name: name,
Id: formatID(key.ID(), req.Options[keyFormatOptionName].(string)), // key.ID().Pretty(),
Id: formatID(key.ID(), req.Options[keyFormatOptionName].(string)),
})
}

Expand Down
4 changes: 2 additions & 2 deletions test/sharness/t0027-rotate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ test_rotate() {
test_expect_success "checking ID" '
ipfs config Identity.PeerID > expected-id &&
ipfs id -f "<id>\n" > actual-id &&
ipfs key list -l -f=b58mh | grep self | cut -d " " -f1 > keystore-id &&
ipfs key list -l -f=b58mh | grep oldkey | cut -d " " -f1 | tr -d "\n" > old-keystore-id &&
ipfs key list -l --ipns-base=b58mh | grep self | cut -d " " -f1 > keystore-id &&
ipfs key list -l --ipns-base=b58mh | grep oldkey | cut -d " " -f1 | tr -d "\n" > old-keystore-id &&
test_cmp expected-id actual-id &&
test_cmp expected-id keystore-id &&
test_cmp old-keystore-id first_id
Expand Down
16 changes: 8 additions & 8 deletions test/sharness/t0100-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test_name_with_self() {
ipfs init --profile=test -a=ed25519 > /dev/null
;;
esac &&
export PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
export PEERID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
test_check_peerid "${PEERID}"
'

Expand Down Expand Up @@ -109,8 +109,8 @@ test_name_with_self() {
# test publishing with B36CID and B58MH resolve to the same B36CID

test_expect_success "verify self key output" '
B58MH_ID=`ipfs key list -f=b58mh -l | grep self | cut -d " " -f1` &&
B36CID_ID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
B58MH_ID=`ipfs key list --ipns-base=b58mh -l | grep self | cut -d " " -f1` &&
B36CID_ID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
test_check_peerid "${B58MH_ID}" &&
test_check_peerid "${B36CID_ID}"
'
Expand Down Expand Up @@ -250,15 +250,15 @@ test_name_with_key() {
test_expect_success "'prepare keys" '
case $GEN_ALG in
rsa)
export KEY=`ipfs key gen -f=b58mh --type=rsa --size=2048 key` &&
export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
export KEY=`ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 key` &&
export KEY_B36CID=`ipfs key list --ipns-base=b36cid -l | grep key | cut -d " " -f1`
;;
ed25519_b58)
export KEY=`ipfs key gen -f=b58mh --type=ed25519 key`
export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
export KEY=`ipfs key gen --ipns-base=b58mh --type=ed25519 key`
export KEY_B36CID=`ipfs key list --ipns-base=b36cid -l | grep key | cut -d " " -f1`
;;
ed25519_b36)
export KEY=`ipfs key gen -f=b36cid --type=ed25519 key`
export KEY=`ipfs key gen --ipns-base=b36cid --type=ed25519 key`
export KEY_B36CID=$KEY
;;
esac &&
Expand Down
6 changes: 3 additions & 3 deletions test/sharness/t0114-gateway-subdomains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ test_expect_success "Add the test directory" '
'

test_expect_success "Publish test text file to IPNS using RSA keys" '
RSA_KEY=$(ipfs key gen -f=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n")
RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n")
RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0)
RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --codec libp2p-key -b base36)
RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36)
Expand All @@ -125,9 +125,9 @@ test_expect_success "Publish test text file to IPNS using RSA keys" '
'

test_expect_success "Publish test text file to IPNS using ED25519 keys" '
ED25519_KEY=$(ipfs key gen -f=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n")
ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n")
ED25519_IPNS_IDv0=$ED25519_KEY
ED25519_IPNS_IDv1=$(ipfs key list -l -f b36cid | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n")
ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=b36cid | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n")
ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --codec protobuf)
test_check_peerid "${ED25519_KEY}" &&
ipfs name publish --key test_key_ed25519 --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out &&
Expand Down
4 changes: 2 additions & 2 deletions test/sharness/t0160-resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ test_expect_success "resolve: prepare dag" '
'

test_expect_success "resolve: prepare keys" '
self_hash=$(ipfs key list -f=b36cid -l | grep self | cut -d " " -f1) &&
alt_hash=$(ipfs key gen -f=b36cid -t rsa alt)
self_hash=$(ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1) &&
alt_hash=$(ipfs key gen --ipns-base=b36cid -t rsa alt)
echo self_hash $self_hash
echo $(ipfs id -f="<id>")
'
Expand Down
26 changes: 13 additions & 13 deletions test/sharness/t0165-keystore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ test_init_ipfs
test_key_cmd() {
# test key output format
test_expect_success "create an RSA key and test B58MH/B36CID output formats" '
PEERID=$(ipfs key gen -f=b58mh --type=rsa --size=2048 key_rsa) &&
PEERID=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 key_rsa) &&
test_check_rsa2048_b58mh_peerid $PEERID &&
ipfs key rm key_rsa &&
PEERID=$(ipfs key gen -f=b36cid --type=rsa --size=2048 key_rsa) &&
PEERID=$(ipfs key gen --ipns-base=b36cid --type=rsa --size=2048 key_rsa) &&
test_check_rsa2048_b36cid_peerid $PEERID
'

Expand All @@ -27,18 +27,18 @@ rm key_rsa.key
'

test_expect_success "test RSA key B58MH/B36CID multihash format" '
PEERID=$(ipfs key list -f=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
PEERID=$(ipfs key list --ipns-base=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
test_check_rsa2048_b58mh_peerid $PEERID &&
PEERID=$(ipfs key list -f=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
PEERID=$(ipfs key list --ipns-base=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
test_check_rsa2048_b36cid_peerid $PEERID &&
ipfs key rm key_rsa
'

test_expect_success "create an ED25519 key and test B58MH/B36CID output formats" '
PEERID=$(ipfs key gen -f=b58mh --type=ed25519 key_ed25519) &&
PEERID=$(ipfs key gen --ipns-base=b58mh --type=ed25519 key_ed25519) &&
test_check_ed25519_b58mh_peerid $PEERID &&
ipfs key rm key_ed25519 &&
PEERID=$(ipfs key gen -f=b36cid --type=ed25519 key_ed25519) &&
PEERID=$(ipfs key gen --ipns-base=b36cid --type=ed25519 key_ed25519) &&
test_check_ed25519_b36cid_peerid $PEERID
'

Expand All @@ -49,22 +49,22 @@ rm key_ed25519.key
'

test_expect_success "test ED25519 key B58MH/B36CID multihash format" '
PEERID=$(ipfs key list -f=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
PEERID=$(ipfs key list --ipns-base=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
test_check_ed25519_b58mh_peerid $PEERID &&
PEERID=$(ipfs key list -f=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
PEERID=$(ipfs key list --ipns-base=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
test_check_ed25519_b36cid_peerid $PEERID &&
ipfs key rm key_ed25519
'
# end of format test


test_expect_success "create a new rsa key" '
rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048 -f=b58mh)
rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048 --ipns-base=b58mh)
echo $rsahash > rsa_key_id
'

test_expect_success "create a new ed25519 key" '
edhash=$(ipfs key gen generated_ed25519_key --type=ed25519 -f=b58mh)
edhash=$(ipfs key gen generated_ed25519_key --type=ed25519 --ipns-base=b58mh)
echo $edhash > ed25519_key_id
'

Expand Down Expand Up @@ -119,13 +119,13 @@ ipfs key rm key_ed25519
'

test_expect_success "key hashes show up in long list output" '
ipfs key list -l -f=b58mh | grep $edhash > /dev/null &&
ipfs key list -l -f=b58mh | grep $rsahash > /dev/null
ipfs key list -l --ipns-base=b58mh | grep $edhash > /dev/null &&
ipfs key list -l --ipns-base=b58mh | grep $rsahash > /dev/null
'

test_expect_success "key list -l contains self key with peerID" '
PeerID="$(ipfs config Identity.PeerID)"
ipfs key list -l -f=b58mh | grep "$PeerID\s\+self"
ipfs key list -l --ipns-base=b58mh | grep "$PeerID\s\+self"
'

test_expect_success "key rm remove a key" '
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0600-issues-and-regressions-online.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test_expect_success "ipfs daemon --offline --mount fails - #2995" '
test_launch_ipfs_daemon --offline

test_expect_success "'ipfs name resolve' succeeds after ipfs id when daemon offline" '
PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
PEERID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
test_check_peerid "${PEERID}" &&
ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out
'
Expand Down

0 comments on commit 08e0e08

Please sign in to comment.