mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
Move away from deprecated term.AllowsColorOutput (#135454)
* Move away from deprecated term.AllowsColorOutput * Move away from term.IsTerminal
This commit is contained in:
@@ -42,7 +42,6 @@ import (
|
||||
"k8s.io/kubectl/pkg/describe"
|
||||
rbacutil "k8s.io/kubectl/pkg/util/rbac"
|
||||
"k8s.io/kubectl/pkg/util/templates"
|
||||
"k8s.io/kubectl/pkg/util/term"
|
||||
)
|
||||
|
||||
// CanIOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
|
||||
@@ -154,7 +153,7 @@ func NewCmdCanI(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Co
|
||||
func (o *CanIOptions) Complete(f cmdutil.Factory, args []string) error {
|
||||
// Set default WarningPrinter if not already set.
|
||||
if o.WarningPrinter == nil {
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: term.AllowsColorOutput(o.ErrOut)})
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: printers.AllowsColorOutput(o.ErrOut)})
|
||||
}
|
||||
|
||||
if o.List {
|
||||
|
||||
@@ -25,7 +25,9 @@ import (
|
||||
|
||||
"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/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
cliflag "k8s.io/component-base/cli/flag"
|
||||
@@ -53,6 +55,7 @@ import (
|
||||
"k8s.io/kubectl/pkg/cmd/explain"
|
||||
"k8s.io/kubectl/pkg/cmd/expose"
|
||||
"k8s.io/kubectl/pkg/cmd/get"
|
||||
"k8s.io/kubectl/pkg/cmd/kustomize"
|
||||
"k8s.io/kubectl/pkg/cmd/label"
|
||||
"k8s.io/kubectl/pkg/cmd/logs"
|
||||
"k8s.io/kubectl/pkg/cmd/options"
|
||||
@@ -74,10 +77,6 @@ import (
|
||||
utilcomp "k8s.io/kubectl/pkg/util/completion"
|
||||
"k8s.io/kubectl/pkg/util/i18n"
|
||||
"k8s.io/kubectl/pkg/util/templates"
|
||||
"k8s.io/kubectl/pkg/util/term"
|
||||
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/kubectl/pkg/cmd/kustomize"
|
||||
)
|
||||
|
||||
type KubectlOptions struct {
|
||||
@@ -163,7 +162,7 @@ func NewDefaultKubectlCommandWithArgs(o KubectlOptions) *cobra.Command {
|
||||
|
||||
// NewKubectlCommand creates the `kubectl` command and its nested children.
|
||||
func NewKubectlCommand(o KubectlOptions) *cobra.Command {
|
||||
warningHandler := rest.NewWarningWriter(o.IOStreams.ErrOut, rest.WarningWriterOptions{Deduplicate: true, Color: term.AllowsColorOutput(o.IOStreams.ErrOut)})
|
||||
warningHandler := rest.NewWarningWriter(o.IOStreams.ErrOut, rest.WarningWriterOptions{Deduplicate: true, Color: printers.AllowsColorOutput(o.IOStreams.ErrOut)})
|
||||
warningsAsErrors := false
|
||||
var finishProfiling func() error
|
||||
// Parent command to which all subcommands are added.
|
||||
|
||||
@@ -32,12 +32,12 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/genericiooptions"
|
||||
"k8s.io/cli-runtime/pkg/printers"
|
||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
"k8s.io/kubectl/pkg/util/completion"
|
||||
"k8s.io/kubectl/pkg/util/templates"
|
||||
"k8s.io/kubectl/pkg/util/term"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
@@ -264,7 +264,7 @@ func (o *TokenOptions) Run() error {
|
||||
return o.PrintObj(response)
|
||||
}
|
||||
|
||||
if term.IsTerminal(o.Out) {
|
||||
if printers.IsTerminal(o.Out) {
|
||||
// include a newline when printing interactively
|
||||
fmt.Fprintf(o.Out, "%s\n", response.Status.Token)
|
||||
} else {
|
||||
|
||||
@@ -54,7 +54,6 @@ import (
|
||||
"k8s.io/kubectl/pkg/util/i18n"
|
||||
"k8s.io/kubectl/pkg/util/interrupt"
|
||||
"k8s.io/kubectl/pkg/util/templates"
|
||||
"k8s.io/kubectl/pkg/util/term"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
@@ -268,7 +267,7 @@ func (o *DebugOptions) Complete(restClientGetter genericclioptions.RESTClientGet
|
||||
|
||||
// Set default WarningPrinter
|
||||
if o.WarningPrinter == nil {
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: term.AllowsColorOutput(o.ErrOut)})
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: printers.AllowsColorOutput(o.ErrOut)})
|
||||
}
|
||||
|
||||
if o.Applier == nil {
|
||||
|
||||
@@ -40,7 +40,6 @@ import (
|
||||
"k8s.io/kubectl/pkg/util/completion"
|
||||
"k8s.io/kubectl/pkg/util/i18n"
|
||||
"k8s.io/kubectl/pkg/util/templates"
|
||||
"k8s.io/kubectl/pkg/util/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -205,7 +204,7 @@ func (o *DeleteOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Co
|
||||
|
||||
// Set default WarningPrinter if not already set.
|
||||
if o.WarningPrinter == nil {
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: term.AllowsColorOutput(o.ErrOut)})
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: printers.AllowsColorOutput(o.ErrOut)})
|
||||
}
|
||||
|
||||
if len(o.Raw) != 0 {
|
||||
|
||||
@@ -39,7 +39,6 @@ import (
|
||||
"k8s.io/kubectl/pkg/util/completion"
|
||||
"k8s.io/kubectl/pkg/util/i18n"
|
||||
"k8s.io/kubectl/pkg/util/templates"
|
||||
"k8s.io/kubectl/pkg/util/term"
|
||||
)
|
||||
|
||||
type DrainCmdOptions struct {
|
||||
@@ -287,7 +286,7 @@ func (o *DrainCmdOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
||||
|
||||
// Set default WarningPrinter if not already set.
|
||||
if o.WarningPrinter == nil {
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: term.AllowsColorOutput(o.ErrOut)})
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: printers.AllowsColorOutput(o.ErrOut)})
|
||||
}
|
||||
|
||||
builder := f.NewBuilder().
|
||||
|
||||
@@ -41,7 +41,6 @@ import (
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
"k8s.io/kubectl/pkg/util/i18n"
|
||||
"k8s.io/kubectl/pkg/util/templates"
|
||||
"k8s.io/kubectl/pkg/util/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -250,7 +249,7 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
|
||||
o.builder = f.NewBuilder
|
||||
// Set default WarningPrinter if not already set.
|
||||
if o.WarningPrinter == nil {
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: term.AllowsColorOutput(o.ErrOut)})
|
||||
o.WarningPrinter = printers.NewWarningPrinter(o.ErrOut, printers.WarningPrinterOptions{Color: printers.AllowsColorOutput(o.ErrOut)})
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user