Fix collaboration service name (#1577)

* fix: collaboration service name

* change: do not use app name in service name

* feat: make collaboration service name configurable

* test: fix test config
This commit is contained in:
Michael Barz
2025-09-29 10:06:05 +02:00
committed by GitHub
parent 754ac7a699
commit 4a0cc1004f
8 changed files with 14 additions and 12 deletions

View File

@@ -2973,11 +2973,13 @@ def wopiCollaborationService(name):
environment["COLLABORATION_APP_ADDR"] = "https://collabora:9980"
environment["COLLABORATION_APP_ICON"] = "https://collabora:9980/favicon.ico"
elif name == "onlyoffice":
environment["COLLABORATION_SERVICE_NAME"] = "collboration-onlyoffice"
environment["COLLABORATION_APP_NAME"] = "OnlyOffice"
environment["COLLABORATION_APP_PRODUCT"] = "OnlyOffice"
environment["COLLABORATION_APP_ADDR"] = "https://onlyoffice"
environment["COLLABORATION_APP_ICON"] = "https://onlyoffice/web-apps/apps/documenteditor/main/resources/img/favicon.ico"
elif name == "fakeoffice":
environment["COLLABORATION_SERVICE_NAME"] = "collboration-fakeoficce"
environment["COLLABORATION_APP_NAME"] = "FakeOffice"
environment["COLLABORATION_APP_PRODUCT"] = "Microsoft"
environment["COLLABORATION_APP_ADDR"] = "http://fakeoffice:8080"

View File

@@ -25,14 +25,14 @@ func Version(cfg *config.Config) *cli.Command {
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name + "." + cfg.App.Name)
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name+"."+cfg.App.Name, err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running " + cfg.Service.Name + "." + cfg.App.Name + " service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -2,5 +2,5 @@ package config
// Service defines the available service configuration.
type Service struct {
Name string `yaml:"-"`
Name string `yaml:"name" env:"COLLABORATION_SERVICE_NAME" desc:"The name of the service which is registered. You only need to change this when more than one collaboration service is needed." introductionVersion:"3.6.0"`
}

View File

@@ -19,7 +19,7 @@ import (
// There are no explicit requirements for the context, and it will be passed
// without changes to the underlying RegisterService method.
func RegisterOpenCloudService(ctx context.Context, cfg *config.Config, logger log.Logger) error {
svc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name+"."+cfg.App.Name, cfg.GRPC.Protocol, cfg.GRPC.Addr, version.GetString())
svc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, cfg.GRPC.Addr, version.GetString())
return registry.RegisterService(ctx, logger, svc, cfg.Debug.Addr)
}
@@ -51,7 +51,7 @@ func RegisterAppProvider(
Name: cfg.App.Name,
Description: cfg.App.Description,
Icon: cfg.App.Icon,
Address: cfg.GRPC.Namespace + "." + cfg.Service.Name + "." + cfg.App.Name,
Address: cfg.GRPC.Namespace + "." + cfg.Service.Name,
MimeTypes: mimeTypes,
ProductName: cfg.App.Product,
},

View File

@@ -22,7 +22,7 @@ func Server(opts ...Option) (*http.Server, error) {
return debug.NewService(
debug.Logger(options.Logger),
debug.Name(options.Config.Service.Name+"."+options.Config.App.Name),
debug.Name(options.Config.Service.Name),
debug.Version(version.GetString()),
debug.Address(options.Config.Debug.Addr),
debug.Token(options.Config.Debug.Token),

View File

@@ -25,7 +25,7 @@ func Server(opts ...Option) (http.Service, error) {
http.TLSConfig(options.Config.HTTP.TLS),
http.Logger(options.Logger),
http.Namespace(options.Config.HTTP.Namespace),
http.Name(options.Config.Service.Name+"."+options.Config.App.Name),
http.Name(options.Config.Service.Name),
http.Version(version.GetString()),
http.Address(options.Config.HTTP.Addr),
http.Context(options.Context),
@@ -41,7 +41,7 @@ func Server(opts ...Option) (http.Service, error) {
middlewares := []func(stdhttp.Handler) stdhttp.Handler{
chimiddleware.RequestID,
middleware.Version(
options.Config.Service.Name+"."+options.Config.App.Name,
options.Config.Service.Name,
version.GetString(),
),
colabmiddleware.AccessLog(
@@ -69,7 +69,7 @@ func Server(opts ...Option) (http.Service, error) {
mux.Use(
otelchi.Middleware(
options.Config.Service.Name+"."+options.Config.App.Name,
options.Config.Service.Name,
otelchi.WithChiRoutes(mux),
otelchi.WithTracerProvider(options.TracerProvider),
otelchi.WithPropagators(tracing.GetPropagator()),

View File

@@ -47,7 +47,7 @@ func NewHandler(opts ...Option) (*Service, func(), error) {
}
return &Service{
id: options.Config.GRPC.Namespace + "." + options.Config.Service.Name + "." + options.Config.App.Name,
id: options.Config.GRPC.Namespace + "." + options.Config.Service.Name,
appURLs: options.AppURLs,
logger: options.Logger,
config: options.Config,

View File

@@ -274,7 +274,7 @@ func DefaultPolicies() []config.Policy {
},
{
Endpoint: "/wopi",
Service: "eu.opencloud.web.collaboration.Collabora",
Service: "eu.opencloud.web.collaboration",
Unprotected: true,
SkipXAccessToken: true,
},