mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Get printer from factory to retrieve handled resources
This commit is contained in:
@@ -101,6 +101,7 @@ func GetPrinter(format, formatArgument string) (ResourcePrinter, bool, error) {
|
||||
type ResourcePrinter interface {
|
||||
// Print receives a runtime object, formats it and prints it to a writer.
|
||||
PrintObj(runtime.Object, io.Writer) error
|
||||
HandledResources() []string
|
||||
}
|
||||
|
||||
// ResourcePrinterFunc is a function that can print objects
|
||||
@@ -111,6 +112,11 @@ func (fn ResourcePrinterFunc) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
return fn(obj, w)
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
func (fn ResourcePrinterFunc) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// VersionedPrinter takes runtime objects and ensures they are converted to a given API version
|
||||
// prior to being passed to a nested printer.
|
||||
type VersionedPrinter struct {
|
||||
@@ -149,6 +155,11 @@ func (p *VersionedPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
return fmt.Errorf("the object cannot be converted to any of the versions: %v", p.version)
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
func (p *VersionedPrinter) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
|
||||
type NamePrinter struct {
|
||||
}
|
||||
@@ -199,6 +210,11 @@ func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
func (p *NamePrinter) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// JSONPrinter is an implementation of ResourcePrinter which outputs an object as JSON.
|
||||
type JSONPrinter struct {
|
||||
}
|
||||
@@ -216,6 +232,11 @@ func (p *JSONPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
func (p *JSONPrinter) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// YAMLPrinter is an implementation of ResourcePrinter which outputs an object as YAML.
|
||||
// The input object is assumed to be in the internal version of an API and is converted
|
||||
// to the given version first.
|
||||
@@ -234,6 +255,11 @@ func (p *YAMLPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
func (p *YAMLPrinter) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
type handlerEntry struct {
|
||||
columns []string
|
||||
printFunc reflect.Value
|
||||
@@ -1214,6 +1240,11 @@ func (p *TemplatePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
func (p *TemplatePrinter) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// safeExecute tries to execute the template, but catches panics and returns an error
|
||||
// should the template engine panic.
|
||||
func (p *TemplatePrinter) safeExecute(w io.Writer, obj interface{}) error {
|
||||
@@ -1352,3 +1383,8 @@ func (j *JSONPathPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
func (p *JSONPathPrinter) HandledResources() []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user