(d map[string]interface{})
| 399 | } |
| 400 | |
| 401 | func (t *cmdAdmin) handleDashboardList(d map[string]interface{}) { |
| 402 | client := t.newTopomClient(d) |
| 403 | defer client.Close() |
| 404 | |
| 405 | list, err := client.List(models.CodisDir, false) |
| 406 | if err != nil { |
| 407 | log.PanicErrorf(err, "list products failed") |
| 408 | } |
| 409 | |
| 410 | nodes := []interface{}{} |
| 411 | |
| 412 | for _, path := range list { |
| 413 | var elem = &struct { |
| 414 | Name string `json:"name"` |
| 415 | Dashboard string `json:"dashboard"` |
| 416 | }{filepath.Base(path), ""} |
| 417 | |
| 418 | if b, err := client.Read(models.LockPath(elem.Name), false); err != nil { |
| 419 | log.PanicErrorf(err, "read topom of product %s failed", elem.Name) |
| 420 | } else if b != nil { |
| 421 | var t = &models.Topom{} |
| 422 | if err := json.Unmarshal(b, t); err != nil { |
| 423 | log.PanicErrorf(err, "decode json failed") |
| 424 | } |
| 425 | elem.Dashboard = t.AdminAddr |
| 426 | } |
| 427 | |
| 428 | nodes = append(nodes, elem) |
| 429 | } |
| 430 | |
| 431 | if b, err := json.MarshalIndent(nodes, "", " "); err != nil { |
| 432 | log.PanicErrorf(err, "json encode failed") |
| 433 | } else { |
| 434 | fmt.Println(string(b)) |
| 435 | } |
| 436 | } |
no test coverage detected