Skip to content

Commit

Permalink
refactor: use Status: cmds.Removed
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
lidel committed Mar 21, 2024
1 parent 7daa23c commit 6529303
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
8 changes: 8 additions & 0 deletions core/commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,18 @@ func TestCommands(t *testing.T) {
"/name/pubsub/subs",
"/name/resolve",
"/object",
"/object/data",
"/object/diff",
"/object/get",
"/object/links",
"/object/new",
"/object/patch",
"/object/patch/add-link",
"/object/patch/append-data",
"/object/patch/rm-link",
"/object/patch/set-data",
"/object/put",
"/object/stat",
"/p2p",
"/p2p/close",
"/p2p/forward",
Expand Down
16 changes: 16 additions & 0 deletions core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,23 @@ directly. Deprecated, use more modern 'ipfs dag' and 'ipfs files' instead.`,
},

Subcommands: map[string]*cmds.Command{
"data": RemovedObjectCmd,
"diff": ObjectDiffCmd,
"get": RemovedObjectCmd,
"links": RemovedObjectCmd,
"new": RemovedObjectCmd,
"patch": ObjectPatchCmd,
"put": RemovedObjectCmd,
"stat": RemovedObjectCmd,
},
}

var RemovedObjectCmd = &cmds.Command{
Status: cmds.Removed,
Helptext: cmds.HelpText{
Tagline: "Removed, use 'ipfs dag' or 'ipfs files' instead.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
return errors.New("removed, use 'ipfs dag' or 'ipfs files' instead")
},
}
6 changes: 4 additions & 2 deletions core/commands/object/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ For modern use cases, use MFS with 'files' commands: 'ipfs files --help'.
},
Arguments: []cmds.Argument{},
Subcommands: map[string]*cmds.Command{
"add-link": patchAddLinkCmd,
"rm-link": patchRmLinkCmd,
"append-data": RemovedObjectCmd,
"add-link": patchAddLinkCmd,
"rm-link": patchRmLinkCmd,
"set-data": RemovedObjectCmd,
},
Options: []cmds.Option{
cmdutils.AllowBigBlockOption,
Expand Down

0 comments on commit 6529303

Please sign in to comment.