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
651faf2e
Unverified
Commit
651faf2e
authored
Feb 21, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74250 from SataQiu/fix-golint-20190219
Fix golint failures on pkg/kubectl/cmd/completion, pkg/kubectl/cmd/cp, pkg/kubectl/cmd/edit
parents
2e531f4f
e2c1f435
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
25 deletions
+30
-25
.golint_failures
hack/.golint_failures
+0
-3
completion.go
pkg/kubectl/cmd/completion/completion.go
+2
-0
cp.go
pkg/kubectl/cmd/cp/cp.go
+5
-0
edit.go
pkg/kubectl/cmd/edit/edit.go
+1
-0
edit_test.go
pkg/kubectl/cmd/edit/edit_test.go
+22
-22
No files found.
hack/.golint_failures
View file @
651faf2e
...
...
@@ -131,15 +131,12 @@ pkg/kubectl/cmd/attach
pkg/kubectl/cmd/autoscale
pkg/kubectl/cmd/certificates
pkg/kubectl/cmd/clusterinfo
pkg/kubectl/cmd/completion
pkg/kubectl/cmd/convert
pkg/kubectl/cmd/cp
pkg/kubectl/cmd/create
pkg/kubectl/cmd/delete
pkg/kubectl/cmd/describe
pkg/kubectl/cmd/diff
pkg/kubectl/cmd/drain
pkg/kubectl/cmd/edit
pkg/kubectl/cmd/exec
pkg/kubectl/cmd/explain
pkg/kubectl/cmd/expose
...
...
pkg/kubectl/cmd/completion/completion.go
View file @
651faf2e
...
...
@@ -92,6 +92,7 @@ var (
}
)
// NewCmdCompletion creates the `completion` command
func
NewCmdCompletion
(
out
io
.
Writer
,
boilerPlate
string
)
*
cobra
.
Command
{
shells
:=
[]
string
{}
for
s
:=
range
completionShells
{
...
...
@@ -114,6 +115,7 @@ func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
return
cmd
}
// RunCompletion checks given arguments and executes command
func
RunCompletion
(
out
io
.
Writer
,
boilerPlate
string
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"Shell not specified."
)
...
...
pkg/kubectl/cmd/cp/cp.go
View file @
651faf2e
...
...
@@ -66,6 +66,7 @@ var (
/file/path for a local file`
)
)
// CopyOptions have the data required to perform the copy operation
type
CopyOptions
struct
{
Container
string
Namespace
string
...
...
@@ -77,6 +78,7 @@ type CopyOptions struct {
genericclioptions
.
IOStreams
}
// NewCopyOptions creates the options for copy
func
NewCopyOptions
(
ioStreams
genericclioptions
.
IOStreams
)
*
CopyOptions
{
return
&
CopyOptions
{
IOStreams
:
ioStreams
,
...
...
@@ -140,6 +142,7 @@ func extractFileSpec(arg string) (fileSpec, error) {
return
fileSpec
{},
errFileSpecDoesntMatchFormat
}
// Complete completes all the required options
func
(
o
*
CopyOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
var
err
error
o
.
Namespace
,
_
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
...
...
@@ -159,6 +162,7 @@ func (o *CopyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
return
nil
}
// Validate makes sure provided values for CopyOptions are valid
func
(
o
*
CopyOptions
)
Validate
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
!=
2
{
return
cmdutil
.
UsageErrorf
(
cmd
,
cpUsageStr
)
...
...
@@ -166,6 +170,7 @@ func (o *CopyOptions) Validate(cmd *cobra.Command, args []string) error {
return
nil
}
// Run performs the execution
func
(
o
*
CopyOptions
)
Run
(
args
[]
string
)
error
{
if
len
(
args
)
<
2
{
return
fmt
.
Errorf
(
"source and destination are required"
)
...
...
pkg/kubectl/cmd/edit/edit.go
View file @
651faf2e
...
...
@@ -67,6 +67,7 @@ var (
kubectl edit deployment/mydeployment -o yaml --save-config`
))
)
// NewCmdEdit creates the `edit` command
func
NewCmdEdit
(
f
cmdutil
.
Factory
,
ioStreams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
o
:=
editor
.
NewEditOptions
(
editor
.
NormalEditMode
,
ioStreams
)
o
.
ValidateOptions
=
cmdutil
.
ValidateOptions
{
EnableValidation
:
true
}
...
...
pkg/kubectl/cmd/edit/edit_test.go
View file @
651faf2e
...
...
@@ -129,30 +129,30 @@ func TestEdit(t *testing.T) {
}
}
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
ioutil
.
NopCloser
(
bytes
.
NewReader
(
resultingOutput
))},
nil
}
else
{
if
step
.
StepType
!=
"request"
{
t
.
Fatalf
(
"%s, step %d: expected request step, got %s %s"
,
name
,
i
,
req
.
Method
,
req
.
URL
.
Path
)
}
body
=
tryIndent
(
body
)
expectedInput
=
tryIndent
(
expectedInput
)
if
req
.
Method
!=
step
.
RequestMethod
||
req
.
URL
.
Path
!=
step
.
RequestPath
||
req
.
Header
.
Get
(
"Content-Type"
)
!=
step
.
RequestContentType
{
t
.
Fatalf
(
"%s, step %d: expected
\n
%s %s (content-type=%s)
\n
got
\n
%s %s (content-type=%s)"
,
name
,
i
,
step
.
RequestMethod
,
step
.
RequestPath
,
step
.
RequestContentType
,
req
.
Method
,
req
.
URL
.
Path
,
req
.
Header
.
Get
(
"Content-Type"
),
)
}
if
!
bytes
.
Equal
(
body
,
expectedInput
)
{
if
updateInputFixtures
{
// Convenience to allow recapturing the input and persisting it here
ioutil
.
WriteFile
(
inputFile
,
body
,
os
.
FileMode
(
0644
))
}
else
{
t
.
Errorf
(
"%s, step %d: diff in edit content:
\n
%s"
,
name
,
i
,
diff
.
StringDiff
(
string
(
body
),
string
(
expectedInput
)))
t
.
Logf
(
"If the change in input is expected, rerun tests with %s=true to update input fixtures"
,
updateEnvVar
)
}
}
if
step
.
StepType
!=
"request"
{
t
.
Fatalf
(
"%s, step %d: expected request step, got %s %s"
,
name
,
i
,
req
.
Method
,
req
.
URL
.
Path
)
}
body
=
tryIndent
(
body
)
expectedInput
=
tryIndent
(
expectedInput
)
if
req
.
Method
!=
step
.
RequestMethod
||
req
.
URL
.
Path
!=
step
.
RequestPath
||
req
.
Header
.
Get
(
"Content-Type"
)
!=
step
.
RequestContentType
{
t
.
Fatalf
(
"%s, step %d: expected
\n
%s %s (content-type=%s)
\n
got
\n
%s %s (content-type=%s)"
,
name
,
i
,
step
.
RequestMethod
,
step
.
RequestPath
,
step
.
RequestContentType
,
req
.
Method
,
req
.
URL
.
Path
,
req
.
Header
.
Get
(
"Content-Type"
),
)
}
if
!
bytes
.
Equal
(
body
,
expectedInput
)
{
if
updateInputFixtures
{
// Convenience to allow recapturing the input and persisting it here
ioutil
.
WriteFile
(
inputFile
,
body
,
os
.
FileMode
(
0644
))
}
else
{
t
.
Errorf
(
"%s, step %d: diff in edit content:
\n
%s"
,
name
,
i
,
diff
.
StringDiff
(
string
(
body
),
string
(
expectedInput
)))
t
.
Logf
(
"If the change in input is expected, rerun tests with %s=true to update input fixtures"
,
updateEnvVar
)
}
return
&
http
.
Response
{
StatusCode
:
step
.
ResponseStatusCode
,
Header
:
cmdtesting
.
DefaultHeader
(),
Body
:
ioutil
.
NopCloser
(
bytes
.
NewReader
(
resultingOutput
))},
nil
}
return
&
http
.
Response
{
StatusCode
:
step
.
ResponseStatusCode
,
Header
:
cmdtesting
.
DefaultHeader
(),
Body
:
ioutil
.
NopCloser
(
bytes
.
NewReader
(
resultingOutput
))},
nil
}
handler
:=
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
...
...
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