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
a0a69a35
Commit
a0a69a35
authored
Dec 19, 2017
by
Zhenguo Niu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more validate conditions when run kubectl get with --raw
parent
8d24ce11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
get.go
pkg/kubectl/cmd/resource/get.go
+8
-0
No files found.
pkg/kubectl/cmd/resource/get.go
View file @
a0a69a35
...
@@ -25,6 +25,8 @@ import (
...
@@ -25,6 +25,8 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"net/url"
kapierrors
"k8s.io/apimachinery/pkg/api/errors"
kapierrors
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -213,6 +215,12 @@ func (options *GetOptions) Validate(cmd *cobra.Command) error {
...
@@ -213,6 +215,12 @@ func (options *GetOptions) Validate(cmd *cobra.Command) error {
if
len
(
options
.
Raw
)
>
0
&&
(
options
.
Watch
||
options
.
WatchOnly
||
len
(
options
.
LabelSelector
)
>
0
||
options
.
Export
)
{
if
len
(
options
.
Raw
)
>
0
&&
(
options
.
Watch
||
options
.
WatchOnly
||
len
(
options
.
LabelSelector
)
>
0
||
options
.
Export
)
{
return
fmt
.
Errorf
(
"--raw may not be specified with other flags that filter the server request or alter the output"
)
return
fmt
.
Errorf
(
"--raw may not be specified with other flags that filter the server request or alter the output"
)
}
}
if
len
(
cmdutil
.
GetFlagString
(
cmd
,
"output"
))
>
0
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"--raw and --output are mutually exclusive"
)
}
if
_
,
err
:=
url
.
ParseRequestURI
(
options
.
Raw
);
err
!=
nil
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"--raw must be a valid URL path: %v"
,
err
)
}
if
cmdutil
.
GetFlagBool
(
cmd
,
"show-labels"
)
{
if
cmdutil
.
GetFlagBool
(
cmd
,
"show-labels"
)
{
outputOption
:=
cmd
.
Flags
()
.
Lookup
(
"output"
)
.
Value
.
String
()
outputOption
:=
cmd
.
Flags
()
.
Lookup
(
"output"
)
.
Value
.
String
()
if
outputOption
!=
""
&&
outputOption
!=
"wide"
{
if
outputOption
!=
""
&&
outputOption
!=
"wide"
{
...
...
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