Beispiel #1
0
func init() {
	flag.IntVar(&port, []string{"p", "-port"}, 8080, "Port to listen on for the API")
	flag.StringVar(&master, []string{"m", "-master"}, "localhost:5050", "Master to connect to")
	flag.BoolVar(&debug, []string{"D", "-debug"}, false, "")
	flag.StringVar(&user, []string{"u", "-user"}, "root", "User to execute tasks as")
	flag.StringVar(&ip, []string{"-ip"}, "", "IP address to listen on [default: autodetect]")

	flag.Parse()
}
Beispiel #2
0
func init() {
	flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp")
	flag.BoolVar(&b, []string{"b", "#bal", "#bol", "-bal"}, false, "a simple bool")
	flag.BoolVar(&b, []string{"g", "#gil"}, false, "a simple bool")
	flag.BoolVar(&b2, []string{"#-bool"}, false, "a simple bool")
	flag.IntVar(&i, []string{"-integer", "-number"}, -1, "a simple integer")
	flag.StringVar(&str, []string{"s", "#hidden", "-string"}, "", "a simple string") //-s -hidden and --string will work, but -hidden won't be in the usage
	flag.BoolVar(&h, []string{"h", "#help", "-help"}, false, "display the help")
	flag.StringVar(&str, []string{"mode"}, "mode1", "set the mode\nmode1: use the mode1\nmode2: use the mode2\nmode3: use the mode3")
	flag.Parse()
}
Beispiel #3
0
func init() {
	flag.BoolVar(&b, []string{"b"}, false, "a simple bool")
	flag.IntVar(&i, []string{"#integer", "-integer"}, -1, "a simple integer")
	flag.StringVar(&str, []string{"s", "#hidden", "-string"}, "", "a simple string") //-s -hidden and --string will work, but -hidden won't be in the usage
	flag.BoolVar(&h, []string{"h", "#help", "-help"}, false, "display the help")
	flag.Parse()
}
Beispiel #4
0
// Juste add a nice flag (using docker mflag) and start it
func main() {
	flag.StringVar(&Address, []string{"l", "-listen"}, "127.0.0.1:8081", "IPaddress to listen from ex: (127.0.0.1:8081)")
	flag.Parse()
	s := &Server{
		Bind: Address,
	}
	s.Init()
	s.Start()
}
Beispiel #5
0
func main() {

	// setup command line arguments
	var (
		kubernetes bool
		mesos      bool
		scheduler  string
		host       string
		app        string
		version    bool
		discover   bool
	)

	// Override flag with docker mflag
	// TODO :
	//      - need to simplify flags, there is way too much of them
	flag.StringVar(&app, []string{"a", "-app"}, "", "App id used by your scheduler")
	flag.StringVar(&host, []string{"h", "-host"}, "", "Host to use with the scheduler")

	flag.BoolVar(&kubernetes, []string{"k", "-kubernetes"}, false, "Connect to Kubernetes endpoint")
	flag.BoolVar(&mesos, []string{"m", "-mesos"}, false, "Connect to Mesos endpoint")
	flag.StringVar(&scheduler, []string{"s", "-scheduler"}, "mesos", "Literral adapter")

	flag.BoolVar(&discover, []string{"d", "-discover"}, false, "Discover all apps and endpoints")
	flag.BoolVar(&version, []string{"v", "-version"}, false, "Show Version")

	log.SetPrefix("[WIP]")
	log.SetFlags(0)
	flag.Parse()

	if version {
		showVersion()
		os.Exit(0)
	}

	if !discover && app == "" {
		log.Fatal("Application can't be null")
	}

	if host == "" {
		log.Fatal("Host can't be null")
	}

	if kubernetes {
		scheduler = "kubernetes"
	}

	client, err := api.NewClient(scheduler, host)
	if err != nil {
		log.Fatalf("Error %s", err)
	}

	// TODO
	// - need to delegate the String() function
	//   to the client
	// - need to handle nginx conf via template
	//   or via etcd to be purge via confd
	//   or find another way
	if app != "" && !discover {
		response, err := client.Discover(app)
		if err != nil {
			log.Fatalf("%s", err)
		}
		r, _ := json.Marshal(response)
		fmt.Printf("%s\n", r)
	}

	if discover {
		response, err := client.DiscoverAll()
		if err != nil {
			log.Fatalf("%s", err)
		}
		r, _ := json.Marshal(response)
		fmt.Printf("%s\n", r)
	}

}