mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Show openapi custom columns in kubectl get
Change the name of the flag to something slightly more user-friendly, while making it default true. The flag is kept so that someone can revert it temporarly if things go wrong.
This commit is contained in:
parent
9778b1a9ba
commit
1d99b763df
@ -197,6 +197,7 @@ go_test(
|
|||||||
],
|
],
|
||||||
data = [
|
data = [
|
||||||
"testdata",
|
"testdata",
|
||||||
|
"//api/openapi-spec:swagger-spec",
|
||||||
"//examples:config",
|
"//examples:config",
|
||||||
"//test/fixtures",
|
"//test/fixtures",
|
||||||
],
|
],
|
||||||
|
@ -32,6 +32,7 @@ go_test(
|
|||||||
name = "go_default_test",
|
name = "go_default_test",
|
||||||
srcs = ["get_test.go"],
|
srcs = ["get_test.go"],
|
||||||
data = [
|
data = [
|
||||||
|
"//api/openapi-spec:swagger-spec",
|
||||||
"//examples:config",
|
"//examples:config",
|
||||||
"//test/fixtures",
|
"//test/fixtures",
|
||||||
],
|
],
|
||||||
@ -45,6 +46,7 @@ go_test(
|
|||||||
"//pkg/kubectl/cmd/testing:go_default_library",
|
"//pkg/kubectl/cmd/testing:go_default_library",
|
||||||
"//pkg/kubectl/cmd/util:go_default_library",
|
"//pkg/kubectl/cmd/util:go_default_library",
|
||||||
"//pkg/kubectl/cmd/util/openapi:go_default_library",
|
"//pkg/kubectl/cmd/util/openapi:go_default_library",
|
||||||
|
"//pkg/kubectl/cmd/util/openapi/testing:go_default_library",
|
||||||
"//pkg/kubectl/scheme:go_default_library",
|
"//pkg/kubectl/scheme:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||||
|
@ -75,7 +75,7 @@ var (
|
|||||||
You can filter the list using a label selector and the --selector flag. If the
|
You can filter the list using a label selector and the --selector flag. If the
|
||||||
desired resource type is namespaced you will only see results in your current
|
desired resource type is namespaced you will only see results in your current
|
||||||
namespace unless you pass --all-namespaces.
|
namespace unless you pass --all-namespaces.
|
||||||
|
|
||||||
This command will hide resources that have completed, such as pods that are
|
This command will hide resources that have completed, such as pods that are
|
||||||
in the Succeeded or Failed phases. You can see the full results for any
|
in the Succeeded or Failed phases. You can see the full results for any
|
||||||
resource by providing the --show-all flag. Uninitialized objects are not
|
resource by providing the --show-all flag. Uninitialized objects are not
|
||||||
@ -114,7 +114,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
useOpenAPIPrintColumnFlagLabel = "experimental-use-openapi-print-columns"
|
useOpenAPIPrintColumnFlagLabel = "use-openapi-print-columns"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCmdGet creates a command object for the generic "get" action, which
|
// NewCmdGet creates a command object for the generic "get" action, which
|
||||||
@ -641,9 +641,7 @@ func (options *GetOptions) printGeneric(printer printers.ResourcePrinter, r *res
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addOpenAPIPrintColumnFlags(cmd *cobra.Command) {
|
func addOpenAPIPrintColumnFlags(cmd *cobra.Command) {
|
||||||
cmd.Flags().Bool(useOpenAPIPrintColumnFlagLabel, false, "If true, use x-kubernetes-print-column metadata (if present) from the OpenAPI schema for displaying a resource.")
|
cmd.Flags().Bool(useOpenAPIPrintColumnFlagLabel, true, "If true, use x-kubernetes-print-column metadata (if present) from the OpenAPI schema for displaying a resource.")
|
||||||
// marking it deprecated so that it is hidden from usage/help text.
|
|
||||||
cmd.Flags().MarkDeprecated(useOpenAPIPrintColumnFlagLabel, "This flag is experimental and may be removed in the future.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldGetNewPrinterForMapping(printer printers.ResourcePrinter, lastMapping, mapping *meta.RESTMapping) bool {
|
func shouldGetNewPrinterForMapping(printer printers.ResourcePrinter, lastMapping, mapping *meta.RESTMapping) bool {
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -49,9 +50,12 @@ import (
|
|||||||
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
|
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
|
||||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||||
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
|
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
|
||||||
|
openapitesting "k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/testing"
|
||||||
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var openapiSchemaPath = filepath.Join("..", "..", "..", "..", "api", "openapi-spec", "swagger.json")
|
||||||
|
|
||||||
// This init should be removed after switching this command and its tests to user external types.
|
// This init should be removed after switching this command and its tests to user external types.
|
||||||
func init() {
|
func init() {
|
||||||
api.AddToScheme(scheme.Scheme)
|
api.AddToScheme(scheme.Scheme)
|
||||||
@ -206,6 +210,7 @@ func TestGetUnknownSchemaObject(t *testing.T) {
|
|||||||
f, tf, _, _ := cmdtesting.NewAPIFactory()
|
f, tf, _, _ := cmdtesting.NewAPIFactory()
|
||||||
_, _, codec, _ := cmdtesting.NewTestFactory()
|
_, _, codec, _ := cmdtesting.NewTestFactory()
|
||||||
tf.Printer = &testPrinter{}
|
tf.Printer = &testPrinter{}
|
||||||
|
tf.OpenAPISchemaFunc = openapitesting.CreateOpenAPISchemaFunc(openapiSchemaPath)
|
||||||
tf.UnstructuredClient = &fake.RESTClient{
|
tf.UnstructuredClient = &fake.RESTClient{
|
||||||
NegotiatedSerializer: unstructuredSerializer,
|
NegotiatedSerializer: unstructuredSerializer,
|
||||||
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, cmdtesting.NewInternalType("", "", "foo"))},
|
Resp: &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, cmdtesting.NewInternalType("", "", "foo"))},
|
||||||
|
Loading…
Reference in New Issue
Block a user