From e4dbec59cf43de7f4c74bfe9b87b9f34578c1f06 Mon Sep 17 00:00:00 2001 From: rht Date: Sun, 16 Aug 2015 07:00:04 +0700 Subject: [PATCH 1/2] Show readonly commands in gateway readonly API License: MIT Signed-off-by: rht --- core/commands/root.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/commands/root.go b/core/commands/root.go index 1b842a486..3053679da 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -109,6 +109,12 @@ var rootSubcommands = map[string]*cmds.Command{ "version": VersionCmd, "bitswap": BitswapCmd, } + +// RootRO is the readonly version of Root +var RootRO = &cmds.Command{} + +var CommandsDaemonROCmd = CommandsCmd(RootRO) + var rootROSubcommands = map[string]*cmds.Command{ "block": &cmds.Command{ Subcommands: map[string]*cmds.Command{ @@ -117,7 +123,7 @@ var rootROSubcommands = map[string]*cmds.Command{ }, }, "cat": CatCmd, - "commands": CommandsDaemonCmd, + "commands": CommandsDaemonROCmd, "ls": LsCmd, "name": &cmds.Command{ Subcommands: map[string]*cmds.Command{ @@ -136,8 +142,6 @@ var rootROSubcommands = map[string]*cmds.Command{ //"resolve": ResolveCmd, } -var RootRO = &cmds.Command{} - func init() { *RootRO = *Root Root.Subcommands = rootSubcommands From 916f987de2c35db71815b54bbb9a0a71df829838 Mon Sep 17 00:00:00 2001 From: rht Date: Sun, 16 Aug 2015 07:21:10 +0700 Subject: [PATCH 2/2] Sanitize readonly refs License: MIT Signed-off-by: rht --- core/commands/root.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/commands/root.go b/core/commands/root.go index 3053679da..c99f02660 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -115,6 +115,8 @@ var RootRO = &cmds.Command{} var CommandsDaemonROCmd = CommandsCmd(RootRO) +var RefsROCmd = &cmds.Command{} + var rootROSubcommands = map[string]*cmds.Command{ "block": &cmds.Command{ Subcommands: map[string]*cmds.Command{ @@ -138,12 +140,17 @@ var rootROSubcommands = map[string]*cmds.Command{ "stat": objectStatCmd, }, }, - "refs": RefsCmd, + "refs": RefsROCmd, //"resolve": ResolveCmd, } func init() { *RootRO = *Root + + // sanitize readonly refs command + *RefsROCmd = *RefsCmd + RefsROCmd.Subcommands = map[string]*cmds.Command{} + Root.Subcommands = rootSubcommands RootRO.Subcommands = rootROSubcommands }