Add Kubectl support for Daemon
This commit is contained in:

committed by
Mike Danese

parent
a92c8b6886
commit
30f5b93d2f
@@ -384,6 +384,7 @@ var jobColumns = []string{"JOB", "CONTAINER(S)", "IMAGE(S)", "SELECTOR", "SUCCES
|
||||
var serviceColumns = []string{"NAME", "CLUSTER_IP", "EXTERNAL_IP", "PORT(S)", "SELECTOR", "AGE"}
|
||||
var endpointColumns = []string{"NAME", "ENDPOINTS", "AGE"}
|
||||
var nodeColumns = []string{"NAME", "LABELS", "STATUS", "AGE"}
|
||||
var daemonColumns = []string{"CONTROLLER", "CONTAINER(S)", "IMAGE(S)", "SELECTOR", "NODE-SELECTOR"}
|
||||
var eventColumns = []string{"FIRSTSEEN", "LASTSEEN", "COUNT", "NAME", "KIND", "SUBOBJECT", "REASON", "SOURCE", "MESSAGE"}
|
||||
var limitRangeColumns = []string{"NAME", "AGE"}
|
||||
var resourceQuotaColumns = []string{"NAME", "AGE"}
|
||||
@@ -406,6 +407,8 @@ func (h *HumanReadablePrinter) addDefaultHandlers() {
|
||||
h.Handler(podTemplateColumns, printPodTemplateList)
|
||||
h.Handler(replicationControllerColumns, printReplicationController)
|
||||
h.Handler(replicationControllerColumns, printReplicationControllerList)
|
||||
h.Handler(daemonColumns, printDaemon)
|
||||
h.Handler(daemonColumns, printDaemonList)
|
||||
h.Handler(jobColumns, printJob)
|
||||
h.Handler(jobColumns, printJobList)
|
||||
h.Handler(serviceColumns, printService)
|
||||
@@ -810,6 +813,60 @@ func printServiceList(list *api.ServiceList, w io.Writer, withNamespace bool, wi
|
||||
return nil
|
||||
}
|
||||
|
||||
func printDaemon(daemon *expapi.Daemon, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
|
||||
name := daemon.Name
|
||||
namespace := daemon.Namespace
|
||||
|
||||
containers := daemon.Spec.Template.Spec.Containers
|
||||
var firstContainer api.Container
|
||||
if len(containers) > 0 {
|
||||
firstContainer, containers = containers[0], containers[1:]
|
||||
}
|
||||
|
||||
if withNamespace {
|
||||
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
|
||||
name,
|
||||
firstContainer.Name,
|
||||
firstContainer.Image,
|
||||
labels.FormatLabels(daemon.Spec.Selector),
|
||||
labels.FormatLabels(daemon.Spec.Template.Spec.NodeSelector),
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := fmt.Fprint(w, appendLabels(daemon.Labels, columnLabels)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Lay out all the other containers on separate lines.
|
||||
extraLinePrefix := "\t"
|
||||
if withNamespace {
|
||||
extraLinePrefix = "\t\t"
|
||||
}
|
||||
for _, container := range containers {
|
||||
_, err := fmt.Fprintf(w, "%s%s\t%s\t%s\t%s", extraLinePrefix, container.Name, container.Image, "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := fmt.Fprint(w, appendLabelTabs(columnLabels)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func printDaemonList(list *expapi.DaemonList, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
|
||||
for _, daemon := range list.Items {
|
||||
if err := printDaemon(&daemon, w, withNamespace, wide, showAll, columnLabels); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func printEndpoints(endpoints *api.Endpoints, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
|
||||
name := endpoints.Name
|
||||
namespace := endpoints.Namespace
|
||||
|
Reference in New Issue
Block a user