forked from docker-archive/deploykit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (35 loc) · 1.21 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
package main
import (
"os"
log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/pkg/cli"
instance_plugin "github.com/docker/infrakit/pkg/rpc/instance"
"github.com/spf13/cobra"
)
func main() {
cmd := &cobra.Command{
Use: os.Args[0],
Short: "MAAS instance plugin",
}
name := cmd.Flags().String("name", "instance-maas", "Plugin name to advertise for discovery")
logLevel := cmd.Flags().Int("log", cli.DefaultLogLevel, "Logging level. 0 is least verbose. Max is 5")
apiKey := cmd.Flags().String("apikey", "aaaa:bbbb:ccccc", "MAAS API KEY. <consumer_key>:<key>:<secret>")
maasURL := cmd.Flags().String("url", "127.0.0.1:80", "MAAS Server URL. <url>:<port>")
apiVersion := cmd.Flags().String("apiversion", "1.0", "MAAS api Version. 1.0")
defaultDir, err := os.Getwd()
if err != nil {
log.Error(err)
os.Exit(1)
}
dir := cmd.Flags().String("dir", defaultDir, "MaaS directory")
cmd.RunE = func(c *cobra.Command, args []string) error {
cli.SetLogLevel(*logLevel)
cli.RunPlugin(*name, instance_plugin.PluginServer(NewMaasPlugin(*dir, *apiKey, *maasURL, *apiVersion)))
return nil
}
// cmd.AddCommand(cli.VersionCommand())
if err := cmd.Execute(); err != nil {
log.Error(err)
os.Exit(1)
}
}