From 65293033118aeacd0e57a01fe1e9a4e2052da7a9 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 21 Mar 2024 21:38:02 +0100 Subject: [PATCH] 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/ --- core/commands/commands_test.go | 8 ++++++++ core/commands/object/object.go | 16 ++++++++++++++++ core/commands/object/patch.go | 6 ++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/commands/commands_test.go b/core/commands/commands_test.go index 5eb1e908dfae..9e4da274cb7a 100644 --- a/core/commands/commands_test.go +++ b/core/commands/commands_test.go @@ -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", diff --git a/core/commands/object/object.go b/core/commands/object/object.go index d9f956e5663e..380ca2533895 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -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") }, } diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 9b595a9d2d24..5a82dfe0b699 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -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,