-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
62 lines (50 loc) · 1.51 KB
/
root.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
58
59
60
61
62
// Copyright © 2017 Naveego
package cmd
import (
"fmt"
"github.com/hashicorp/go-hclog"
"os"
"github.com/hashicorp/go-plugin"
"github.com/naveego/dataflow-contracts/plugins"
"github.com/naveego/plugin-oracle/internal"
"github.com/naveego/plugin-oracle/internal/pub"
"github.com/naveego/plugin-oracle/version"
"github.com/spf13/cobra"
)
var verbose *bool
// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "plugin-pub-mssql",
Short: "A publisher that pulls data from SQL.",
Long: fmt.Sprintf(`Version %s
Runs the publisher in externally controlled mode.`, version.Version.String()),
Run: func(cmd *cobra.Command, args []string) {
log := hclog.New(&hclog.LoggerOptions{
Level: hclog.Trace,
Output: os.Stderr,
JSONFormat: false,
Name: "plugin-oracle",
})
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: plugin.HandshakeConfig{
ProtocolVersion: plugins.PublisherProtocolVersion,
MagicCookieKey:plugins.PublisherMagicCookieKey,
MagicCookieValue:plugins.PublisherMagicCookieValue,
},
Plugins: map[string]plugin.Plugin{
"publisher": pub.NewServerPlugin(internal.NewServer(log)),
},
Logger: log,
// A non-nil value here enables gRPC serving for this plugin...
GRPCServer: plugin.DefaultGRPCServer,
})
}}
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
verbose = RootCmd.Flags().BoolP("verbose", "v", false, "enable verbose logging")
}