Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3b5e2285
Unverified
Commit
3b5e2285
authored
May 01, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77112 from SataQiu/fix-golint-kubectl-20190427
Fix some golint failures of pkg/kubectl/cmd/attach pkg/kubectl/cmd/autoscale
parents
b03e4bbc
6f7690e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
attach.go
pkg/kubectl/cmd/attach/attach.go
+5
-1
autoscale.go
pkg/kubectl/cmd/autoscale/autoscale.go
+6
-0
No files found.
pkg/kubectl/cmd/attach/attach.go
View file @
3b5e2285
...
@@ -61,7 +61,7 @@ const (
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
...
@@ -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
{
...
...
pkg/kubectl/cmd/autoscale/autoscale.go
View file @
3b5e2285
...
@@ -53,6 +53,7 @@ var (
...
@@ -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 {
...
@@ -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
...
@@ -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) *
...
@@ -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
...
@@ -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 {
...
@@ -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
()
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment