orbiter/cmd/autoscaler-ls.go
Gianluca Arbezzano be8f301328 Add basic commands to help with debugging
Add new API call to get all the autoscalers currently managed by
orbiter:

```
curl http://localhost:8000/autoscaler
```

Add command into the CLI to get this list

```
export ORBITER_HOST=http://localhost:8000 orbiter autoscler ls
```

Add command into the CLI to print all the events fired by the daemon:

```
export ORBITER_HOST=http://localhost:8000 orbiter system events
```
2017-03-18 19:49:17 +00:00

41 lines
755 B
Go

package cmd
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"github.com/Sirupsen/logrus"
)
type AutoscalerListCmd struct {
}
func (c *AutoscalerListCmd) Run(args []string) int {
r, err := http.Get(fmt.Sprintf("%s/autoscaler", os.Getenv("ORBITER_HOST")))
if err != nil {
logrus.Fatal(err)
return 1
}
defer r.Body.Close()
body, err := ioutil.ReadAll(r.Body)
if err != nil {
logrus.Fatal(err)
return 1
}
fmt.Printf("%s\n\r", body)
return 0
}
func (c *AutoscalerListCmd) Help() string {
helpText := `
Usage: List of autoscalers currently enabled. `
return strings.TrimSpace(helpText)
}
func (r *AutoscalerListCmd) Synopsis() string {
return "List all autoscalers currently managed by orbiter."
}