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
9e9b9f2d
Commit
9e9b9f2d
authored
Nov 20, 2015
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix outputversion restmapper
parent
ed95a6d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
restmapper.go
pkg/api/meta/restmapper.go
+13
-2
kubectl.go
pkg/kubectl/kubectl.go
+5
-14
No files found.
pkg/api/meta/restmapper.go
View file @
9e9b9f2d
...
@@ -189,9 +189,21 @@ func (m *DefaultRESTMapper) GroupForResource(resource string) (string, error) {
...
@@ -189,9 +189,21 @@ func (m *DefaultRESTMapper) GroupForResource(resource string) (string, error) {
// them with group/version tuples.
// them with group/version tuples.
// TODO this should probably become RESTMapping(GroupKind, versions ...string)
// TODO this should probably become RESTMapping(GroupKind, versions ...string)
func
(
m
*
DefaultRESTMapper
)
RESTMapping
(
kind
string
,
versions
...
string
)
(
*
RESTMapping
,
error
)
{
func
(
m
*
DefaultRESTMapper
)
RESTMapping
(
kind
string
,
versions
...
string
)
(
*
RESTMapping
,
error
)
{
// TODO, this looks really strange, but once this API is update, the version detection becomes clean again
// because you won't be able to request cross-group kinds
hadVersion
:=
false
for
_
,
gvString
:=
range
versions
{
currGroupVersion
,
err
:=
unversioned
.
ParseGroupVersion
(
gvString
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
currGroupVersion
.
Version
)
!=
0
{
hadVersion
=
true
}
}
// Pick an appropriate version
// Pick an appropriate version
var
groupVersion
*
unversioned
.
GroupVersion
var
groupVersion
*
unversioned
.
GroupVersion
hadVersion
:=
false
for
_
,
v
:=
range
versions
{
for
_
,
v
:=
range
versions
{
if
len
(
v
)
==
0
{
if
len
(
v
)
==
0
{
continue
continue
...
@@ -202,7 +214,6 @@ func (m *DefaultRESTMapper) RESTMapping(kind string, versions ...string) (*RESTM
...
@@ -202,7 +214,6 @@ func (m *DefaultRESTMapper) RESTMapping(kind string, versions ...string) (*RESTM
}
}
currGVK
:=
currGroupVersion
.
WithKind
(
kind
)
currGVK
:=
currGroupVersion
.
WithKind
(
kind
)
hadVersion
=
true
if
_
,
ok
:=
m
.
kindToPluralResource
[
currGVK
];
ok
{
if
_
,
ok
:=
m
.
kindToPluralResource
[
currGVK
];
ok
{
groupVersion
=
&
currGroupVersion
groupVersion
=
&
currGroupVersion
break
break
...
...
pkg/kubectl/kubectl.go
View file @
9e9b9f2d
...
@@ -51,21 +51,12 @@ type OutputVersionMapper struct {
...
@@ -51,21 +51,12 @@ type OutputVersionMapper struct {
// RESTMapping implements meta.RESTMapper by prepending the output version to the preferred version list.
// RESTMapping implements meta.RESTMapper by prepending the output version to the preferred version list.
func
(
m
OutputVersionMapper
)
RESTMapping
(
kind
string
,
versions
...
string
)
(
*
meta
.
RESTMapping
,
error
)
{
func
(
m
OutputVersionMapper
)
RESTMapping
(
kind
string
,
versions
...
string
)
(
*
meta
.
RESTMapping
,
error
)
{
preferred
:=
[]
string
{
m
.
OutputVersion
}
mapping
,
err
:=
m
.
RESTMapper
.
RESTMapping
(
kind
,
m
.
OutputVersion
)
for
_
,
version
:=
range
versions
{
if
err
==
nil
{
if
len
(
version
)
>
0
{
return
mapping
,
nil
preferred
=
append
(
preferred
,
version
)
}
}
}
// if the caller wants to use the default version list, try with the preferred version, and on
// error, use the default behavior.
return
m
.
RESTMapper
.
RESTMapping
(
kind
,
versions
...
)
if
len
(
preferred
)
==
1
{
if
m
,
err
:=
m
.
RESTMapper
.
RESTMapping
(
kind
,
preferred
...
);
err
==
nil
{
return
m
,
nil
}
preferred
=
nil
}
return
m
.
RESTMapper
.
RESTMapping
(
kind
,
preferred
...
)
}
}
// ShortcutExpander is a RESTMapper that can be used for Kubernetes
// ShortcutExpander is a RESTMapper that can be used for Kubernetes
...
...
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