1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-13 09:45:08 +08:00

key cmd: fix codeclimate warnings

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera
2018-08-07 15:10:34 +02:00
parent 9c6959cf2c
commit 640be715dc
3 changed files with 13 additions and 13 deletions

View File

@ -100,7 +100,7 @@ var keyGenCmd = &cmds.Command{
cmds.EmitOnce(res, &KeyOutput{
Name: name,
Id: key.Id().Pretty(),
Id: key.ID().Pretty(),
})
},
Encoders: cmds.EncoderMap{
@ -140,7 +140,7 @@ var keyListCmd = &cmds.Command{
list := make([]KeyOutput, 0, len(keys))
for _, key := range keys {
list = append(list, KeyOutput{Name: key.Name(), Id: key.Id().Pretty()})
list = append(list, KeyOutput{Name: key.Name(), Id: key.ID().Pretty()})
}
cmds.EmitOnce(res, &KeyOutputList{list})
@ -182,7 +182,7 @@ var keyRenameCmd = &cmds.Command{
cmds.EmitOnce(res, &KeyRenameOutput{
Was: name,
Now: newName,
Id: key.Id().Pretty(),
Id: key.ID().Pretty(),
Overwrite: overwritten,
})
},
@ -231,7 +231,7 @@ var keyRmCmd = &cmds.Command{
return
}
list = append(list, KeyOutput{Name: name, Id: key.Id().Pretty()})
list = append(list, KeyOutput{Name: name, Id: key.ID().Pretty()})
}
cmds.EmitOnce(res, &KeyOutputList{list})
@ -244,7 +244,7 @@ var keyRmCmd = &cmds.Command{
func keyOutputListMarshaler() cmds.EncoderFunc {
return cmds.MakeEncoder(func(req *cmds.Request, w io.Writer, v interface{}) error {
withId, _ := req.Options["l"].(bool)
withID, _ := req.Options["l"].(bool)
list, ok := v.(*KeyOutputList)
if !ok {
@ -253,7 +253,7 @@ func keyOutputListMarshaler() cmds.EncoderFunc {
tw := tabwriter.NewWriter(w, 1, 2, 1, ' ', 0)
for _, s := range list.Keys {
if withId {
if withID {
fmt.Fprintf(tw, "%s\t%s\t\n", s.Id, s.Name)
} else {
fmt.Fprintf(tw, "%s\n", s.Name)

View File

@ -16,8 +16,8 @@ type Key interface {
// Path returns key path
Path() Path
// Id returns key PeerID
Id() peer.ID
// ID returns key PeerID
ID() peer.ID
}
// KeyAPI specifies the interface to Keystore

View File

@ -18,7 +18,7 @@ type KeyAPI CoreAPI
type key struct {
name string
peerId peer.ID
peerID peer.ID
}
// Name returns the key name
@ -28,7 +28,7 @@ func (k *key) Name() string {
// Path returns the path of the key.
func (k *key) Path() coreiface.Path {
path, err := coreiface.ParsePath(ipfspath.Join([]string{"/ipns", k.peerId.Pretty()}))
path, err := coreiface.ParsePath(ipfspath.Join([]string{"/ipns", k.peerID.Pretty()}))
if err != nil {
panic("error parsing path: " + err.Error())
}
@ -36,9 +36,9 @@ func (k *key) Path() coreiface.Path {
return path
}
// Id returns key PeerID
func (k *key) Id() peer.ID {
return k.peerId
// ID returns key PeerID
func (k *key) ID() peer.ID {
return k.peerID
}
// Generate generates new key, stores it in the keystore under the specified