Bumping k8s dependencies to 1.13
This commit is contained in:
262
vendor/k8s.io/kubernetes/pkg/printers/internalversion/printers.go
generated
vendored
262
vendor/k8s.io/kubernetes/pkg/printers/internalversion/printers.go
generated
vendored
@@ -21,7 +21,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -31,6 +30,7 @@ import (
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
||||
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
|
||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
rbacv1beta1 "k8s.io/api/rbac/v1beta1"
|
||||
@@ -43,11 +43,11 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/duration"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/kubernetes/pkg/api/events"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
"k8s.io/kubernetes/pkg/apis/batch"
|
||||
"k8s.io/kubernetes/pkg/apis/certificates"
|
||||
"k8s.io/kubernetes/pkg/apis/coordination"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/core/helper"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
@@ -82,6 +82,7 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
||||
{Name: "IP", Type: "string", Priority: 1, Description: apiv1.PodStatus{}.SwaggerDoc()["podIP"]},
|
||||
{Name: "Node", Type: "string", Priority: 1, Description: apiv1.PodSpec{}.SwaggerDoc()["nodeName"]},
|
||||
{Name: "Nominated Node", Type: "string", Priority: 1, Description: apiv1.PodStatus{}.SwaggerDoc()["nominatedNodeName"]},
|
||||
}
|
||||
h.TableHandler(podColumnDefinitions, printPodList)
|
||||
h.TableHandler(podColumnDefinitions, printPod)
|
||||
@@ -149,8 +150,8 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
|
||||
jobColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Desired", Type: "integer", Description: batchv1.JobSpec{}.SwaggerDoc()["completions"]},
|
||||
{Name: "Successful", Type: "integer", Description: batchv1.JobStatus{}.SwaggerDoc()["succeeded"]},
|
||||
{Name: "Completions", Type: "string", Description: batchv1.JobStatus{}.SwaggerDoc()["succeeded"]},
|
||||
{Name: "Duration", Type: "string", Description: "Time required to complete the job."},
|
||||
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
||||
{Name: "Containers", Type: "string", Priority: 1, Description: "Names of each container in the template."},
|
||||
{Name: "Images", Type: "string", Priority: 1, Description: "Images referenced by each container in the template."},
|
||||
@@ -233,15 +234,15 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
|
||||
eventColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Last Seen", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["lastTimestamp"]},
|
||||
{Name: "First Seen", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["firstTimestamp"]},
|
||||
{Name: "Count", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["count"]},
|
||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Kind", Type: "string", Description: apiv1.Event{}.InvolvedObject.SwaggerDoc()["kind"]},
|
||||
{Name: "Subobject", Type: "string", Description: apiv1.Event{}.InvolvedObject.SwaggerDoc()["fieldPath"]},
|
||||
{Name: "Type", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["type"]},
|
||||
{Name: "Reason", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["reason"]},
|
||||
{Name: "Source", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["source"]},
|
||||
{Name: "Kind", Type: "string", Description: apiv1.Event{}.InvolvedObject.SwaggerDoc()["kind"]},
|
||||
{Name: "Source", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["source"]},
|
||||
{Name: "Message", Type: "string", Description: apiv1.Event{}.SwaggerDoc()["message"]},
|
||||
{Name: "Subobject", Type: "string", Priority: 1, Description: apiv1.Event{}.InvolvedObject.SwaggerDoc()["fieldPath"]},
|
||||
{Name: "First Seen", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["firstTimestamp"]},
|
||||
{Name: "Count", Type: "string", Priority: 1, Description: apiv1.Event{}.SwaggerDoc()["count"]},
|
||||
{Name: "Name", Type: "string", Priority: 1, Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
}
|
||||
h.TableHandler(eventColumnDefinitions, printEvent)
|
||||
h.TableHandler(eventColumnDefinitions, printEventList)
|
||||
@@ -393,6 +394,14 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
h.TableHandler(certificateSigningRequestColumnDefinitions, printCertificateSigningRequest)
|
||||
h.TableHandler(certificateSigningRequestColumnDefinitions, printCertificateSigningRequestList)
|
||||
|
||||
leaseColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Holder", Type: "string", Description: coordinationv1beta1.LeaseSpec{}.SwaggerDoc()["holderIdentity"]},
|
||||
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
||||
}
|
||||
h.TableHandler(leaseColumnDefinitions, printLease)
|
||||
h.TableHandler(leaseColumnDefinitions, printLeaseList)
|
||||
|
||||
storageClassColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Provisioner", Type: "string", Description: storagev1.StorageClass{}.SwaggerDoc()["provisioner"]},
|
||||
@@ -457,7 +466,7 @@ func printObjectMeta(obj runtime.Object, options printers.PrintOptions) ([]metav
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, m.GetName(), translateTimestamp(m.GetCreationTimestamp()))
|
||||
row.Cells = append(row.Cells, m.GetName(), translateTimestampSince(m.GetCreationTimestamp()))
|
||||
rows = append(rows, row)
|
||||
return rows, nil
|
||||
}
|
||||
@@ -473,19 +482,33 @@ func formatEndpoints(endpoints *api.Endpoints, ports sets.String) string {
|
||||
count := 0
|
||||
for i := range endpoints.Subsets {
|
||||
ss := &endpoints.Subsets[i]
|
||||
for i := range ss.Ports {
|
||||
port := &ss.Ports[i]
|
||||
if ports == nil || ports.Has(port.Name) {
|
||||
for i := range ss.Addresses {
|
||||
if len(list) == max {
|
||||
more = true
|
||||
if len(ss.Ports) == 0 {
|
||||
// It's possible to have headless services with no ports.
|
||||
for i := range ss.Addresses {
|
||||
if len(list) == max {
|
||||
more = true
|
||||
}
|
||||
if !more {
|
||||
list = append(list, ss.Addresses[i].IP)
|
||||
}
|
||||
count++
|
||||
}
|
||||
} else {
|
||||
// "Normal" services with ports defined.
|
||||
for i := range ss.Ports {
|
||||
port := &ss.Ports[i]
|
||||
if ports == nil || ports.Has(port.Name) {
|
||||
for i := range ss.Addresses {
|
||||
if len(list) == max {
|
||||
more = true
|
||||
}
|
||||
addr := &ss.Addresses[i]
|
||||
if !more {
|
||||
hostPort := net.JoinHostPort(addr.IP, strconv.Itoa(int(port.Port)))
|
||||
list = append(list, hostPort)
|
||||
}
|
||||
count++
|
||||
}
|
||||
addr := &ss.Addresses[i]
|
||||
if !more {
|
||||
hostPort := net.JoinHostPort(addr.IP, strconv.Itoa(int(port.Port)))
|
||||
list = append(list, hostPort)
|
||||
}
|
||||
count++
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -497,14 +520,24 @@ func formatEndpoints(endpoints *api.Endpoints, ports sets.String) string {
|
||||
return ret
|
||||
}
|
||||
|
||||
// translateTimestamp returns the elapsed time since timestamp in
|
||||
// translateTimestampSince returns the elapsed time since timestamp in
|
||||
// human-readable approximation.
|
||||
func translateTimestamp(timestamp metav1.Time) string {
|
||||
func translateTimestampSince(timestamp metav1.Time) string {
|
||||
if timestamp.IsZero() {
|
||||
return "<unknown>"
|
||||
}
|
||||
|
||||
return duration.ShortHumanDuration(time.Since(timestamp.Time))
|
||||
return duration.HumanDuration(time.Since(timestamp.Time))
|
||||
}
|
||||
|
||||
// translateTimestampUntil returns the elapsed time until timestamp in
|
||||
// human-readable approximation.
|
||||
func translateTimestampUntil(timestamp metav1.Time) string {
|
||||
if timestamp.IsZero() {
|
||||
return "<unknown>"
|
||||
}
|
||||
|
||||
return duration.HumanDuration(time.Until(timestamp.Time))
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -608,10 +641,11 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
|
||||
reason = "Terminating"
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, pod.Name, fmt.Sprintf("%d/%d", readyContainers, totalContainers), reason, int64(restarts), translateTimestamp(pod.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, pod.Name, fmt.Sprintf("%d/%d", readyContainers, totalContainers), reason, int64(restarts), translateTimestampSince(pod.CreationTimestamp))
|
||||
|
||||
if options.Wide {
|
||||
nodeName := pod.Spec.NodeName
|
||||
nominatedNodeName := pod.Status.NominatedNodeName
|
||||
podIP := pod.Status.PodIP
|
||||
if podIP == "" {
|
||||
podIP = "<none>"
|
||||
@@ -619,10 +653,10 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
|
||||
if nodeName == "" {
|
||||
nodeName = "<none>"
|
||||
}
|
||||
row.Cells = append(row.Cells, podIP, nodeName)
|
||||
if len(pod.Status.NominatedNodeName) > 0 {
|
||||
row.Cells = append(row.Cells, pod.Status.NominatedNodeName)
|
||||
if nominatedNodeName == "" {
|
||||
nominatedNodeName = "<none>"
|
||||
}
|
||||
row.Cells = append(row.Cells, podIP, nodeName, nominatedNodeName)
|
||||
}
|
||||
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
@@ -668,7 +702,7 @@ func printPodDisruptionBudget(obj *policy.PodDisruptionBudget, options printers.
|
||||
maxUnavailable = "N/A"
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, minAvailable, maxUnavailable, int64(obj.Status.PodDisruptionsAllowed), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, minAvailable, maxUnavailable, int64(obj.Status.PodDisruptionsAllowed), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -694,7 +728,7 @@ func printReplicationController(obj *api.ReplicationController, options printers
|
||||
currentReplicas := obj.Status.Replicas
|
||||
readyReplicas := obj.Status.ReadyReplicas
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
||||
row.Cells = append(row.Cells, names, images, labels.FormatLabels(obj.Spec.Selector))
|
||||
@@ -723,7 +757,7 @@ func printReplicaSet(obj *extensions.ReplicaSet, options printers.PrintOptions)
|
||||
currentReplicas := obj.Status.Replicas
|
||||
readyReplicas := obj.Status.ReadyReplicas
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
||||
row.Cells = append(row.Cells, names, images, metav1.FormatLabelSelector(obj.Spec.Selector))
|
||||
@@ -750,12 +784,28 @@ func printJob(obj *batch.Job, options printers.PrintOptions) ([]metav1beta1.Tabl
|
||||
|
||||
var completions string
|
||||
if obj.Spec.Completions != nil {
|
||||
completions = strconv.Itoa(int(*obj.Spec.Completions))
|
||||
completions = fmt.Sprintf("%d/%d", obj.Status.Succeeded, *obj.Spec.Completions)
|
||||
} else {
|
||||
completions = "<none>"
|
||||
parallelism := int32(0)
|
||||
if obj.Spec.Parallelism != nil {
|
||||
parallelism = *obj.Spec.Parallelism
|
||||
}
|
||||
if parallelism > 1 {
|
||||
completions = fmt.Sprintf("%d/1 of %d", obj.Status.Succeeded, parallelism)
|
||||
} else {
|
||||
completions = fmt.Sprintf("%d/1", obj.Status.Succeeded)
|
||||
}
|
||||
}
|
||||
var jobDuration string
|
||||
switch {
|
||||
case obj.Status.StartTime == nil:
|
||||
case obj.Status.CompletionTime == nil:
|
||||
jobDuration = duration.HumanDuration(time.Now().Sub(obj.Status.StartTime.Time))
|
||||
default:
|
||||
jobDuration = duration.HumanDuration(obj.Status.CompletionTime.Sub(obj.Status.StartTime.Time))
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, completions, int64(obj.Status.Succeeded), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, completions, jobDuration, translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
||||
row.Cells = append(row.Cells, names, images, metav1.FormatLabelSelector(obj.Spec.Selector))
|
||||
@@ -782,10 +832,10 @@ func printCronJob(obj *batch.CronJob, options printers.PrintOptions) ([]metav1be
|
||||
|
||||
lastScheduleTime := "<none>"
|
||||
if obj.Status.LastScheduleTime != nil {
|
||||
lastScheduleTime = translateTimestamp(*obj.Status.LastScheduleTime)
|
||||
lastScheduleTime = translateTimestampSince(*obj.Status.LastScheduleTime)
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, obj.Spec.Schedule, printBoolPtr(obj.Spec.Suspend), int64(len(obj.Status.Active)), lastScheduleTime, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, obj.Spec.Schedule, printBoolPtr(obj.Spec.Suspend), int64(len(obj.Status.Active)), lastScheduleTime, translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
names, images := layoutContainerCells(obj.Spec.JobTemplate.Spec.Template.Spec.Containers)
|
||||
row.Cells = append(row.Cells, names, images, metav1.FormatLabelSelector(obj.Spec.JobTemplate.Spec.Selector))
|
||||
@@ -884,7 +934,7 @@ func printService(obj *api.Service, options printers.PrintOptions) ([]metav1beta
|
||||
svcPorts = "<none>"
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, string(svcType), internalIP, externalIP, svcPorts, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, string(svcType), internalIP, externalIP, svcPorts, translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
row.Cells = append(row.Cells, labels.FormatLabels(obj.Spec.Selector))
|
||||
}
|
||||
@@ -948,7 +998,7 @@ func printIngress(obj *extensions.Ingress, options printers.PrintOptions) ([]met
|
||||
hosts := formatHosts(obj.Spec.Rules)
|
||||
address := loadBalancerStatusStringer(obj.Status.LoadBalancer, options.Wide)
|
||||
ports := formatPorts(obj.Spec.TLS)
|
||||
createTime := translateTimestamp(obj.CreationTimestamp)
|
||||
createTime := translateTimestampSince(obj.CreationTimestamp)
|
||||
row.Cells = append(row.Cells, obj.Name, hosts, address, ports, createTime)
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
@@ -971,7 +1021,7 @@ func printStatefulSet(obj *apps.StatefulSet, options printers.PrintOptions) ([]m
|
||||
}
|
||||
desiredReplicas := obj.Spec.Replicas
|
||||
currentReplicas := obj.Status.Replicas
|
||||
createTime := translateTimestamp(obj.CreationTimestamp)
|
||||
createTime := translateTimestampSince(obj.CreationTimestamp)
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), createTime)
|
||||
if options.Wide {
|
||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
||||
@@ -1003,7 +1053,7 @@ func printDaemonSet(obj *extensions.DaemonSet, options printers.PrintOptions) ([
|
||||
numberUpdated := obj.Status.UpdatedNumberScheduled
|
||||
numberAvailable := obj.Status.NumberAvailable
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredScheduled), int64(currentScheduled), int64(numberReady), int64(numberUpdated), int64(numberAvailable), labels.FormatLabels(obj.Spec.Template.Spec.NodeSelector), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredScheduled), int64(currentScheduled), int64(numberReady), int64(numberUpdated), int64(numberAvailable), labels.FormatLabels(obj.Spec.Template.Spec.NodeSelector), translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
||||
row.Cells = append(row.Cells, names, images, metav1.FormatLabelSelector(obj.Spec.Selector))
|
||||
@@ -1027,7 +1077,7 @@ func printEndpoints(obj *api.Endpoints, options printers.PrintOptions) ([]metav1
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, formatEndpoints(obj, nil), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, formatEndpoints(obj, nil), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1047,7 +1097,7 @@ func printNamespace(obj *api.Namespace, options printers.PrintOptions) ([]metav1
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, string(obj.Status.Phase), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, string(obj.Status.Phase), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1067,7 +1117,7 @@ func printSecret(obj *api.Secret, options printers.PrintOptions) ([]metav1beta1.
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, string(obj.Type), int64(len(obj.Data)), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, string(obj.Type), int64(len(obj.Data)), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1087,7 +1137,7 @@ func printServiceAccount(obj *api.ServiceAccount, options printers.PrintOptions)
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, int64(len(obj.Secrets)), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(len(obj.Secrets)), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1136,7 +1186,7 @@ func printNode(obj *api.Node, options printers.PrintOptions) ([]metav1beta1.Tabl
|
||||
roles = "<none>"
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, strings.Join(status, ","), roles, translateTimestamp(obj.CreationTimestamp), obj.Status.NodeInfo.KubeletVersion)
|
||||
row.Cells = append(row.Cells, obj.Name, strings.Join(status, ","), roles, translateTimestampSince(obj.CreationTimestamp), obj.Status.NodeInfo.KubeletVersion)
|
||||
if options.Wide {
|
||||
osImage, kernelVersion, crVersion := obj.Status.NodeInfo.OSImage, obj.Status.NodeInfo.KernelVersion, obj.Status.NodeInfo.ContainerRuntimeVersion
|
||||
if osImage == "" {
|
||||
@@ -1234,7 +1284,7 @@ func printPersistentVolume(obj *api.PersistentVolume, options printers.PrintOpti
|
||||
row.Cells = append(row.Cells, obj.Name, aSize, modesStr, reclaimPolicyStr,
|
||||
string(phase), claimRefUID, helper.GetPersistentVolumeClass(obj),
|
||||
obj.Status.Reason,
|
||||
translateTimestamp(obj.CreationTimestamp))
|
||||
translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1269,7 +1319,7 @@ func printPersistentVolumeClaim(obj *api.PersistentVolumeClaim, options printers
|
||||
capacity = storage.String()
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, string(phase), obj.Spec.VolumeName, capacity, accessModes, helper.GetPersistentVolumeClaimClass(obj), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, string(phase), obj.Spec.VolumeName, capacity, accessModes, helper.GetPersistentVolumeClaimClass(obj), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1290,25 +1340,42 @@ func printEvent(obj *api.Event, options printers.PrintOptions) ([]metav1beta1.Ta
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
// While watching event, we should print absolute time.
|
||||
var FirstTimestamp, LastTimestamp string
|
||||
var firstTimestamp, lastTimestamp string
|
||||
if options.AbsoluteTimestamps {
|
||||
FirstTimestamp = obj.FirstTimestamp.String()
|
||||
LastTimestamp = obj.LastTimestamp.String()
|
||||
firstTimestamp = obj.FirstTimestamp.String()
|
||||
lastTimestamp = obj.LastTimestamp.String()
|
||||
} else {
|
||||
FirstTimestamp = translateTimestamp(obj.FirstTimestamp)
|
||||
LastTimestamp = translateTimestamp(obj.LastTimestamp)
|
||||
firstTimestamp = translateTimestampSince(obj.FirstTimestamp)
|
||||
lastTimestamp = translateTimestampSince(obj.LastTimestamp)
|
||||
}
|
||||
if options.Wide {
|
||||
row.Cells = append(row.Cells,
|
||||
lastTimestamp,
|
||||
obj.Type,
|
||||
obj.Reason,
|
||||
obj.InvolvedObject.Kind,
|
||||
formatEventSource(obj.Source),
|
||||
strings.TrimSpace(obj.Message),
|
||||
obj.InvolvedObject.FieldPath,
|
||||
firstTimestamp,
|
||||
int64(obj.Count),
|
||||
obj.Name,
|
||||
)
|
||||
} else {
|
||||
row.Cells = append(row.Cells,
|
||||
lastTimestamp,
|
||||
obj.Type,
|
||||
obj.Reason,
|
||||
obj.InvolvedObject.Kind,
|
||||
strings.TrimSpace(obj.Message),
|
||||
)
|
||||
}
|
||||
row.Cells = append(row.Cells, LastTimestamp, FirstTimestamp,
|
||||
int64(obj.Count), obj.Name, obj.InvolvedObject.Kind,
|
||||
obj.InvolvedObject.FieldPath, obj.Type, obj.Reason,
|
||||
formatEventSource(obj.Source), obj.Message)
|
||||
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
// Sorts and prints the EventList in a human-friendly format.
|
||||
func printEventList(list *api.EventList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
sort.Sort(events.SortableEvents(list.Items))
|
||||
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
||||
for i := range list.Items {
|
||||
r, err := printEvent(&list.Items[i], options)
|
||||
@@ -1325,7 +1392,7 @@ func printRoleBinding(obj *rbac.RoleBinding, options printers.PrintOptions) ([]m
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
roleRef := fmt.Sprintf("%s/%s", obj.RoleRef.Kind, obj.RoleRef.Name)
|
||||
users, groups, sas, _ := rbac.SubjectsStrings(obj.Subjects)
|
||||
@@ -1352,7 +1419,7 @@ func printClusterRoleBinding(obj *rbac.ClusterRoleBinding, options printers.Prin
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, translateTimestampSince(obj.CreationTimestamp))
|
||||
if options.Wide {
|
||||
roleRef := fmt.Sprintf("%s/%s", obj.RoleRef.Kind, obj.RoleRef.Name)
|
||||
users, groups, sas, _ := rbac.SubjectsStrings(obj.Subjects)
|
||||
@@ -1382,7 +1449,7 @@ func printCertificateSigningRequest(obj *certificates.CertificateSigningRequest,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, translateTimestamp(obj.CreationTimestamp), obj.Spec.Username, status)
|
||||
row.Cells = append(row.Cells, obj.Name, translateTimestampSince(obj.CreationTimestamp), obj.Spec.Username, status)
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1475,7 +1542,7 @@ func printDeployment(obj *extensions.Deployment, options printers.PrintOptions)
|
||||
currentReplicas := obj.Status.Replicas
|
||||
updatedReplicas := obj.Status.UpdatedReplicas
|
||||
availableReplicas := obj.Status.AvailableReplicas
|
||||
age := translateTimestamp(obj.CreationTimestamp)
|
||||
age := translateTimestampSince(obj.CreationTimestamp)
|
||||
containers := obj.Spec.Template.Spec.Containers
|
||||
selector, err := metav1.LabelSelectorAsSelector(obj.Spec.Selector)
|
||||
if err != nil {
|
||||
@@ -1513,47 +1580,47 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met
|
||||
for i, spec := range specs {
|
||||
switch spec.Type {
|
||||
case autoscaling.ExternalMetricSourceType:
|
||||
if spec.External.TargetAverageValue != nil {
|
||||
if spec.External.Target.AverageValue != nil {
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].External != nil && statuses[i].External.CurrentAverageValue != nil {
|
||||
current = statuses[i].External.CurrentAverageValue.String()
|
||||
if len(statuses) > i && statuses[i].External != nil && &statuses[i].External.Current.AverageValue != nil {
|
||||
current = statuses[i].External.Current.AverageValue.String()
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s (avg)", current, spec.External.TargetAverageValue.String()))
|
||||
list = append(list, fmt.Sprintf("%s/%s (avg)", current, spec.External.Target.AverageValue.String()))
|
||||
} else {
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].External != nil {
|
||||
current = statuses[i].External.CurrentValue.String()
|
||||
current = statuses[i].External.Current.Value.String()
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.External.TargetValue.String()))
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.External.Target.Value.String()))
|
||||
}
|
||||
case autoscaling.PodsMetricSourceType:
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].Pods != nil {
|
||||
current = statuses[i].Pods.CurrentAverageValue.String()
|
||||
current = statuses[i].Pods.Current.AverageValue.String()
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Pods.TargetAverageValue.String()))
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Pods.Target.AverageValue.String()))
|
||||
case autoscaling.ObjectMetricSourceType:
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].Object != nil {
|
||||
current = statuses[i].Object.CurrentValue.String()
|
||||
current = statuses[i].Object.Current.Value.String()
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Object.TargetValue.String()))
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Object.Target.Value.String()))
|
||||
case autoscaling.ResourceMetricSourceType:
|
||||
if spec.Resource.TargetAverageValue != nil {
|
||||
if spec.Resource.Target.AverageValue != nil {
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].Resource != nil {
|
||||
current = statuses[i].Resource.CurrentAverageValue.String()
|
||||
current = statuses[i].Resource.Current.AverageValue.String()
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Resource.TargetAverageValue.String()))
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Resource.Target.AverageValue.String()))
|
||||
} else {
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].Resource != nil && statuses[i].Resource.CurrentAverageUtilization != nil {
|
||||
current = fmt.Sprintf("%d%%", *statuses[i].Resource.CurrentAverageUtilization)
|
||||
if len(statuses) > i && statuses[i].Resource != nil && statuses[i].Resource.Current.AverageUtilization != nil {
|
||||
current = fmt.Sprintf("%d%%", *statuses[i].Resource.Current.AverageUtilization)
|
||||
}
|
||||
|
||||
target := "<auto>"
|
||||
if spec.Resource.TargetAverageUtilization != nil {
|
||||
target = fmt.Sprintf("%d%%", *spec.Resource.TargetAverageUtilization)
|
||||
if spec.Resource.Target.AverageUtilization != nil {
|
||||
target = fmt.Sprintf("%d%%", *spec.Resource.Target.AverageUtilization)
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, target))
|
||||
}
|
||||
@@ -1591,7 +1658,7 @@ func printHorizontalPodAutoscaler(obj *autoscaling.HorizontalPodAutoscaler, opti
|
||||
}
|
||||
maxPods := obj.Spec.MaxReplicas
|
||||
currentReplicas := obj.Status.CurrentReplicas
|
||||
row.Cells = append(row.Cells, obj.Name, reference, metrics, minPods, int64(maxPods), int64(currentReplicas), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, reference, metrics, minPods, int64(maxPods), int64(currentReplicas), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1611,7 +1678,7 @@ func printConfigMap(obj *api.ConfigMap, options printers.PrintOptions) ([]metav1
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, int64(len(obj.Data)), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(len(obj.Data)), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1664,7 +1731,7 @@ func printNetworkPolicy(obj *networking.NetworkPolicy, options printers.PrintOpt
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, metav1.FormatLabelSelector(&obj.Spec.PodSelector), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, metav1.FormatLabelSelector(&obj.Spec.PodSelector), translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@@ -1690,7 +1757,7 @@ func printStorageClass(obj *storage.StorageClass, options printers.PrintOptions)
|
||||
name += " (default)"
|
||||
}
|
||||
provtype := obj.Provisioner
|
||||
row.Cells = append(row.Cells, name, provtype, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, name, provtype, translateTimestampSince(obj.CreationTimestamp))
|
||||
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
@@ -1707,6 +1774,31 @@ func printStorageClassList(list *storage.StorageClassList, options printers.Prin
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func printLease(obj *coordination.Lease, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
|
||||
var holderIdentity string
|
||||
if obj.Spec.HolderIdentity != nil {
|
||||
holderIdentity = *obj.Spec.HolderIdentity
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, holderIdentity, translateTimestampSince(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
func printLeaseList(list *coordination.LeaseList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
||||
for i := range list.Items {
|
||||
r, err := printLease(&list.Items[i], options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows = append(rows, r...)
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func printStatus(obj *metav1.Status, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
@@ -1776,7 +1868,7 @@ func printControllerRevision(obj *apps.ControllerRevision, options printers.Prin
|
||||
controllerName = printers.FormatResourceName(gvk.GroupKind(), controllerRef.Name, withKind)
|
||||
}
|
||||
revision := obj.Revision
|
||||
age := translateTimestamp(obj.CreationTimestamp)
|
||||
age := translateTimestampSince(obj.CreationTimestamp)
|
||||
row.Cells = append(row.Cells, obj.Name, controllerName, revision, age)
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user