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
917a0b6f
Commit
917a0b6f
authored
Mar 14, 2017
by
shiywang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix kubectl config return 0 on error
parent
302aab9b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
46 deletions
+29
-46
create_authinfo.go
pkg/kubectl/cmd/config/create_authinfo.go
+8
-10
create_authinfo_test.go
pkg/kubectl/cmd/config/create_authinfo_test.go
+1
-1
create_cluster.go
pkg/kubectl/cmd/config/create_cluster.go
+4
-7
create_context.go
pkg/kubectl/cmd/config/create_context.go
+4
-7
set.go
pkg/kubectl/cmd/config/set.go
+4
-7
unset.go
pkg/kubectl/cmd/config/unset.go
+4
-7
use_context.go
pkg/kubectl/cmd/config/use_context.go
+4
-7
No files found.
pkg/kubectl/cmd/config/create_authinfo.go
View file @
917a0b6f
...
...
@@ -105,11 +105,11 @@ func newCmdConfigSetAuthInfo(out io.Writer, options *createAuthInfoOptions) *cob
Long
:
create_authinfo_long
,
Example
:
create_authinfo_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
!
options
.
complete
(
cmd
,
out
)
{
err
:=
options
.
complete
(
cmd
,
out
)
if
err
!=
nil
{
cmd
.
Help
()
return
cmdutil
.
CheckErr
(
err
)
}
cmdutil
.
CheckErr
(
options
.
run
())
fmt
.
Fprintf
(
out
,
"User %q set.
\n
"
,
options
.
name
)
},
...
...
@@ -238,30 +238,28 @@ func (o *createAuthInfoOptions) modifyAuthInfo(existingAuthInfo clientcmdapi.Aut
return
modifiedAuthInfo
}
func
(
o
*
createAuthInfoOptions
)
complete
(
cmd
*
cobra
.
Command
,
out
io
.
Writer
)
bool
{
func
(
o
*
createAuthInfoOptions
)
complete
(
cmd
*
cobra
.
Command
,
out
io
.
Writer
)
error
{
args
:=
cmd
.
Flags
()
.
Args
()
if
len
(
args
)
!=
1
{
return
f
alse
return
f
mt
.
Errorf
(
"Unexpected args: %v"
,
args
)
}
authProviderArgs
,
err
:=
cmd
.
Flags
()
.
GetStringSlice
(
flagAuthProviderArg
)
if
err
!=
nil
{
fmt
.
Fprintf
(
out
,
"Error: %s
\n
"
,
err
)
return
false
return
fmt
.
Errorf
(
"Error: %s
\n
"
,
err
)
}
if
len
(
authProviderArgs
)
>
0
{
newPairs
,
removePairs
,
err
:=
cmdutil
.
ParsePairs
(
authProviderArgs
,
flagAuthProviderArg
,
true
)
if
err
!=
nil
{
fmt
.
Fprintf
(
out
,
"Error: %s
\n
"
,
err
)
return
false
return
fmt
.
Errorf
(
"Error: %s
\n
"
,
err
)
}
o
.
authProviderArgs
=
newPairs
o
.
authProviderArgsToRemove
=
removePairs
}
o
.
name
=
args
[
0
]
return
true
return
nil
}
func
(
o
createAuthInfoOptions
)
validate
()
error
{
...
...
pkg/kubectl/cmd/config/create_authinfo_test.go
View file @
917a0b6f
...
...
@@ -160,7 +160,7 @@ func TestCreateAuthInfoOptions(t *testing.T) {
continue
}
if
!
opts
.
complete
(
cmd
,
buff
)
{
if
err
:=
opts
.
complete
(
cmd
,
buff
);
err
!=
nil
{
if
!
test
.
wantCompleteErr
{
t
.
Errorf
(
"case %d: complete() error for flags %q: %s"
,
i
,
test
.
flags
,
buff
)
}
...
...
pkg/kubectl/cmd/config/create_cluster.go
View file @
917a0b6f
...
...
@@ -69,10 +69,7 @@ func NewCmdConfigSetCluster(out io.Writer, configAccess clientcmd.ConfigAccess)
Long
:
create_cluster_long
,
Example
:
create_cluster_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
!
options
.
complete
(
cmd
)
{
return
}
cmdutil
.
CheckErr
(
options
.
complete
(
cmd
))
cmdutil
.
CheckErr
(
options
.
run
())
fmt
.
Fprintf
(
out
,
"Cluster %q set.
\n
"
,
options
.
name
)
},
...
...
@@ -152,15 +149,15 @@ func (o *createClusterOptions) modifyCluster(existingCluster clientcmdapi.Cluste
return
modifiedCluster
}
func
(
o
*
createClusterOptions
)
complete
(
cmd
*
cobra
.
Command
)
bool
{
func
(
o
*
createClusterOptions
)
complete
(
cmd
*
cobra
.
Command
)
error
{
args
:=
cmd
.
Flags
()
.
Args
()
if
len
(
args
)
!=
1
{
cmd
.
Help
()
return
f
alse
return
f
mt
.
Errorf
(
"Unexpected args: %v"
,
args
)
}
o
.
name
=
args
[
0
]
return
true
return
nil
}
func
(
o
createClusterOptions
)
validate
()
error
{
...
...
pkg/kubectl/cmd/config/create_context.go
View file @
917a0b6f
...
...
@@ -59,10 +59,7 @@ func NewCmdConfigSetContext(out io.Writer, configAccess clientcmd.ConfigAccess)
Long
:
create_context_long
,
Example
:
create_context_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
!
options
.
complete
(
cmd
)
{
return
}
cmdutil
.
CheckErr
(
options
.
complete
(
cmd
))
cmdutil
.
CheckErr
(
options
.
run
())
fmt
.
Fprintf
(
out
,
"Context %q set.
\n
"
,
options
.
name
)
},
...
...
@@ -116,15 +113,15 @@ func (o *createContextOptions) modifyContext(existingContext clientcmdapi.Contex
return
modifiedContext
}
func
(
o
*
createContextOptions
)
complete
(
cmd
*
cobra
.
Command
)
bool
{
func
(
o
*
createContextOptions
)
complete
(
cmd
*
cobra
.
Command
)
error
{
args
:=
cmd
.
Flags
()
.
Args
()
if
len
(
args
)
!=
1
{
cmd
.
Help
()
return
f
alse
return
f
mt
.
Errorf
(
"Unexpected args: %v"
,
args
)
}
o
.
name
=
args
[
0
]
return
true
return
nil
}
func
(
o
createContextOptions
)
validate
()
error
{
...
...
pkg/kubectl/cmd/config/set.go
View file @
917a0b6f
...
...
@@ -60,10 +60,7 @@ func NewCmdConfigSet(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.
Short
:
i18n
.
T
(
"Sets an individual value in a kubeconfig file"
),
Long
:
set_long
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
!
options
.
complete
(
cmd
)
{
return
}
cmdutil
.
CheckErr
(
options
.
complete
(
cmd
))
cmdutil
.
CheckErr
(
options
.
run
())
fmt
.
Fprintf
(
out
,
"Property %q set.
\n
"
,
options
.
propertyName
)
},
...
...
@@ -106,16 +103,16 @@ func (o setOptions) run() error {
return
nil
}
func
(
o
*
setOptions
)
complete
(
cmd
*
cobra
.
Command
)
bool
{
func
(
o
*
setOptions
)
complete
(
cmd
*
cobra
.
Command
)
error
{
endingArgs
:=
cmd
.
Flags
()
.
Args
()
if
len
(
endingArgs
)
!=
2
{
cmd
.
Help
()
return
f
alse
return
f
mt
.
Errorf
(
"Unexpected args: %v"
,
endingArgs
)
}
o
.
propertyValue
=
endingArgs
[
1
]
o
.
propertyName
=
endingArgs
[
0
]
return
true
return
nil
}
func
(
o
setOptions
)
validate
()
error
{
...
...
pkg/kubectl/cmd/config/unset.go
View file @
917a0b6f
...
...
@@ -48,10 +48,7 @@ func NewCmdConfigUnset(out io.Writer, configAccess clientcmd.ConfigAccess) *cobr
Short
:
i18n
.
T
(
"Unsets an individual value in a kubeconfig file"
),
Long
:
unset_long
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
!
options
.
complete
(
cmd
)
{
return
}
cmdutil
.
CheckErr
(
options
.
complete
(
cmd
))
cmdutil
.
CheckErr
(
options
.
run
())
fmt
.
Fprintf
(
out
,
"Property %q unset.
\n
"
,
options
.
propertyName
)
},
...
...
@@ -87,15 +84,15 @@ func (o unsetOptions) run() error {
return
nil
}
func
(
o
*
unsetOptions
)
complete
(
cmd
*
cobra
.
Command
)
bool
{
func
(
o
*
unsetOptions
)
complete
(
cmd
*
cobra
.
Command
)
error
{
endingArgs
:=
cmd
.
Flags
()
.
Args
()
if
len
(
endingArgs
)
!=
1
{
cmd
.
Help
()
return
f
alse
return
f
mt
.
Errorf
(
"Unexpected args: %v"
,
endingArgs
)
}
o
.
propertyName
=
endingArgs
[
0
]
return
true
return
nil
}
func
(
o
unsetOptions
)
validate
()
error
{
...
...
pkg/kubectl/cmd/config/use_context.go
View file @
917a0b6f
...
...
@@ -50,10 +50,7 @@ func NewCmdConfigUseContext(out io.Writer, configAccess clientcmd.ConfigAccess)
Long
:
`Sets the current-context in a kubeconfig file`
,
Example
:
use_context_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
!
options
.
complete
(
cmd
)
{
return
}
cmdutil
.
CheckErr
(
options
.
complete
(
cmd
))
cmdutil
.
CheckErr
(
options
.
run
())
fmt
.
Fprintf
(
out
,
"Switched to context %q.
\n
"
,
options
.
contextName
)
},
...
...
@@ -82,15 +79,15 @@ func (o useContextOptions) run() error {
return
nil
}
func
(
o
*
useContextOptions
)
complete
(
cmd
*
cobra
.
Command
)
bool
{
func
(
o
*
useContextOptions
)
complete
(
cmd
*
cobra
.
Command
)
error
{
endingArgs
:=
cmd
.
Flags
()
.
Args
()
if
len
(
endingArgs
)
!=
1
{
cmd
.
Help
()
return
f
alse
return
f
mt
.
Errorf
(
"Unexpected args: %v"
,
endingArgs
)
}
o
.
contextName
=
endingArgs
[
0
]
return
true
return
nil
}
func
(
o
useContextOptions
)
validate
(
config
*
clientcmdapi
.
Config
)
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