reva icon indicating copy to clipboard operation
reva copied to clipboard

Enable fetching plugins from github repository

Open jimil749 opened this issue 3 years ago • 3 comments

This PR adds following changes:

  1. Feature: Enables fetching reva-plugins from github, Users can provide following configuration:
[grpc.services.userprovider]
driver=https://github.com/jimil749/json

This configuration downloads the plugin source code into /var/reva/tmp/ext/<pluginType>/<driver>, compiles the code and loads it onto reva at runtime. Repo used for testing: https://github.com/jimil749/json

  1. Fix: Use Struct based approach to encode and decode context kv pairs. Instead of sending map[interface{}]interface{} over RPC, we extract kv pairs into following struct:
type Ctx struct {
    User   []*userpb.User
    Token  []string
}

and send this struct over RPC.

PS: @ishank011 I did not test having github repo w/o go.mod because the traditional go get would be deprecated in the further go versions. If we still want to support plugins w/o go modules, we'd have to download the files into GOPATH for successful compilation.

jimil749 avatar Aug 07 '21 06:08 jimil749

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

update-docs[bot] avatar Aug 07 '21 06:08 update-docs[bot]

This pull request introduces 3 alerts when merging 160af2ba660e59567de628441dd552ab1cbc092f into ec4099da830e7adad86e37a56b33b07835c91559 - view on LGTM.com

new alerts:

  • 3 for Useless assignment to local variable

lgtm-com[bot] avatar Aug 11 '21 17:08 lgtm-com[bot]

I've pushed a couple of changes, let me know what do you think about them:

  1. Go-getter: Now, instead of trimming, we ask user to specify the protocol that they want to use. They just need to append the url with the required protocol. So for git protocol, correct configuration would be git::https://github.com/jimil749/json.
  2. Context: Use SetContext and GetContextStruct from plugin pkg to set and get contexts.
  3. Compilation: Add cmd.Dir field to run the build command in the directory where the source code lies. This is because building a go project with go.mod from the current Reva directory is not possible.

Due to (3) the user needs to provide absolute path to the source in order to compile local plugins.

jimil749 avatar Aug 11 '21 17:08 jimil749