Skip to content

Commit 850ec3c

Browse files
committed
refactor: use Status: cmds.Removed
This allows us to return meaningful error to end users who were not aware of deprecation, and also produce useful removal notice at https://docs.ipfs.tech/reference/kubo/rpc/ for people who try to execute commands or RPC from old tutorials.
1 parent 7daa23c commit 850ec3c

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

core/commands/commands_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ func TestCommands(t *testing.T) {
6161
"/dag/stat",
6262
"/dht",
6363
"/dht/query",
64+
"/dht/findprovs",
65+
"/dht/findpeer",
66+
"/dht/get",
67+
"/dht/provide",
68+
"/dht/put",
6469
"/routing",
6570
"/routing/put",
6671
"/routing/get",
@@ -120,10 +125,18 @@ func TestCommands(t *testing.T) {
120125
"/name/pubsub/subs",
121126
"/name/resolve",
122127
"/object",
128+
"/object/data",
123129
"/object/diff",
130+
"/object/get",
131+
"/object/links",
132+
"/object/new",
124133
"/object/patch",
125134
"/object/patch/add-link",
135+
"/object/patch/append-data",
126136
"/object/patch/rm-link",
137+
"/object/patch/set-data",
138+
"/object/put",
139+
"/object/stat",
127140
"/p2p",
128141
"/p2p/close",
129142
"/p2p/forward",

core/commands/dht.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ import (
1515
var ErrNotDHT = errors.New("routing service is not a DHT")
1616

1717
var DhtCmd = &cmds.Command{
18+
Status: cmds.Deprecated,
1819
Helptext: cmds.HelpText{
1920
Tagline: "Issue commands directly through the DHT.",
2021
ShortDescription: ``,
2122
},
2223

2324
Subcommands: map[string]*cmds.Command{
24-
"query": queryDhtCmd,
25+
"query": queryDhtCmd,
26+
"findprovs": RemovedDHTCmd,
27+
"findpeer": RemovedDHTCmd,
28+
"get": RemovedDHTCmd,
29+
"put": RemovedDHTCmd,
30+
"provide": RemovedDHTCmd,
2531
},
2632
}
2733

@@ -32,6 +38,7 @@ type kademlia interface {
3238
}
3339

3440
var queryDhtCmd = &cmds.Command{
41+
Status: cmds.Deprecated,
3542
Helptext: cmds.HelpText{
3643
Tagline: "Find the closest Peer IDs to a given Peer ID by querying the DHT.",
3744
ShortDescription: "Outputs a list of newline-delimited Peer IDs.",
@@ -114,3 +121,12 @@ var queryDhtCmd = &cmds.Command{
114121
},
115122
Type: routing.QueryEvent{},
116123
}
124+
var RemovedDHTCmd = &cmds.Command{
125+
Status: cmds.Removed,
126+
Helptext: cmds.HelpText{
127+
Tagline: "Removed, use 'ipfs routing' instead.",
128+
},
129+
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
130+
return errors.New("removed, use 'ipfs routing' instead")
131+
},
132+
}

core/commands/object/object.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,23 @@ directly. Deprecated, use more modern 'ipfs dag' and 'ipfs files' instead.`,
2828
},
2929

3030
Subcommands: map[string]*cmds.Command{
31+
"data": RemovedObjectCmd,
3132
"diff": ObjectDiffCmd,
33+
"get": RemovedObjectCmd,
34+
"links": RemovedObjectCmd,
35+
"new": RemovedObjectCmd,
3236
"patch": ObjectPatchCmd,
37+
"put": RemovedObjectCmd,
38+
"stat": RemovedObjectCmd,
39+
},
40+
}
41+
42+
var RemovedObjectCmd = &cmds.Command{
43+
Status: cmds.Removed,
44+
Helptext: cmds.HelpText{
45+
Tagline: "Removed, use 'ipfs dag' or 'ipfs files' instead.",
46+
},
47+
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
48+
return errors.New("removed, use 'ipfs dag' or 'ipfs files' instead")
3349
},
3450
}

core/commands/object/patch.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ For modern use cases, use MFS with 'files' commands: 'ipfs files --help'.
3737
},
3838
Arguments: []cmds.Argument{},
3939
Subcommands: map[string]*cmds.Command{
40-
"add-link": patchAddLinkCmd,
41-
"rm-link": patchRmLinkCmd,
40+
"append-data": RemovedObjectCmd,
41+
"add-link": patchAddLinkCmd,
42+
"rm-link": patchRmLinkCmd,
43+
"set-data": RemovedObjectCmd,
4244
},
4345
Options: []cmds.Option{
4446
cmdutils.AllowBigBlockOption,

0 commit comments

Comments
 (0)