Skip to content

Commit d3a0d38

Browse files
XenoPhexaxyzhao
andcommitted
remove code for coloring process row that no longer exists
[#158931754] Co-authored-by: Alex Zhao <[email protected]>
1 parent 0473b73 commit d3a0d38

File tree

4 files changed

+9
-100
lines changed

4 files changed

+9
-100
lines changed

command/ui.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type UI interface {
1717
DisplayInstancesTableForApp(table [][]string)
1818
DisplayKeyValueTable(prefix string, table [][]string, padding int)
1919
DisplayKeyValueTableForApp(table [][]string)
20-
DisplayKeyValueTableForV3App(table [][]string, crashedProcesses []string)
2120
DisplayLogMessage(message ui.LogMessage, displayHeader bool)
2221
DisplayNewline()
2322
DisplayNonWrappingTable(prefix string, table [][]string, padding int)

command/v3/shared/app_summary_displayer.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,24 @@ func (display AppSummaryDisplayer) displayAppTable(summary v3action.ApplicationS
8888
isoRow = append(isoRow, display.UI.TranslateText("isolation segment:"), appStats[0].IsolationSegment)
8989
}
9090

91-
keyValueTable := [][]string{
92-
{display.UI.TranslateText("name:"), summary.Application.Name},
93-
{display.UI.TranslateText("requested state:"), strings.ToLower(string(summary.State))},
94-
isoRow,
95-
{display.UI.TranslateText("routes:"), routes.Summary()},
96-
{display.UI.TranslateText("last uploaded:"), display.UI.UserFriendlyDate(GetCreatedTime(summary))},
97-
{display.UI.TranslateText("stack:"), summary.CurrentDroplet.Stack},
98-
}
99-
10091
var lifecycleInfo []string
101-
10292
if summary.LifecycleType == constant.AppLifecycleTypeDocker {
10393
lifecycleInfo = []string{display.UI.TranslateText("docker image:"), summary.CurrentDroplet.Image}
10494
} else {
10595
lifecycleInfo = []string{display.UI.TranslateText("buildpacks:"), display.buildpackNames(summary.CurrentDroplet.Buildpacks)}
10696
}
10797

108-
keyValueTable = append(keyValueTable, lifecycleInfo)
109-
110-
crashedProcesses := []string{}
111-
for i := range summary.ProcessSummaries {
112-
if display.processInstancesAreAllCrashed(&summary.ProcessSummaries[i]) {
113-
crashedProcesses = append(crashedProcesses, summary.ProcessSummaries[i].Type)
114-
}
98+
keyValueTable := [][]string{
99+
{display.UI.TranslateText("name:"), summary.Application.Name},
100+
{display.UI.TranslateText("requested state:"), strings.ToLower(string(summary.State))},
101+
isoRow,
102+
{display.UI.TranslateText("routes:"), routes.Summary()},
103+
{display.UI.TranslateText("last uploaded:"), display.UI.UserFriendlyDate(GetCreatedTime(summary))},
104+
{display.UI.TranslateText("stack:"), summary.CurrentDroplet.Stack},
105+
lifecycleInfo,
115106
}
116107

117-
display.UI.DisplayKeyValueTableForV3App(keyValueTable, crashedProcesses)
108+
display.UI.DisplayKeyValueTable("", keyValueTable, 3)
118109

119110
display.displayProcessTable(summary)
120111
}

util/ui/ui_for_app.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,3 @@ func (ui *UI) DisplayKeyValueTableForApp(table [][]string) {
2929
}
3030
ui.DisplayKeyValueTable("", table, 3)
3131
}
32-
33-
func (ui *UI) DisplayKeyValueTableForV3App(table [][]string, crashedProcesses []string) {
34-
if len(crashedProcesses) > 0 {
35-
redColor := color.New(color.FgRed, color.Bold)
36-
table[1][1] = ui.modifyColor(table[1][1], redColor)
37-
38-
processes := strings.Split(table[2][1], ",")
39-
newProcesses := []string{}
40-
for _, process := range processes {
41-
parts := strings.Split(process, ":")
42-
isCrashedProcess := false
43-
for _, crashedProcess := range crashedProcesses {
44-
if parts[0] == crashedProcess {
45-
isCrashedProcess = true
46-
break
47-
}
48-
}
49-
50-
if isCrashedProcess {
51-
newProcesses = append(newProcesses, ui.modifyColor(process, redColor))
52-
} else {
53-
newProcesses = append(newProcesses, process)
54-
}
55-
}
56-
57-
table[2][1] = strings.Join(newProcesses, ",")
58-
}
59-
60-
ui.DisplayKeyValueTable("", table, 3)
61-
}

util/ui/ui_for_app_test.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -29,57 +29,6 @@ var _ = Describe("UI", func() {
2929
ui.Err = NewBuffer()
3030
})
3131

32-
Describe("DisplayKeyValueTableForV3App", func() {
33-
Context("when the app is running properly", func() {
34-
BeforeEach(func() {
35-
ui.DisplayKeyValueTableForV3App([][]string{
36-
{"name:", "dora"},
37-
{"requested state:", "started"},
38-
{"processes:", "web:1/1,worker:2/2"}},
39-
[]string{},
40-
)
41-
})
42-
43-
It("displays a table with the no change in coloring", func() {
44-
Expect(ui.Out).To(Say("name: dora\n"))
45-
Expect(ui.Out).To(Say("requested state: started\n"))
46-
Expect(ui.Out).To(Say("processes: web:1/1,worker:2/2\n"))
47-
})
48-
})
49-
50-
Context("when the app is stopped and has 0 instances", func() {
51-
BeforeEach(func() {
52-
ui.DisplayKeyValueTableForV3App([][]string{
53-
{"name:", "dora"},
54-
{"requested state:", "stopped"},
55-
{"processes:", "web:1/1,worker:2/2"}},
56-
[]string{})
57-
})
58-
59-
It("displays a table with the no change in coloring", func() {
60-
Expect(ui.Out).To(Say("name: dora\n"))
61-
Expect(ui.Out).To(Say("requested state: stopped\n"))
62-
Expect(ui.Out).To(Say("processes: web:1/1,worker:2/2\n"))
63-
})
64-
})
65-
66-
Context("when the app is started and has 1 crashed process", func() {
67-
BeforeEach(func() {
68-
ui.DisplayKeyValueTableForV3App([][]string{
69-
{"name:", "dora"},
70-
{"requested state:", "started"},
71-
{"processes:", "web:0/1,worker:2/2"}},
72-
[]string{"web"})
73-
})
74-
75-
It("displays a table with requested state and crashed instance count in red", func() {
76-
Expect(ui.Out).To(Say("name: dora\n"))
77-
Expect(ui.Out).To(Say("requested state: \x1b\\[31;1mstarted\x1b\\[0m\n"))
78-
Expect(ui.Out).To(Say("processes: \x1b\\[31;1mweb:0/1\x1b\\[0m,worker:2/2\n"))
79-
})
80-
})
81-
})
82-
8332
Describe("DisplayInstancesTableForApp", func() {
8433
Context("in english", func() {
8534
It("displays a table with red coloring for down and crashed", func() {

0 commit comments

Comments
 (0)