From b0504d9312785a587828a8e5a2e9dcc7d796a8c0 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Thu, 11 May 2023 09:00:07 +0200 Subject: [PATCH] Expose OCM as disabled if no endpoint is configured for it --- .../http/services/ocmprovider/ocmprovider.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/http/services/ocmprovider/ocmprovider.go b/internal/http/services/ocmprovider/ocmprovider.go index fb5033da88f..a88f9e52a01 100644 --- a/internal/http/services/ocmprovider/ocmprovider.go +++ b/internal/http/services/ocmprovider/ocmprovider.go @@ -35,7 +35,7 @@ func init() { type config struct { OCMPrefix string `mapstructure:"ocm_prefix" docs:"ocm;The prefix URL where the OCM API is served."` - Endpoint string `mapstructure:"endpoint" docs:"http://localhost;This host's URL."` + Endpoint string `mapstructure:"endpoint" docs:"This host's URL. If it's not configured, it is assumed OCM is not available."` Provider string `mapstructure:"provider" docs:"reva;A friendly name that defines this service."` WebdavRoot string `mapstructure:"webdav_root" docs:"/remote.php/dav/ocm;The root URL of the WebDAV endpoint to serve OCM shares."` WebappRoot string `mapstructure:"webapp_root" docs:"/external/sciencemesh;The root URL to serve Web apps via OCM."` @@ -66,9 +66,6 @@ func (c *config) init() { if c.OCMPrefix == "" { c.OCMPrefix = "ocm" } - if c.Endpoint == "" { - c.Endpoint = "http://localhost" - } if c.Provider == "" { c.Provider = "reva" } @@ -83,6 +80,19 @@ func (c *config) init() { func (c *config) prepare() *discoveryData { // generates the (static) data structure to be exposed by /ocm-provider d := &discoveryData{} + if c.Endpoint == "" { + d.Enabled = false + d.Endpoint = "" + d.APIVersion = "1.1.0" + d.Provider = c.Provider + d.ResourceTypes = []resourceTypes{{ + Name: "file", + ShareTypes: []string{}, + Protocols: map[string]string{}, + }} + d.Capabilities = []string{} + return d + } d.Enabled = true d.APIVersion = "1.1.0" d.Endpoint = fmt.Sprintf("%s/%s", c.Endpoint, c.OCMPrefix)