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
a3ffb050
Commit
a3ffb050
authored
Jun 19, 2015
by
Satnam Singh
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9972 from smarterclayton/split_versioned_object
Split AsVersionedObjects so it can be reused
parents
341e5f98
1707c5d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
+24
-13
result.go
pkg/kubectl/resource/result.go
+24
-13
No files found.
pkg/kubectl/resource/result.go
View file @
a3ffb050
...
...
@@ -207,6 +207,29 @@ func (r *Result) Watch(resourceVersion string) (watch.Interface, error) {
// version will be preferred as the conversion target, but the Object's mapping version will be
// used if that version is not present.
func
AsVersionedObject
(
infos
[]
*
Info
,
forceList
bool
,
version
string
)
(
runtime
.
Object
,
error
)
{
objects
,
err
:=
AsVersionedObjects
(
infos
,
version
)
if
err
!=
nil
{
return
nil
,
err
}
var
object
runtime
.
Object
if
len
(
objects
)
==
1
&&
!
forceList
{
object
=
objects
[
0
]
}
else
{
object
=
&
api
.
List
{
Items
:
objects
}
converted
,
err
:=
tryConvert
(
api
.
Scheme
,
object
,
version
,
latest
.
Version
)
if
err
!=
nil
{
return
nil
,
err
}
object
=
converted
}
return
object
,
nil
}
// AsVersionedObjects converts a list of infos into versioned objects. The provided
// version will be preferred as the conversion target, but the Object's mapping version will be
// used if that version is not present.
func
AsVersionedObjects
(
infos
[]
*
Info
,
version
string
)
([]
runtime
.
Object
,
error
)
{
objects
:=
[]
runtime
.
Object
{}
for
_
,
info
:=
range
infos
{
if
info
.
Object
==
nil
{
...
...
@@ -233,19 +256,7 @@ func AsVersionedObject(infos []*Info, forceList bool, version string) (runtime.O
}
objects
=
append
(
objects
,
converted
)
}
var
object
runtime
.
Object
if
len
(
objects
)
==
1
&&
!
forceList
{
object
=
objects
[
0
]
}
else
{
object
=
&
api
.
List
{
Items
:
objects
}
converted
,
err
:=
tryConvert
(
api
.
Scheme
,
object
,
version
,
latest
.
Version
)
if
err
!=
nil
{
return
nil
,
err
}
object
=
converted
}
return
object
,
nil
return
objects
,
nil
}
// tryConvert attempts to convert the given object to the provided versions in order. This function assumes
...
...
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