Skip to content

Commit

Permalink
Expose OCM as disabled if no endpoint is configured for it
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed May 11, 2023
1 parent c8527d4 commit 6bbbb70
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/http/services/ocmprovider/ocmprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
Expand Down Expand Up @@ -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"
}
Expand All @@ -83,6 +80,14 @@ 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{{}}
return d
}
d.Enabled = true
d.APIVersion = "1.1.0"
d.Endpoint = fmt.Sprintf("%s/%s", c.Endpoint, c.OCMPrefix)
Expand Down

0 comments on commit 6bbbb70

Please sign in to comment.