Skip to content

Commit 8592f34

Browse files
mrow4aliyinan926
authored andcommitted
Unify listing with status/event
1 parent 29a4329 commit 8592f34

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

sparkctl/cmd/list.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222

23+
"github.com/olekukonko/tablewriter"
2324
"github.com/spf13/cobra"
2425

2526
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -50,9 +51,17 @@ func doList(crdClientset crdclientset.Interface) error {
5051
return err
5152
}
5253

54+
table := tablewriter.NewWriter(os.Stdout)
55+
table.SetHeader([]string{"Name", "State", "Submission Age", "Completion Age"})
5356
for _, app := range apps.Items {
54-
fmt.Println(app.Name)
57+
table.Append([]string{
58+
string(app.Name),
59+
string(app.Status.AppState.State),
60+
getSinceTime(app.Status.SubmissionTime),
61+
getSinceTime(app.Status.CompletionTime),
62+
})
5563
}
64+
table.Render()
5665

5766
return nil
5867
}

sparkctl/cmd/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func doStatus(name string, crdClientset crdclientset.Interface) error {
6363
func printStatus(app *v1alpha1.SparkApplication) {
6464
fmt.Println("application state:")
6565
table := tablewriter.NewWriter(os.Stdout)
66-
table.SetHeader([]string{"State", "Submitted age", "Completed age", "Driver Pod", "Driver UI", "Retries"})
66+
table.SetHeader([]string{"State", "Submission Age", "Completion Age", "Driver Pod", "Driver UI", "Retries"})
6767
table.Append([]string{
6868
string(app.Status.AppState.State),
6969
getSinceTime(app.Status.SubmissionTime),

0 commit comments

Comments
 (0)