Skip to content

Commit

Permalink
✨ show status
Browse files Browse the repository at this point in the history
  • Loading branch information
budougumi0617 committed Sep 24, 2019
1 parent a96db53 commit 85dcc29
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"strings"
"time"

"github.com/manifoldco/promptui"
v1 "k8s.io/api/core/v1"
Expand All @@ -22,17 +23,24 @@ func getPods() (*v1.Pod, error) {
if err != nil {
log.Fatal(err)
}
fmt.Printf("pods.Item[0] = %+v\n", pods.Items[0])

templates := &promptui.SelectTemplates{
Label: "{{ . }}?",
Active: "\u2388 {{ .Name | cyan }} ({{ .Namespace | red }})",
Inactive: " {{ .Name | cyan }} ({{ .Namespace | red }})",
Selected: "\u2388 executed {{ .Name| red }}",
Active: "\u2388 {{ .Name | cyan }} ({{ .Namespace | red }} {{ .Status.Phase }})",
Inactive: " {{ .Name | cyan }} ({{ .Namespace | red }} {{ .Status.Phase }})",
Selected: "\u2388 executed {{ .Name | red }}",
Details: `
--------- Pod ----------
{{ "Name:" | faint }} {{ printf "%q" .Name }}
{{ "Namespacege:" | faint }} {{ .Namespace }}`,
{{ "Namespacege:" | faint }} {{ .Namespace }}
{{ "Status:" | faint }} {{ .Status.Phase }}
{{ "Age:" | faint }} {{ now | since | print }}`,
// {{ "Age:" | faint }} {{ now | since .CreationTimestamp | print }}`,
FuncMap: promptui.FuncMap,
}
templates.FuncMap["since"] = time.Since
templates.FuncMap["now"] = time.Now

searcher := func(input string, index int) bool {
pod := pods.Items[index]
Expand Down

0 comments on commit 85dcc29

Please sign in to comment.