mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Refactor commands to use new factory method
This commit is contained in:
@@ -35,9 +35,10 @@ import (
|
||||
"k8s.io/client-go/rest/fake"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||
"k8s.io/kubernetes/pkg/util/strings"
|
||||
)
|
||||
|
||||
@@ -97,12 +98,12 @@ func (t *testPrinter) AfterPrint(output io.Writer, res string) error {
|
||||
|
||||
type testDescriber struct {
|
||||
Name, Namespace string
|
||||
Settings kubectl.DescriberSettings
|
||||
Settings printers.DescriberSettings
|
||||
Output string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (t *testDescriber) Describe(namespace, name string, describerSettings kubectl.DescriberSettings) (output string, err error) {
|
||||
func (t *testDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (output string, err error) {
|
||||
t.Namespace, t.Name = namespace, name
|
||||
t.Settings = describerSettings
|
||||
return t.Output, t.Err
|
||||
@@ -146,10 +147,12 @@ func stringBody(body string) io.ReadCloser {
|
||||
|
||||
func Example_printReplicationControllerWithNamespace() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
WithNamespace: true,
|
||||
ColumnLabels: []string{},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -197,10 +200,12 @@ func Example_printReplicationControllerWithNamespace() {
|
||||
|
||||
func Example_printMultiContainersReplicationControllerWithWide() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
Wide: true,
|
||||
ColumnLabels: []string{},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -250,9 +255,11 @@ func Example_printMultiContainersReplicationControllerWithWide() {
|
||||
|
||||
func Example_printReplicationController() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -302,10 +309,12 @@ func Example_printReplicationController() {
|
||||
|
||||
func Example_printPodWithWideFormat() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
Wide: true,
|
||||
ColumnLabels: []string{},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -343,10 +352,12 @@ func Example_printPodWithWideFormat() {
|
||||
|
||||
func Example_printPodWithShowLabels() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
ShowLabels: true,
|
||||
ColumnLabels: []string{},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -479,9 +490,11 @@ func newAllPhasePodList() *api.PodList {
|
||||
|
||||
func Example_printPodHideTerminated() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
ColumnLabels: []string{},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -512,10 +525,12 @@ func Example_printPodHideTerminated() {
|
||||
|
||||
func Example_printPodShowAll() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
ShowAll: true,
|
||||
ColumnLabels: []string{},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -539,10 +554,12 @@ func Example_printPodShowAll() {
|
||||
|
||||
func Example_printServiceWithNamespacesAndLabels() {
|
||||
f, tf, _, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = kubectl.NewHumanReadablePrinter(kubectl.PrintOptions{
|
||||
p := printers.NewHumanReadablePrinter(printers.PrintOptions{
|
||||
WithNamespace: true,
|
||||
ColumnLabels: []string{"l1"},
|
||||
})
|
||||
printersinternal.AddHandlers(p)
|
||||
tf.Printer = p
|
||||
tf.Client = &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: ns,
|
||||
|
||||
Reference in New Issue
Block a user