mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
fix some golint failures of pkg/kubectl/cmd/attach pkg/kubectl/cmd/autoscale
This commit is contained in:
parent
1c5eed4233
commit
6f7690e139
@ -61,7 +61,7 @@ const (
|
|||||||
defaultPodLogsTimeout = 20 * time.Second
|
defaultPodLogsTimeout = 20 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// AttachOptions declare the arguments accepted by the Exec command
|
// AttachOptions declare the arguments accepted by the Attach command
|
||||||
type AttachOptions struct {
|
type AttachOptions struct {
|
||||||
exec.StreamOptions
|
exec.StreamOptions
|
||||||
|
|
||||||
@ -84,6 +84,7 @@ type AttachOptions struct {
|
|||||||
Config *restclient.Config
|
Config *restclient.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewAttachOptions creates the options for attach
|
||||||
func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
|
func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
|
||||||
return &AttachOptions{
|
return &AttachOptions{
|
||||||
StreamOptions: exec.StreamOptions{
|
StreamOptions: exec.StreamOptions{
|
||||||
@ -94,6 +95,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 genericclioptions.IOStreams) *cobra.Command {
|
||||||
o := NewAttachOptions(streams)
|
o := NewAttachOptions(streams)
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
@ -120,6 +122,7 @@ type RemoteAttach interface {
|
|||||||
Attach(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue remotecommand.TerminalSizeQueue) error
|
Attach(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue remotecommand.TerminalSizeQueue) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultAttachFunc is the default AttachFunc used
|
||||||
func DefaultAttachFunc(o *AttachOptions, containerToAttach *corev1.Container, raw bool, sizeQueue remotecommand.TerminalSizeQueue) func() error {
|
func DefaultAttachFunc(o *AttachOptions, containerToAttach *corev1.Container, raw bool, sizeQueue remotecommand.TerminalSizeQueue) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
restClient, err := restclient.RESTClientFor(o.Config)
|
restClient, err := restclient.RESTClientFor(o.Config)
|
||||||
@ -146,6 +149,7 @@ func DefaultAttachFunc(o *AttachOptions, containerToAttach *corev1.Container, ra
|
|||||||
// DefaultRemoteAttach is the standard implementation of attaching
|
// DefaultRemoteAttach is the standard implementation of attaching
|
||||||
type DefaultRemoteAttach struct{}
|
type DefaultRemoteAttach struct{}
|
||||||
|
|
||||||
|
// Attach executes attach to a running container
|
||||||
func (*DefaultRemoteAttach) Attach(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue remotecommand.TerminalSizeQueue) error {
|
func (*DefaultRemoteAttach) Attach(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue remotecommand.TerminalSizeQueue) error {
|
||||||
exec, err := remotecommand.NewSPDYExecutor(config, method, url)
|
exec, err := remotecommand.NewSPDYExecutor(config, method, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -53,6 +53,7 @@ var (
|
|||||||
kubectl autoscale rc foo --max=5 --cpu-percent=80`))
|
kubectl autoscale rc foo --max=5 --cpu-percent=80`))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AutoscaleOptions declare the arguments accepted by the Autoscale command
|
||||||
type AutoscaleOptions struct {
|
type AutoscaleOptions struct {
|
||||||
FilenameOptions *resource.FilenameOptions
|
FilenameOptions *resource.FilenameOptions
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ type AutoscaleOptions struct {
|
|||||||
genericclioptions.IOStreams
|
genericclioptions.IOStreams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewAutoscaleOptions creates the options for autoscale
|
||||||
func NewAutoscaleOptions(ioStreams genericclioptions.IOStreams) *AutoscaleOptions {
|
func NewAutoscaleOptions(ioStreams genericclioptions.IOStreams) *AutoscaleOptions {
|
||||||
return &AutoscaleOptions{
|
return &AutoscaleOptions{
|
||||||
PrintFlags: genericclioptions.NewPrintFlags("autoscaled").WithTypeSetter(scheme.Scheme),
|
PrintFlags: genericclioptions.NewPrintFlags("autoscaled").WithTypeSetter(scheme.Scheme),
|
||||||
@ -93,6 +95,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 genericclioptions.IOStreams) *cobra.Command {
|
||||||
o := NewAutoscaleOptions(ioStreams)
|
o := NewAutoscaleOptions(ioStreams)
|
||||||
|
|
||||||
@ -128,6 +131,7 @@ func NewCmdAutoscale(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Complete verifies command line arguments and loads data from the command environment
|
||||||
func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
|
func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
|
||||||
var err error
|
var err error
|
||||||
o.dryRun = cmdutil.GetFlagBool(cmd, "dry-run")
|
o.dryRun = cmdutil.GetFlagBool(cmd, "dry-run")
|
||||||
@ -187,6 +191,7 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate checks that the provided attach options are specified.
|
||||||
func (o *AutoscaleOptions) Validate() error {
|
func (o *AutoscaleOptions) Validate() error {
|
||||||
if o.Max < 1 {
|
if o.Max < 1 {
|
||||||
return fmt.Errorf("--max=MAXPODS is required and must be at least 1, max: %d", o.Max)
|
return fmt.Errorf("--max=MAXPODS is required and must be at least 1, max: %d", o.Max)
|
||||||
@ -198,6 +203,7 @@ func (o *AutoscaleOptions) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run performs the execution
|
||||||
func (o *AutoscaleOptions) Run() error {
|
func (o *AutoscaleOptions) Run() error {
|
||||||
r := o.builder.
|
r := o.builder.
|
||||||
Unstructured().
|
Unstructured().
|
||||||
|
Loading…
Reference in New Issue
Block a user