From d85e5dee8a94a0607eb11f91b429b31b084b8ea1 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Fri, 4 Feb 2022 11:22:40 +0100 Subject: [PATCH 1/2] ensure the same data on /ocs/v?.php/config like oC10 --- changelog/unreleased/fix-ocs-config-values.md | 6 +++++ storage/pkg/command/frontend.go | 24 +++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 changelog/unreleased/fix-ocs-config-values.md diff --git a/changelog/unreleased/fix-ocs-config-values.md b/changelog/unreleased/fix-ocs-config-values.md new file mode 100644 index 0000000000..29144b234a --- /dev/null +++ b/changelog/unreleased/fix-ocs-config-values.md @@ -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 diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index 1010b13dc5..c206801683 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -4,6 +4,7 @@ import ( "context" "flag" "fmt" + "net/url" "os" "path" "strconv" @@ -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)) @@ -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, @@ -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, @@ -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 From 4578f5cd5a85395bb0695982ab68c0394c890fb5 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Tue, 29 Mar 2022 12:38:29 +0200 Subject: [PATCH 2/2] move ocs config host logic to reva cs3org/reva#2692 --- storage/pkg/command/frontend.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index c206801683..06be385308 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -4,7 +4,6 @@ import ( "context" "flag" "fmt" - "net/url" "os" "path" "strconv" @@ -97,11 +96,7 @@ func Frontend(cfg *config.Config) *cli.Command { } } - revaCfg, err := frontendConfigFromStruct(c, cfg, filesCfg) - if err != nil { - logger.Error().Err(err).Msg("could not generate frontend configuration") - return err - } + revaCfg := frontendConfigFromStruct(c, cfg, filesCfg) gr.Add(func() error { runtime.RunWithOptions(revaCfg, pidFile, runtime.WithLogger(&logger.Logger)) @@ -144,12 +139,7 @@ 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{}, error) { - frontendURL, err := url.Parse(cfg.Reva.Frontend.PublicURL) - if err != nil { - return map[string]interface{}{}, err - } - +func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[string]interface{}) map[string]interface{} { return map[string]interface{}{ "core": map[string]interface{}{ "max_cpus": cfg.Reva.Users.MaxCPUs, @@ -227,7 +217,7 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s "config": map[string]interface{}{ "version": "1.7", "website": "ownCloud", - "host": frontendURL.Host + frontendURL.Path, + "host": cfg.Reva.Frontend.PublicURL, "contact": "", "ssl": "false", }, @@ -318,7 +308,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