Skip to content

Commit 067b3a9

Browse files
committed
Updates to sort results so they are consistent between runs
1 parent faa7801 commit 067b3a9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

main.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ const (
3838
)
3939

4040
type PodResult struct {
41-
PodName string
42-
Output string
43-
Error error
41+
podName string
42+
output string
43+
err error
4444
}
4545

4646
type ByPodName []PodResult
4747

4848
func (p ByPodName) Len() int { return len(p) }
49-
func (p ByPodName) Less(i, j int) bool { return p[i].PodName < p[j].PodName }
49+
func (p ByPodName) Less(i, j int) bool { return p[i].podName < p[j].podName }
5050
func (p ByPodName) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
5151

5252
func main() {
@@ -113,11 +113,15 @@ func main() {
113113
sort.Sort(ByPodName(results))
114114

115115
for _, result := range results {
116-
fmt.Printf("%sPod %s\n%s%s",
117-
colorize(divColor, divText),
118-
colorize(podNameColor, result.PodName),
119-
colorize(divColor, divText),
120-
result.Output)
116+
if result.err != nil {
117+
fmt.Printf("Error executing command on pod %s: %v\n%s", result.podName, err, result.output)
118+
} else {
119+
fmt.Printf("%sPod %s\n%s%s",
120+
colorize(divColor, divText),
121+
colorize(podNameColor, result.podName),
122+
colorize(divColor, divText),
123+
result.output)
124+
}
121125
}
122126
}
123127

0 commit comments

Comments
 (0)