Skip to content

Commit

Permalink
Merge pull request #109 from flant/fix_status_progress_table_format
Browse files Browse the repository at this point in the history
[logging] Fix status progress table style
  • Loading branch information
distorhead authored Jul 2, 2019
2 parents 0e9c8bc + 58002a3 commit e03cb93
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/flant/kubedog
require (
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/fatih/color v1.7.0
github.com/flant/logboek v0.2.3-0.20190626194023-1580e4b6b6d9
github.com/flant/logboek v0.2.3
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/protobuf v1.3.1 // indirect
github.com/google/btree v1.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ github.com/flant/logboek v0.2.2 h1:SlJG9/ojsTyfjkRSAxnWZCULWoejEM3fDZXkkOFKSCk=
github.com/flant/logboek v0.2.2/go.mod h1:eEQXX0UOWpyC8iaA9QOvzx8drZ64u0SRESiwQKnxF+I=
github.com/flant/logboek v0.2.3-0.20190626194023-1580e4b6b6d9 h1:3DJ8TgWZfyi0nQtYkPPMtKlMbA8rIuTed9MpJg6IeZ8=
github.com/flant/logboek v0.2.3-0.20190626194023-1580e4b6b6d9/go.mod h1:eEQXX0UOWpyC8iaA9QOvzx8drZ64u0SRESiwQKnxF+I=
github.com/flant/logboek v0.2.3 h1:NVc6TEXQeW0NEg0frSEvtw/fL7phnOnfjvjuJktLEUM=
github.com/flant/logboek v0.2.3/go.mod h1:eEQXX0UOWpyC8iaA9QOvzx8drZ64u0SRESiwQKnxF+I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
Expand Down
29 changes: 13 additions & 16 deletions pkg/utils/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ type Table struct {
columnsCount int

service struct {
header string
headerRest string
row string
rowRest string
lastRow string
lastRowRest string
extraRow string
extraRowRest string
lastExtraRow string
lastExtraRowRest string
header string
headerRest string
row string
rowRest string
lastRow string
lastRowRest string
}

buf *bytes.Buffer
Expand Down Expand Up @@ -63,10 +59,6 @@ func (t *Table) SubTable(columnsRatio ...float64) Table {
st.service.rowRest = "│ "
st.service.lastRow = "└── "
st.service.lastRowRest = " "
st.service.extraRow = "│ ├── "
st.service.extraRowRest = "│ │ "
st.service.lastExtraRow = "│ └── "
st.service.lastExtraRowRest = "│ "

return st
}
Expand Down Expand Up @@ -115,13 +107,18 @@ func (t *Table) Row(columns ...interface{}) {
t.apply(rowColumns...)

if len(extraRowColumns) != 0 {
t.withService(t.service.extraRow, t.service.extraRowRest, func() {
serviceExtraRow := t.serviceRestText + t.service.row
serviceExtraRowRest := t.serviceRestText + t.service.rowRest
serviceLastExtraRow := t.serviceRestText + t.service.lastRow
serviceLastExtraRowRest := t.serviceRestText + t.service.lastRowRest

t.withService(serviceExtraRow, serviceExtraRowRest, func() {
for _, column := range extraRowColumns[:len(extraRowColumns)-1] {
t.apply(column)
}
})

t.withService(t.service.lastExtraRow, t.service.lastExtraRowRest, func() {
t.withService(serviceLastExtraRow, serviceLastExtraRowRest, func() {
t.apply(extraRowColumns[len(extraRowColumns)-1])
})
}
Expand Down
1 change: 1 addition & 0 deletions playground/table/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func main() {
{"654fc55df-5zs4m", "3/3", "Pulling", "0", "49m", color.RedString("pod/myapp-backend-cbdb856d7-bvplx Failed: Error: ImagePullBackOff"), color.RedString("pod/myapp-backend-cbdb856d7-b6ms8 Failed: Failed to pull image \"ubuntu:kaka\": rpc error: code Unknown desc = Error response from daemon: manifest for ubuntu:kaka not found")},
{"654fc55df-hsm67", "3/3", color.GreenString("Running") + " -> " + color.RedString("Terminating"), "0", "49m"},
{"654fc55df-fffff", "3/3", "Ready", "0", "49m"},
{"654fc55df-5zs4m", "3/3", "Pulling", "0", "49m", color.RedString("pod/myapp-backend-cbdb856d7-bvplx Failed: Error: ImagePullBackOff"), color.RedString("pod/myapp-backend-cbdb856d7-b6ms8 Failed: Failed to pull image \"ubuntu:kaka\": rpc error: code Unknown desc = Error response from daemon: manifest for ubuntu:kaka not found")},
}...)
st.Commit(color.RedString("pod/myapp-backend-cbdb856d7-b6ms8 Failed: Failed to pull image \"ubuntu:kaka\": rpc error: code Unknown desc = Error response from daemon: manifest for ubuntu:kaka not found"), color.RedString("pod/myapp-backend-cbdb856d7-b6ms8 Failed: Failed to pull image \"ubuntu:kaka\": rpc error: code Unknown desc = Error response from daemon: manifest for ubuntu:kaka not found"))
t.Row("deploy/grafana", "1/1", 1, 1)
Expand Down

0 comments on commit e03cb93

Please sign in to comment.