From 59f42882e1af5f412a2bc98d6375de97cf339e33 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Mon, 24 Aug 2020 17:41:52 +0200 Subject: [PATCH] cmd: check if config is initialized before assignment --- changelog/unreleased/ocm-fixes.md | 3 ++- cmd/reva/arguments.go | 6 ++++++ cmd/reva/executor.go | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/changelog/unreleased/ocm-fixes.md b/changelog/unreleased/ocm-fixes.md index b653a55470..c8f017099c 100644 --- a/changelog/unreleased/ocm-fixes.md +++ b/changelog/unreleased/ocm-fixes.md @@ -1,3 +1,4 @@ -Bugfix: Minor fixes in OCM shares, gateway uploads and smtpclient +Bugfix: Minor fixes in reva cmd, gateway uploads and smtpclient https://github.com/cs3org/reva/pull/1082 +https://github.com/cs3org/reva/pull/1116 diff --git a/cmd/reva/arguments.go b/cmd/reva/arguments.go index fd7b16da29..0d6a7cb3bf 100644 --- a/cmd/reva/arguments.go +++ b/cmd/reva/arguments.go @@ -195,8 +195,14 @@ func (c *Completer) shareReceivedArgumentCompleter() []prompt.Suggest { } func executeCommand(cmd *command, args ...string) (bytes.Buffer, error) { + var b bytes.Buffer var err error + + if conf == nil || conf.Host == "" { + return b, errors.New("reva not configured") + } + if err = cmd.Parse(args); err != nil { return b, err } diff --git a/cmd/reva/executor.go b/cmd/reva/executor.go index 0fab5e92a6..80a13652ac 100644 --- a/cmd/reva/executor.go +++ b/cmd/reva/executor.go @@ -46,10 +46,10 @@ func (e *Executor) Execute(s string) { args := strings.Split(s, " ") // Verify that the configuration is set, either in memory or in a file. - if conf.Host == "" { + if conf == nil || conf.Host == "" { c, err := readConfig() if err != nil && args[0] != "configure" { - fmt.Println("reva is not configured, please run the configure command") + fmt.Println("reva is not configured, please pass the -host flag or run the configure command") return } else if args[0] != "configure" { conf = c