-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (48 loc) · 1.38 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
"github.com/hashicorp/go-hclog"
hashPlugin "github.com/hashicorp/go-plugin"
"github.com/jimil749/reva-plugin-benchmark/pkg/shared"
)
// this is just for the purpose of testing
func main() {
log.SetOutput(ioutil.Discard)
logger := hclog.New(&hclog.LoggerOptions{
Name: "plugin",
Output: os.Stdout,
Level: hclog.NoLevel,
})
// We're a host. Start by launching the plugin process.
client := hashPlugin.NewClient(&hashPlugin.ClientConfig{
HandshakeConfig: shared.Handshake,
Plugins: shared.PluginMap,
Cmd: exec.Command("./hashicorp-plugin"),
AllowedProtocols: []hashPlugin.Protocol{
hashPlugin.ProtocolNetRPC},
Logger: logger,
})
defer client.Kill()
// Connect via RPC
rpcClient, err := client.Client()
if err != nil {
fmt.Println("Error:", err.Error())
os.Exit(1)
}
// Request the plugin
raw, err := rpcClient.Dispense("json")
if err != nil {
fmt.Println("Error:", err.Error())
os.Exit(1)
}
// We should have the manager now! This feels like a normal interface
// implementation but is in fact over an RPC connection.
manager := raw.(shared.UserManager)
user, _ := manager.GetUser(&userpb.UserId{OpaqueId: "4c510ada-c86b-4815-8820-42cdf82c3d51", Idp: "cernbox.cern.ch"})
fmt.Printf(user.DisplayName)
}