Kubectl explain now also prints the Kind and APIVersion of the resource

This commit is contained in:
Marko Luksa
2017-11-13 15:12:33 +01:00
parent 710523ed7d
commit c77d5d0f90
5 changed files with 50 additions and 14 deletions

View File

@@ -21,6 +21,7 @@ import (
"strings"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kube-openapi/pkg/util/proto"
)
@@ -47,7 +48,7 @@ func SplitAndParseResourceRequest(inResource string, mapper meta.RESTMapper) (st
// PrintModelDescription prints the description of a specific model or dot path.
// If recursive, all components nested within the fields of the schema will be
// printed.
func PrintModelDescription(fieldsPath []string, w io.Writer, schema proto.Schema, recursive bool) error {
func PrintModelDescription(fieldsPath []string, w io.Writer, schema proto.Schema, gvk schema.GroupVersionKind, recursive bool) error {
fieldName := ""
if len(fieldsPath) != 0 {
fieldName = fieldsPath[len(fieldsPath)-1]
@@ -60,5 +61,5 @@ func PrintModelDescription(fieldsPath []string, w io.Writer, schema proto.Schema
}
b := fieldsPrinterBuilder{Recursive: recursive}
f := &Formatter{Writer: w, Wrap: 80}
return PrintModel(fieldName, f, b, schema)
return PrintModel(fieldName, f, b, schema, gvk)
}