Skip to content

Commit

Permalink
fix plugins when reva is build with version 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Aug 15, 2023
1 parent b1579eb commit 829efc8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 11 additions & 0 deletions cmd/revad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
4 changes: 3 additions & 1 deletion pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ package reva
import (
"sort"
"strings"

"github.com/cs3org/reva/pkg/plugin"
)

// Plugin is a type used as reva plugin.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 829efc8

Please sign in to comment.