@@ -40,15 +40,15 @@ func (c *podModel) updateData(force bool) {
4040
4141 // 格式化时间输出
4242 timeStr := "-"
43- startTime := pod .Status .StartTime
44- if startTime == nil {
45- timeStr = pod .Status .StartTime .Format (time .DateTime )
43+ if startTime := pod .Status .StartTime ; startTime != nil {
44+ timeStr = startTime .Format (time .DateTime )
4645 }
4746
4847 rows = append (rows , table.Row {
4948 name ,
5049 pod .Status .PodIP ,
51- PodPhaseView (pod .Status .Phase ),
50+ PodPhaseView (pod ),
51+ PodReadyView (pod ),
5252 timeStr ,
5353 })
5454 }
@@ -76,7 +76,8 @@ func ShowPod(app string, lastModel tea.Model) (tea.Model, error) {
7676 m .TableFilter .Table = ui .NewTableWithData ([]table.Column {
7777 {Title : "名称" , Width : 0 },
7878 {Title : "IP" , Width : 15 },
79- {Title : "状态" , Width : 9 },
79+ {Title : "状态" , Width : 4 },
80+ {Title : "就绪" , Width : 4 },
8081 {Title : "启动时间" , Width : 19 },
8182 }, nil )
8283 m .TableFilter .Focus ()
@@ -135,13 +136,29 @@ var phaseAlias = map[v1.PodPhase]string{
135136 v1 .PodSucceeded : "🔅" ,
136137 v1 .PodFailed : "❌️" ,
137138 v1 .PodUnknown : "❓️" ,
139+ "Terminating" : "✴️" ,
138140}
139141
140142// PodPhaseView 友好显示POD状态
141- func PodPhaseView (phaes v1.PodPhase ) string {
142- result := phaseAlias [phaes ]
143+ func PodPhaseView (pod v1.Pod ) string {
144+ phase := pod .Status .Phase
145+ if pod .DeletionTimestamp != nil {
146+ phase = "Terminating"
147+ }
148+
149+ result := phaseAlias [phase ]
143150 if result == "" {
144- result = string (phaes )
151+ result = string (phase )
145152 }
146153 return result
147154}
155+
156+ // PodReadyView 友好显示POD的Ready状态
157+ func PodReadyView (pod v1.Pod ) string {
158+ for _ , condition := range pod .Status .Conditions {
159+ if condition .Type == v1 .PodReady && condition .Status == v1 .ConditionTrue {
160+ return "✔️"
161+ }
162+ }
163+ return "❌️"
164+ }
0 commit comments