Skip to content

Commit

Permalink
chore: use separate rows for ip and port in result
Browse files Browse the repository at this point in the history
Signed-off-by: Tsong Lew <[email protected]>
  • Loading branch information
tsonglew committed Nov 16, 2022
1 parent d03afff commit eba2ed2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions tools-v2/internal/utils/row.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const (
ROW_USED = "used"
ROW_VERSION = "version"
ROW_ZONE = "zone"
ROW_IP = "ip"
ROW_PORT = "port"

// s3
ROW_S3CHUNKINFO_CHUNKID = "s3ChunkId"
Expand Down
10 changes: 5 additions & 5 deletions tools-v2/pkg/cli/command/curvebs/list/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ package client
import (
"context"
"fmt"

cmderror "github.com/opencurve/curve/tools-v2/internal/error"
cobrautil "github.com/opencurve/curve/tools-v2/internal/utils"
basecmd "github.com/opencurve/curve/tools-v2/pkg/cli/command"
Expand Down Expand Up @@ -103,10 +102,10 @@ func (pCmd *ClientCommand) Init(cmd *cobra.Command, args []string) error {
}
pCmd.Rpc = append(pCmd.Rpc, rpc)

header := []string{cobrautil.ROW_ADDR}
header := []string{cobrautil.ROW_IP, cobrautil.ROW_PORT}
pCmd.SetHeader(header)
pCmd.TableNew.SetAutoMergeCellsByColumnIndex(cobrautil.GetIndexSlice(
pCmd.Header, []string{cobrautil.ROW_ADDR},
pCmd.Header, header,
))
return nil
}
Expand Down Expand Up @@ -135,12 +134,13 @@ func (pCmd *ClientCommand) RunCommand(cmd *cobra.Command, args []string) error {
infos := res.(*nameserver2.ListClientResponse).GetClientInfos()
for _, info := range infos {
row := make(map[string]string)
row[cobrautil.ROW_ADDR] = fmt.Sprintf("%s:%d", info.GetIp(), info.GetPort())
row[cobrautil.ROW_IP] = info.GetIp()
row[cobrautil.ROW_PORT] = fmt.Sprintf("%d", info.GetPort())
rows = append(rows, row)
}
}
list := cobrautil.ListMap2ListSortByKeys(rows, pCmd.Header, []string{
cobrautil.ROW_ADDR,
cobrautil.ROW_IP,
})
pCmd.TableNew.AppendBulk(list)
errRet := cmderror.MergeCmdError(errors)
Expand Down

0 comments on commit eba2ed2

Please sign in to comment.