mirror of https://github.com/k3s-io/k3s
Merge pull request #77112 from SataQiu/fix-golint-kubectl-20190427
Fix some golint failures of pkg/kubectl/cmd/attach pkg/kubectl/cmd/autoscalek3s-v1.15.3
commit
3b5e2285b0
|
@ -61,7 +61,7 @@ const (
|
|||
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 {
|
||||
exec.StreamOptions
|
||||
|
||||
|
@ -84,6 +84,7 @@ type AttachOptions struct {
|
|||
Config *restclient.Config
|
||||
}
|
||||
|
||||
// NewAttachOptions creates the options for attach
|
||||
func NewAttachOptions(streams genericclioptions.IOStreams) *AttachOptions {
|
||||
return &AttachOptions{
|
||||
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 {
|
||||
o := NewAttachOptions(streams)
|
||||
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
|
||||
}
|
||||
|
||||
// DefaultAttachFunc is the default AttachFunc used
|
||||
func DefaultAttachFunc(o *AttachOptions, containerToAttach *corev1.Container, raw bool, sizeQueue remotecommand.TerminalSizeQueue) func() error {
|
||||
return func() error {
|
||||
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
|
||||
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 {
|
||||
exec, err := remotecommand.NewSPDYExecutor(config, method, url)
|
||||
if err != nil {
|
||||
|
|
|
@ -53,6 +53,7 @@ var (
|
|||
kubectl autoscale rc foo --max=5 --cpu-percent=80`))
|
||||
)
|
||||
|
||||
// AutoscaleOptions declare the arguments accepted by the Autoscale command
|
||||
type AutoscaleOptions struct {
|
||||
FilenameOptions *resource.FilenameOptions
|
||||
|
||||
|
@ -82,6 +83,7 @@ type AutoscaleOptions struct {
|
|||
genericclioptions.IOStreams
|
||||
}
|
||||
|
||||
// NewAutoscaleOptions creates the options for autoscale
|
||||
func NewAutoscaleOptions(ioStreams genericclioptions.IOStreams) *AutoscaleOptions {
|
||||
return &AutoscaleOptions{
|
||||
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 {
|
||||
o := NewAutoscaleOptions(ioStreams)
|
||||
|
||||
|
@ -128,6 +131,7 @@ func NewCmdAutoscale(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *
|
|||
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 {
|
||||
var err error
|
||||
o.dryRun = cmdutil.GetFlagBool(cmd, "dry-run")
|
||||
|
@ -187,6 +191,7 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
|||
return nil
|
||||
}
|
||||
|
||||
// Validate checks that the provided attach options are specified.
|
||||
func (o *AutoscaleOptions) Validate() error {
|
||||
if o.Max < 1 {
|
||||
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
|
||||
}
|
||||
|
||||
// Run performs the execution
|
||||
func (o *AutoscaleOptions) Run() error {
|
||||
r := o.builder.
|
||||
Unstructured().
|
||||
|
|
Loading…
Reference in New Issue