From 829efc8529ffc0947a7c4e8697b99bb92ae63670 Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte Date: Tue, 15 Aug 2023 16:24:44 +0200 Subject: [PATCH] fix plugins when reva is build with version 1.21 --- cmd/revad/main.go | 11 +++++++++++ pkg/plugin/plugin.go | 4 +++- plugins.go | 5 ----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/revad/main.go b/cmd/revad/main.go index 8041e19e9b2..51a5805bda0 100644 --- a/cmd/revad/main.go +++ b/cmd/revad/main.go @@ -29,10 +29,12 @@ import ( "sync" "syscall" + "github.com/cs3org/reva" "github.com/cs3org/reva/cmd/revad/pkg/config" "github.com/cs3org/reva/cmd/revad/pkg/grace" "github.com/cs3org/reva/cmd/revad/runtime" "github.com/cs3org/reva/pkg/logger" + "github.com/cs3org/reva/pkg/plugin" "github.com/cs3org/reva/pkg/sysinfo" "github.com/google/uuid" "github.com/pkg/errors" @@ -58,6 +60,8 @@ var ( func Main() { flag.Parse() + initPlugins() + // initialize the global system information if err := sysinfo.InitSystemInfo(&sysinfo.RevaVersion{Version: version, BuildDate: buildDate, GitCommit: gitCommit, GoVersion: goVersion}); err != nil { fmt.Fprintf(os.Stderr, "error initializing system info: %s\n", err.Error()) @@ -89,6 +93,13 @@ func Main() { runConfigs(confs) } +func initPlugins() { + plugins := reva.GetPlugins("") + for _, p := range plugins { + plugin.RegisterPlugin(p.ID.Namespace(), p.ID.Namespace(), p.New) + } +} + func handleVersionFlag() { if *versionFlag { fmt.Fprintf(os.Stderr, "%s\n", getVersionString()) diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go index d4bfa9251cd..c1f9866435c 100644 --- a/pkg/plugin/plugin.go +++ b/pkg/plugin/plugin.go @@ -18,7 +18,9 @@ package plugin -import "reflect" +import ( + "reflect" +) // RegistryFunc is the func a component that is pluggable // must define to register the new func in its own registry. diff --git a/plugins.go b/plugins.go index 72c7479350f..b1f2a389f15 100644 --- a/plugins.go +++ b/plugins.go @@ -21,8 +21,6 @@ package reva import ( "sort" "strings" - - "github.com/cs3org/reva/pkg/plugin" ) // Plugin is a type used as reva plugin. @@ -98,10 +96,7 @@ func RegisterPlugin(p Plugin) { panic("plugin new func cannot be nil") } - name := plug.ID.Name() - ns := plug.ID.Namespace() registry[string(p.RevaPlugin().ID)] = p - plugin.RegisterPlugin(ns, name, plug.New) } func hasPrefixSlices(s, prefix []string) bool {