@cryptotaxi247 / kubo / commits / e700c02cb

core/commands/publish: Allow explicit local node ID

Instead of raising "keychains not yet implemented" whenever we have an explicit node ID, only raise the error when the given node ID isn't the local node. This allows folks to use the more-general explicit-node-ID form in scripts and such now, as long as they use the local node name when calling those scripts. Also add a test for this case, and update the comment for the one-argument case to match the current syntax for extracting a multihash name string. License: MIT Signed-off-by: W. Trevor King <wking@tremily.us>

W. Trevor King committed Jun 19, 2015 at 04:05 UTC e700c02cbdc42ae5714e1b70a672cf5c54205243
2 files changed +19 -4
core/commands/publish.go
+7 -4
@@ -72,16 +72,19 @@ Publish an <ipfs-path> to another public key (not implemented):
72 return
73 }
74
75 + var name string
76 var pstr string
77
78 switch len(args) {
79 case 2:
79 - // name = args[0]
80 + name = args[0]
81 pstr = args[1]
81 - res.SetError(errors.New("keychains not yet implemented"), cmds.ErrNormal)
82 - return
82 + if name != n.Identity.Pretty() {
83 + res.SetError(errors.New("keychains not yet implemented"), cmds.ErrNormal)
84 + return
85 + }
86 case 1:
84 - // name = n.Identity.ID.String()
87 + // name = n.Identity.Pretty()
88 pstr = args[0]
89 }
90
test/sharness/t0100-name.sh
+12
@@ -52,4 +52,16 @@ test_expect_success "resolve output looks good" '
52 test_cmp output expected4
53 '
54
55 +# publish with an explicit node ID
56 +
57 +test_expect_success "'ipfs name publish <local-id> <hash>' succeeds" '
58 + PEERID=`ipfs id --format="<id>"` &&
59 + ipfs name publish "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
60 +'
61 +
62 +test_expect_success "publish with our explicit node ID looks good" '
63 + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish &&
64 + test_cmp expected_node_id_publish actual_node_id_publish
65 +'
66 +
67 test_done