mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-04 02:37:36 +00:00
kubectl: API changes to support --subresource in kubectl
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com> Co-authored-by: Nikhita Raghunath <nikitaraghunath@gmail.com> Co-authored-by: Yuvaraj Kakaraparthi <kakaraparthy@vmware.com>
This commit is contained in:
committed by
Madhav Jivrajani
parent
08bf54678e
commit
801c39b478
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
apiserverinternalv1alpha1 "k8s.io/api/apiserverinternal/v1alpha1"
|
||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
||||
@@ -589,6 +590,13 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
}
|
||||
h.TableHandler(storageVersionColumnDefinitions, printStorageVersion)
|
||||
h.TableHandler(storageVersionColumnDefinitions, printStorageVersionList)
|
||||
|
||||
scaleColumnDefinitions := []metav1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Desired", Type: "integer", Description: autoscalingv1.ScaleSpec{}.SwaggerDoc()["replicas"]},
|
||||
{Name: "Available", Type: "integer", Description: autoscalingv1.ScaleStatus{}.SwaggerDoc()["replicas"]},
|
||||
}
|
||||
h.TableHandler(scaleColumnDefinitions, printScale)
|
||||
}
|
||||
|
||||
// Pass ports=nil for all ports.
|
||||
@@ -2622,6 +2630,14 @@ func printPriorityLevelConfigurationList(list *flowcontrol.PriorityLevelConfigur
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func printScale(obj *autoscaling.Scale, options printers.GenerateOptions) ([]metav1.TableRow, error) {
|
||||
row := metav1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, obj.Spec.Replicas, obj.Status.Replicas)
|
||||
return []metav1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
func printBoolPtr(value *bool) string {
|
||||
if value != nil {
|
||||
return printBool(*value)
|
||||
|
Reference in New Issue
Block a user