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
ffd8f3da
Unverified
Commit
ffd8f3da
authored
Mar 22, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73255 from ds-ms/golint
Fix linting issues in pkg/kubectl/cmd/version
parents
18ac575d
0417d23a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
.golint_failures
hack/.golint_failures
+0
-1
version.go
pkg/kubectl/cmd/version/version.go
+14
-7
No files found.
hack/.golint_failures
View file @
ffd8f3da
...
...
@@ -168,7 +168,6 @@ pkg/kubectl/cmd/testing
pkg/kubectl/cmd/top
pkg/kubectl/cmd/util
pkg/kubectl/cmd/util/openapi
pkg/kubectl/cmd/version
pkg/kubectl/cmd/wait
pkg/kubectl/describe/versioned
pkg/kubectl/generate
...
...
pkg/kubectl/cmd/version/version.go
View file @
ffd8f3da
...
...
@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/version"
)
// Version is a struct for version information
type
Version
struct
{
ClientVersion
*
apimachineryversion
.
Info
`json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"`
ServerVersion
*
apimachineryversion
.
Info
`json:"serverVersion,omitempty" yaml:"serverVersion,omitempty"`
...
...
@@ -45,7 +46,8 @@ var (
kubectl version`
))
)
type
VersionOptions
struct
{
// Options is a struct to support version command
type
Options
struct
{
ClientOnly
bool
Short
bool
Output
string
...
...
@@ -55,15 +57,17 @@ type VersionOptions struct {
genericclioptions
.
IOStreams
}
func
NewVersionOptions
(
ioStreams
genericclioptions
.
IOStreams
)
*
VersionOptions
{
return
&
VersionOptions
{
// NewOptions returns initialized Options
func
NewOptions
(
ioStreams
genericclioptions
.
IOStreams
)
*
Options
{
return
&
Options
{
IOStreams
:
ioStreams
,
}
}
// NewCmdVersion returns a cobra command for fetching versions
func
NewCmdVersion
(
f
cmdutil
.
Factory
,
ioStreams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
o
:=
New
Version
Options
(
ioStreams
)
o
:=
NewOptions
(
ioStreams
)
cmd
:=
&
cobra
.
Command
{
Use
:
"version"
,
Short
:
i18n
.
T
(
"Print the client and server version information"
),
...
...
@@ -81,7 +85,8 @@ func NewCmdVersion(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *co
return
cmd
}
func
(
o
*
VersionOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
// Complete completes all the required options
func
(
o
*
Options
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
var
err
error
o
.
discoveryClient
,
err
=
f
.
ToDiscoveryClient
()
// if we had an empty rest.Config, continue and just print out client information.
...
...
@@ -92,7 +97,8 @@ func (o *VersionOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
return
nil
}
func
(
o
*
VersionOptions
)
Validate
()
error
{
// Validate validates the provided options
func
(
o
*
Options
)
Validate
()
error
{
if
o
.
Output
!=
""
&&
o
.
Output
!=
"yaml"
&&
o
.
Output
!=
"json"
{
return
errors
.
New
(
`--output must be 'yaml' or 'json'`
)
}
...
...
@@ -100,7 +106,8 @@ func (o *VersionOptions) Validate() error {
return
nil
}
func
(
o
*
VersionOptions
)
Run
()
error
{
// Run executes version command
func
(
o
*
Options
)
Run
()
error
{
var
(
serverVersion
*
apimachineryversion
.
Info
serverErr
error
...
...
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