mirror of https://github.com/k3s-io/k3s
remove legacyscheme dep from printFlags
parent
d09cd75ea6
commit
40e52bf07d
|
@ -30,14 +30,15 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
// AnnotateOptions have the data required to perform the annotate operation
|
||||
|
@ -110,7 +111,7 @@ var (
|
|||
|
||||
func NewAnnotateOptions(ioStreams genericclioptions.IOStreams) *AnnotateOptions {
|
||||
return &AnnotateOptions{
|
||||
PrintFlags: printers.NewPrintFlags("annotated"),
|
||||
PrintFlags: printers.NewPrintFlags("annotated", legacyscheme.Scheme),
|
||||
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
|
|
@ -42,6 +42,7 @@ import (
|
|||
"k8s.io/client-go/dynamic"
|
||||
scaleclient "k8s.io/client-go/scale"
|
||||
oapi "k8s.io/kube-openapi/pkg/util/proto"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
|
@ -118,7 +119,7 @@ func NewApplyOptions(ioStreams genericclioptions.IOStreams) *ApplyOptions {
|
|||
return &ApplyOptions{
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
DeleteFlags: NewDeleteFlags("that contains the configuration to apply"),
|
||||
PrintFlags: printers.NewPrintFlags("created"),
|
||||
PrintFlags: printers.NewPrintFlags("created", legacyscheme.Scheme),
|
||||
|
||||
Overwrite: true,
|
||||
OpenApiPatch: true,
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
@ -82,7 +83,7 @@ var (
|
|||
|
||||
func NewSetLastAppliedOptions(ioStreams genericclioptions.IOStreams) *SetLastAppliedOptions {
|
||||
return &SetLastAppliedOptions{
|
||||
PrintFlags: printers.NewPrintFlags("configured"),
|
||||
PrintFlags: printers.NewPrintFlags("configured", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ var (
|
|||
func NewReconcileOptions(ioStreams genericclioptions.IOStreams) *ReconcileOptions {
|
||||
return &ReconcileOptions{
|
||||
FilenameOptions: &resource.FilenameOptions{},
|
||||
PrintFlags: printers.NewPrintFlags("reconciled"),
|
||||
PrintFlags: printers.NewPrintFlags("reconciled", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ type AutoscaleOptions struct {
|
|||
|
||||
func NewAutoscaleOptions(ioStreams genericclioptions.IOStreams) *AutoscaleOptions {
|
||||
return &AutoscaleOptions{
|
||||
PrintFlags: printers.NewPrintFlags("autoscaled"),
|
||||
PrintFlags: printers.NewPrintFlags("autoscaled", legacyscheme.Scheme),
|
||||
FilenameOptions: &resource.FilenameOptions{},
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
|
|
@ -98,7 +98,7 @@ func (o *CertificateOptions) Validate() error {
|
|||
|
||||
func NewCmdCertificateApprove(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
options := CertificateOptions{
|
||||
PrintFlags: printers.NewPrintFlags("approved"),
|
||||
PrintFlags: printers.NewPrintFlags("approved", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
cmd := &cobra.Command{
|
||||
|
@ -155,7 +155,7 @@ func (o *CertificateOptions) RunCertificateApprove(force bool) error {
|
|||
|
||||
func NewCmdCertificateDeny(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
options := CertificateOptions{
|
||||
PrintFlags: printers.NewPrintFlags("denied"),
|
||||
PrintFlags: printers.NewPrintFlags("denied", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
cmd := &cobra.Command{
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
|
@ -56,7 +57,7 @@ type ClusterInfoDumpOptions struct {
|
|||
// NewCmdCreateSecret groups subcommands to create various types of secrets
|
||||
func NewCmdClusterInfoDump(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
o := &ClusterInfoDumpOptions{
|
||||
PrintFlags: printers.NewPrintFlags(""),
|
||||
PrintFlags: printers.NewPrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
|
|
|
@ -29,12 +29,14 @@ go_library(
|
|||
"//build/visible_to:pkg_kubectl_cmd_config_CONSUMERS",
|
||||
],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/kubectl/cmd/templates:go_default_library",
|
||||
"//pkg/kubectl/cmd/util:go_default_library",
|
||||
"//pkg/kubectl/genericclioptions:go_default_library",
|
||||
"//pkg/kubectl/util/i18n:go_default_library",
|
||||
"//pkg/printers:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
|
||||
|
|
|
@ -19,6 +19,7 @@ package config
|
|||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
|
@ -74,14 +75,14 @@ func (f *kubectlConfigPrintFlags) WithDefaultOutput(output string) *kubectlConfi
|
|||
return f
|
||||
}
|
||||
|
||||
func newKubeConfigPrintFlags(operation string) *kubectlConfigPrintFlags {
|
||||
func newKubeConfigPrintFlags(scheme runtime.ObjectConvertor) *kubectlConfigPrintFlags {
|
||||
outputFormat := ""
|
||||
|
||||
return &kubectlConfigPrintFlags{
|
||||
OutputFormat: &outputFormat,
|
||||
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(operation),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", scheme),
|
||||
TemplateFlags: printers.NewKubeTemplatePrintFlags(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"k8s.io/client-go/tools/clientcmd"
|
||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
"k8s.io/client-go/tools/clientcmd/api/latest"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
|
@ -68,7 +69,7 @@ var (
|
|||
|
||||
func NewCmdConfigView(f cmdutil.Factory, streams genericclioptions.IOStreams, ConfigAccess clientcmd.ConfigAccess) *cobra.Command {
|
||||
o := &ViewOptions{
|
||||
PrintFlags: newKubeConfigPrintFlags("").WithDefaultOutput("yaml"),
|
||||
PrintFlags: newKubeConfigPrintFlags(legacyscheme.Scheme).WithDefaultOutput("yaml"),
|
||||
ConfigAccess: ConfigAccess,
|
||||
|
||||
IOStreams: streams,
|
||||
|
|
|
@ -103,7 +103,7 @@ type ConvertOptions struct {
|
|||
|
||||
func NewConvertOptions(ioStreams genericclioptions.IOStreams) *ConvertOptions {
|
||||
return &ConvertOptions{
|
||||
PrintFlags: printers.NewPrintFlags("converted").WithDefaultOutput("yaml"),
|
||||
PrintFlags: printers.NewPrintFlags("converted", scheme.Scheme).WithDefaultOutput("yaml"),
|
||||
local: true,
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
|
|
|
@ -19,14 +19,13 @@ package create
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"net/url"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
|
@ -78,7 +77,7 @@ var (
|
|||
|
||||
func NewCreateOptions(ioStreams genericclioptions.IOStreams) *CreateOptions {
|
||||
return &CreateOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
@ -347,7 +346,7 @@ type CreateSubcommandOptions struct {
|
|||
|
||||
func NewCreateSubcommandOptions(ioStreams genericclioptions.IOStreams) *CreateSubcommandOptions {
|
||||
return &CreateSubcommandOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ func TestCreateDeploymentNoImage(t *testing.T) {
|
|||
cmd.Flags().Set("output", "name")
|
||||
options := &DeploymentOpts{
|
||||
CreateSubcommandOptions: &CreateSubcommandOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
DryRun: true,
|
||||
IOStreams: ioStreams,
|
||||
},
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
clientbatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
|
@ -63,7 +64,7 @@ type CreateJobOptions struct {
|
|||
|
||||
func NewCreateJobOptions(ioStreams genericclioptions.IOStreams) *CreateJobOptions {
|
||||
return &CreateJobOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
fake "k8s.io/client-go/kubernetes/fake"
|
||||
clienttesting "k8s.io/client-go/testing"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
)
|
||||
|
@ -84,7 +85,7 @@ func TestCreateJobFromCronJob(t *testing.T) {
|
|||
f := cmdtesting.NewTestFactory()
|
||||
defer f.Cleanup()
|
||||
|
||||
printFlags := NewPrintFlags("created")
|
||||
printFlags := NewPrintFlags("created", legacyscheme.Scheme)
|
||||
|
||||
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||
cmdOptions := &CreateJobOptions{
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestCreatePdb(t *testing.T) {
|
|||
cmd.Flags().Set("dry-run", "true")
|
||||
cmd.Flags().Set("output", outputFormat)
|
||||
|
||||
printFlags := NewPrintFlags("created")
|
||||
printFlags := NewPrintFlags("created", legacyscheme.Scheme)
|
||||
printFlags.OutputFormat = &outputFormat
|
||||
|
||||
options := &PodDisruptionBudgetOpts{
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestCreatePriorityClass(t *testing.T) {
|
|||
cmd.Flags().Set("dry-run", "true")
|
||||
cmd.Flags().Set("output", outputFormat)
|
||||
|
||||
printFlags := NewPrintFlags("created")
|
||||
printFlags := NewPrintFlags("created", legacyscheme.Scheme)
|
||||
printFlags.OutputFormat = &outputFormat
|
||||
|
||||
options := &PriorityClassOpts{
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
clientgorbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
|
@ -119,7 +120,7 @@ type CreateRoleOptions struct {
|
|||
|
||||
func NewCreateRoleOptions(ioStreams genericclioptions.IOStreams) *CreateRoleOptions {
|
||||
return &CreateRoleOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
|
|
|
@ -376,14 +376,14 @@ func TestComplete(t *testing.T) {
|
|||
"test-missing-name": {
|
||||
params: []string{},
|
||||
roleOptions: &CreateRoleOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
"test-duplicate-verbs": {
|
||||
params: []string{roleName},
|
||||
roleOptions: &CreateRoleOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
Name: roleName,
|
||||
Verbs: []string{
|
||||
"get",
|
||||
|
@ -416,7 +416,7 @@ func TestComplete(t *testing.T) {
|
|||
"test-verball": {
|
||||
params: []string{roleName},
|
||||
roleOptions: &CreateRoleOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
Name: roleName,
|
||||
Verbs: []string{
|
||||
"get",
|
||||
|
@ -445,7 +445,7 @@ func TestComplete(t *testing.T) {
|
|||
"test-duplicate-resourcenames": {
|
||||
params: []string{roleName},
|
||||
roleOptions: &CreateRoleOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
Name: roleName,
|
||||
Verbs: []string{"*"},
|
||||
ResourceNames: []string{"foo", "foo"},
|
||||
|
@ -470,7 +470,7 @@ func TestComplete(t *testing.T) {
|
|||
"test-valid-complete-case": {
|
||||
params: []string{roleName},
|
||||
roleOptions: &CreateRoleOptions{
|
||||
PrintFlags: NewPrintFlags("created"),
|
||||
PrintFlags: NewPrintFlags("created", legacyscheme.Scheme),
|
||||
Name: roleName,
|
||||
Verbs: []string{"*"},
|
||||
ResourceNames: []string{"foo"},
|
||||
|
|
|
@ -19,6 +19,7 @@ package create
|
|||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
|
@ -68,14 +69,14 @@ func (f *PrintFlags) AddFlags(cmd *cobra.Command) {
|
|||
}
|
||||
}
|
||||
|
||||
func NewPrintFlags(operation string) *PrintFlags {
|
||||
func NewPrintFlags(operation string, scheme runtime.ObjectConvertor) *PrintFlags {
|
||||
outputFormat := ""
|
||||
|
||||
return &PrintFlags{
|
||||
OutputFormat: &outputFormat,
|
||||
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(operation),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(operation, scheme),
|
||||
TemplateFlags: printers.NewKubeTemplatePrintFlags(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ var (
|
|||
|
||||
func NewCmdCordon(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
options := &DrainOptions{
|
||||
PrintFlags: printers.NewPrintFlags("cordoned"),
|
||||
PrintFlags: printers.NewPrintFlags("cordoned", legacyscheme.Scheme),
|
||||
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ var (
|
|||
|
||||
func NewCmdUncordon(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
|
||||
options := &DrainOptions{
|
||||
PrintFlags: printers.NewPrintFlags("uncordoned"),
|
||||
PrintFlags: printers.NewPrintFlags("uncordoned", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ var (
|
|||
|
||||
func NewDrainOptions(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *DrainOptions {
|
||||
return &DrainOptions{
|
||||
PrintFlags: printers.NewPrintFlags("drained"),
|
||||
PrintFlags: printers.NewPrintFlags("drained", legacyscheme.Scheme),
|
||||
|
||||
IOStreams: ioStreams,
|
||||
backOff: clockwork.NewRealClock(),
|
||||
|
|
|
@ -834,7 +834,7 @@ func TestDeletePods(t *testing.T) {
|
|||
defer tf.Cleanup()
|
||||
|
||||
o := DrainOptions{
|
||||
PrintFlags: printers.NewPrintFlags("drained"),
|
||||
PrintFlags: printers.NewPrintFlags("drained", legacyscheme.Scheme),
|
||||
}
|
||||
o.Out = os.Stdout
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ type ExposeServiceOptions struct {
|
|||
func NewExposeServiceOptions(ioStreams genericclioptions.IOStreams) *ExposeServiceOptions {
|
||||
return &ExposeServiceOptions{
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
PrintFlags: printers.NewPrintFlags("exposed"),
|
||||
PrintFlags: printers.NewPrintFlags("exposed", legacyscheme.Scheme),
|
||||
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
IOStreams: ioStreams,
|
||||
|
|
|
@ -136,7 +136,7 @@ const (
|
|||
// NewGetOptions returns a GetOptions with default chunk size 500.
|
||||
func NewGetOptions(parent string, streams genericclioptions.IOStreams) *GetOptions {
|
||||
return &GetOptions{
|
||||
PrintFlags: NewGetPrintFlags(),
|
||||
PrintFlags: NewGetPrintFlags(legacyscheme.Scheme),
|
||||
CmdParent: parent,
|
||||
|
||||
IOStreams: streams,
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
|
@ -152,7 +153,7 @@ func (f *PrintFlags) AddFlags(cmd *cobra.Command) {
|
|||
|
||||
// NewGetPrintFlags returns flags associated with humanreadable,
|
||||
// template, and "name" printing, with default values set.
|
||||
func NewGetPrintFlags() *PrintFlags {
|
||||
func NewGetPrintFlags(scheme runtime.ObjectConvertor) *PrintFlags {
|
||||
outputFormat := ""
|
||||
noHeaders := false
|
||||
|
||||
|
@ -160,8 +161,8 @@ func NewGetPrintFlags() *PrintFlags {
|
|||
OutputFormat: &outputFormat,
|
||||
NoHeaders: &noHeaders,
|
||||
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", scheme),
|
||||
TemplateFlags: printers.NewKubeTemplatePrintFlags(),
|
||||
HumanReadableFlags: NewHumanPrintFlags(),
|
||||
CustomColumnsFlags: printers.NewCustomColumnsPrintFlags(),
|
||||
|
|
|
@ -32,6 +32,7 @@ import (
|
|||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructuredscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
|
@ -114,7 +115,7 @@ func NewLabelOptions(ioStreams genericclioptions.IOStreams) *LabelOptions {
|
|||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
||||
PrintFlags: printers.NewPrintFlags("labeled"),
|
||||
PrintFlags: printers.NewPrintFlags("labeled", legacyscheme.Scheme),
|
||||
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
|
@ -98,7 +99,7 @@ func NewPatchOptions(ioStreams genericclioptions.IOStreams) *PatchOptions {
|
|||
return &PatchOptions{
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
PrintFlags: printers.NewPrintFlags("patched"),
|
||||
PrintFlags: printers.NewPrintFlags("patched", legacyscheme.Scheme),
|
||||
IOStreams: ioStreams,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
@ -96,7 +97,7 @@ func NewReplaceOptions(streams genericclioptions.IOStreams) *ReplaceOptions {
|
|||
// we only support "-o name" for this command, so only register the name printer
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
OutputFormat: &outputFormat,
|
||||
NamePrintFlags: printers.NewNamePrintFlags("replaced"),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("replaced", legacyscheme.Scheme),
|
||||
},
|
||||
DeleteFlags: NewDeleteFlags("to use to replace the resource."),
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ type RollingUpdateOptions struct {
|
|||
|
||||
func NewRollingUpdateOptions(streams genericclioptions.IOStreams) *RollingUpdateOptions {
|
||||
return &RollingUpdateOptions{
|
||||
PrintFlags: printers.NewPrintFlags("rolling updated"),
|
||||
PrintFlags: printers.NewPrintFlags("rolling updated", legacyscheme.Scheme),
|
||||
FilenameOptions: &resource.FilenameOptions{},
|
||||
DeploymentKey: "deployment",
|
||||
Timeout: timeout,
|
||||
|
|
|
@ -63,7 +63,7 @@ var (
|
|||
|
||||
func NewCmdRolloutPause(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
|
||||
o := &PauseConfig{
|
||||
PrintFlags: printers.NewPrintFlags("paused"),
|
||||
PrintFlags: printers.NewPrintFlags("paused", legacyscheme.Scheme),
|
||||
IOStreams: streams,
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ var (
|
|||
|
||||
func NewCmdRolloutResume(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
|
||||
o := &ResumeConfig{
|
||||
PrintFlags: printers.NewPrintFlags("resumed"),
|
||||
PrintFlags: printers.NewPrintFlags("resumed", legacyscheme.Scheme),
|
||||
IOStreams: streams,
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ package rollout
|
|||
import (
|
||||
"io"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
|
@ -27,8 +29,6 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// UndoOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
|
||||
|
@ -64,7 +64,7 @@ var (
|
|||
|
||||
func NewCmdRolloutUndo(f cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
o := &UndoOptions{
|
||||
PrintFlags: printers.NewPrintFlags(""),
|
||||
PrintFlags: printers.NewPrintFlags("", legacyscheme.Scheme),
|
||||
}
|
||||
|
||||
validArgs := []string{"deployment", "daemonset", "statefulset"}
|
||||
|
|
|
@ -126,7 +126,7 @@ type RunOptions struct {
|
|||
|
||||
func NewRunOptions(streams genericclioptions.IOStreams) *RunOptions {
|
||||
return &RunOptions{
|
||||
PrintFlags: printers.NewPrintFlags("created"),
|
||||
PrintFlags: printers.NewPrintFlags("created", legacyscheme.Scheme),
|
||||
DeleteFlags: NewDeleteFlags("to use to replace the resource."),
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ func TestRunArgsFollowDashRules(t *testing.T) {
|
|||
cmd.Flags().Set("image", "nginx")
|
||||
cmd.Flags().Set("generator", "run/v1")
|
||||
|
||||
printFlags := printers.NewPrintFlags("created")
|
||||
printFlags := printers.NewPrintFlags("created", legacyscheme.Scheme)
|
||||
printer, err := printFlags.ToPrinter()
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@ -366,7 +366,7 @@ func TestGenerateService(t *testing.T) {
|
|||
}),
|
||||
}
|
||||
|
||||
printFlags := printers.NewPrintFlags("created")
|
||||
printFlags := printers.NewPrintFlags("created", legacyscheme.Scheme)
|
||||
printer, err := printFlags.ToPrinter()
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
batchclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/batch/internalversion"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
|
@ -100,7 +101,7 @@ func NewScaleOptions(ioStreams genericclioptions.IOStreams) *ScaleOptions {
|
|||
// we only support "-o name" for this command, so only register the name printer
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
OutputFormat: &outputFormat,
|
||||
NamePrintFlags: printers.NewNamePrintFlags("scaled"),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("scaled", legacyscheme.Scheme),
|
||||
},
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
CurrentReplicas: -1,
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/types"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
envutil "k8s.io/kubernetes/pkg/kubectl/cmd/util/env"
|
||||
|
@ -126,7 +127,7 @@ type EnvOptions struct {
|
|||
// pod templates are selected by default and allowing environment to be overwritten
|
||||
func NewEnvOptions(streams genericclioptions.IOStreams) *EnvOptions {
|
||||
return &EnvOptions{
|
||||
PrintFlags: printers.NewPrintFlags("env updated"),
|
||||
PrintFlags: printers.NewPrintFlags("env updated", legacyscheme.Scheme),
|
||||
|
||||
ContainerSelector: "*",
|
||||
Overwrite: true,
|
||||
|
|
|
@ -24,8 +24,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||
|
@ -39,11 +37,13 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/rest/fake"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
func TestSetEnvLocal(t *testing.T) {
|
||||
|
@ -66,8 +66,8 @@ func TestSetEnvLocal(t *testing.T) {
|
|||
streams, _, buf, bufErr := genericclioptions.NewTestIOStreams()
|
||||
opts := NewEnvOptions(streams)
|
||||
opts.PrintFlags = &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
OutputFormat: &outputFormat,
|
||||
}
|
||||
opts.FilenameOptions = resource.FilenameOptions{
|
||||
|
@ -109,8 +109,8 @@ func TestSetMultiResourcesEnvLocal(t *testing.T) {
|
|||
streams, _, buf, bufErr := genericclioptions.NewTestIOStreams()
|
||||
opts := NewEnvOptions(streams)
|
||||
opts.PrintFlags = &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
OutputFormat: &outputFormat,
|
||||
}
|
||||
opts.FilenameOptions = resource.FilenameOptions{
|
||||
|
@ -497,8 +497,8 @@ func TestSetEnvRemote(t *testing.T) {
|
|||
streams := genericclioptions.NewTestIOStreamsDiscard()
|
||||
opts := NewEnvOptions(streams)
|
||||
opts.PrintFlags = &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
OutputFormat: &outputFormat,
|
||||
}
|
||||
opts.Local = false
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
|
@ -87,7 +88,7 @@ var (
|
|||
|
||||
func NewImageOptions(streams genericclioptions.IOStreams) *SetImageOptions {
|
||||
return &SetImageOptions{
|
||||
PrintFlags: printers.NewPrintFlags("image updated"),
|
||||
PrintFlags: printers.NewPrintFlags("image updated", legacyscheme.Scheme),
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||
|
@ -73,8 +74,8 @@ func TestImageLocal(t *testing.T) {
|
|||
|
||||
opts := SetImageOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
@ -100,8 +101,8 @@ func TestImageLocal(t *testing.T) {
|
|||
|
||||
func TestSetImageValidation(t *testing.T) {
|
||||
printFlags := &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -196,8 +197,8 @@ func TestSetMultiResourcesImageLocal(t *testing.T) {
|
|||
|
||||
opts := SetImageOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
@ -590,8 +591,8 @@ func TestSetImageRemote(t *testing.T) {
|
|||
cmd.Flags().Set("output", outputFormat)
|
||||
opts := SetImageOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
|
|
@ -94,7 +94,7 @@ type SetResourcesOptions struct {
|
|||
// pod templates are selected by default.
|
||||
func NewResourcesOptions(streams genericclioptions.IOStreams) *SetResourcesOptions {
|
||||
return &SetResourcesOptions{
|
||||
PrintFlags: printers.NewPrintFlags("resource requirements updated"),
|
||||
PrintFlags: printers.NewPrintFlags("resource requirements updated", legacyscheme.Scheme),
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
|
|
@ -72,8 +72,8 @@ func TestResourcesLocal(t *testing.T) {
|
|||
|
||||
opts := SetResourcesOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
@ -127,8 +127,8 @@ func TestSetMultiResourcesLimitsLocal(t *testing.T) {
|
|||
|
||||
opts := SetResourcesOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
@ -508,8 +508,8 @@ func TestSetResourcesRemote(t *testing.T) {
|
|||
cmd.Flags().Set("output", outputFormat)
|
||||
opts := SetResourcesOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
|
|
@ -79,7 +79,7 @@ var (
|
|||
|
||||
func NewSelectorOptions(streams genericclioptions.IOStreams) *SetSelectorOptions {
|
||||
return &SetSelectorOptions{
|
||||
PrintFlags: printers.NewPrintFlags("selector updated"),
|
||||
PrintFlags: printers.NewPrintFlags("selector updated", legacyscheme.Scheme),
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
|
|
@ -79,7 +79,7 @@ type SetServiceAccountOptions struct {
|
|||
|
||||
func NewSetServiceAccountOptions(streams genericclioptions.IOStreams) *SetServiceAccountOptions {
|
||||
return &SetServiceAccountOptions{
|
||||
PrintFlags: printers.NewPrintFlags("serviceaccount updated"),
|
||||
PrintFlags: printers.NewPrintFlags("serviceaccount updated", legacyscheme.Scheme),
|
||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||
|
||||
Recorder: genericclioptions.NoopRecorder{},
|
||||
|
|
|
@ -91,8 +91,8 @@ func TestSetServiceAccountLocal(t *testing.T) {
|
|||
testapi.Default = testapi.Groups[input.apiGroup]
|
||||
saConfig := SetServiceAccountOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
@ -135,8 +135,8 @@ func TestSetServiceAccountMultiLocal(t *testing.T) {
|
|||
cmd.Flags().Set("local", "true")
|
||||
opts := SetServiceAccountOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
@ -379,8 +379,8 @@ func TestSetServiceAccountRemote(t *testing.T) {
|
|||
cmd.Flags().Set("output", outputFormat)
|
||||
saConfig := SetServiceAccountOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
@ -426,8 +426,8 @@ func TestServiceAccountValidation(t *testing.T) {
|
|||
|
||||
saConfig := &SetServiceAccountOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: printers.NewNamePrintFlags(""),
|
||||
JSONYamlPrintFlags: printers.NewJSONYamlPrintFlags(legacyscheme.Scheme),
|
||||
NamePrintFlags: printers.NewNamePrintFlags("", legacyscheme.Scheme),
|
||||
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
|
|
@ -82,7 +82,7 @@ type SubjectOptions struct {
|
|||
|
||||
func NewSubjectOptions(streams genericclioptions.IOStreams) *SubjectOptions {
|
||||
return &SubjectOptions{
|
||||
PrintFlags: printers.NewPrintFlags("subjects updated"),
|
||||
PrintFlags: printers.NewPrintFlags("subjects updated", legacyscheme.Scheme),
|
||||
|
||||
IOStreams: streams,
|
||||
}
|
||||
|
|
|
@ -17,11 +17,10 @@ limitations under the License.
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -87,7 +86,7 @@ var (
|
|||
|
||||
func NewCmdTaint(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
|
||||
options := &TaintOptions{
|
||||
PrintFlags: printers.NewPrintFlags("tainted"),
|
||||
PrintFlags: printers.NewPrintFlags("tainted", legacyscheme.Scheme),
|
||||
IOStreams: streams,
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ go_library(
|
|||
"//build/visible_to:pkg_kubectl_cmd_util_editor_CONSUMERS",
|
||||
],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/kubectl:go_default_library",
|
||||
"//pkg/kubectl/cmd/util:go_default_library",
|
||||
|
|
|
@ -42,6 +42,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
@ -88,7 +89,7 @@ func NewEditOptions(editMode EditMode, ioStreams genericclioptions.IOStreams) *E
|
|||
|
||||
EditMode: editMode,
|
||||
|
||||
PrintFlags: printers.NewPrintFlags("edited"),
|
||||
PrintFlags: printers.NewPrintFlags("edited", legacyscheme.Scheme),
|
||||
|
||||
WindowsLineEndings: goruntime.GOOS == "windows",
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type NoCompatiblePrinterError struct {
|
||||
|
@ -53,6 +55,8 @@ type PrintFlags struct {
|
|||
NamePrintFlags *NamePrintFlags
|
||||
|
||||
OutputFormat *string
|
||||
|
||||
Scheme runtime.ObjectConvertor
|
||||
}
|
||||
|
||||
func (f *PrintFlags) Complete(successTemplate string) error {
|
||||
|
@ -95,13 +99,15 @@ func (f *PrintFlags) WithDefaultOutput(output string) *PrintFlags {
|
|||
return f
|
||||
}
|
||||
|
||||
func NewPrintFlags(operation string) *PrintFlags {
|
||||
func NewPrintFlags(operation string, scheme runtime.ObjectConvertor) *PrintFlags {
|
||||
outputFormat := ""
|
||||
|
||||
return &PrintFlags{
|
||||
OutputFormat: &outputFormat,
|
||||
|
||||
JSONYamlPrintFlags: NewJSONYamlPrintFlags(),
|
||||
NamePrintFlags: NewNamePrintFlags(operation),
|
||||
Scheme: scheme,
|
||||
|
||||
JSONYamlPrintFlags: NewJSONYamlPrintFlags(scheme),
|
||||
NamePrintFlags: NewNamePrintFlags(operation, scheme),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -400,7 +400,7 @@ func TestNamePrinter(t *testing.T) {
|
|||
"pod/foo\npod/bar\n"},
|
||||
}
|
||||
|
||||
printFlags := printers.NewPrintFlags("").WithDefaultOutput("name")
|
||||
printFlags := printers.NewPrintFlags("", legacyscheme.Scheme).WithDefaultOutput("name")
|
||||
printer, err := printFlags.ToPrinter()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected err: %v", err)
|
||||
|
|
|
@ -21,14 +21,16 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
kubectlscheme "k8s.io/kubernetes/pkg/kubectl/scheme"
|
||||
)
|
||||
|
||||
// JSONYamlPrintFlags provides default flags necessary for json/yaml printing.
|
||||
// Given the following flag values, a printer can be requested that knows
|
||||
// how to handle printing based on these values.
|
||||
type JSONYamlPrintFlags struct{}
|
||||
type JSONYamlPrintFlags struct {
|
||||
Scheme runtime.ObjectConvertor
|
||||
}
|
||||
|
||||
// ToPrinter receives an outputFormat and returns a printer capable of
|
||||
// handling --output=(yaml|json) printing.
|
||||
|
@ -48,7 +50,7 @@ func (f *JSONYamlPrintFlags) ToPrinter(outputFormat string) (ResourcePrinter, er
|
|||
}
|
||||
|
||||
// wrap the printer in a versioning printer that understands when to convert and when not to convert
|
||||
return NewVersionedPrinter(printer, legacyscheme.Scheme, legacyscheme.Scheme, kubectlscheme.Scheme.PrioritizedVersionsAllGroups()...), nil
|
||||
return NewVersionedPrinter(printer, f.Scheme, f.Scheme.(runtime.ObjectTyper), kubectlscheme.Scheme.PrioritizedVersionsAllGroups()...), nil
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,6 +60,6 @@ func (f *JSONYamlPrintFlags) AddFlags(c *cobra.Command) {}
|
|||
|
||||
// NewJSONYamlPrintFlags returns flags associated with
|
||||
// yaml or json printing, with default values set.
|
||||
func NewJSONYamlPrintFlags() *JSONYamlPrintFlags {
|
||||
return &JSONYamlPrintFlags{}
|
||||
func NewJSONYamlPrintFlags(scheme runtime.ObjectConvertor) *JSONYamlPrintFlags {
|
||||
return &JSONYamlPrintFlags{Scheme: scheme}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
|
@ -59,7 +60,7 @@ func TestPrinterSupportsExpectedJSONYamlFormats(t *testing.T) {
|
|||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
printFlags := printers.JSONYamlPrintFlags{}
|
||||
printFlags := printers.JSONYamlPrintFlags{Scheme: legacyscheme.Scheme}
|
||||
|
||||
p, err := printFlags.ToPrinter(tc.outputFormat)
|
||||
if tc.expectNoMatch {
|
||||
|
|
|
@ -32,6 +32,8 @@ import (
|
|||
// a resource's fully-qualified Kind.group/name, or a successful
|
||||
// message about that resource if an Operation is provided.
|
||||
type NamePrintFlags struct {
|
||||
Scheme runtime.ObjectConvertor
|
||||
|
||||
// Operation describes the name of the action that
|
||||
// took place on an object, to be included in the
|
||||
// finalized "successful" message.
|
||||
|
@ -73,7 +75,7 @@ func (f *NamePrintFlags) AddFlags(c *cobra.Command) {}
|
|||
|
||||
// NewNamePrintFlags returns flags associated with
|
||||
// --name printing, with default values set.
|
||||
func NewNamePrintFlags(operation string) *NamePrintFlags {
|
||||
func NewNamePrintFlags(operation string, scheme runtime.ObjectConvertor) *NamePrintFlags {
|
||||
return &NamePrintFlags{
|
||||
Operation: operation,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue