Move formatLabels function to labels package
As the TODO above the function instructed, move formatLables function to labels package.
This commit is contained in:
@@ -155,7 +155,7 @@ func (d *NamespaceDescriber) Describe(namespace, name string) (string, error) {
|
||||
func describeNamespace(namespace *api.Namespace, resourceQuotaList *api.ResourceQuotaList, limitRangeList *api.LimitRangeList) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", namespace.Name)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(namespace.Labels))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(namespace.Labels))
|
||||
fmt.Fprintf(out, "Status:\t%s\n", string(namespace.Status.Phase))
|
||||
if resourceQuotaList != nil {
|
||||
fmt.Fprintf(out, "\n")
|
||||
@@ -416,7 +416,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
|
||||
fmt.Fprintf(out, "Namespace:\t%s\n", pod.Namespace)
|
||||
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&pod.Spec))
|
||||
fmt.Fprintf(out, "Node:\t%s\n", pod.Spec.NodeName+"/"+pod.Status.HostIP)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(pod.Labels))
|
||||
if pod.DeletionTimestamp != nil {
|
||||
fmt.Fprintf(out, "Status:\tTerminating (expires %s)\n", pod.DeletionTimestamp.Time.Format(time.RFC1123Z))
|
||||
fmt.Fprintf(out, "Termination Grace Period:\t%ds\n", pod.DeletionGracePeriodSeconds)
|
||||
@@ -584,7 +584,7 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
|
||||
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", pv.Name)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pv.Labels))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(pv.Labels))
|
||||
fmt.Fprintf(out, "Status:\t%s\n", pv.Status.Phase)
|
||||
if pv.Spec.ClaimRef != nil {
|
||||
fmt.Fprintf(out, "Claim:\t%s\n", pv.Spec.ClaimRef.Namespace+"/"+pv.Spec.ClaimRef.Name)
|
||||
@@ -611,7 +611,7 @@ func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string) (strin
|
||||
return "", err
|
||||
}
|
||||
|
||||
labels := formatLabels(pvc.Labels)
|
||||
labels := labels.FormatLabels(pvc.Labels)
|
||||
storage := pvc.Spec.Resources.Requests[api.ResourceStorage]
|
||||
capacity := ""
|
||||
accessModes := ""
|
||||
@@ -756,8 +756,8 @@ func describeReplicationController(controller *api.ReplicationController, events
|
||||
} else {
|
||||
fmt.Fprintf(out, "Image(s):\t%s\n", "<no template>")
|
||||
}
|
||||
fmt.Fprintf(out, "Selector:\t%s\n", formatLabels(controller.Spec.Selector))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(controller.Labels))
|
||||
fmt.Fprintf(out, "Selector:\t%s\n", labels.FormatLabels(controller.Spec.Selector))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(controller.Labels))
|
||||
fmt.Fprintf(out, "Replicas:\t%d current / %d desired\n", controller.Status.Replicas, controller.Spec.Replicas)
|
||||
fmt.Fprintf(out, "Pods Status:\t%d Running / %d Waiting / %d Succeeded / %d Failed\n", running, waiting, succeeded, failed)
|
||||
if controller.Spec.Template != nil {
|
||||
@@ -790,8 +790,8 @@ func describeSecret(secret *api.Secret) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", secret.Name)
|
||||
fmt.Fprintf(out, "Namespace:\t%s\n", secret.Namespace)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(secret.Labels))
|
||||
fmt.Fprintf(out, "Annotations:\t%s\n", formatLabels(secret.Annotations))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(secret.Labels))
|
||||
fmt.Fprintf(out, "Annotations:\t%s\n", labels.FormatLabels(secret.Annotations))
|
||||
|
||||
fmt.Fprintf(out, "\nType:\t%s\n", secret.Type)
|
||||
|
||||
@@ -851,8 +851,8 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", service.Name)
|
||||
fmt.Fprintf(out, "Namespace:\t%s\n", service.Namespace)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(service.Labels))
|
||||
fmt.Fprintf(out, "Selector:\t%s\n", formatLabels(service.Spec.Selector))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(service.Labels))
|
||||
fmt.Fprintf(out, "Selector:\t%s\n", labels.FormatLabels(service.Spec.Selector))
|
||||
fmt.Fprintf(out, "Type:\t%s\n", service.Spec.Type)
|
||||
fmt.Fprintf(out, "IP:\t%s\n", service.Spec.ClusterIP)
|
||||
if len(service.Status.LoadBalancer.Ingress) > 0 {
|
||||
@@ -914,7 +914,7 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", serviceAccount.Name)
|
||||
fmt.Fprintf(out, "Namespace:\t%s\n", serviceAccount.Namespace)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(serviceAccount.Labels))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(serviceAccount.Labels))
|
||||
fmt.Fprintln(out)
|
||||
|
||||
var (
|
||||
@@ -1000,7 +1000,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
|
||||
func describeNode(node *api.Node, pods []*api.Pod, events *api.EventList) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", node.Name)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(node.Labels))
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(node.Labels))
|
||||
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", node.CreationTimestamp.Time.Format(time.RFC1123Z))
|
||||
if len(node.Status.Conditions) > 0 {
|
||||
fmt.Fprint(out, "Conditions:\n Type\tStatus\tLastHeartbeatTime\tLastTransitionTime\tReason\tMessage\n")
|
||||
|
Reference in New Issue
Block a user