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
1d37c549
Commit
1d37c549
authored
Oct 21, 2015
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert/disable the slash syntax for kubectl explain group/version
parent
236193a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
19 deletions
+10
-19
explain.go
pkg/kubectl/cmd/explain.go
+8
-7
explain.go
pkg/kubectl/explain.go
+2
-12
No files found.
pkg/kubectl/cmd/explain.go
View file @
1d37c549
...
@@ -72,17 +72,18 @@ func RunExplain(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
...
@@ -72,17 +72,18 @@ func RunExplain(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
apiV
:=
cmdutil
.
GetFlagString
(
cmd
,
"api-version"
)
apiV
:=
cmdutil
.
GetFlagString
(
cmd
,
"api-version"
)
mapper
,
_
:=
f
.
Object
()
mapper
,
_
:=
f
.
Object
()
group
,
inModel
,
fieldsPath
,
err
:=
kubectl
.
SplitAndParseResourceRequest
(
args
[
0
],
mapper
)
// TODO: After we figured out the new syntax to separate group and resource, allow
// the users to use it in explain (kubectl explain <group><syntax><resource>).
// Refer to issue #16039 for why we do this. Refer to PR #15808 that used "/" syntax.
inModel
,
fieldsPath
,
err
:=
kubectl
.
SplitAndParseResourceRequest
(
args
[
0
],
mapper
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
len
(
group
)
==
0
{
// TODO: We should deduce the group for a resource by discovering the supported resources at server.
// TODO: We should deduce the group for a resource by discovering the supported resources at server.
group
,
err
:=
mapper
.
GroupForResource
(
inModel
)
group
,
err
=
mapper
.
GroupForResource
(
inModel
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
if
len
(
apiV
)
==
0
{
if
len
(
apiV
)
==
0
{
...
...
pkg/kubectl/explain.go
View file @
1d37c549
...
@@ -41,11 +41,10 @@ func GetSwaggerSchema(apiVer string, kubeClient client.Interface) (*swagger.ApiD
...
@@ -41,11 +41,10 @@ func GetSwaggerSchema(apiVer string, kubeClient client.Interface) (*swagger.ApiD
}
}
// SplitAndParseResourceRequest separates the users input into a model and fields
// SplitAndParseResourceRequest separates the users input into a model and fields
func
SplitAndParseResourceRequest
(
inResource
string
,
mapper
meta
.
RESTMapper
)
(
string
,
string
,
[]
string
,
error
)
{
func
SplitAndParseResourceRequest
(
inResource
string
,
mapper
meta
.
RESTMapper
)
(
string
,
[]
string
,
error
)
{
inResource
,
fieldsPath
:=
splitDotNotation
(
inResource
)
inResource
,
fieldsPath
:=
splitDotNotation
(
inResource
)
group
,
inResource
:=
splitGroupFromResource
(
inResource
)
inResource
,
_
=
mapper
.
ResourceSingularizer
(
expandResourceShortcut
(
inResource
))
inResource
,
_
=
mapper
.
ResourceSingularizer
(
expandResourceShortcut
(
inResource
))
return
group
,
inResource
,
fieldsPath
,
nil
return
inResource
,
fieldsPath
,
nil
}
}
// PrintModelDescription prints the description of a specific model or dot path
// PrintModelDescription prints the description of a specific model or dot path
...
@@ -86,15 +85,6 @@ func PrintModelDescription(inModel string, fieldsPath []string, w io.Writer, swa
...
@@ -86,15 +85,6 @@ func PrintModelDescription(inModel string, fieldsPath []string, w io.Writer, swa
return
printModelInfo
(
w
,
pointedModel
,
pointedModelAsProp
)
return
printModelInfo
(
w
,
pointedModel
,
pointedModelAsProp
)
}
}
func
splitGroupFromResource
(
resource
string
)
(
string
,
string
)
{
seg
:=
strings
.
SplitN
(
resource
,
"/"
,
2
)
if
len
(
seg
)
==
1
{
return
""
,
seg
[
0
]
}
else
{
return
seg
[
0
],
seg
[
1
]
}
}
func
splitDotNotation
(
model
string
)
(
string
,
[]
string
)
{
func
splitDotNotation
(
model
string
)
(
string
,
[]
string
)
{
var
fieldsPath
[]
string
var
fieldsPath
[]
string
dotModel
:=
strings
.
Split
(
model
,
"."
)
dotModel
:=
strings
.
Split
(
model
,
"."
)
...
...
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