@@ -140,6 +140,40 @@ func main() {
140140 table .Append ([]string {"sum of all container" , fmt .Sprintf ("%d" , allCPU ), fmt .Sprintf ("%d" , allMemory ), fmt .Sprintf ("%d" , allMemoryReservation )})
141141 taskCPU , _ := strconv .ParseInt (taskDefinition .CPU , 10 , 64 )
142142 taskMemory , _ := strconv .ParseInt (taskDefinition .Memory , 10 , 64 )
143- table .SetFooter ([]string {"leftover" , fmt .Sprintf ("%d" , taskCPU - allCPU ), fmt .Sprintf ("%d" , taskMemory - allMemory ), fmt .Sprintf ("%d" , taskMemory - allMemoryReservation )})
143+
144+ leftoverCPU := taskCPU - allCPU
145+ leftoverMemory := taskMemory - allMemory
146+ leftoverMemoryReservation := taskMemory - allMemoryReservation
147+
148+ footerStrings := []string {
149+ "leftover" ,
150+ fmt .Sprintf ("%d" , leftoverCPU ),
151+ fmt .Sprintf ("%d" , leftoverMemory ),
152+ fmt .Sprintf ("%d" , leftoverMemoryReservation ),
153+ }
154+ table .SetFooter (footerStrings )
155+
156+ footerColors := make ([]tablewriter.Colors , 4 )
157+ footerColors [0 ] = tablewriter.Colors {} // For "leftover" label
158+
159+ if leftoverCPU < 0 {
160+ footerColors [1 ] = tablewriter.Colors {tablewriter .FgRedColor }
161+ } else {
162+ footerColors [1 ] = tablewriter.Colors {}
163+ }
164+
165+ if leftoverMemory < 0 {
166+ footerColors [2 ] = tablewriter.Colors {tablewriter .FgRedColor }
167+ } else {
168+ footerColors [2 ] = tablewriter.Colors {}
169+ }
170+
171+ if leftoverMemoryReservation < 0 {
172+ footerColors [3 ] = tablewriter.Colors {tablewriter .FgRedColor }
173+ } else {
174+ footerColors [3 ] = tablewriter.Colors {}
175+ }
176+ table .SetFooterColor (footerColors ... )
177+
144178 table .Render ()
145179}
0 commit comments