forked from docker-archive/deploykit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (41 loc) · 1.15 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
package main
import (
"os"
log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/plugin"
"github.com/docker/infrakit/pkg/run"
"github.com/docker/infrakit/pkg/run/v0/vanilla"
"github.com/docker/infrakit/pkg/template"
"github.com/docker/infrakit/pkg/types"
"github.com/spf13/cobra"
)
var defaultTemplateOptions = template.Options{MultiPass: true}
func main() {
cmd := &cobra.Command{
Use: os.Args[0],
Short: "Vanilla flavor plugin",
}
options := vanilla.DefaultOptions
logLevel := cmd.Flags().Int("log", cli.DefaultLogLevel, "Logging level. 0 is least verbose. Max is 5")
name := "flavor-vanilla"
cmd.Flags().StringVar(&name, "name", name, "Plugin name to advertise for discovery")
cmd.Run = func(c *cobra.Command, args []string) {
cli.SetLogLevel(*logLevel)
name, impl, onStop, err := vanilla.Run(nil, plugin.Name(name), types.AnyValueMust(options))
if err != nil {
return
}
_, running, err := run.ServeRPC(name, onStop, impl)
if err != nil {
return
}
<-running
}
cmd.AddCommand(cli.VersionCommand())
err := cmd.Execute()
if err != nil {
log.Error(err)
os.Exit(1)
}
}