MCPcopy
hub / github.com/CodisLabs/codis / handleDashboardList

Method handleDashboardList

cmd/admin/admin.go:401–436  ·  view source on GitHub ↗
(d map[string]interface{})

Source from the content-addressed store, hash-verified

399}
400
401func (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}

Callers 1

MainMethod · 0.95

Calls 7

newTopomClientMethod · 0.95
PanicErrorfMethod · 0.80
LockPathMethod · 0.80
PrintlnMethod · 0.80
CloseMethod · 0.65
ListMethod · 0.65
ReadMethod · 0.65

Tested by

no test coverage detected