mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Make minion printing prettier; standardize on MinionList.Items like the other list types.
This commit is contained in:
parent
c12a3773f5
commit
2cc038298b
@ -186,7 +186,7 @@ type Minion struct {
|
|||||||
// A list of minions.
|
// A list of minions.
|
||||||
type MinionList struct {
|
type MinionList struct {
|
||||||
JSONBase `json:",inline" yaml:",inline"`
|
JSONBase `json:",inline" yaml:",inline"`
|
||||||
Minions []Minion `json:"minions,omitempty" yaml:"minions,omitempty"`
|
Items []Minion `json:"minions,omitempty" yaml:"minions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status is a return value for calls that don't return other objects.
|
// Status is a return value for calls that don't return other objects.
|
||||||
|
@ -64,6 +64,7 @@ type HumanReadablePrinter struct{}
|
|||||||
var podColumns = []string{"Name", "Image(s)", "Host", "Labels"}
|
var podColumns = []string{"Name", "Image(s)", "Host", "Labels"}
|
||||||
var replicationControllerColumns = []string{"Name", "Image(s)", "Selector", "Replicas"}
|
var replicationControllerColumns = []string{"Name", "Image(s)", "Selector", "Replicas"}
|
||||||
var serviceColumns = []string{"Name", "Labels", "Selector", "Port"}
|
var serviceColumns = []string{"Name", "Labels", "Selector", "Port"}
|
||||||
|
var minionColumns = []string{"Minion identifier"}
|
||||||
var statusColumns = []string{"Status"}
|
var statusColumns = []string{"Status"}
|
||||||
|
|
||||||
func (h *HumanReadablePrinter) unknown(data []byte, w io.Writer) error {
|
func (h *HumanReadablePrinter) unknown(data []byte, w io.Writer) error {
|
||||||
@ -135,6 +136,20 @@ func (h *HumanReadablePrinter) printServiceList(list *api.ServiceList, w io.Writ
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *HumanReadablePrinter) printMinion(minion *api.Minion, w io.Writer) error {
|
||||||
|
_, err := fmt.Fprintf(w, "%s\n", minion.ID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *HumanReadablePrinter) printMinionList(list *api.MinionList, w io.Writer) error {
|
||||||
|
for _, minion := range list.Items {
|
||||||
|
if err := h.printMinion(&minion, w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (h *HumanReadablePrinter) printStatus(status *api.Status, w io.Writer) error {
|
func (h *HumanReadablePrinter) printStatus(status *api.Status, w io.Writer) error {
|
||||||
err := h.printHeader(statusColumns, w)
|
err := h.printHeader(statusColumns, w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -187,6 +202,12 @@ func (h *HumanReadablePrinter) Print(data []byte, output io.Writer) error {
|
|||||||
case *api.ServiceList:
|
case *api.ServiceList:
|
||||||
h.printHeader(serviceColumns, w)
|
h.printHeader(serviceColumns, w)
|
||||||
return h.printServiceList(o, w)
|
return h.printServiceList(o, w)
|
||||||
|
case *api.Minion:
|
||||||
|
h.printHeader(minionColumns, w)
|
||||||
|
return h.printMinion(o, w)
|
||||||
|
case *api.MinionList:
|
||||||
|
h.printHeader(minionColumns, w)
|
||||||
|
return h.printMinionList(o, w)
|
||||||
case *api.Status:
|
case *api.Status:
|
||||||
return h.printStatus(o, w)
|
return h.printStatus(o, w)
|
||||||
default:
|
default:
|
||||||
|
@ -121,7 +121,7 @@ func (storage *MinionRegistryStorage) List(selector labels.Selector) (interface{
|
|||||||
}
|
}
|
||||||
var list api.MinionList
|
var list api.MinionList
|
||||||
for _, name := range nameList {
|
for _, name := range nameList {
|
||||||
list.Minions = append(list.Minions, storage.toApiMinion(name))
|
list.Items = append(list.Items, storage.toApiMinion(name))
|
||||||
}
|
}
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ func TestMinionRegistryStorage(t *testing.T) {
|
|||||||
JSONBase: api.JSONBase{ID: "foo"},
|
JSONBase: api.JSONBase{ID: "foo"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(list.(api.MinionList).Minions, expect) {
|
if !reflect.DeepEqual(list.(api.MinionList).Items, expect) {
|
||||||
t.Errorf("Unexpected list value: %#v", list)
|
t.Errorf("Unexpected list value: %#v", list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user