Migrate genericclioptions.IOStreams usage to genericiooptions

Kubernetes-commit: 00c30941260a27e6929aef84c7fdbc8f1508518c
This commit is contained in:
Arda Güçlü 2023-04-05 14:07:46 +03:00 committed by Kubernetes Publisher
parent 8da1ed5082
commit 3f05cfcd78
150 changed files with 736 additions and 641 deletions

View File

@ -19,14 +19,15 @@ package cmd
import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
)
// NewCmdAlpha creates a command that acts as an alternate root command for features in alpha
func NewCmdAlpha(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdAlpha(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "alpha",
Short: i18n.T("Commands for features in alpha"),

View File

@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -63,11 +64,11 @@ type AnnotateFlags struct {
resourceVersion string
Selector string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewAnnotateFlags returns a default AnnotateFlags
func NewAnnotateFlags(streams genericclioptions.IOStreams) *AnnotateFlags {
func NewAnnotateFlags(streams genericiooptions.IOStreams) *AnnotateFlags {
return &AnnotateFlags{
PrintFlags: genericclioptions.NewPrintFlags("annotate").WithTypeSetter(scheme.Scheme),
RecordFlags: genericclioptions.NewRecordFlags(),
@ -88,7 +89,7 @@ type AnnotateOptions struct {
fieldManager string
resource.FilenameOptions
genericclioptions.IOStreams
genericiooptions.IOStreams
list bool
local bool
@ -143,7 +144,7 @@ var (
)
// NewCmdAnnotate creates the `annotate` command
func NewCmdAnnotate(parent string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdAnnotate(parent string, f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
flags := NewAnnotateFlags(streams)
cmd := &cobra.Command{
@ -166,7 +167,7 @@ func NewCmdAnnotate(parent string, f cmdutil.Factory, streams genericclioptions.
}
// AddFlags registers flags for a cli.
func (flags *AnnotateFlags) AddFlags(cmd *cobra.Command, ioStreams genericclioptions.IOStreams) {
func (flags *AnnotateFlags) AddFlags(cmd *cobra.Command, ioStreams genericiooptions.IOStreams) {
flags.PrintFlags.AddFlags(cmd)
flags.RecordFlags.AddFlags(cmd)

View File

@ -28,7 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -440,7 +440,7 @@ func TestAnnotateErrors(t *testing.T) {
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
iostreams, _, bufOut, bufErr := genericclioptions.NewTestIOStreams()
iostreams, _, bufOut, bufErr := genericiooptions.NewTestIOStreams()
cmd := NewCmdAnnotate("kubectl", tf, iostreams)
cmd.SetOut(bufOut)
cmd.SetErr(bufOut)
@ -498,7 +498,7 @@ func TestAnnotateObject(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
iostreams, _, bufOut, _ := genericclioptions.NewTestIOStreams()
iostreams, _, bufOut, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdAnnotate("kubectl", tf, iostreams)
cmd.SetOut(bufOut)
cmd.SetErr(bufOut)
@ -564,7 +564,7 @@ func TestAnnotateResourceVersion(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
iostreams, _, bufOut, _ := genericclioptions.NewTestIOStreams()
iostreams, _, bufOut, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdAnnotate("kubectl", tf, iostreams)
cmd.SetOut(bufOut)
cmd.SetErr(bufOut)
@ -619,7 +619,7 @@ func TestAnnotateObjectFromFile(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
iostreams, _, bufOut, _ := genericclioptions.NewTestIOStreams()
iostreams, _, bufOut, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdAnnotate("kubectl", tf, iostreams)
cmd.SetOut(bufOut)
cmd.SetErr(bufOut)
@ -651,7 +651,7 @@ func TestAnnotateLocal(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
iostreams, _, _, _ := genericclioptions.NewTestIOStreams()
iostreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdAnnotate("kubectl", tf, iostreams)
flags := NewAnnotateFlags(iostreams)
flags.Local = true
@ -707,7 +707,7 @@ func TestAnnotateMultipleObjects(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
iostreams, _, _, _ := genericclioptions.NewTestIOStreams()
iostreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdAnnotate("kubectl", tf, iostreams)
cmd.SetOut(iostreams.Out)
cmd.SetErr(iostreams.Out)

View File

@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/discovery"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -74,7 +75,7 @@ type APIResourceOptions struct {
discoveryClient discovery.CachedDiscoveryInterface
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// groupResource contains the APIGroup and APIResource
@ -85,7 +86,7 @@ type groupResource struct {
}
// NewAPIResourceOptions creates the options for APIResource
func NewAPIResourceOptions(ioStreams genericclioptions.IOStreams) *APIResourceOptions {
func NewAPIResourceOptions(ioStreams genericiooptions.IOStreams) *APIResourceOptions {
return &APIResourceOptions{
IOStreams: ioStreams,
Namespaced: true,
@ -93,7 +94,7 @@ func NewAPIResourceOptions(ioStreams genericclioptions.IOStreams) *APIResourceOp
}
// NewCmdAPIResources creates the `api-resources` command
func NewCmdAPIResources(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdAPIResources(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewAPIResourceOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -22,17 +22,17 @@ import (
"github.com/spf13/cobra"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
)
func TestAPIResourcesComplete(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
cmd := NewCmdAPIResources(tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdAPIResources(tf, genericiooptions.NewTestIOStreamsDiscard())
parentCmd := &cobra.Command{Use: "kubectl"}
parentCmd.AddCommand(cmd)
o := NewAPIResourceOptions(genericclioptions.NewTestIOStreamsDiscard())
o := NewAPIResourceOptions(genericiooptions.NewTestIOStreamsDiscard())
err := o.Complete(tf, cmd, []string{})
if err != nil {
@ -79,7 +79,7 @@ func TestAPIResourcesValidate(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(tt *testing.T) {
o := NewAPIResourceOptions(genericclioptions.NewTestIOStreamsDiscard())
o := NewAPIResourceOptions(genericiooptions.NewTestIOStreamsDiscard())
tc.optionSetupFn(o)
err := o.Validate()
if tc.expectedError == "" {
@ -305,7 +305,7 @@ bazzes b somegroup/v1 true Baz
for _, tc := range testCases {
t.Run(tc.name, func(tt *testing.T) {
dc.Invalidations = 0
ioStreams, _, out, errOut := genericclioptions.NewTestIOStreams()
ioStreams, _, out, errOut := genericiooptions.NewTestIOStreams()
cmd := NewCmdAPIResources(tf, ioStreams)
tc.commandSetupFn(cmd)
cmd.Run(cmd, []string{})

View File

@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/discovery"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
@ -40,18 +41,18 @@ var (
type APIVersionsOptions struct {
discoveryClient discovery.CachedDiscoveryInterface
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewAPIVersionsOptions creates the options for APIVersions
func NewAPIVersionsOptions(ioStreams genericclioptions.IOStreams) *APIVersionsOptions {
func NewAPIVersionsOptions(ioStreams genericiooptions.IOStreams) *APIVersionsOptions {
return &APIVersionsOptions{
IOStreams: ioStreams,
}
}
// NewCmdAPIVersions creates the `api-versions` command
func NewCmdAPIVersions(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdAPIVersions(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewAPIVersionsOptions(ioStreams)
cmd := &cobra.Command{
Use: "api-versions",

View File

@ -17,21 +17,22 @@ limitations under the License.
package apiresources
import (
"github.com/spf13/cobra"
"testing"
"github.com/spf13/cobra"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
)
func TestAPIVersionsComplete(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
cmd := NewCmdAPIVersions(tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdAPIVersions(tf, genericiooptions.NewTestIOStreamsDiscard())
parentCmd := &cobra.Command{Use: "kubectl"}
parentCmd.AddCommand(cmd)
o := NewAPIVersionsOptions(genericclioptions.NewTestIOStreamsDiscard())
o := NewAPIVersionsOptions(genericiooptions.NewTestIOStreamsDiscard())
err := o.Complete(tf, cmd, []string{})
if err != nil {
@ -76,7 +77,7 @@ func TestAPIVersionsRun(t *testing.T) {
tf := cmdtesting.NewTestFactory().WithDiscoveryClient(dc)
defer tf.Cleanup()
ioStreams, _, out, errOut := genericclioptions.NewTestIOStreams()
ioStreams, _, out, errOut := genericiooptions.NewTestIOStreams()
cmd := NewCmdAPIVersions(tf, ioStreams)
cmd.Run(cmd, []string{})

View File

@ -35,6 +35,7 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/dynamic"
@ -75,7 +76,7 @@ type ApplyFlags struct {
PruneWhitelist []string // TODO: Remove this in kubectl 1.28 or later
PruneAllowlist []string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// ApplyOptions defines flags and other configuration parameters for the `apply` command
@ -109,7 +110,7 @@ type ApplyOptions struct {
Namespace string
EnforceNamespace bool
genericclioptions.IOStreams
genericiooptions.IOStreams
// Objects (and some denormalized data) which are to be
// applied. The standard way to fill in this structure
@ -179,7 +180,7 @@ var (
var ApplySetToolVersion = version.Get().GitVersion
// NewApplyFlags returns a default ApplyFlags
func NewApplyFlags(streams genericclioptions.IOStreams) *ApplyFlags {
func NewApplyFlags(streams genericiooptions.IOStreams) *ApplyFlags {
return &ApplyFlags{
RecordFlags: genericclioptions.NewRecordFlags(),
DeleteFlags: delete.NewDeleteFlags("The files that contain the configurations to apply."),
@ -193,7 +194,7 @@ func NewApplyFlags(streams genericclioptions.IOStreams) *ApplyFlags {
}
// NewCmdApply creates the `apply` command
func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
flags := NewApplyFlags(ioStreams)
cmd := &cobra.Command{

View File

@ -19,7 +19,7 @@ package apply
import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/cmd/util/editor"
"k8s.io/kubectl/pkg/util/completion"
@ -58,7 +58,7 @@ var (
)
// NewCmdApplyEditLastApplied created the cobra CLI command for the `apply edit-last-applied` command.
func NewCmdApplyEditLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdApplyEditLastApplied(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := editor.NewEditOptions(editor.ApplyEditMode, ioStreams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -56,7 +57,7 @@ type SetLastAppliedOptions struct {
builder *resource.Builder
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// PatchBuffer caches changes that are to be applied.
@ -84,7 +85,7 @@ var (
)
// NewSetLastAppliedOptions takes option arguments from a CLI stream and returns it at SetLastAppliedOptions type.
func NewSetLastAppliedOptions(ioStreams genericclioptions.IOStreams) *SetLastAppliedOptions {
func NewSetLastAppliedOptions(ioStreams genericiooptions.IOStreams) *SetLastAppliedOptions {
return &SetLastAppliedOptions{
PrintFlags: genericclioptions.NewPrintFlags("configured").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -92,7 +93,7 @@ func NewSetLastAppliedOptions(ioStreams genericclioptions.IOStreams) *SetLastApp
}
// NewCmdApplySetLastApplied creates the cobra CLI `apply` subcommand `set-last-applied`.`
func NewCmdApplySetLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdApplySetLastApplied(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewSetLastAppliedOptions(ioStreams)
cmd := &cobra.Command{
Use: "set-last-applied -f FILENAME",

View File

@ -44,6 +44,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
sptest "k8s.io/apimachinery/pkg/util/strategicpatch/testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
dynamicfakeclient "k8s.io/client-go/dynamic/fake"
restclient "k8s.io/client-go/rest"
@ -90,7 +91,7 @@ func TestApplyExtraArgsFail(t *testing.T) {
defer f.Cleanup()
cmd := &cobra.Command{}
flags := NewApplyFlags(genericclioptions.NewTestIOStreamsDiscard())
flags := NewApplyFlags(genericiooptions.NewTestIOStreamsDiscard())
flags.AddFlags(cmd)
_, err := flags.ToOptions(f, cmd, "kubectl", []string{"rc"})
require.EqualError(t, err, "Unexpected args: [rc]\nSee ' -h' for help and examples")
@ -105,13 +106,13 @@ func TestAlphaEnablement(t *testing.T) {
defer f.Cleanup()
cmd := &cobra.Command{}
flags := NewApplyFlags(genericclioptions.NewTestIOStreamsDiscard())
flags := NewApplyFlags(genericiooptions.NewTestIOStreamsDiscard())
flags.AddFlags(cmd)
require.Nil(t, cmd.Flags().Lookup(flag), "flag %q should not be registered without the %q feature enabled", flag, feature)
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{feature}, t, func(t *testing.T) {
cmd := &cobra.Command{}
flags := NewApplyFlags(genericclioptions.NewTestIOStreamsDiscard())
flags := NewApplyFlags(genericiooptions.NewTestIOStreamsDiscard())
flags.AddFlags(cmd)
require.NotNil(t, cmd.Flags().Lookup(flag), "flag %q should be registered with the %q feature enabled", flag, feature)
})
@ -239,7 +240,7 @@ func TestApplyFlagValidation(t *testing.T) {
f.UnstructuredClient = f.Client
cmdtesting.WithAlphaEnvs(test.enableAlphas, t, func(t *testing.T) {
cmd := &cobra.Command{}
flags := NewApplyFlags(genericclioptions.NewTestIOStreamsDiscard())
flags := NewApplyFlags(genericiooptions.NewTestIOStreamsDiscard())
flags.AddFlags(cmd)
cmd.Flags().Set("filename", "unused")
for _, arg := range test.args {
@ -498,7 +499,7 @@ func TestRunApplyPrintsValidObjectList(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameCM)
cmd.Flags().Set("output", "json")
@ -638,7 +639,7 @@ func TestRunApplyViewLastApplied(t *testing.T) {
}
})
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApplyViewLastApplied(tf, ioStreams)
if test.filePath != "" {
cmd.Flags().Set("filename", test.filePath)
@ -684,7 +685,7 @@ func TestApplyObjectWithoutAnnotation(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "name")
@ -731,7 +732,7 @@ func TestApplyObject(t *testing.T) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "name")
@ -779,7 +780,7 @@ func TestApplyPruneObjects(t *testing.T) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("prune", "true")
@ -1021,7 +1022,7 @@ func TestApplyPruneObjectsWithAllowlist(t *testing.T) {
}
}
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("prune", "true")
@ -1193,7 +1194,7 @@ func TestApplyCSAMigration(t *testing.T) {
tf.OpenAPISchemaFunc = FakeOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "yaml")
@ -1222,7 +1223,7 @@ func TestApplyCSAMigration(t *testing.T) {
// Apply the upgraded object.
// Expect only a single PATCH call to apiserver
ioStreams, _, _, errBuf = genericclioptions.NewTestIOStreams()
ioStreams, _, _, errBuf = genericiooptions.NewTestIOStreams()
cmd = NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "yaml")
@ -1281,7 +1282,7 @@ func TestApplyObjectOutput(t *testing.T) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "yaml")
@ -1342,7 +1343,7 @@ func TestApplyRetry(t *testing.T) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "name")
@ -1391,7 +1392,7 @@ func TestApplyNonExistObject(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "name")
@ -1444,7 +1445,7 @@ func TestApplyEmptyPatch(t *testing.T) {
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
// 1. apply non exist object
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "name")
@ -1459,7 +1460,7 @@ func TestApplyEmptyPatch(t *testing.T) {
}
// 2. test apply already exist object, will not send empty patch request
ioStreams, _, buf, _ = genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ = genericiooptions.NewTestIOStreams()
cmd = NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "name")
@ -1517,7 +1518,7 @@ func testApplyMultipleObjects(t *testing.T, asList bool) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
if asList {
cmd.Flags().Set("filename", filenameRCSVC)
@ -1612,7 +1613,7 @@ func TestApplyNULLPreservation(t *testing.T) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameDeployObjClientside)
cmd.Flags().Set("output", "name")
@ -1674,7 +1675,7 @@ func TestUnstructuredApply(t *testing.T) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameWidgetClientside)
cmd.Flags().Set("output", "name")
@ -1738,7 +1739,7 @@ func TestUnstructuredIdempotentApply(t *testing.T) {
tf.OpenAPISchemaFunc = testingOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameWidgetClientside)
cmd.Flags().Set("output", "name")
@ -1843,7 +1844,7 @@ func TestRunApplySetLastApplied(t *testing.T) {
}
})
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApplySetLastApplied(tf, ioStreams)
cmd.Flags().Set("filename", test.filePath)
cmd.Flags().Set("output", test.output)
@ -1981,7 +1982,7 @@ func TestForceApply(t *testing.T) {
tf.Client = tf.UnstructuredClient
tf.ClientConfigVal = &restclient.Config{}
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("output", "name")
@ -2022,7 +2023,7 @@ func TestDontAllowForceApplyWithServerDryRun(t *testing.T) {
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("dry-run", "server")
@ -2050,7 +2051,7 @@ func TestDontAllowForceApplyWithServerSide(t *testing.T) {
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("server-side", "true")
@ -2072,7 +2073,7 @@ func TestDontAllowApplyWithPodGeneratedName(t *testing.T) {
defer tf.Cleanup()
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenamePodGeneratedName)
cmd.Flags().Set("dry-run", "client")
@ -2165,7 +2166,7 @@ func TestApplySetParentValidation(t *testing.T) {
t.Run(name, func(t *testing.T) {
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.ApplySet}, t, func(t *testing.T) {
cmd := &cobra.Command{}
flags := NewApplyFlags(genericclioptions.NewTestIOStreamsDiscard())
flags := NewApplyFlags(genericiooptions.NewTestIOStreamsDiscard())
flags.AddFlags(cmd)
cmd.Flags().Set("filename", filenameRC)
cmd.Flags().Set("applyset", test.applysetFlag)
@ -2311,7 +2312,7 @@ func TestLoadObjects(t *testing.T) {
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.ApplySet}, t, func(t *testing.T) {
cmd := &cobra.Command{}
flags := NewApplyFlags(genericclioptions.NewTestIOStreamsDiscard())
flags := NewApplyFlags(genericiooptions.NewTestIOStreamsDiscard())
flags.AddFlags(cmd)
cmd.Flags().Set("filename", testFile+".yaml")
cmd.Flags().Set("applyset", filepath.Base(filepath.Dir(testFile)))
@ -2381,7 +2382,7 @@ func TestApplySetParentManagement(t *testing.T) {
// Initially, the rc 'exists' server side but the svc and applyset secret do not
// This should 'update' the rc and create the secret
ioStreams, _, outbuff, errbuff := genericclioptions.NewTestIOStreams()
ioStreams, _, outbuff, errbuff := genericiooptions.NewTestIOStreams()
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.ApplySet}, t, func(t *testing.T) {
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameRC)
@ -2609,7 +2610,7 @@ func TestApplySetInvalidLiveParent(t *testing.T) {
setUpClientsForApplySetWithSSA(t, tf, secret)
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.ApplySet}, t, func(t *testing.T) {
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdApply("kubectl", tf, ioStreams)
cmd.Flags().Set("filename", filenameSVC)
cmd.Flags().Set("server-side", "true")
@ -2630,7 +2631,7 @@ func TestApplySet_ClusterScopedCustomResourceParent(t *testing.T) {
cr := readUnstructuredFromFile(t, filenameApplySetCR)
setUpClientsForApplySetWithSSA(t, tf, replicationController, crd)
ioStreams, _, outbuff, errbuff := genericclioptions.NewTestIOStreams()
ioStreams, _, outbuff, errbuff := genericiooptions.NewTestIOStreams()
cmdutil.BehaviorOnFatal(func(s string, i int) {
require.Equal(t, "error: custom resource ApplySet parents cannot be created automatically", s)
})
@ -2836,7 +2837,7 @@ func TestApplyWithPruneV2(t *testing.T) {
t.Logf("applying manifest %v", manifest)
cmd := &cobra.Command{}
flags := NewApplyFlags(genericclioptions.NewTestIOStreamsDiscard())
flags := NewApplyFlags(genericiooptions.NewTestIOStreamsDiscard())
flags.AddFlags(cmd)
cmd.Flags().Set("filename", filepath.Join(testdir, manifest+".yaml"))
cmd.Flags().Set("applyset", filepath.Base(testdir))
@ -2929,7 +2930,7 @@ metadata:
}
tf.UnstructuredClient = tf.Client
ioStreams, _, outbuff, errbuff := genericclioptions.NewTestIOStreams()
ioStreams, _, outbuff, errbuff := genericiooptions.NewTestIOStreams()
cmdutil.BehaviorOnFatal(fatalNoExit(t, ioStreams))
defer cmdutil.DefaultBehaviorOnFatal()
@ -3117,7 +3118,7 @@ func TestApplyWithPruneV2Fail(t *testing.T) {
t.Logf("applying manifest %v", manifest)
var unifiedOutput bytes.Buffer
ioStreams := genericclioptions.IOStreams{
ioStreams := genericiooptions.IOStreams{
ErrOut: &unifiedOutput,
Out: &unifiedOutput,
In: bytes.NewBufferString(""),
@ -3165,7 +3166,7 @@ func TestApplyWithPruneV2Fail(t *testing.T) {
// fatalNoExit is a handler that replaces the default cmdutil.BehaviorOnFatal,
// that still prints as expected, but does not call os.Exit (which terminates our tests)
func fatalNoExit(t *testing.T, ioStreams genericclioptions.IOStreams) func(msg string, code int) {
func fatalNoExit(t *testing.T, ioStreams genericiooptions.IOStreams) func(msg string, code int) {
return func(msg string, code int) {
if len(msg) > 0 {
// add newline if needed
@ -3216,7 +3217,7 @@ func TestApplySetDryRun(t *testing.T) {
}
t.Run("server side dry run", func(t *testing.T) {
ioStreams, _, outbuff, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, outbuff, _ := genericiooptions.NewTestIOStreams()
tf.Client = fakeDryRunClient(t, true)
tf.UnstructuredClient = tf.Client
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.ApplySet}, t, func(t *testing.T) {
@ -3234,7 +3235,7 @@ func TestApplySetDryRun(t *testing.T) {
})
t.Run("client side dry run", func(t *testing.T) {
ioStreams, _, outbuff, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, outbuff, _ := genericiooptions.NewTestIOStreams()
tf.Client = fakeDryRunClient(t, false)
tf.UnstructuredClient = tf.Client
cmdtesting.WithAlphaEnvs([]cmdutil.FeatureGate{cmdutil.ApplySet}, t, func(t *testing.T) {

View File

@ -22,7 +22,7 @@ import (
"fmt"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util"
@ -41,7 +41,7 @@ type ViewLastAppliedOptions struct {
All bool
Factory cmdutil.Factory
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -60,7 +60,7 @@ var (
)
// NewViewLastAppliedOptions takes option arguments from a CLI stream and returns it at ViewLastAppliedOptions type.
func NewViewLastAppliedOptions(ioStreams genericclioptions.IOStreams) *ViewLastAppliedOptions {
func NewViewLastAppliedOptions(ioStreams genericiooptions.IOStreams) *ViewLastAppliedOptions {
return &ViewLastAppliedOptions{
OutputFormat: "yaml",
@ -69,7 +69,7 @@ func NewViewLastAppliedOptions(ioStreams genericclioptions.IOStreams) *ViewLastA
}
// NewCmdApplyViewLastApplied creates the cobra CLI `apply` subcommand `view-last-applied`.`
func NewCmdApplyViewLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdApplyViewLastApplied(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
options := NewViewLastAppliedOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/dynamic"
"k8s.io/klog/v2"
@ -40,7 +40,7 @@ type ApplySetDeleteOptions struct {
Printer printers.ResourcePrinter
IOStreams genericclioptions.IOStreams
IOStreams genericiooptions.IOStreams
}
// PruneObject is an apiserver object that should be deleted as part of prune.

View File

@ -29,6 +29,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/remotecommand"
@ -88,7 +89,7 @@ type AttachOptions struct {
}
// NewAttachOptions creates the options for attach
func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
func NewAttachOptions(streams genericiooptions.IOStreams) *AttachOptions {
return &AttachOptions{
StreamOptions: exec.StreamOptions{
IOStreams: streams,
@ -99,7 +100,7 @@ func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
}
// NewCmdAttach returns the attach Cobra command
func NewCmdAttach(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdAttach(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := NewAttachOptions(streams)
cmd := &cobra.Command{
Use: "attach (POD | TYPE/NAME) -c CONTAINER",

View File

@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
"k8s.io/client-go/tools/remotecommand"
@ -308,7 +309,7 @@ func TestAttach(t *testing.T) {
options := &AttachOptions{
StreamOptions: exec.StreamOptions{
ContainerName: test.container,
IOStreams: genericclioptions.NewTestIOStreamsDiscard(),
IOStreams: genericiooptions.NewTestIOStreamsDiscard(),
},
Attach: remoteAttach,
GetPodTimeout: 1000,
@ -379,7 +380,7 @@ func TestAttachWarnings(t *testing.T) {
tf := cmdtesting.NewTestFactory().WithNamespace("test")
defer tf.Cleanup()
streams, _, _, bufErr := genericclioptions.NewTestIOStreams()
streams, _, _, bufErr := genericiooptions.NewTestIOStreams()
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
ns := scheme.Codecs.WithoutConversion()

View File

@ -18,13 +18,13 @@ package auth
import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)
// NewCmdAuth returns an initialized Command instance for 'auth' sub command
func NewCmdAuth(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdAuth(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
// Parent command to which all subcommands are added.
cmds := &cobra.Command{
Use: "auth",

View File

@ -34,7 +34,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
discovery "k8s.io/client-go/discovery"
authorizationv1client "k8s.io/client-go/kubernetes/typed/authorization/v1"
@ -62,7 +62,7 @@ type CanIOptions struct {
ResourceName string
List bool
genericclioptions.IOStreams
genericiooptions.IOStreams
WarningPrinter *printers.WarningPrinter
}
@ -110,7 +110,7 @@ var (
)
// NewCmdCanI returns an initialized Command for 'auth can-i' sub command
func NewCmdCanI(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCanI(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := &CanIOptions{
IOStreams: streams,
}

View File

@ -27,7 +27,7 @@ import (
authorizationv1 "k8s.io/api/authorization/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
@ -215,7 +215,7 @@ func TestRunAccessList(t *testing.T) {
}
}),
}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
options.IOStreams = ioStreams
if err := options.Complete(tf, []string{}); err != nil {
t.Errorf("got unexpected error when do Complete(): %v", err)
@ -291,7 +291,7 @@ func TestRunResourceFor(t *testing.T) {
tf := cmdtesting.NewTestFactory().WithNamespace("test")
defer tf.Cleanup()
ioStreams, _, _, buf := genericclioptions.NewTestIOStreams()
ioStreams, _, _, buf := genericiooptions.NewTestIOStreams()
test.o.IOStreams = ioStreams
test.o.WarningPrinter = printers.NewWarningPrinter(test.o.IOStreams.ErrOut, printers.WarningPrinterOptions{Color: false})

View File

@ -28,6 +28,7 @@ import (
rbacv1alpha1 "k8s.io/api/rbac/v1alpha1"
rbacv1beta1 "k8s.io/api/rbac/v1beta1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
@ -53,7 +54,7 @@ type ReconcileOptions struct {
PrintObject printers.ResourcePrinterFunc
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -76,7 +77,7 @@ var (
)
// NewReconcileOptions returns a new ReconcileOptions instance
func NewReconcileOptions(ioStreams genericclioptions.IOStreams) *ReconcileOptions {
func NewReconcileOptions(ioStreams genericiooptions.IOStreams) *ReconcileOptions {
return &ReconcileOptions{
FilenameOptions: &resource.FilenameOptions{},
PrintFlags: genericclioptions.NewPrintFlags("reconciled").WithTypeSetter(scheme.Scheme),
@ -85,7 +86,7 @@ func NewReconcileOptions(ioStreams genericclioptions.IOStreams) *ReconcileOption
}
// NewCmdReconcile holds the options for 'auth reconcile' sub command
func NewCmdReconcile(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdReconcile(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := NewReconcileOptions(streams)
cmd := &cobra.Command{

View File

@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
authenticationv1alpha1client "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1"
authenticationv1beta1client "k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
@ -45,11 +46,11 @@ type WhoAmIFlags struct {
RESTClientGetter genericclioptions.RESTClientGetter
PrintFlags *genericclioptions.PrintFlags
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewWhoAmIFlags returns a default WhoAmIFlags.
func NewWhoAmIFlags(restClientGetter genericclioptions.RESTClientGetter, streams genericclioptions.IOStreams) *WhoAmIFlags {
func NewWhoAmIFlags(restClientGetter genericclioptions.RESTClientGetter, streams genericiooptions.IOStreams) *WhoAmIFlags {
return &WhoAmIFlags{
RESTClientGetter: restClientGetter,
PrintFlags: genericclioptions.NewPrintFlags("").WithTypeSetter(scheme.Scheme),
@ -107,7 +108,7 @@ type WhoAmIOptions struct {
resourcePrinterFunc printers.ResourcePrinterFunc
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -129,7 +130,7 @@ var (
)
// NewCmdWhoAmI returns an initialized Command for 'auth whoami' sub command. Experimental.
func NewCmdWhoAmI(restClientGetter genericclioptions.RESTClientGetter, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdWhoAmI(restClientGetter genericclioptions.RESTClientGetter, streams genericiooptions.IOStreams) *cobra.Command {
flags := NewWhoAmIFlags(restClientGetter, streams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
autoscalingv1client "k8s.io/client-go/kubernetes/typed/autoscaling/v1"
@ -80,11 +81,11 @@ type AutoscaleOptions struct {
HPAClient autoscalingv1client.HorizontalPodAutoscalersGetter
scaleKindResolver scale.ScaleKindResolver
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewAutoscaleOptions creates the options for autoscale
func NewAutoscaleOptions(ioStreams genericclioptions.IOStreams) *AutoscaleOptions {
func NewAutoscaleOptions(ioStreams genericiooptions.IOStreams) *AutoscaleOptions {
return &AutoscaleOptions{
PrintFlags: genericclioptions.NewPrintFlags("autoscaled").WithTypeSetter(scheme.Scheme),
FilenameOptions: &resource.FilenameOptions{},
@ -96,7 +97,7 @@ func NewAutoscaleOptions(ioStreams genericclioptions.IOStreams) *AutoscaleOption
}
// NewCmdAutoscale returns the autoscale Cobra command
func NewCmdAutoscale(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdAutoscale(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewAutoscaleOptions(ioStreams)
validArgs := []string{"deployment", "replicaset", "replicationcontroller", "statefulset"}

View File

@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
v1 "k8s.io/client-go/kubernetes/typed/certificates/v1"
@ -40,7 +41,7 @@ import (
)
// NewCmdCertificate returns `certificate` Cobra command
func NewCmdCertificate(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCertificate(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "certificate SUBCOMMAND",
DisableFlagsInUseLine: true,
@ -70,11 +71,11 @@ type CertificateOptions struct {
certificatesV1Client v1.CertificatesV1Interface
builder *resource.Builder
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCertificateOptions creates CertificateOptions struct for `certificate` command
func NewCertificateOptions(ioStreams genericclioptions.IOStreams, operation string) *CertificateOptions {
func NewCertificateOptions(ioStreams genericiooptions.IOStreams, operation string) *CertificateOptions {
return &CertificateOptions{
PrintFlags: genericclioptions.NewPrintFlags(operation).WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -119,7 +120,7 @@ func (o *CertificateOptions) Validate() error {
}
// NewCmdCertificateApprove returns the `certificate approve` Cobra command
func NewCmdCertificateApprove(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCertificateApprove(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCertificateOptions(ioStreams, "approved")
cmd := &cobra.Command{
@ -167,7 +168,7 @@ func (o *CertificateOptions) RunCertificateApprove(force bool) error {
}
// NewCmdCertificateDeny returns the `certificate deny` Cobra command
func NewCmdCertificateDeny(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCertificateDeny(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCertificateOptions(ioStreams, "denied")
cmd := &cobra.Command{

View File

@ -29,7 +29,7 @@ import (
certificatesv1 "k8s.io/api/certificates/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -235,7 +235,7 @@ func TestCertificates(t *testing.T) {
NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer,
Client: fakeClient,
}
streams, _, buf, errbuf := genericclioptions.NewTestIOStreams()
streams, _, buf, errbuf := genericiooptions.NewTestIOStreams()
tf.ClientConfigVal.Transport = fakeClient.Transport
defer func() {

View File

@ -25,6 +25,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
restclient "k8s.io/client-go/rest"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -47,7 +48,7 @@ var (
)
type ClusterInfoOptions struct {
genericclioptions.IOStreams
genericiooptions.IOStreams
Namespace string
@ -55,7 +56,7 @@ type ClusterInfoOptions struct {
Client *restclient.Config
}
func NewCmdClusterInfo(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdClusterInfo(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := &ClusterInfoOptions{
IOStreams: ioStreams,
}

View File

@ -29,6 +29,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
@ -59,10 +60,10 @@ type ClusterInfoDumpOptions struct {
RESTClientGetter genericclioptions.RESTClientGetter
LogsForObject polymorphichelpers.LogsForObjectFunc
genericclioptions.IOStreams
genericiooptions.IOStreams
}
func NewCmdClusterInfoDump(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdClusterInfoDump(restClientGetter genericclioptions.RESTClientGetter, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := &ClusterInfoDumpOptions{
PrintFlags: genericclioptions.NewPrintFlags("").WithTypeSetter(scheme.Scheme).WithDefaultOutput("json"),

View File

@ -21,7 +21,7 @@ import (
"path"
"testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
)
@ -41,7 +41,7 @@ func TestSetupOutputWriterNoOp(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, _, buf, _ := genericclioptions.NewTestIOStreams()
_, _, buf, _ := genericiooptions.NewTestIOStreams()
f := cmdtesting.NewTestFactory()
defer f.Cleanup()
@ -63,7 +63,7 @@ func TestSetupOutputWriterFile(t *testing.T) {
fullPath := path.Join(dir, file) + extension
defer os.RemoveAll(dir)
_, _, buf, _ := genericclioptions.NewTestIOStreams()
_, _, buf, _ := genericiooptions.NewTestIOStreams()
f := cmdtesting.NewTestFactory()
defer f.Cleanup()

View File

@ -28,6 +28,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
cliflag "k8s.io/component-base/cli/flag"
@ -92,7 +93,7 @@ type KubectlOptions struct {
Arguments []string
ConfigFlags *genericclioptions.ConfigFlags
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var defaultConfigFlags = genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag().WithDiscoveryBurst(300).WithDiscoveryQPS(50.0)
@ -103,7 +104,7 @@ func NewDefaultKubectlCommand() *cobra.Command {
PluginHandler: NewDefaultPluginHandler(plugin.ValidPluginFilenamePrefixes),
Arguments: os.Args,
ConfigFlags: defaultConfigFlags,
IOStreams: genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr},
IOStreams: genericiooptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr},
})
}

View File

@ -27,13 +27,14 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)
func TestNormalizationFuncGlobalExistence(t *testing.T) {
// This test can be safely deleted when we will not support multiple flag formats
root := NewKubectlCommand(KubectlOptions{IOStreams: genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}})
root := NewKubectlCommand(KubectlOptions{IOStreams: genericiooptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}})
if root.Parent() != nil {
t.Fatal("We expect the root command to be returned")
@ -132,7 +133,7 @@ func TestKubectlSubcommandShadowPlugin(t *testing.T) {
pluginsHandler := &testPluginHandler{
pluginsDirectory: "plugin/testdata",
}
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
root := NewDefaultKubectlCommandWithArgs(KubectlOptions{PluginHandler: pluginsHandler, Arguments: test.args, IOStreams: ioStreams})
if err := root.Execute(); err != nil {
@ -236,7 +237,7 @@ func TestKubectlCommandHandlesPlugins(t *testing.T) {
pluginsHandler := &testPluginHandler{
pluginsDirectory: "plugin/testdata",
}
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
root := NewDefaultKubectlCommandWithArgs(KubectlOptions{PluginHandler: pluginsHandler, Arguments: test.args, IOStreams: ioStreams})
if err := root.Execute(); err != nil {

View File

@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)
func TestBashCompletions(t *testing.T) {
@ -69,7 +69,7 @@ See 'kubectl completion -h' for help and examples`,
for _, tc := range testCases {
t.Run(tc.name, func(tt *testing.T) {
_, _, out, _ := genericclioptions.NewTestIOStreams()
_, _, out, _ := genericiooptions.NewTestIOStreams()
parentCmd := &cobra.Command{
Use: "kubectl",
}

View File

@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/tools/clientcmd"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
@ -31,7 +31,7 @@ import (
)
// NewCmdConfig creates a command object for the "config" action, and adds all child commands to it.
func NewCmdConfig(pathOptions *clientcmd.PathOptions, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdConfig(pathOptions *clientcmd.PathOptions, streams genericiooptions.IOStreams) *cobra.Command {
if len(pathOptions.ExplicitFileFlag) == 0 {
pathOptions.ExplicitFileFlag = clientcmd.RecommendedConfigPathFlag
}
@ -54,7 +54,7 @@ func NewCmdConfig(pathOptions *clientcmd.PathOptions, streams genericclioptions.
// file paths are common to all sub commands
cmd.PersistentFlags().StringVar(&pathOptions.LoadingRules.ExplicitPath, pathOptions.ExplicitFileFlag, pathOptions.LoadingRules.ExplicitPath, "use a particular kubeconfig file")
// TODO(juanvallejo): update all subcommands to work with genericclioptions.IOStreams
// TODO(juanvallejo): update all subcommands to work with genericiooptions.IOStreams
cmd.AddCommand(NewCmdConfigView(streams, pathOptions))
cmd.AddCommand(NewCmdConfigSetCluster(streams.Out, pathOptions))
cmd.AddCommand(NewCmdConfigSetCredentials(streams.Out, pathOptions))

View File

@ -26,7 +26,7 @@ import (
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -862,7 +862,7 @@ func testConfigCommand(args []string, startingConfig clientcmdapi.Config, t *tes
argsToUse = append(argsToUse, "--kubeconfig="+fakeKubeFile.Name())
argsToUse = append(argsToUse, args...)
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdConfig(clientcmd.NewDefaultPathOptions(), streams)
// "context" is a global flag, inherited from base kubectl command in the real world
cmd.PersistentFlags().String("context", "", "The name of the kubeconfig context to use")

View File

@ -21,7 +21,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -44,11 +44,11 @@ type DeleteUserOptions struct {
config *clientcmdapi.Config
configFile string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewDeleteUserOptions creates the options for the command
func NewDeleteUserOptions(ioStreams genericclioptions.IOStreams, configAccess clientcmd.ConfigAccess) *DeleteUserOptions {
func NewDeleteUserOptions(ioStreams genericiooptions.IOStreams, configAccess clientcmd.ConfigAccess) *DeleteUserOptions {
return &DeleteUserOptions{
configAccess: configAccess,
IOStreams: ioStreams,
@ -56,7 +56,7 @@ func NewDeleteUserOptions(ioStreams genericclioptions.IOStreams, configAccess cl
}
// NewCmdConfigDeleteUser returns a Command instance for 'config delete-user' sub command
func NewCmdConfigDeleteUser(streams genericclioptions.IOStreams, configAccess clientcmd.ConfigAccess) *cobra.Command {
func NewCmdConfigDeleteUser(streams genericiooptions.IOStreams, configAccess clientcmd.ConfigAccess) *cobra.Command {
o := NewDeleteUserOptions(streams, configAccess)
cmd := &cobra.Command{

View File

@ -21,7 +21,7 @@ import (
"strings"
"testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -51,7 +51,7 @@ func TestDeleteUserComplete(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
ioStreams, _, out, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, out, _ := genericiooptions.NewTestIOStreams()
pathOptions, err := tf.PathOptionsWithConfig(clientcmdapi.Config{})
if err != nil {
t.Fatalf("unexpected error executing command: %v", err)
@ -116,7 +116,7 @@ func TestDeleteUserValidate(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
pathOptions, err := tf.PathOptionsWithConfig(test.config)
if err != nil {
t.Fatalf("unexpected error executing command: %v", err)
@ -165,7 +165,7 @@ func TestDeleteUserRun(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
ioStreams, _, out, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, out, _ := genericiooptions.NewTestIOStreams()
pathOptions, err := tf.PathOptionsWithConfig(test.config)
if err != nil {
t.Fatalf("unexpected error executing command: %v", err)

View File

@ -27,7 +27,7 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
@ -46,7 +46,7 @@ type GetContextsOptions struct {
outputFormat string
noHeaders bool
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -62,7 +62,7 @@ var (
// NewCmdConfigGetContexts creates a command object for the "get-contexts" action, which
// retrieves one or more contexts from a kubeconfig.
func NewCmdConfigGetContexts(streams genericclioptions.IOStreams, configAccess clientcmd.ConfigAccess) *cobra.Command {
func NewCmdConfigGetContexts(streams genericiooptions.IOStreams, configAccess clientcmd.ConfigAccess) *cobra.Command {
options := &GetContextsOptions{
configAccess: configAccess,

View File

@ -20,7 +20,7 @@ import (
"os"
"testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)
@ -156,7 +156,7 @@ func (test getContextsTest) run(t *testing.T) {
pathOptions := clientcmd.NewDefaultPathOptions()
pathOptions.GlobalFile = fakeKubeFile.Name()
pathOptions.EnvVar = ""
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
options := GetContextsOptions{
configAccess: pathOptions,
}

View File

@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/tools/clientcmd"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
@ -39,11 +39,11 @@ var (
type GetUsersOptions struct {
configAccess clientcmd.ConfigAccess
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewGetUsersOptions creates the options for the command
func NewGetUsersOptions(ioStreams genericclioptions.IOStreams, configAccess clientcmd.ConfigAccess) *GetUsersOptions {
func NewGetUsersOptions(ioStreams genericiooptions.IOStreams, configAccess clientcmd.ConfigAccess) *GetUsersOptions {
return &GetUsersOptions{
configAccess: configAccess,
IOStreams: ioStreams,
@ -52,7 +52,7 @@ func NewGetUsersOptions(ioStreams genericclioptions.IOStreams, configAccess clie
// NewCmdConfigGetUsers creates a command object for the "get-users" action, which
// lists all users defined in the kubeconfig.
func NewCmdConfigGetUsers(streams genericclioptions.IOStreams, configAccess clientcmd.ConfigAccess) *cobra.Command {
func NewCmdConfigGetUsers(streams genericiooptions.IOStreams, configAccess clientcmd.ConfigAccess) *cobra.Command {
o := NewGetUsersOptions(streams, configAccess)
cmd := &cobra.Command{

View File

@ -19,7 +19,7 @@ package config
import (
"testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
)
@ -56,7 +56,7 @@ minikube
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
ioStreams, _, out, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, out, _ := genericiooptions.NewTestIOStreams()
pathOptions, err := tf.PathOptionsWithConfig(test.config)
if err != nil {
t.Fatalf("unexpected error executing command: %v", err)

View File

@ -18,8 +18,11 @@ package config
import (
"errors"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
@ -45,7 +48,7 @@ type ViewOptions struct {
Context string
OutputFormat string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -66,7 +69,7 @@ var (
)
// NewCmdConfigView returns a Command instance for 'config view' sub command
func NewCmdConfigView(streams genericclioptions.IOStreams, ConfigAccess clientcmd.ConfigAccess) *cobra.Command {
func NewCmdConfigView(streams genericiooptions.IOStreams, ConfigAccess clientcmd.ConfigAccess) *cobra.Command {
o := &ViewOptions{
PrintFlags: genericclioptions.NewPrintFlags("").WithTypeSetter(scheme.Scheme).WithDefaultOutput("yaml"),
ConfigAccess: ConfigAccess,

View File

@ -20,7 +20,7 @@ import (
"os"
"testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)
@ -305,7 +305,7 @@ func (test viewClusterTest) run(t *testing.T) {
pathOptions := clientcmd.NewDefaultPathOptions()
pathOptions.GlobalFile = fakeKubeFile.Name()
pathOptions.EnvVar = ""
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdConfigView(streams, pathOptions)
// "context" is a global flag, inherited from base kubectl command in the real world
cmd.Flags().String("context", "", "The name of the kubeconfig context to use")

View File

@ -27,7 +27,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/kubectl/pkg/cmd/exec"
@ -78,18 +78,18 @@ type CopyOptions struct {
args []string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCopyOptions creates the options for copy
func NewCopyOptions(ioStreams genericclioptions.IOStreams) *CopyOptions {
func NewCopyOptions(ioStreams genericiooptions.IOStreams) *CopyOptions {
return &CopyOptions{
IOStreams: ioStreams,
}
}
// NewCmdCp creates a new Copy command.
func NewCmdCp(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCp(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCopyOptions(ioStreams)
cmd := &cobra.Command{
@ -266,7 +266,7 @@ func (o *CopyOptions) Run() error {
func (o *CopyOptions) checkDestinationIsDir(dest fileSpec) error {
options := &exec.ExecOptions{
StreamOptions: exec.StreamOptions{
IOStreams: genericclioptions.IOStreams{
IOStreams: genericiooptions.IOStreams{
Out: bytes.NewBuffer([]byte{}),
ErrOut: bytes.NewBuffer([]byte{}),
},
@ -314,7 +314,7 @@ func (o *CopyOptions) copyToPod(src, dest fileSpec, options *exec.ExecOptions) e
}
options.StreamOptions = exec.StreamOptions{
IOStreams: genericclioptions.IOStreams{
IOStreams: genericiooptions.IOStreams{
In: reader,
Out: o.Out,
ErrOut: o.ErrOut,
@ -361,7 +361,7 @@ func (t *TarPipe) initReadFrom(n uint64) {
t.reader, t.outStream = io.Pipe()
options := &exec.ExecOptions{
StreamOptions: exec.StreamOptions{
IOStreams: genericclioptions.IOStreams{
IOStreams: genericiooptions.IOStreams{
In: nil,
Out: t.outStream,
ErrOut: t.o.Out,

View File

@ -31,11 +31,11 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest/fake"
kexec "k8s.io/kubectl/pkg/cmd/exec"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -405,7 +405,7 @@ func TestTarUntar(t *testing.T) {
}
}
opts := NewCopyOptions(genericclioptions.NewTestIOStreamsDiscard())
opts := NewCopyOptions(genericiooptions.NewTestIOStreamsDiscard())
writer := &bytes.Buffer{}
if err := makeTar(newLocalPath(dir), newRemotePath(dir), writer); err != nil {
@ -467,7 +467,7 @@ func TestTarUntarWrongPrefix(t *testing.T) {
}
createTmpFile(t, completePath, "sample data")
opts := NewCopyOptions(genericclioptions.NewTestIOStreamsDiscard())
opts := NewCopyOptions(genericiooptions.NewTestIOStreamsDiscard())
writer := &bytes.Buffer{}
if err := makeTar(newLocalPath(dir), newRemotePath(dir), writer); err != nil {
@ -589,7 +589,7 @@ func TestBadTar(t *testing.T) {
t.FailNow()
}
opts := NewCopyOptions(genericclioptions.NewTestIOStreamsDiscard())
opts := NewCopyOptions(genericiooptions.NewTestIOStreamsDiscard())
if err := opts.untarAll("", "", "/prefix", remotePath{}, newLocalPath(dir), &buf); err != nil {
t.Errorf("unexpected error: %v ", err)
t.FailNow()
@ -618,7 +618,7 @@ func TestCopyToPod(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCp(tf, ioStreams)
@ -689,7 +689,7 @@ func TestCopyToPodNoPreserve(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCp(tf, ioStreams)
@ -753,7 +753,7 @@ func TestValidate(t *testing.T) {
expectedErr: true,
},
}
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
opts := NewCopyOptions(ioStreams)
for _, test := range tests {
@ -908,7 +908,7 @@ func TestUntar(t *testing.T) {
// Capture warnings to stderr for debugging.
output := (*testWriter)(t)
opts := NewCopyOptions(genericclioptions.IOStreams{In: &bytes.Buffer{}, Out: output, ErrOut: output})
opts := NewCopyOptions(genericiooptions.IOStreams{In: &bytes.Buffer{}, Out: output, ErrOut: output})
require.NoError(t, opts.untarAll("", "", "", remotePath{}, newLocalPath(basedir), buf))
@ -959,7 +959,7 @@ func TestUntar_SingleFile(t *testing.T) {
// Capture warnings to stderr for debugging.
output := (*testWriter)(t)
opts := NewCopyOptions(genericclioptions.IOStreams{In: &bytes.Buffer{}, Out: output, ErrOut: output})
opts := NewCopyOptions(genericiooptions.IOStreams{In: &bytes.Buffer{}, Out: output, ErrOut: output})
require.NoError(t, opts.untarAll("", "", srcName, remotePath{}, newLocalPath(dest), buf))
cmpFileData(t, dest, content)

View File

@ -33,6 +33,7 @@ import (
kruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/dynamic"
@ -65,7 +66,7 @@ type CreateOptions struct {
Recorder genericclioptions.Recorder
PrintObj func(obj kruntime.Object) error
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -86,7 +87,7 @@ var (
)
// NewCreateOptions returns an initialized CreateOptions instance
func NewCreateOptions(ioStreams genericclioptions.IOStreams) *CreateOptions {
func NewCreateOptions(ioStreams genericiooptions.IOStreams) *CreateOptions {
return &CreateOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
RecordFlags: genericclioptions.NewRecordFlags(),
@ -98,7 +99,7 @@ func NewCreateOptions(ioStreams genericclioptions.IOStreams) *CreateOptions {
}
// NewCmdCreate returns new initialized instance of create sub command
func NewCmdCreate(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreate(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCreateOptions(ioStreams)
cmd := &cobra.Command{
@ -302,7 +303,7 @@ func (o *CreateOptions) RunCreate(f cmdutil.Factory, cmd *cobra.Command) error {
}
// RunEditOnCreate performs edit on creation
func RunEditOnCreate(f cmdutil.Factory, printFlags *genericclioptions.PrintFlags, recordFlags *genericclioptions.RecordFlags, ioStreams genericclioptions.IOStreams, cmd *cobra.Command, options *resource.FilenameOptions, fieldManager string) error {
func RunEditOnCreate(f cmdutil.Factory, printFlags *genericclioptions.PrintFlags, recordFlags *genericclioptions.RecordFlags, ioStreams genericiooptions.IOStreams, cmd *cobra.Command, options *resource.FilenameOptions, fieldManager string) error {
editOptions := editor.NewEditOptions(editor.EditBeforeCreateMode, ioStreams)
editOptions.FilenameOptions = *options
validationDirective, err := cmdutil.GetValidationDirective(cmd)
@ -358,11 +359,11 @@ type CreateSubcommandOptions struct {
PrintObj printers.ResourcePrinterFunc
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCreateSubcommandOptions returns initialized CreateSubcommandOptions
func NewCreateSubcommandOptions(ioStreams genericclioptions.IOStreams) *CreateSubcommandOptions {
func NewCreateSubcommandOptions(ioStreams genericiooptions.IOStreams) *CreateSubcommandOptions {
return &CreateSubcommandOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,

View File

@ -25,7 +25,7 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cliflag "k8s.io/component-base/cli/flag"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -70,7 +70,7 @@ type CreateClusterRoleOptions struct {
}
// NewCmdCreateClusterRole initializes and returns new ClusterRoles command
func NewCmdCreateClusterRole(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateClusterRole(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
c := &CreateClusterRoleOptions{
CreateRoleOptions: NewCreateRoleOptions(ioStreams),
AggregationRule: map[string]string{},

View File

@ -23,7 +23,7 @@ import (
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
"k8s.io/kubectl/pkg/scheme"
@ -149,7 +149,7 @@ func TestCreateClusterRole(t *testing.T) {
}
for name, test := range tests {
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreateClusterRole(tf, ioStreams)
cmd.Flags().Set("dry-run", "client")
cmd.Flags().Set("output", "yaml")
@ -496,7 +496,7 @@ func TestClusterRoleValidate(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
test.clusterRoleOptions.IOStreams = genericclioptions.NewTestIOStreamsDiscard()
test.clusterRoleOptions.IOStreams = genericiooptions.NewTestIOStreamsDiscard()
var err error
test.clusterRoleOptions.Mapper, err = tf.ToRESTMapper()
if err != nil {

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
rbacclientv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -62,11 +63,11 @@ type ClusterRoleBindingOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewClusterRoleBindingOptions creates a new *ClusterRoleBindingOptions with sane defaults
func NewClusterRoleBindingOptions(ioStreams genericclioptions.IOStreams) *ClusterRoleBindingOptions {
func NewClusterRoleBindingOptions(ioStreams genericiooptions.IOStreams) *ClusterRoleBindingOptions {
return &ClusterRoleBindingOptions{
Users: []string{},
Groups: []string{},
@ -77,7 +78,7 @@ func NewClusterRoleBindingOptions(ioStreams genericclioptions.IOStreams) *Cluste
}
// NewCmdCreateClusterRoleBinding returns an initialized command instance of ClusterRoleBinding
func NewCmdCreateClusterRoleBinding(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateClusterRoleBinding(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewClusterRoleBindingOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -98,11 +99,11 @@ type ConfigMapOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewConfigMapOptions creates a new *ConfigMapOptions with default value
func NewConfigMapOptions(ioStreams genericclioptions.IOStreams) *ConfigMapOptions {
func NewConfigMapOptions(ioStreams genericiooptions.IOStreams) *ConfigMapOptions {
return &ConfigMapOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -110,7 +111,7 @@ func NewConfigMapOptions(ioStreams genericclioptions.IOStreams) *ConfigMapOption
}
// NewCmdCreateConfigMap creates the `create configmap` Cobra command
func NewCmdCreateConfigMap(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateConfigMap(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewConfigMapOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
batchv1client "k8s.io/client-go/kubernetes/typed/batch/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -69,11 +70,11 @@ type CreateCronJobOptions struct {
FieldManager string
CreateAnnotation bool
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCreateCronJobOptions returns an initialized CreateCronJobOptions instance
func NewCreateCronJobOptions(ioStreams genericclioptions.IOStreams) *CreateCronJobOptions {
func NewCreateCronJobOptions(ioStreams genericiooptions.IOStreams) *CreateCronJobOptions {
return &CreateCronJobOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -81,7 +82,7 @@ func NewCreateCronJobOptions(ioStreams genericclioptions.IOStreams) *CreateCronJ
}
// NewCmdCreateCronJob is a command to create CronJobs.
func NewCmdCreateCronJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateCronJob(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCreateCronJobOptions(ioStreams)
cmd := &cobra.Command{
Use: "cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]",

View File

@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
utilrand "k8s.io/apimachinery/pkg/util/rand"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -75,11 +76,11 @@ type CreateDeploymentOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCreateDeploymentOptions returns an initialized CreateDeploymentOptions instance
func NewCreateDeploymentOptions(ioStreams genericclioptions.IOStreams) *CreateDeploymentOptions {
func NewCreateDeploymentOptions(ioStreams genericiooptions.IOStreams) *CreateDeploymentOptions {
return &CreateDeploymentOptions{
Port: -1,
Replicas: 1,
@ -90,7 +91,7 @@ func NewCreateDeploymentOptions(ioStreams genericclioptions.IOStreams) *CreateDe
// NewCmdCreateDeployment is a macro command to create a new deployment.
// This command is better known to users as `kubectl create deployment`.
func NewCmdCreateDeployment(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateDeployment(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCreateDeploymentOptions(ioStreams)
cmd := &cobra.Command{
Use: "deployment NAME --image=image -- [COMMAND] [args...]",

View File

@ -26,6 +26,7 @@ import (
"github.com/stretchr/testify/assert"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -51,7 +52,7 @@ func TestCreateDeployment(t *testing.T) {
}
tf.ClientConfigVal = &restclient.Config{}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreateDeployment(tf, ioStreams)
cmd.Flags().Set("dry-run", "client")
cmd.Flags().Set("output", "name")
@ -82,7 +83,7 @@ func TestCreateDeploymentWithPort(t *testing.T) {
}
tf.ClientConfigVal = &restclient.Config{}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreateDeployment(tf, ioStreams)
cmd.Flags().Set("dry-run", "client")
cmd.Flags().Set("output", "yaml")
@ -113,7 +114,7 @@ func TestCreateDeploymentWithReplicas(t *testing.T) {
}
tf.ClientConfigVal = &restclient.Config{}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreateDeployment(tf, ioStreams)
cmd.Flags().Set("dry-run", "client")
cmd.Flags().Set("output", "jsonpath={.spec.replicas}")
@ -143,7 +144,7 @@ func TestCreateDeploymentNoImage(t *testing.T) {
}
tf.ClientConfigVal = &restclient.Config{}
ioStreams := genericclioptions.NewTestIOStreamsDiscard()
ioStreams := genericiooptions.NewTestIOStreamsDiscard()
cmd := NewCmdCreateDeployment(tf, ioStreams)
cmd.Flags().Set("output", "name")
options := &CreateDeploymentOptions{

View File

@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -121,11 +122,11 @@ type CreateIngressOptions struct {
FieldManager string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCreateIngressOptions creates the CreateIngressOptions to be used later
func NewCreateIngressOptions(ioStreams genericclioptions.IOStreams) *CreateIngressOptions {
func NewCreateIngressOptions(ioStreams genericiooptions.IOStreams) *CreateIngressOptions {
return &CreateIngressOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -134,7 +135,7 @@ func NewCreateIngressOptions(ioStreams genericclioptions.IOStreams) *CreateIngre
// NewCmdCreateIngress is a macro command to create a new ingress.
// This command is better known to users as `kubectl create ingress`.
func NewCmdCreateIngress(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateIngress(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCreateIngressOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
batchv1client "k8s.io/client-go/kubernetes/typed/batch/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -71,11 +72,11 @@ type CreateJobOptions struct {
FieldManager string
CreateAnnotation bool
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCreateJobOptions initializes and returns new CreateJobOptions instance
func NewCreateJobOptions(ioStreams genericclioptions.IOStreams) *CreateJobOptions {
func NewCreateJobOptions(ioStreams genericiooptions.IOStreams) *CreateJobOptions {
return &CreateJobOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -83,7 +84,7 @@ func NewCreateJobOptions(ioStreams genericclioptions.IOStreams) *CreateJobOption
}
// NewCmdCreateJob is a command to ease creating Jobs from CronJobs.
func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCreateJobOptions(ioStreams)
cmd := &cobra.Command{
Use: "job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]",

View File

@ -30,6 +30,7 @@ import (
"k8s.io/kubectl/pkg/util"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
@ -60,11 +61,11 @@ type NamespaceOptions struct {
PrintObj func(obj runtime.Object) error
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewNamespaceOptions creates a new *NamespaceOptions with sane defaults
func NewNamespaceOptions(ioStreams genericclioptions.IOStreams) *NamespaceOptions {
func NewNamespaceOptions(ioStreams genericiooptions.IOStreams) *NamespaceOptions {
return &NamespaceOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -72,7 +73,7 @@ func NewNamespaceOptions(ioStreams genericclioptions.IOStreams) *NamespaceOption
}
// NewCmdCreateNamespace is a macro command to create a new namespace
func NewCmdCreateNamespace(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateNamespace(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewNamespaceOptions(ioStreams)

View File

@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
policyv1client "k8s.io/client-go/kubernetes/typed/policy/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -72,11 +73,11 @@ type PodDisruptionBudgetOpts struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewPodDisruptionBudgetOpts creates a new *PodDisruptionBudgetOpts with sane defaults
func NewPodDisruptionBudgetOpts(ioStreams genericclioptions.IOStreams) *PodDisruptionBudgetOpts {
func NewPodDisruptionBudgetOpts(ioStreams genericiooptions.IOStreams) *PodDisruptionBudgetOpts {
return &PodDisruptionBudgetOpts{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -84,7 +85,7 @@ func NewPodDisruptionBudgetOpts(ioStreams genericclioptions.IOStreams) *PodDisru
}
// NewCmdCreatePodDisruptionBudget is a macro command to create a new pod disruption budget.
func NewCmdCreatePodDisruptionBudget(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreatePodDisruptionBudget(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewPodDisruptionBudgetOpts(ioStreams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
schedulingv1client "k8s.io/client-go/kubernetes/typed/scheduling/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -67,11 +68,11 @@ type PriorityClassOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewPriorityClassOptions returns an initialized PriorityClassOptions instance
func NewPriorityClassOptions(ioStreams genericclioptions.IOStreams) *PriorityClassOptions {
func NewPriorityClassOptions(ioStreams genericiooptions.IOStreams) *PriorityClassOptions {
return &PriorityClassOptions{
Value: 0,
PreemptionPolicy: "PreemptLowerPriority",
@ -81,7 +82,7 @@ func NewPriorityClassOptions(ioStreams genericclioptions.IOStreams) *PriorityCla
}
// NewCmdCreatePriorityClass is a macro command to create a new priorityClass.
func NewCmdCreatePriorityClass(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreatePriorityClass(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewPriorityClassOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -51,7 +52,7 @@ func TestCreatePriorityClass(t *testing.T) {
outputFormat := "name"
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreatePriorityClass(tf, ioStreams)
cmd.Flags().Set("value", "1000")
cmd.Flags().Set("global-default", "true")

View File

@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
coreclient "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -68,11 +69,11 @@ type QuotaOpts struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewQuotaOpts creates a new *QuotaOpts with sane defaults
func NewQuotaOpts(ioStreams genericclioptions.IOStreams) *QuotaOpts {
func NewQuotaOpts(ioStreams genericiooptions.IOStreams) *QuotaOpts {
return &QuotaOpts{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -80,7 +81,7 @@ func NewQuotaOpts(ioStreams genericclioptions.IOStreams) *QuotaOpts {
}
// NewCmdCreateQuota is a macro command to create a new quota
func NewCmdCreateQuota(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateQuota(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewQuotaOpts(ioStreams)
cmd := &cobra.Command{

View File

@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
clientgorbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -148,11 +149,11 @@ type CreateRoleOptions struct {
FieldManager string
CreateAnnotation bool
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCreateRoleOptions returns an initialized CreateRoleOptions instance
func NewCreateRoleOptions(ioStreams genericclioptions.IOStreams) *CreateRoleOptions {
func NewCreateRoleOptions(ioStreams genericiooptions.IOStreams) *CreateRoleOptions {
return &CreateRoleOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
@ -161,7 +162,7 @@ func NewCreateRoleOptions(ioStreams genericclioptions.IOStreams) *CreateRoleOpti
}
// NewCmdCreateRole returnns an initialized Command instance for 'create role' sub command
func NewCmdCreateRole(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateRole(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewCreateRoleOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
"k8s.io/kubectl/pkg/scheme"
@ -133,7 +134,7 @@ func TestCreateRole(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreateRole(tf, ioStreams)
cmd.Flags().Set("dry-run", "client")
cmd.Flags().Set("output", "yaml")
@ -341,7 +342,7 @@ func TestValidate(t *testing.T) {
}
for name, test := range tests {
test.roleOptions.IOStreams = genericclioptions.NewTestIOStreamsDiscard()
test.roleOptions.IOStreams = genericiooptions.NewTestIOStreamsDiscard()
var err error
test.roleOptions.Mapper, err = tf.ToRESTMapper()
@ -645,7 +646,7 @@ func TestComplete(t *testing.T) {
}
for name, test := range tests {
cmd := NewCmdCreateRole(tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdCreateRole(tf, genericiooptions.NewTestIOStreamsDiscard())
cmd.Flags().Set("resource", test.resources)
err := test.roleOptions.Complete(tf, cmd, test.params)

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
rbacclientv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -67,11 +68,11 @@ type RoleBindingOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewRoleBindingOptions creates a new *RoleBindingOptions with sane defaults
func NewRoleBindingOptions(ioStreams genericclioptions.IOStreams) *RoleBindingOptions {
func NewRoleBindingOptions(ioStreams genericiooptions.IOStreams) *RoleBindingOptions {
return &RoleBindingOptions{
Users: []string{},
Groups: []string{},
@ -82,7 +83,7 @@ func NewRoleBindingOptions(ioStreams genericclioptions.IOStreams) *RoleBindingOp
}
// NewCmdCreateRoleBinding returns an initialized Command instance for 'create rolebinding' sub command
func NewCmdCreateRoleBinding(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateRoleBinding(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewRoleBindingOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -41,7 +42,7 @@ import (
// NewCmdCreateSecret groups subcommands to create various types of secrets.
// This is the entry point of create_secret.go which will be called by create.go
func NewCmdCreateSecret(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateSecret(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "secret",
Short: i18n.T("Create a secret using specified subcommand"),
@ -114,11 +115,11 @@ type CreateSecretOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewSecretOptions creates a new *CreateSecretOptions with default value
func NewSecretOptions(ioStreams genericclioptions.IOStreams) *CreateSecretOptions {
func NewSecretOptions(ioStreams genericiooptions.IOStreams) *CreateSecretOptions {
return &CreateSecretOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -126,7 +127,7 @@ func NewSecretOptions(ioStreams genericclioptions.IOStreams) *CreateSecretOption
}
// NewCmdCreateSecretGeneric is a command to create generic secrets from files, directories, or literal values
func NewCmdCreateSecretGeneric(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateSecretGeneric(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewSecretOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -111,11 +112,11 @@ type CreateSecretDockerRegistryOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewSecretDockerRegistryOptions creates a new *CreateSecretDockerRegistryOptions with default value
func NewSecretDockerRegistryOptions(ioStreams genericclioptions.IOStreams) *CreateSecretDockerRegistryOptions {
func NewSecretDockerRegistryOptions(ioStreams genericiooptions.IOStreams) *CreateSecretDockerRegistryOptions {
return &CreateSecretDockerRegistryOptions{
Server: "https://index.docker.io/v1/",
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
@ -124,7 +125,7 @@ func NewSecretDockerRegistryOptions(ioStreams genericclioptions.IOStreams) *Crea
}
// NewCmdCreateSecretDockerRegistry is a macro command for creating secrets to work with Docker registries
func NewCmdCreateSecretDockerRegistry(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateSecretDockerRegistry(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewSecretDockerRegistryOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -72,11 +73,11 @@ type CreateSecretTLSOptions struct {
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewSecretTLSOptions creates a new *CreateSecretTLSOptions with default value
func NewSecretTLSOptions(ioStrems genericclioptions.IOStreams) *CreateSecretTLSOptions {
func NewSecretTLSOptions(ioStrems genericiooptions.IOStreams) *CreateSecretTLSOptions {
return &CreateSecretTLSOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStrems,
@ -84,7 +85,7 @@ func NewSecretTLSOptions(ioStrems genericclioptions.IOStreams) *CreateSecretTLSO
}
// NewCmdCreateSecretTLS is a macro command for creating secrets to work with TLS client or server
func NewCmdCreateSecretTLS(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateSecretTLS(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewSecretTLSOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -40,7 +41,7 @@ import (
)
// NewCmdCreateService is a macro command to create a new service
func NewCmdCreateService(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateService(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "service",
Aliases: []string{"svc"},
@ -76,11 +77,11 @@ type ServiceOptions struct {
Client corev1client.CoreV1Interface
DryRunStrategy cmdutil.DryRunStrategy
ValidationDirective string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewServiceOptions creates a ServiceOptions struct
func NewServiceOptions(ioStreams genericclioptions.IOStreams, serviceType corev1.ServiceType) *ServiceOptions {
func NewServiceOptions(ioStreams genericiooptions.IOStreams, serviceType corev1.ServiceType) *ServiceOptions {
return &ServiceOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -239,7 +240,7 @@ var (
)
// NewCmdCreateServiceClusterIP is a command to create a ClusterIP service
func NewCmdCreateServiceClusterIP(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateServiceClusterIP(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewServiceOptions(ioStreams, corev1.ServiceTypeClusterIP)
cmd := &cobra.Command{
@ -277,7 +278,7 @@ var (
)
// NewCmdCreateServiceNodePort is a macro command for creating a NodePort service
func NewCmdCreateServiceNodePort(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateServiceNodePort(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewServiceOptions(ioStreams, corev1.ServiceTypeNodePort)
cmd := &cobra.Command{
@ -314,7 +315,7 @@ var (
)
// NewCmdCreateServiceLoadBalancer is a macro command for creating a LoadBalancer service
func NewCmdCreateServiceLoadBalancer(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateServiceLoadBalancer(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewServiceOptions(ioStreams, corev1.ServiceTypeLoadBalancer)
cmd := &cobra.Command{
@ -354,7 +355,7 @@ var (
)
// NewCmdCreateServiceExternalName is a macro command for creating an ExternalName service
func NewCmdCreateServiceExternalName(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateServiceExternalName(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewServiceOptions(ioStreams, corev1.ServiceTypeExternalName)
cmd := &cobra.Command{

View File

@ -17,15 +17,16 @@ limitations under the License.
package create
import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"testing"
restclient "k8s.io/client-go/rest"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
"testing"
v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/cli-runtime/pkg/genericiooptions"
)
func TestCreateServices(t *testing.T) {
@ -279,7 +280,7 @@ func TestCreateServiceWithNamespace(t *testing.T) {
tf.ClientConfigVal = &restclient.Config{}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreateServiceClusterIP(tf, ioStreams)
cmd.Flags().Set("dry-run", "client")
cmd.Flags().Set("output", "jsonpath={.metadata.namespace}")

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
coreclient "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -62,11 +63,11 @@ type ServiceAccountOpts struct {
Mapper meta.RESTMapper
Client *coreclient.CoreV1Client
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewServiceAccountOpts creates a new *ServiceAccountOpts with sane defaults
func NewServiceAccountOpts(ioStreams genericclioptions.IOStreams) *ServiceAccountOpts {
func NewServiceAccountOpts(ioStreams genericiooptions.IOStreams) *ServiceAccountOpts {
return &ServiceAccountOpts{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -74,7 +75,7 @@ func NewServiceAccountOpts(ioStreams genericclioptions.IOStreams) *ServiceAccoun
}
// NewCmdCreateServiceAccount is a macro command to create a new service account
func NewCmdCreateServiceAccount(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateServiceAccount(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewServiceAccountOpts(ioStreams)
cmd := &cobra.Command{

View File

@ -21,7 +21,7 @@ import (
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -34,8 +34,8 @@ func TestExtraArgsFail(t *testing.T) {
f := cmdtesting.NewTestFactory()
defer f.Cleanup()
c := NewCmdCreate(f, genericclioptions.NewTestIOStreamsDiscard())
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
c := NewCmdCreate(f, genericiooptions.NewTestIOStreamsDiscard())
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
options := NewCreateOptions(ioStreams)
if options.Complete(f, c, []string{"rc"}) == nil {
t.Errorf("unexpected non-error")
@ -66,7 +66,7 @@ func TestCreateObject(t *testing.T) {
}),
}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreate(tf, ioStreams)
cmd.Flags().Set("filename", "../../../testdata/redis-master-controller.yaml")
cmd.Flags().Set("output", "name")
@ -103,7 +103,7 @@ func TestCreateMultipleObject(t *testing.T) {
}),
}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreate(tf, ioStreams)
cmd.Flags().Set("filename", "../../../testdata/redis-master-controller.yaml")
cmd.Flags().Set("filename", "../../../testdata/frontend-service.yaml")
@ -140,7 +140,7 @@ func TestCreateDirectory(t *testing.T) {
}),
}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreate(tf, ioStreams)
cmd.Flags().Set("filename", "../../../testdata/replace/legacy")
cmd.Flags().Set("output", "name")

View File

@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/scheme"
@ -66,7 +67,7 @@ type TokenOptions struct {
CoreClient corev1client.CoreV1Interface
// IOStreams are the output streams for the operation. Required.
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -98,7 +99,7 @@ var (
}
)
func NewTokenOpts(ioStreams genericclioptions.IOStreams) *TokenOptions {
func NewTokenOpts(ioStreams genericiooptions.IOStreams) *TokenOptions {
return &TokenOptions{
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -106,7 +107,7 @@ func NewTokenOpts(ioStreams genericclioptions.IOStreams) *TokenOptions {
}
// NewCmdCreateToken returns an initialized Command for 'create token' sub command
func NewCmdCreateToken(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCreateToken(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewTokenOpts(ioStreams)
cmd := &cobra.Command{

View File

@ -33,7 +33,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -299,7 +299,7 @@ status:
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, stdout, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, stdout, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdCreateToken(tf, ioStreams)
if test.output != "" {
cmd.Flags().Set("output", test.output)

View File

@ -38,6 +38,7 @@ import (
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes"
@ -135,14 +136,14 @@ type DebugOptions struct {
podClient corev1client.CoreV1Interface
Builder *resource.Builder
genericclioptions.IOStreams
genericiooptions.IOStreams
WarningPrinter *printers.WarningPrinter
resource.FilenameOptions
}
// NewDebugOptions returns a DebugOptions initialized with default values.
func NewDebugOptions(streams genericclioptions.IOStreams) *DebugOptions {
func NewDebugOptions(streams genericiooptions.IOStreams) *DebugOptions {
return &DebugOptions{
Args: []string{},
IOStreams: streams,
@ -152,7 +153,7 @@ func NewDebugOptions(streams genericclioptions.IOStreams) *DebugOptions {
}
// NewCmdDebug returns a cobra command that runs kubectl debug.
func NewCmdDebug(restClientGetter genericclioptions.RESTClientGetter, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdDebug(restClientGetter genericclioptions.RESTClientGetter, streams genericiooptions.IOStreams) *cobra.Command {
o := NewDebugOptions(streams)
cmd := &cobra.Command{

View File

@ -28,7 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
"k8s.io/utils/pointer"
)
@ -316,7 +316,7 @@ func TestGenerateDebugContainer(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
tc.opts.IOStreams = genericclioptions.NewTestIOStreamsDiscard()
tc.opts.IOStreams = genericiooptions.NewTestIOStreamsDiscard()
suffixCounter = 0
if tc.pod == nil {
@ -1334,7 +1334,7 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
if err != nil {
t.Fatalf("Fail to create profile applier: %s: %v", tc.opts.Profile, err)
}
tc.opts.IOStreams = genericclioptions.NewTestIOStreamsDiscard()
tc.opts.IOStreams = genericiooptions.NewTestIOStreamsDiscard()
suffixCounter = 0
if tc.havePod == nil {
@ -1716,7 +1716,7 @@ func TestGenerateNodeDebugPod(t *testing.T) {
if err != nil {
t.Fatalf("Fail to create profile applier: %s: %v", tc.opts.Profile, err)
}
tc.opts.IOStreams = genericclioptions.NewTestIOStreamsDiscard()
tc.opts.IOStreams = genericiooptions.NewTestIOStreamsDiscard()
suffixCounter = 0
pod, err := tc.opts.generateNodeDebugPod(tc.node)
@ -1732,7 +1732,7 @@ func TestGenerateNodeDebugPod(t *testing.T) {
func TestCompleteAndValidate(t *testing.T) {
tf := cmdtesting.NewTestFactory().WithNamespace("test")
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmpFilter := cmp.FilterPath(func(p cmp.Path) bool {
switch p.String() {
// IOStreams contains unexported fields

View File

@ -30,6 +30,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/dynamic"
@ -132,11 +133,11 @@ type DeleteOptions struct {
Mapper meta.RESTMapper
Result *resource.Result
genericclioptions.IOStreams
genericiooptions.IOStreams
WarningPrinter *printers.WarningPrinter
}
func NewCmdDelete(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdDelete(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
deleteFlags := NewDeleteCommandFlags("containing the resource to delete.")
cmd := &cobra.Command{

View File

@ -25,6 +25,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/dynamic"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)
@ -49,7 +50,7 @@ type DeleteFlags struct {
Raw *string
}
func (f *DeleteFlags) ToOptions(dynamicClient dynamic.Interface, streams genericclioptions.IOStreams) (*DeleteOptions, error) {
func (f *DeleteFlags) ToOptions(dynamicClient dynamic.Interface, streams genericiooptions.IOStreams) (*DeleteOptions, error) {
options := &DeleteOptions{
DynamicClient: dynamicClient,
IOStreams: streams,
@ -226,7 +227,7 @@ func NewDeleteFlags(usage string) *DeleteFlags {
}
}
func parseCascadingFlag(streams genericclioptions.IOStreams, cascadingFlag string) (metav1.DeletionPropagation, error) {
func parseCascadingFlag(streams genericiooptions.IOStreams, cascadingFlag string) (metav1.DeletionPropagation, error) {
boolValue, err := strconv.ParseBool(cascadingFlag)
// The flag is not a boolean
if err != nil {

View File

@ -29,7 +29,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -77,7 +77,7 @@ func TestDeleteObjectByTuple(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("cascade", "false")
@ -88,7 +88,7 @@ func TestDeleteObjectByTuple(t *testing.T) {
}
// Test cascading delete of object without client-side reaper doesn't make GET requests
streams, _, buf, _ = genericclioptions.NewTestIOStreams()
streams, _, buf, _ = genericiooptions.NewTestIOStreams()
cmd = NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("output", "name")
@ -139,7 +139,7 @@ func TestCascadingStrategy(t *testing.T) {
// DeleteOptions.PropagationPolicy should be Background, when cascading strategy is empty (default).
backgroundPolicy := metav1.DeletePropagationBackground
policy = &backgroundPolicy
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("output", "name")
@ -151,7 +151,7 @@ func TestCascadingStrategy(t *testing.T) {
// DeleteOptions.PropagationPolicy should be Foreground, when cascading strategy is foreground.
foregroundPolicy := metav1.DeletePropagationForeground
policy = &foregroundPolicy
streams, _, buf, _ = genericclioptions.NewTestIOStreams()
streams, _, buf, _ = genericiooptions.NewTestIOStreams()
cmd = NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("cascade", "foreground")
@ -164,7 +164,7 @@ func TestCascadingStrategy(t *testing.T) {
// Test that delete options should be set to orphan when cascading strategy is orphan.
orphanPolicy := metav1.DeletePropagationOrphan
policy = &orphanPolicy
streams, _, buf, _ = genericclioptions.NewTestIOStreams()
streams, _, buf, _ = genericiooptions.NewTestIOStreams()
cmd = NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("cascade", "orphan")
@ -206,7 +206,7 @@ func TestDeleteNamedObject(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("cascade", "false")
@ -217,7 +217,7 @@ func TestDeleteNamedObject(t *testing.T) {
}
// Test cascading delete of object without client-side reaper doesn't make GET requests
streams, _, buf, _ = genericclioptions.NewTestIOStreams()
streams, _, buf, _ = genericiooptions.NewTestIOStreams()
cmd = NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("cascade", "false")
@ -250,7 +250,7 @@ func TestDeleteObject(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("filename", "../../../testdata/redis-master-controller.yaml")
cmd.Flags().Set("cascade", "false")
@ -386,7 +386,7 @@ func TestGracePeriodScenarios(t *testing.T) {
}
// Test the command using the flags specified in the test case
streams, _, out, errOut := genericclioptions.NewTestIOStreams()
streams, _, out, errOut := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("output", "name")
if test.forceFlag {
@ -442,7 +442,7 @@ func TestDeleteObjectNotFound(t *testing.T) {
GracePeriod: -1,
CascadingStrategy: metav1.DeletePropagationOrphan,
Output: "name",
IOStreams: genericclioptions.NewTestIOStreamsDiscard(),
IOStreams: genericiooptions.NewTestIOStreamsDiscard(),
}
err := options.Complete(tf, []string{}, fakecmd())
if err != nil {
@ -471,7 +471,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
}
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("filename", "../../../testdata/redis-master-controller.yaml")
@ -522,7 +522,7 @@ func TestDeleteAllNotFound(t *testing.T) {
DeleteAll: true,
IgnoreNotFound: false,
Output: "name",
IOStreams: genericclioptions.NewTestIOStreamsDiscard(),
IOStreams: genericiooptions.NewTestIOStreamsDiscard(),
}
err := options.Complete(tf, []string{"services"}, fakecmd())
if err != nil {
@ -563,7 +563,7 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
}
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("all", "true")
@ -599,7 +599,7 @@ func TestDeleteMultipleObject(t *testing.T) {
}
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("filename", "../../../testdata/redis-master-controller.yaml")
@ -636,7 +636,7 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
}
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
options := &DeleteOptions{
FilenameOptions: resource.FilenameOptions{
@ -688,7 +688,7 @@ func TestDeleteMultipleResourcesWithTheSameName(t *testing.T) {
}
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")
@ -721,7 +721,7 @@ func TestDeleteDirectory(t *testing.T) {
}
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("filename", "../../../testdata/replace/legacy")
@ -767,7 +767,7 @@ func TestDeleteMultipleSelector(t *testing.T) {
}
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("selector", "a=b")
@ -811,7 +811,7 @@ func TestResourceErrors(t *testing.T) {
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
options := &DeleteOptions{
FilenameOptions: resource.FilenameOptions{},
GracePeriod: -1,

View File

@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/describe"
@ -77,11 +77,11 @@ type DescribeFlags struct {
AllNamespaces bool
FilenameOptions *resource.FilenameOptions
DescriberSettings *describe.DescriberSettings
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewDescribeFlags returns a default DescribeFlags
func NewDescribeFlags(f cmdutil.Factory, streams genericclioptions.IOStreams) *DescribeFlags {
func NewDescribeFlags(f cmdutil.Factory, streams genericiooptions.IOStreams) *DescribeFlags {
return &DescribeFlags{
Factory: f,
FilenameOptions: &resource.FilenameOptions{},
@ -141,7 +141,7 @@ func (flags *DescribeFlags) ToOptions(parent string, args []string) (*DescribeOp
return o, nil
}
func NewCmdDescribe(parent string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdDescribe(parent string, f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
flags := NewDescribeFlags(f, streams)
cmd := &cobra.Command{
@ -290,5 +290,5 @@ type DescribeOptions struct {
DescriberSettings *describe.DescriberSettings
FilenameOptions *resource.FilenameOptions
genericclioptions.IOStreams
genericiooptions.IOStreams
}

View File

@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -49,7 +50,7 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, cmdtesting.NewInternalType("", "", "foo"))},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDescribe("kubectl", tf, streams)
cmd.Run(cmd, []string{"type", "foo"})
@ -82,7 +83,7 @@ func TestDescribeUnknownNamespacedSchemaObject(t *testing.T) {
}
tf.WithNamespace("non-default")
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDescribe("kubectl", tf, streams)
cmd.Run(cmd, []string{"namespacedtype", "foo"})
@ -122,7 +123,7 @@ func TestDescribeObject(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDescribe("kubectl", tf, streams)
cmd.Flags().Set("filename", "../../../testdata/redis-master-controller.yaml")
@ -155,7 +156,7 @@ func TestDescribeListObjects(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, pods)},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDescribe("kubectl", tf, streams)
cmd.Run(cmd, []string{"pods"})
@ -182,7 +183,7 @@ func TestDescribeObjectShowEvents(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, pods)},
}
cmd := NewCmdDescribe("kubectl", tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdDescribe("kubectl", tf, genericiooptions.NewTestIOStreamsDiscard())
cmd.Flags().Set("show-events", "true")
cmd.Run(cmd, []string{"pods"})
if d.Settings.ShowEvents != true {
@ -208,7 +209,7 @@ func TestDescribeObjectSkipEvents(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, pods)},
}
cmd := NewCmdDescribe("kubectl", tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdDescribe("kubectl", tf, genericiooptions.NewTestIOStreamsDiscard())
cmd.Flags().Set("show-events", "false")
cmd.Run(cmd, []string{"pods"})
if d.Settings.ShowEvents != false {
@ -234,7 +235,7 @@ func TestDescribeObjectChunkSize(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, pods)},
}
cmd := NewCmdDescribe("kubectl", tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdDescribe("kubectl", tf, genericiooptions.NewTestIOStreamsDiscard())
cmd.Flags().Set("chunk-size", "100")
cmd.Run(cmd, []string{"pods"})
if d.Settings.ChunkSize != 100 {
@ -246,7 +247,7 @@ func TestDescribeHelpMessage(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdDescribe("kubectl", tf, streams)
cmd.SetArgs([]string{"-h"})
@ -306,7 +307,7 @@ func TestDescribeNoResourcesFound(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, pods)},
}
streams, _, buf, errbuf := genericclioptions.NewTestIOStreams()
streams, _, buf, errbuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdDescribe("kubectl", tf, streams)
for name, value := range testCase.flags {

View File

@ -32,7 +32,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/dynamic"
"k8s.io/klog/v2"
@ -119,7 +119,7 @@ type DiffOptions struct {
tracker *tracker
}
func NewDiffOptions(ioStreams genericclioptions.IOStreams) *DiffOptions {
func NewDiffOptions(ioStreams genericiooptions.IOStreams) *DiffOptions {
return &DiffOptions{
Diff: &DiffProgram{
Exec: exec.New(),
@ -128,7 +128,7 @@ func NewDiffOptions(ioStreams genericclioptions.IOStreams) *DiffOptions {
}
}
func NewCmdDiff(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdDiff(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
options := NewDiffOptions(streams)
cmd := &cobra.Command{
Use: "diff -f FILENAME",
@ -179,7 +179,7 @@ func NewCmdDiff(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C
// program. By default, `diff(1)` will be used.
type DiffProgram struct {
Exec exec.Interface
genericclioptions.IOStreams
genericiooptions.IOStreams
}
func (d *DiffProgram) getCommand(args ...string) (string, exec.Cmd) {
@ -326,7 +326,7 @@ type InfoObject struct {
ServerSideApply bool
FieldManager string
ForceConflicts bool
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var _ Object = &InfoObject{}

View File

@ -29,7 +29,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/utils/exec"
)
@ -71,7 +71,7 @@ func TestDiffProgram(t *testing.T) {
for i, c := range externalDiffCommands {
os.Setenv("KUBECTL_EXTERNAL_DIFF", c)
streams, _, stdout, _ := genericclioptions.NewTestIOStreams()
streams, _, stdout, _ := genericiooptions.NewTestIOStreams()
diff := DiffProgram{
IOStreams: streams,
Exec: exec.New(),

View File

@ -28,6 +28,7 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -48,7 +49,7 @@ type DrainCmdOptions struct {
drainer *drain.Helper
nodeInfos []*resource.Info
genericclioptions.IOStreams
genericiooptions.IOStreams
WarningPrinter *printers.WarningPrinter
}
@ -61,7 +62,7 @@ var (
kubectl cordon foo`))
)
func NewCmdCordon(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdCordon(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewDrainCmdOptions(f, ioStreams)
cmd := &cobra.Command{
@ -90,7 +91,7 @@ var (
kubectl uncordon foo`))
)
func NewCmdUncordon(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdUncordon(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewDrainCmdOptions(f, ioStreams)
cmd := &cobra.Command{
@ -144,7 +145,7 @@ var (
kubectl drain foo --grace-period=900`))
)
func NewDrainCmdOptions(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *DrainCmdOptions {
func NewDrainCmdOptions(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *DrainCmdOptions {
o := &DrainCmdOptions{
PrintFlags: genericclioptions.NewPrintFlags("drained").WithTypeSetter(scheme.Scheme),
IOStreams: ioStreams,
@ -176,7 +177,7 @@ func (o *DrainCmdOptions) onPodDeletedOrEvicted(pod *corev1.Pod, usingEviction b
}
}
func NewCmdDrain(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdDrain(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewDrainCmdOptions(f, ioStreams)
cmd := &cobra.Command{

View File

@ -29,8 +29,6 @@ import (
"time"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
@ -38,6 +36,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -75,7 +74,7 @@ func TestCordon(t *testing.T) {
description string
node *corev1.Node
expected *corev1.Node
cmd func(cmdutil.Factory, genericclioptions.IOStreams) *cobra.Command
cmd func(cmdutil.Factory, genericiooptions.IOStreams) *cobra.Command
arg string
expectFatal bool
}{
@ -211,7 +210,7 @@ func TestCordon(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
cmd := test.cmd(tf, ioStreams)
var recovered interface{}
@ -873,7 +872,7 @@ func TestDrain(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, outBuf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, outBuf, errBuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdDrain(tf, ioStreams)
var recovered interface{}

View File

@ -19,7 +19,8 @@ package edit
import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/cmd/util/editor"
"k8s.io/kubectl/pkg/util/completion"
@ -70,7 +71,7 @@ var (
)
// NewCmdEdit creates the `edit` command
func NewCmdEdit(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdEdit(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := editor.NewEditOptions(editor.NormalEditMode, ioStreams)
cmd := &cobra.Command{
Use: "edit (RESOURCE/NAME | -f FILENAME)",

View File

@ -34,7 +34,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
"k8s.io/kubectl/pkg/cmd/apply"
@ -227,7 +227,7 @@ func TestEdit(t *testing.T) {
}
tf.WithNamespace(testcase.Namespace)
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, errBuf := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
var cmd *cobra.Command
switch testcase.Mode {

View File

@ -35,6 +35,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
runtimeresource "k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes"
@ -84,11 +85,11 @@ type EventsFlags struct {
ForObject string
FilterTypes []string
ChunkSize int64
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewEventsFlags returns a default EventsFlags
func NewEventsFlags(restClientGetter genericclioptions.RESTClientGetter, streams genericclioptions.IOStreams) *EventsFlags {
func NewEventsFlags(restClientGetter genericclioptions.RESTClientGetter, streams genericiooptions.IOStreams) *EventsFlags {
return &EventsFlags{
RESTClientGetter: restClientGetter,
PrintFlags: genericclioptions.NewPrintFlags("events").WithTypeSetter(scheme.Scheme),
@ -112,11 +113,11 @@ type EventsOptions struct {
PrintObj printers.ResourcePrinterFunc
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCmdEvents creates a new events command
func NewCmdEvents(restClientGetter genericclioptions.RESTClientGetter, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdEvents(restClientGetter genericclioptions.RESTClientGetter, streams genericiooptions.IOStreams) *cobra.Command {
flags := NewEventsFlags(restClientGetter, streams)
cmd := &cobra.Command{

View File

@ -18,17 +18,17 @@ package events
import (
"io"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"net/http"
"testing"
"time"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
)
@ -108,7 +108,7 @@ func getFakeEvents() *corev1.EventList {
func TestEventIsSorted(t *testing.T) {
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
clientset, err := kubernetes.NewForConfig(cmdtesting.DefaultClientConfig())
if err != err {
t.Fatal(err)
@ -146,7 +146,7 @@ otherfoo 15m (x3 over 25m) Normal ScalingReplicaSet Deployment/bar S
func TestEventNoHeaders(t *testing.T) {
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
clientset, err := kubernetes.NewForConfig(cmdtesting.DefaultClientConfig())
if err != err {
t.Fatal(err)
@ -183,7 +183,7 @@ otherfoo 15m (x3 over 25m) Normal ScalingReplicaSet Deployment/bar Sc
func TestEventFiltered(t *testing.T) {
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
clientset, err := kubernetes.NewForConfig(cmdtesting.DefaultClientConfig())
if err != err {
t.Fatal(err)

View File

@ -28,6 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
coreclient "k8s.io/client-go/kubernetes/typed/core/v1"
restclient "k8s.io/client-go/rest"
@ -76,7 +77,7 @@ const (
defaultPodExecTimeout = 60 * time.Second
)
func NewCmdExec(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdExec(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
options := &ExecOptions{
StreamOptions: StreamOptions{
IOStreams: streams,
@ -143,7 +144,7 @@ type StreamOptions struct {
// InterruptParent, if set, is used to handle interrupts while attached
InterruptParent *interrupt.Handler
genericclioptions.IOStreams
genericiooptions.IOStreams
// for testing
overrideStreams func() (io.ReadCloser, io.Writer, io.Writer)

View File

@ -29,7 +29,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
"k8s.io/client-go/tools/remotecommand"
@ -142,7 +142,7 @@ func TestPodAndContainer(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
cmd := NewCmdExec(tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdExec(tf, genericiooptions.NewTestIOStreamsDiscard())
options := test.p
options.ErrOut = bytes.NewBuffer([]byte{})
options.Out = bytes.NewBuffer([]byte{})
@ -235,11 +235,11 @@ func TestExec(t *testing.T) {
StreamOptions: StreamOptions{
PodName: "foo",
ContainerName: "bar",
IOStreams: genericclioptions.NewTestIOStreamsDiscard(),
IOStreams: genericiooptions.NewTestIOStreamsDiscard(),
},
Executor: ex,
}
cmd := NewCmdExec(tf, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdExec(tf, genericiooptions.NewTestIOStreamsDiscard())
args := []string{"pod/foo", "command"}
if err := params.Complete(tf, cmd, args, -1); err != nil {
t.Fatal(err)
@ -290,7 +290,7 @@ func execPod() *corev1.Pod {
}
func TestSetupTTY(t *testing.T) {
streams, _, _, stderr := genericclioptions.NewTestIOStreams()
streams, _, _, stderr := genericiooptions.NewTestIOStreams()
// test 1 - don't attach stdin
o := &StreamOptions{

View File

@ -23,7 +23,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
openapiclient "k8s.io/client-go/openapi"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/explain"
@ -57,7 +57,7 @@ var (
)
type ExplainOptions struct {
genericclioptions.IOStreams
genericiooptions.IOStreams
CmdParent string
APIVersion string
@ -76,7 +76,7 @@ type ExplainOptions struct {
OpenAPIV3Client openapiclient.Client
}
func NewExplainOptions(parent string, streams genericclioptions.IOStreams) *ExplainOptions {
func NewExplainOptions(parent string, streams genericiooptions.IOStreams) *ExplainOptions {
return &ExplainOptions{
IOStreams: streams,
CmdParent: parent,
@ -85,7 +85,7 @@ func NewExplainOptions(parent string, streams genericclioptions.IOStreams) *Expl
}
// NewCmdExplain returns a cobra command for swagger docs
func NewCmdExplain(parent string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdExplain(parent string, f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := NewExplainOptions(parent, streams)
cmd := &cobra.Command{

View File

@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
sptest "k8s.io/apimachinery/pkg/util/strategicpatch/testing"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/discovery"
openapiclient "k8s.io/client-go/openapi"
"k8s.io/client-go/rest"
@ -57,8 +57,8 @@ func TestExplainInvalidArgs(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
opts := explain.NewExplainOptions("kubectl", genericclioptions.NewTestIOStreamsDiscard())
cmd := explain.NewCmdExplain("kubectl", tf, genericclioptions.NewTestIOStreamsDiscard())
opts := explain.NewExplainOptions("kubectl", genericiooptions.NewTestIOStreamsDiscard())
cmd := explain.NewCmdExplain("kubectl", tf, genericiooptions.NewTestIOStreamsDiscard())
err := opts.Complete(tf, cmd, []string{})
if err != nil {
t.Fatalf("unexpected error %v", err)
@ -84,8 +84,8 @@ func TestExplainNotExistResource(t *testing.T) {
tf := cmdtesting.NewTestFactory()
defer tf.Cleanup()
opts := explain.NewExplainOptions("kubectl", genericclioptions.NewTestIOStreamsDiscard())
cmd := explain.NewCmdExplain("kubectl", tf, genericclioptions.NewTestIOStreamsDiscard())
opts := explain.NewExplainOptions("kubectl", genericiooptions.NewTestIOStreamsDiscard())
cmd := explain.NewCmdExplain("kubectl", tf, genericiooptions.NewTestIOStreamsDiscard())
err := opts.Complete(tf, cmd, []string{"foo"})
if err != nil {
t.Fatalf("unexpected error %v", err)
@ -208,7 +208,7 @@ func runExplainTestCases(t *testing.T, cases []explainTestCase) {
tf.OpenAPISchemaFunc = FakeOpenAPISchema.OpenAPISchemaFn
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
type catchFatal error

View File

@ -34,6 +34,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -131,12 +132,12 @@ type ExposeServiceOptions struct {
ClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
Recorder genericclioptions.Recorder
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewExposeServiceOptions creates a new ExposeServiceOptions and return a pointer to the
// struct
func NewExposeServiceOptions(ioStreams genericclioptions.IOStreams) *ExposeServiceOptions {
func NewExposeServiceOptions(ioStreams genericiooptions.IOStreams) *ExposeServiceOptions {
return &ExposeServiceOptions{
RecordFlags: genericclioptions.NewRecordFlags(),
PrintFlags: genericclioptions.NewPrintFlags("exposed").WithTypeSetter(scheme.Scheme),
@ -147,7 +148,7 @@ func NewExposeServiceOptions(ioStreams genericclioptions.IOStreams) *ExposeServi
}
// NewCmdExposeService is a command to expose the service from user's input
func NewCmdExposeService(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdExposeService(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := NewExposeServiceOptions(streams)
validArgs := []string{}

View File

@ -28,7 +28,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
"k8s.io/kubectl/pkg/scheme"
@ -658,7 +658,7 @@ func TestRunExposeService(t *testing.T) {
}),
}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdExposeService(tf, ioStreams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -834,7 +834,7 @@ status:
}),
}
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdExposeService(tf, ioStreams)
cmd.SetOut(buf)
cmd.Flags().Set("protocol", "UDP")

View File

@ -36,7 +36,7 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
kubernetesscheme "k8s.io/client-go/kubernetes/scheme"
@ -82,7 +82,7 @@ type GetOptions struct {
NoHeaders bool
IgnoreNotFound bool
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -142,7 +142,7 @@ const (
var supportedSubresources = []string{"status", "scale"}
// NewGetOptions returns a GetOptions with default chunk size 500.
func NewGetOptions(parent string, streams genericclioptions.IOStreams) *GetOptions {
func NewGetOptions(parent string, streams genericiooptions.IOStreams) *GetOptions {
return &GetOptions{
PrintFlags: NewGetPrintFlags(),
CmdParent: parent,
@ -155,7 +155,7 @@ func NewGetOptions(parent string, streams genericclioptions.IOStreams) *GetOptio
// NewCmdGet creates a command object for the generic "get" action, which
// retrieves one or more resources from a server.
func NewCmdGet(parent string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdGet(parent string, f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := NewGetOptions(parent, streams)
cmd := &cobra.Command{

View File

@ -38,7 +38,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
@ -101,7 +101,7 @@ func TestGetUnknownSchemaObject(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -145,7 +145,7 @@ func TestGetSchemaObject(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.Run(cmd, []string{"replicationcontrollers", "foo"})
@ -166,7 +166,7 @@ func TestGetObjects(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -192,7 +192,7 @@ func TestGetObjectSubresourceStatus(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &replicationcontrollers.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -220,7 +220,7 @@ func TestGetObjectSubresourceScale(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: replicationControllersScaleSubresourceTableObjBody(codec, replicationcontrollers.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -248,7 +248,7 @@ func TestGetTableObjects(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: podTableObjBody(codec, pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -274,7 +274,7 @@ func TestGetV1TableObjects(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: podV1TableObjBody(codec, pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -300,7 +300,7 @@ func TestGetObjectsShowKind(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -327,7 +327,7 @@ func TestGetTableObjectsShowKind(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: podTableObjBody(codec, pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -381,7 +381,7 @@ func TestGetMultipleResourceTypesShowKinds(t *testing.T) {
}),
}
streams, _, buf, bufErr := genericclioptions.NewTestIOStreams()
streams, _, buf, bufErr := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -443,7 +443,7 @@ func TestGetMultipleTableResourceTypesShowKinds(t *testing.T) {
}),
}
streams, _, buf, bufErr := genericclioptions.NewTestIOStreams()
streams, _, buf, bufErr := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -505,7 +505,7 @@ func TestNoBlankLinesForGetMultipleTableResource(t *testing.T) {
}),
}
streams, _, buf, bufErr := genericclioptions.NewTestIOStreams()
streams, _, buf, bufErr := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -575,7 +575,7 @@ func TestNoBlankLinesForGetAll(t *testing.T) {
}),
}
streams, _, buf, errbuf := genericclioptions.NewTestIOStreams()
streams, _, buf, errbuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -602,7 +602,7 @@ func TestNotFoundMessageForGetNonNamespacedResources(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: emptyTableObjBody(codec)},
}
streams, _, buf, errbuf := genericclioptions.NewTestIOStreams()
streams, _, buf, errbuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -631,7 +631,7 @@ func TestGetObjectsShowLabels(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -658,7 +658,7 @@ func TestGetTableObjectsShowLabels(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: podTableObjBody(codec, pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -694,7 +694,7 @@ func TestGetEmptyTable(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: emptyTable},
}
streams, _, buf, errbuf := genericclioptions.NewTestIOStreams()
streams, _, buf, errbuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -745,7 +745,7 @@ func TestGetObjectIgnoreNotFound(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -772,7 +772,7 @@ func TestEmptyResult(t *testing.T) {
}),
}
streams, _, _, errbuf := genericclioptions.NewTestIOStreams()
streams, _, _, errbuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
// we're assuming that an empty file is being passed from stdin
cmd.Flags().Set("filename", "-")
@ -797,7 +797,7 @@ func TestEmptyResultJSON(t *testing.T) {
}),
}
streams, _, outbuf, errbuf := genericclioptions.NewTestIOStreams()
streams, _, outbuf, errbuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
// we're assuming that an empty file is being passed from stdin
cmd.Flags().Set("filename", "-")
@ -861,7 +861,7 @@ func TestGetSortedObjects(t *testing.T) {
}
tf.ClientConfigVal = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &corev1.SchemeGroupVersion}}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -901,7 +901,7 @@ func TestGetSortedObjectsUnstructuredTable(t *testing.T) {
}
tf.ClientConfigVal = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: &corev1.SchemeGroupVersion}}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1134,7 +1134,7 @@ func TestGetObjectsIdentifiedByFile(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1161,7 +1161,7 @@ func TestGetTableObjectsIdentifiedByFile(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: podTableObjBody(codec, pods.Items[0])},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1188,7 +1188,7 @@ func TestGetListObjects(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, pods)},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1215,7 +1215,7 @@ func TestGetListTableObjects(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: podTableObjBody(codec, pods.Items...)},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1242,7 +1242,7 @@ func TestGetListComponentStatus(t *testing.T) {
Resp: &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: componentStatusTableObjBody(codec, (*statuses).Items...)},
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1292,7 +1292,7 @@ func TestGetMixedGenericObjects(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1342,7 +1342,7 @@ func TestGetMultipleTypeObjects(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1382,7 +1382,7 @@ func TestGetMultipleTypeTableObjects(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1423,7 +1423,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1526,7 +1526,7 @@ func TestGetMultipleTypeObjectsWithLabelSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1571,7 +1571,7 @@ func TestGetMultipleTypeTableObjectsWithLabelSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1616,7 +1616,7 @@ func TestGetMultipleTypeObjectsWithFieldSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1661,7 +1661,7 @@ func TestGetMultipleTypeTableObjectsWithFieldSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1708,7 +1708,7 @@ func TestGetMultipleTypeObjectsWithDirectReference(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1753,7 +1753,7 @@ func TestGetMultipleTypeTableObjectsWithDirectReference(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1909,7 +1909,7 @@ func TestWatchLabelSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -1961,7 +1961,7 @@ func TestWatchTableLabelSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2013,7 +2013,7 @@ func TestWatchFieldSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2065,7 +2065,7 @@ func TestWatchTableFieldSelector(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2111,7 +2111,7 @@ func TestWatchResource(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2156,7 +2156,7 @@ func TestWatchStatus(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2203,7 +2203,7 @@ func TestWatchTableResource(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2310,7 +2310,7 @@ func TestWatchResourceTable(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2523,7 +2523,7 @@ pod/foo
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2570,7 +2570,7 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2615,7 +2615,7 @@ func TestWatchOnlyResource(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2658,7 +2658,7 @@ func TestWatchOnlyTableResource(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2704,7 +2704,7 @@ func TestWatchOnlyList(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)
@ -2750,7 +2750,7 @@ func TestWatchOnlyTableList(t *testing.T) {
}),
}
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdGet("kubectl", tf, streams)
cmd.SetOut(buf)
cmd.SetErr(buf)

View File

@ -18,7 +18,8 @@ package kustomize
import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
"sigs.k8s.io/kustomize/kustomize/v5/commands/build"
@ -26,7 +27,7 @@ import (
)
// NewCmdKustomize returns an adapted kustomize build command.
func NewCmdKustomize(streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdKustomize(streams genericiooptions.IOStreams) *cobra.Command {
h := build.MakeHelp("kubectl", "kustomize")
return build.NewCmdBuild(
filesys.MakeFsOnDisk(),

View File

@ -35,6 +35,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -85,7 +86,7 @@ type LabelOptions struct {
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
// Common shared fields
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -118,7 +119,7 @@ var (
kubectl label pods foo bar-`))
)
func NewLabelOptions(ioStreams genericclioptions.IOStreams) *LabelOptions {
func NewLabelOptions(ioStreams genericiooptions.IOStreams) *LabelOptions {
return &LabelOptions{
RecordFlags: genericclioptions.NewRecordFlags(),
Recorder: genericclioptions.NoopRecorder{},
@ -129,7 +130,7 @@ func NewLabelOptions(ioStreams genericclioptions.IOStreams) *LabelOptions {
}
}
func NewCmdLabel(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdLabel(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewLabelOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -30,7 +30,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -346,7 +346,7 @@ func TestLabelErrors(t *testing.T) {
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, _, _ := genericiooptions.NewTestIOStreams()
buf := bytes.NewBuffer([]byte{})
cmd := NewCmdLabel(tf, ioStreams)
cmd.SetOut(buf)
@ -406,7 +406,7 @@ func TestLabelForResourceFromFile(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdLabel(tf, ioStreams)
opts := NewLabelOptions(ioStreams)
opts.Filenames = []string{"../../../testdata/controller.yaml"}
@ -438,7 +438,7 @@ func TestLabelLocal(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdLabel(tf, ioStreams)
opts := NewLabelOptions(ioStreams)
opts.Filenames = []string{"../../../testdata/controller.yaml"}
@ -495,7 +495,7 @@ func TestLabelMultipleObjects(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
ioStreams, _, buf, _ := genericiooptions.NewTestIOStreams()
opts := NewLabelOptions(ioStreams)
opts.all = true
cmd := NewCmdLabel(tf, ioStreams)
@ -564,7 +564,7 @@ func TestLabelResourceVersion(t *testing.T) {
}
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
iostreams, _, bufOut, _ := genericclioptions.NewTestIOStreams()
iostreams, _, bufOut, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdLabel(tf, iostreams)
cmd.SetOut(bufOut)
cmd.SetErr(bufOut)
@ -689,7 +689,7 @@ pod/foo not labeled
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
iostreams, _, bufOut, _ := genericclioptions.NewTestIOStreams()
iostreams, _, bufOut, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdLabel(tf, iostreams)
cmd.SetOut(bufOut)
cmd.SetErr(bufOut)

View File

@ -32,6 +32,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/rest"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/polymorphichelpers"
@ -125,14 +126,14 @@ type LogsOptions struct {
RESTClientGetter genericclioptions.RESTClientGetter
LogsForObject polymorphichelpers.LogsForObjectFunc
genericclioptions.IOStreams
genericiooptions.IOStreams
TailSpecified bool
containerNameFromRefSpecRegexp *regexp.Regexp
}
func NewLogsOptions(streams genericclioptions.IOStreams, allContainers bool) *LogsOptions {
func NewLogsOptions(streams genericiooptions.IOStreams, allContainers bool) *LogsOptions {
return &LogsOptions{
IOStreams: streams,
AllContainers: allContainers,
@ -144,7 +145,7 @@ func NewLogsOptions(streams genericclioptions.IOStreams, allContainers bool) *Lo
}
// NewCmdLogs creates a new pod logs command
func NewCmdLogs(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdLogs(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := NewLogsOptions(streams, false)
cmd := &cobra.Command{

View File

@ -33,6 +33,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -42,13 +43,13 @@ import (
func TestLog(t *testing.T) {
tests := []struct {
name string
opts func(genericclioptions.IOStreams) *LogsOptions
opts func(genericiooptions.IOStreams) *LogsOptions
expectedErr string
expectedOutSubstrings []string
}{
{
name: "v1 - pod log",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -69,7 +70,7 @@ func TestLog(t *testing.T) {
},
{
name: "pod logs with prefix",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -91,7 +92,7 @@ func TestLog(t *testing.T) {
},
{
name: "pod logs with prefix: init container",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -113,7 +114,7 @@ func TestLog(t *testing.T) {
},
{
name: "pod logs with prefix: ephemeral container",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -135,7 +136,7 @@ func TestLog(t *testing.T) {
},
{
name: "get logs from multiple requests sequentially",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -169,7 +170,7 @@ func TestLog(t *testing.T) {
},
{
name: "follow logs from multiple requests concurrently",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
wg := &sync.WaitGroup{}
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
@ -207,7 +208,7 @@ func TestLog(t *testing.T) {
},
{
name: "fail to follow logs from multiple requests when there are more logs sources then MaxFollowConcurrency allows",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
wg := &sync.WaitGroup{}
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
@ -242,7 +243,7 @@ func TestLog(t *testing.T) {
},
{
name: "fail if LogsForObject fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, false)
o.LogsForObject = func(restClientGetter genericclioptions.RESTClientGetter, object, options runtime.Object, timeout time.Duration, allContainers bool) (map[corev1.ObjectReference]restclient.ResponseWrapper, error) {
return nil, errors.New("Error from the LogsForObject")
@ -253,7 +254,7 @@ func TestLog(t *testing.T) {
},
{
name: "fail to get logs, if ConsumeRequestFn fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -280,7 +281,7 @@ func TestLog(t *testing.T) {
},
{
name: "follow logs from multiple requests concurrently with prefix",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
wg := &sync.WaitGroup{}
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
@ -319,7 +320,7 @@ func TestLog(t *testing.T) {
},
{
name: "fail to follow logs from multiple requests, if ConsumeRequestFn fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
wg := &sync.WaitGroup{}
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
@ -355,7 +356,7 @@ func TestLog(t *testing.T) {
},
{
name: "fail to follow logs, if ConsumeRequestFn fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -378,7 +379,7 @@ func TestLog(t *testing.T) {
},
{
name: "get logs from multiple requests and ignores the error if the container fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -413,7 +414,7 @@ func TestLog(t *testing.T) {
},
{
name: "get logs from multiple requests and an container fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -438,7 +439,7 @@ func TestLog(t *testing.T) {
},
{
name: "follow logs from multiple requests and ignores the error if the container fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -474,7 +475,7 @@ func TestLog(t *testing.T) {
},
{
name: "follow logs from multiple requests and an container fails",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
mock := &logTestMock{
logsForObjectRequests: map[corev1.ObjectReference]restclient.ResponseWrapper{
{
@ -504,7 +505,7 @@ func TestLog(t *testing.T) {
tf := cmdtesting.NewTestFactory().WithNamespace("test")
defer tf.Cleanup()
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
streams, _, buf, _ := genericiooptions.NewTestIOStreams()
opts := test.opts(streams)
opts.Namespace = "test"
@ -555,12 +556,12 @@ func TestValidateLogOptions(t *testing.T) {
tests := []struct {
name string
args []string
opts func(genericclioptions.IOStreams) *LogsOptions
opts func(genericiooptions.IOStreams) *LogsOptions
expected string
}{
{
name: "since & since-time",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, false)
o.SinceSeconds = time.Hour
o.SinceTime = "2006-01-02T15:04:05Z"
@ -578,7 +579,7 @@ func TestValidateLogOptions(t *testing.T) {
},
{
name: "negative since-time",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, false)
o.SinceSeconds = -1 * time.Second
@ -595,7 +596,7 @@ func TestValidateLogOptions(t *testing.T) {
},
{
name: "negative limit-bytes",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, false)
o.LimitBytes = -100
@ -612,7 +613,7 @@ func TestValidateLogOptions(t *testing.T) {
},
{
name: "negative tail",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, false)
o.Tail = -100
@ -629,7 +630,7 @@ func TestValidateLogOptions(t *testing.T) {
},
{
name: "container name combined with --all-containers",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, true)
o.Container = "my-container"
@ -646,7 +647,7 @@ func TestValidateLogOptions(t *testing.T) {
},
{
name: "container name combined with second argument",
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, false)
o.Container = "my-container"
o.ContainerNameSpecified = true
@ -664,7 +665,7 @@ func TestValidateLogOptions(t *testing.T) {
},
}
for _, test := range tests {
streams := genericclioptions.NewTestIOStreamsDiscard()
streams := genericiooptions.NewTestIOStreamsDiscard()
o := test.opts(streams)
o.Resources = test.args
@ -687,13 +688,13 @@ func TestLogComplete(t *testing.T) {
tests := []struct {
name string
args []string
opts func(genericclioptions.IOStreams) *LogsOptions
opts func(genericiooptions.IOStreams) *LogsOptions
expected string
}{
{
name: "One args case",
args: []string{"foo"},
opts: func(streams genericclioptions.IOStreams) *LogsOptions {
opts: func(streams genericiooptions.IOStreams) *LogsOptions {
o := NewLogsOptions(streams, false)
o.Selector = "foo"
return o
@ -702,12 +703,12 @@ func TestLogComplete(t *testing.T) {
},
}
for _, test := range tests {
cmd := NewCmdLogs(f, genericclioptions.NewTestIOStreamsDiscard())
cmd := NewCmdLogs(f, genericiooptions.NewTestIOStreamsDiscard())
out := ""
// checkErr breaks tests in case of errors, plus we just
// need to check errors returned by the command validation
o := test.opts(genericclioptions.NewTestIOStreamsDiscard())
o := test.opts(genericiooptions.NewTestIOStreamsDiscard())
err := o.Complete(f, cmd, test.args)
if err == nil {
t.Fatalf("expected error %q, got none", test.expected)
@ -811,7 +812,7 @@ func TestNoResourceFoundMessage(t *testing.T) {
}),
}
streams, _, buf, errbuf := genericclioptions.NewTestIOStreams()
streams, _, buf, errbuf := genericiooptions.NewTestIOStreams()
cmd := NewCmdLogs(tf, streams)
o := NewLogsOptions(streams, false)
o.Selector = "foo"

View File

@ -37,6 +37,7 @@ import (
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
@ -74,7 +75,7 @@ type PatchOptions struct {
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
fieldManager string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
var (
@ -107,7 +108,7 @@ var (
var supportedSubresources = []string{"status", "scale"}
func NewPatchOptions(ioStreams genericclioptions.IOStreams) *PatchOptions {
func NewPatchOptions(ioStreams genericiooptions.IOStreams) *PatchOptions {
return &PatchOptions{
RecordFlags: genericclioptions.NewRecordFlags(),
Recorder: genericclioptions.NoopRecorder{},
@ -116,7 +117,7 @@ func NewPatchOptions(ioStreams genericclioptions.IOStreams) *PatchOptions {
}
}
func NewCmdPatch(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdPatch(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
o := NewPatchOptions(ioStreams)
cmd := &cobra.Command{

View File

@ -23,7 +23,7 @@ import (
jsonpath "github.com/exponent-io/jsonpath"
corev1 "k8s.io/api/core/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@ -57,7 +57,7 @@ func TestPatchObject(t *testing.T) {
}
}),
}
stream, _, buf, _ := genericclioptions.NewTestIOStreams()
stream, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdPatch(tf, stream)
cmd.Flags().Set("namespace", "test")
@ -91,7 +91,7 @@ func TestPatchObjectFromFile(t *testing.T) {
}
}),
}
stream, _, buf, _ := genericclioptions.NewTestIOStreams()
stream, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdPatch(tf, stream)
cmd.Flags().Set("namespace", "test")
@ -138,7 +138,7 @@ func TestPatchNoop(t *testing.T) {
patchObject.Annotations = map[string]string{}
}
patchObject.Annotations["foo"] = "bar"
stream, _, buf, _ := genericclioptions.NewTestIOStreams()
stream, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdPatch(tf, stream)
cmd.Flags().Set("namespace", "test")
cmd.Flags().Set("patch", `{"metadata":{"annotations":{"foo":"bar"}}}`)
@ -177,7 +177,7 @@ func TestPatchObjectFromFileOutput(t *testing.T) {
}
}),
}
stream, _, buf, _ := genericclioptions.NewTestIOStreams()
stream, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdPatch(tf, stream)
cmd.Flags().Set("namespace", "test")
@ -222,7 +222,7 @@ func TestPatchSubresource(t *testing.T) {
}
}),
}
stream, _, buf, _ := genericclioptions.NewTestIOStreams()
stream, _, buf, _ := genericiooptions.NewTestIOStreams()
cmd := NewCmdPatch(tf, stream)
cmd.Flags().Set("namespace", "test")

View File

@ -26,7 +26,8 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
@ -58,7 +59,7 @@ var (
ValidPluginFilenamePrefixes = []string{"kubectl"}
)
func NewCmdPlugin(streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdPlugin(streams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "plugin [flags]",
DisableFlagsInUseLine: true,
@ -79,11 +80,11 @@ type PluginListOptions struct {
PluginPaths []string
genericclioptions.IOStreams
genericiooptions.IOStreams
}
// NewCmdPluginList provides a way to list all plugin executables visible to kubectl
func NewCmdPluginList(streams genericclioptions.IOStreams) *cobra.Command {
func NewCmdPluginList(streams genericiooptions.IOStreams) *cobra.Command {
o := &PluginListOptions{
IOStreams: streams,
}

View File

@ -27,7 +27,8 @@ import (
"strings"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)
// SetupPluginCompletion adds a Cobra command to the command tree for each
@ -81,7 +82,7 @@ func SetupPluginCompletion(cmd *cobra.Command, args []string) {
// for each plugin so that the completion logic knows about the plugins
func addPluginCommands(cmd *cobra.Command) {
kubectl := cmd.Root()
streams := genericclioptions.IOStreams{
streams := genericiooptions.IOStreams{
In: &bytes.Buffer{},
Out: io.Discard,
ErrOut: io.Discard,

Some files were not shown because too many files have changed in this diff Show More