diff options
| -rw-r--r-- | human.go | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -8,9 +8,13 @@ package virtbuf // are in text columns and rows that can be easily read in a terminal import ( + "errors" "fmt" + "net/http" "strings" "time" + + "go.wit.com/log" ) func oldGetDurationStamp(t time.Time) string { @@ -174,3 +178,28 @@ func (d *Droplet) SprintDumpHeader() string { } return header } + +func (d *Droplet) DumpDroplet(w http.ResponseWriter, r *http.Request) (string, error) { + if d == nil { + reason := "DumpDroplet() got d == nil" + log.Warn(reason) + fmt.Fprintln(w, reason) + return "", errors.New(reason) + } + t := d.FormatTEXT() + log.Info(t) + fmt.Fprintln(w, t) + return t, nil +} + +func (c *NewCluster) DumpDroplet(w http.ResponseWriter, r *http.Request) (string, error) { + hostname := r.URL.Query().Get("hostname") + d := c.FindDropletByName(hostname) + if d == nil { + result := "can not find droplet hostname=" + hostname + log.Info(result) + fmt.Fprintln(w, result) + return result, errors.New(result) + } + return d.DumpDroplet(w, r) +} |
