Exemplo n.º 1
0
func (cmd *Command) Run(args []string) error {
	url, args, err := findVulcanUrl(args)
	if err != nil {
		return err
	}
	cmd.vulcanUrl = url
	cmd.client = api.NewClient(cmd.vulcanUrl, cmd.registry)

	app := cli.NewApp()
	app.Name = "vctl"
	app.Usage = "Command line interface to a running vulcan instance"
	app.Flags = flags()

	app.Commands = []cli.Command{
		NewLogCommand(cmd),
		NewKeyCommand(cmd),
		NewTopCommand(cmd),
		NewHostCommand(cmd),
		NewBackendCommand(cmd),
		NewFrontendCommand(cmd),
		NewServerCommand(cmd),
		NewListenerCommand(cmd),
	}
	app.Commands = append(app.Commands, NewMiddlewareCommands(cmd)...)
	return app.Run(args)
}
Exemplo n.º 2
0
func newVulcandClient(vulcandURL string) (*vulcandapi.Client, error) {
	client := vulcandapi.NewClient(vulcandURL, nil)
	if client != nil {
		return client, nil
	}
	return nil, errors.New("Couldn't create VulcandClient !")
}
Exemplo n.º 3
0
/**
Initialize an etcd API client
*/
func newVulcandClient(vulcandAdminURLString string) (*vulcandAPI.Client, error) {
	var u *url.URL
	var err error
	if u, err = url.Parse(os.ExpandEnv(vulcandAdminURLString)); err != nil {
		return nil, fmt.Errorf("Could not parse Vulcand admin URL: %v. Error: %v", vulcandAdminURLString, err)
	}
	if u.Scheme == "" || u.Host == "" || u.Host == ":" || u.Path != "" {
		return nil, fmt.Errorf("Invalid URL provided for Vulcand API server: %v.", u)
	}

	c := vulcandAPI.NewClient(vulcandAdminURLString, vulcandRegistry.GetRegistry())
	if c == nil {
		return nil, fmt.Errorf("Could not initialize Vulcand API client")
	}
	return c, nil
}
Exemplo n.º 4
0
func createRouter(prefix string) (router.Router, error) {
	vURL, err := config.GetString(prefix + ":api-url")
	if err != nil {
		return nil, err
	}
	domain, err := config.GetString(prefix + ":domain")
	if err != nil {
		return nil, err
	}
	client := api.NewClient(vURL, registry.GetRegistry())
	vRouter := &vulcandRouter{
		client: client,
		prefix: prefix,
		domain: domain,
	}
	return vRouter, nil
}
Exemplo n.º 5
0
func (cmd *Command) Run(args []string) error {
	url, args, err := findVulcanUrl(args)
	if err != nil {
		return err
	}
	cmd.vulcanUrl = url
	cmd.client = api.NewClient(cmd.vulcanUrl, cmd.registry)

	app := cli.NewApp()
	app.Name = "vulcanctl"
	app.Usage = "Command line interface to a running vulcan instance"
	app.Flags = flags()

	app.Commands = []cli.Command{
		NewStatusCommand(cmd),
		NewHostCommand(cmd),
		NewUpstreamCommand(cmd),
		NewLocationCommand(cmd),
		NewEndpointCommand(cmd),
	}
	app.Commands = append(app.Commands, NewMiddlewareCommands(cmd)...)
	return app.Run(args)
}