mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
vendor update for CSI 0.3.0
This commit is contained in:
89
vendor/k8s.io/kubernetes/pkg/printers/internalversion/printers.go
generated
vendored
89
vendor/k8s.io/kubernetes/pkg/printers/internalversion/printers.go
generated
vendored
@ -40,6 +40,7 @@ import (
|
||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/duration"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/kubernetes/pkg/api/events"
|
||||
@ -220,6 +221,7 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
{Name: "Roles", Type: "string", Description: "The roles of the node"},
|
||||
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
|
||||
{Name: "Version", Type: "string", Description: apiv1.NodeSystemInfo{}.SwaggerDoc()["kubeletVersion"]},
|
||||
{Name: "Internal-IP", Type: "string", Priority: 1, Description: apiv1.NodeStatus{}.SwaggerDoc()["addresses"]},
|
||||
{Name: "External-IP", Type: "string", Priority: 1, Description: apiv1.NodeStatus{}.SwaggerDoc()["addresses"]},
|
||||
{Name: "OS-Image", Type: "string", Priority: 1, Description: apiv1.NodeSystemInfo{}.SwaggerDoc()["osImage"]},
|
||||
{Name: "Kernel-Version", Type: "string", Priority: 1, Description: apiv1.NodeSystemInfo{}.SwaggerDoc()["kernelVersion"]},
|
||||
@ -286,7 +288,7 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
persistentVolumeClaimColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Status", Type: "string", Description: apiv1.PersistentVolumeClaimStatus{}.SwaggerDoc()["phase"]},
|
||||
{Name: "Volume", Type: "string", Description: apiv1.PersistentVolumeSpec{}.SwaggerDoc()["volumeName"]},
|
||||
{Name: "Volume", Type: "string", Description: apiv1.PersistentVolumeClaimSpec{}.SwaggerDoc()["volumeName"]},
|
||||
{Name: "Capacity", Type: "string", Description: apiv1.PersistentVolumeClaimStatus{}.SwaggerDoc()["capacity"]},
|
||||
{Name: "Access Modes", Type: "string", Description: apiv1.PersistentVolumeClaimStatus{}.SwaggerDoc()["accessModes"]},
|
||||
{Name: "StorageClass", Type: "string", Description: "StorageClass of the pvc"},
|
||||
@ -340,7 +342,7 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
|
||||
podSecurityPolicyColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Data", Type: "string", Description: extensionsv1beta1.PodSecurityPolicySpec{}.SwaggerDoc()["privileged"]},
|
||||
{Name: "Priv", Type: "string", Description: extensionsv1beta1.PodSecurityPolicySpec{}.SwaggerDoc()["privileged"]},
|
||||
{Name: "Caps", Type: "string", Description: extensionsv1beta1.PodSecurityPolicySpec{}.SwaggerDoc()["allowedCapabilities"]},
|
||||
{Name: "SELinux", Type: "string", Description: extensionsv1beta1.PodSecurityPolicySpec{}.SwaggerDoc()["seLinux"]},
|
||||
{Name: "RunAsUser", Type: "string", Description: extensionsv1beta1.PodSecurityPolicySpec{}.SwaggerDoc()["runAsUser"]},
|
||||
@ -501,7 +503,8 @@ func translateTimestamp(timestamp metav1.Time) string {
|
||||
if timestamp.IsZero() {
|
||||
return "<unknown>"
|
||||
}
|
||||
return duration.ShortHumanDuration(time.Now().Sub(timestamp.Time))
|
||||
|
||||
return duration.ShortHumanDuration(time.Since(timestamp.Time))
|
||||
}
|
||||
|
||||
var (
|
||||
@ -572,6 +575,7 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
|
||||
}
|
||||
if !initializing {
|
||||
restarts = 0
|
||||
hasRunning := false
|
||||
for i := len(pod.Status.ContainerStatuses) - 1; i >= 0; i-- {
|
||||
container := pod.Status.ContainerStatuses[i]
|
||||
|
||||
@ -587,9 +591,15 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
|
||||
reason = fmt.Sprintf("ExitCode:%d", container.State.Terminated.ExitCode)
|
||||
}
|
||||
} else if container.Ready && container.State.Running != nil {
|
||||
hasRunning = true
|
||||
readyContainers++
|
||||
}
|
||||
}
|
||||
|
||||
// change pod status back to "Running" if there is at least one container still reporting as "Running" status
|
||||
if reason == "Completed" && hasRunning {
|
||||
reason = "Running"
|
||||
}
|
||||
}
|
||||
|
||||
if pod.DeletionTimestamp != nil && pod.Status.Reason == node.NodeUnreachablePodReason {
|
||||
@ -598,7 +608,7 @@ 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, restarts, translateTimestamp(pod.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, pod.Name, fmt.Sprintf("%d/%d", readyContainers, totalContainers), reason, int64(restarts), translateTimestamp(pod.CreationTimestamp))
|
||||
|
||||
if options.Wide {
|
||||
nodeName := pod.Spec.NodeName
|
||||
@ -658,7 +668,7 @@ func printPodDisruptionBudget(obj *policy.PodDisruptionBudget, options printers.
|
||||
maxUnavailable = "N/A"
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, minAvailable, maxUnavailable, obj.Status.PodDisruptionsAllowed, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, minAvailable, maxUnavailable, int64(obj.Status.PodDisruptionsAllowed), translateTimestamp(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@ -684,7 +694,7 @@ func printReplicationController(obj *api.ReplicationController, options printers
|
||||
currentReplicas := obj.Status.Replicas
|
||||
readyReplicas := obj.Status.ReadyReplicas
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, desiredReplicas, currentReplicas, readyReplicas, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestamp(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))
|
||||
@ -713,7 +723,7 @@ func printReplicaSet(obj *extensions.ReplicaSet, options printers.PrintOptions)
|
||||
currentReplicas := obj.Status.Replicas
|
||||
readyReplicas := obj.Status.ReadyReplicas
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, desiredReplicas, currentReplicas, readyReplicas, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestamp(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))
|
||||
@ -745,7 +755,7 @@ func printJob(obj *batch.Job, options printers.PrintOptions) ([]metav1beta1.Tabl
|
||||
completions = "<none>"
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, completions, obj.Status.Succeeded, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, completions, int64(obj.Status.Succeeded), translateTimestamp(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))
|
||||
@ -775,7 +785,7 @@ func printCronJob(obj *batch.CronJob, options printers.PrintOptions) ([]metav1be
|
||||
lastScheduleTime = translateTimestamp(*obj.Status.LastScheduleTime)
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, obj.Spec.Schedule, printBoolPtr(obj.Spec.Suspend), 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, translateTimestamp(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))
|
||||
@ -962,7 +972,7 @@ func printStatefulSet(obj *apps.StatefulSet, options printers.PrintOptions) ([]m
|
||||
desiredReplicas := obj.Spec.Replicas
|
||||
currentReplicas := obj.Status.Replicas
|
||||
createTime := translateTimestamp(obj.CreationTimestamp)
|
||||
row.Cells = append(row.Cells, obj.Name, desiredReplicas, currentReplicas, createTime)
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), createTime)
|
||||
if options.Wide {
|
||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
||||
row.Cells = append(row.Cells, names, images)
|
||||
@ -993,7 +1003,7 @@ func printDaemonSet(obj *extensions.DaemonSet, options printers.PrintOptions) ([
|
||||
numberUpdated := obj.Status.UpdatedNumberScheduled
|
||||
numberAvailable := obj.Status.NumberAvailable
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, desiredScheduled, currentScheduled, numberReady, numberUpdated, 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), translateTimestamp(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))
|
||||
@ -1057,7 +1067,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, obj.Type, len(obj.Data), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, string(obj.Type), int64(len(obj.Data)), translateTimestamp(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@ -1077,7 +1087,7 @@ func printServiceAccount(obj *api.ServiceAccount, options printers.PrintOptions)
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, len(obj.Secrets), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(len(obj.Secrets)), translateTimestamp(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@ -1138,7 +1148,7 @@ func printNode(obj *api.Node, options printers.PrintOptions) ([]metav1beta1.Tabl
|
||||
if crVersion == "" {
|
||||
crVersion = "<unknown>"
|
||||
}
|
||||
row.Cells = append(row.Cells, getNodeExternalIP(obj), osImage, kernelVersion, crVersion)
|
||||
row.Cells = append(row.Cells, getNodeInternalIP(obj), getNodeExternalIP(obj), osImage, kernelVersion, crVersion)
|
||||
}
|
||||
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
@ -1155,6 +1165,17 @@ func getNodeExternalIP(node *api.Node) string {
|
||||
return "<none>"
|
||||
}
|
||||
|
||||
// Returns the internal IP of the node or "<none>" if none is found.
|
||||
func getNodeInternalIP(node *api.Node) string {
|
||||
for _, address := range node.Status.Addresses {
|
||||
if address.Type == api.NodeInternalIP {
|
||||
return address.Address
|
||||
}
|
||||
}
|
||||
|
||||
return "<none>"
|
||||
}
|
||||
|
||||
// findNodeRoles returns the roles of a given node.
|
||||
// The roles are determined by looking for:
|
||||
// * a node-role.kubernetes.io/<role>="" label
|
||||
@ -1211,7 +1232,7 @@ func printPersistentVolume(obj *api.PersistentVolume, options printers.PrintOpti
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, aSize, modesStr, reclaimPolicyStr,
|
||||
phase, claimRefUID, helper.GetPersistentVolumeClass(obj),
|
||||
string(phase), claimRefUID, helper.GetPersistentVolumeClass(obj),
|
||||
obj.Status.Reason,
|
||||
translateTimestamp(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
@ -1248,7 +1269,7 @@ func printPersistentVolumeClaim(obj *api.PersistentVolumeClaim, options printers
|
||||
capacity = storage.String()
|
||||
}
|
||||
|
||||
row.Cells = append(row.Cells, obj.Name, 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), translateTimestamp(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@ -1278,7 +1299,7 @@ func printEvent(obj *api.Event, options printers.PrintOptions) ([]metav1beta1.Ta
|
||||
LastTimestamp = translateTimestamp(obj.LastTimestamp)
|
||||
}
|
||||
row.Cells = append(row.Cells, LastTimestamp, FirstTimestamp,
|
||||
obj.Count, obj.Name, obj.InvolvedObject.Kind,
|
||||
int64(obj.Count), obj.Name, obj.InvolvedObject.Kind,
|
||||
obj.InvolvedObject.FieldPath, obj.Type, obj.Reason,
|
||||
formatEventSource(obj.Source), obj.Message)
|
||||
|
||||
@ -1461,7 +1482,7 @@ func printDeployment(obj *extensions.Deployment, options printers.PrintOptions)
|
||||
// this shouldn't happen if LabelSelector passed validation
|
||||
return nil, err
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, desiredReplicas, currentReplicas, updatedReplicas, availableReplicas, age)
|
||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(updatedReplicas), int64(availableReplicas), age)
|
||||
if options.Wide {
|
||||
containers, images := layoutContainerCells(containers)
|
||||
row.Cells = append(row.Cells, containers, images, selector.String())
|
||||
@ -1570,7 +1591,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, maxPods, currentReplicas, translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, reference, metrics, minPods, int64(maxPods), int64(currentReplicas), translateTimestamp(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@ -1590,7 +1611,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, len(obj.Data), translateTimestamp(obj.CreationTimestamp))
|
||||
row.Cells = append(row.Cells, obj.Name, int64(len(obj.Data)), translateTimestamp(obj.CreationTimestamp))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
@ -1606,17 +1627,28 @@ func printConfigMapList(list *api.ConfigMapList, options printers.PrintOptions)
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func printPodSecurityPolicy(obj *extensions.PodSecurityPolicy, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
func printPodSecurityPolicy(obj *policy.PodSecurityPolicy, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, obj.Spec.Privileged,
|
||||
obj.Spec.AllowedCapabilities, obj.Spec.SELinux.Rule,
|
||||
obj.Spec.RunAsUser.Rule, obj.Spec.FSGroup.Rule, obj.Spec.SupplementalGroups.Rule, obj.Spec.ReadOnlyRootFilesystem, obj.Spec.Volumes)
|
||||
|
||||
capabilities := make([]string, len(obj.Spec.AllowedCapabilities))
|
||||
for i, c := range obj.Spec.AllowedCapabilities {
|
||||
capabilities[i] = string(c)
|
||||
}
|
||||
volumes := make([]string, len(obj.Spec.Volumes))
|
||||
for i, v := range obj.Spec.Volumes {
|
||||
volumes[i] = string(v)
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, fmt.Sprintf("%v", obj.Spec.Privileged),
|
||||
strings.Join(capabilities, ","), string(obj.Spec.SELinux.Rule),
|
||||
string(obj.Spec.RunAsUser.Rule), string(obj.Spec.FSGroup.Rule),
|
||||
string(obj.Spec.SupplementalGroups.Rule), obj.Spec.ReadOnlyRootFilesystem,
|
||||
strings.Join(volumes, ","))
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
func printPodSecurityPolicyList(list *extensions.PodSecurityPolicyList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
func printPodSecurityPolicyList(list *policy.PodSecurityPolicyList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
||||
for i := range list.Items {
|
||||
r, err := printPodSecurityPolicy(&list.Items[i], options)
|
||||
@ -1736,7 +1768,12 @@ func printControllerRevision(obj *apps.ControllerRevision, options printers.Prin
|
||||
controllerName := "<none>"
|
||||
if controllerRef != nil {
|
||||
withKind := true
|
||||
controllerName = printers.FormatResourceName(controllerRef.Kind, controllerRef.Name, withKind)
|
||||
gv, err := schema.ParseGroupVersion(controllerRef.APIVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gvk := gv.WithKind(controllerRef.Kind)
|
||||
controllerName = printers.FormatResourceName(gvk.GroupKind(), controllerRef.Name, withKind)
|
||||
}
|
||||
revision := obj.Revision
|
||||
age := translateTimestamp(obj.CreationTimestamp)
|
||||
|
Reference in New Issue
Block a user