Skip to content

Commit

Permalink
ensure the same data on /ocs/v?.php/config like oC10
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek committed Mar 1, 2022
1 parent ccf6bf1 commit e2ead9d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-ocs-config-values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: ensure the same data on /ocs/v?.php/config like oC10

We've fixed the returned values on the /ocs/v?.php/config endpoints,
so that they now return the same values as an oC10 would do.

https://github.com/owncloud/ocis/pull/3113
24 changes: 17 additions & 7 deletions storage/pkg/command/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
"net/url"
"os"
"path"
"strconv"
Expand Down Expand Up @@ -96,7 +97,11 @@ func Frontend(cfg *config.Config) *cli.Command {
}
}

revaCfg := frontendConfigFromStruct(c, cfg, filesCfg)
revaCfg, err := frontendConfigFromStruct(c, cfg, filesCfg)
if err != nil {
logger.Error().Err(err).Msg("could not generate frontend configuration")
return err
}

gr.Add(func() error {
runtime.RunWithOptions(revaCfg, pidFile, runtime.WithLogger(&logger.Logger))
Expand Down Expand Up @@ -139,7 +144,12 @@ func Frontend(cfg *config.Config) *cli.Command {
}

// frontendConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[string]interface{}) map[string]interface{} {
func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[string]interface{}) (map[string]interface{}, error) {
frontendURL, err := url.Parse(cfg.Reva.Frontend.PublicURL)
if err != nil {
return map[string]interface{}{}, err
}

return map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
Expand Down Expand Up @@ -215,10 +225,10 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s
},
},
"config": map[string]interface{}{
"version": "1.8",
"website": "reva",
"host": cfg.Reva.Frontend.PublicURL,
"contact": "admin@localhost",
"version": "1.7",
"website": "ownCloud",
"host": frontendURL.Host + frontendURL.Path,
"contact": "",
"ssl": "false",
},
"default_upload_protocol": cfg.Reva.DefaultUploadProtocol,
Expand Down Expand Up @@ -308,7 +318,7 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s
},
},
},
}
}, nil
}

// loadUserAgent reads the user-agent-whitelist-lock-in, since it is a string flag, and attempts to construct a map of
Expand Down

0 comments on commit e2ead9d

Please sign in to comment.