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
99b97858
Commit
99b97858
authored
Jan 27, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3836 from mfojtik/extract_list_ptr
Ensure the ptr is pointing to reflect.Slice in ExtractList
parents
7e558a75
ae3f10a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
helper.go
pkg/runtime/helper.go
+4
-0
helper_test.go
pkg/runtime/helper_test.go
+2
-2
No files found.
pkg/runtime/helper.go
View file @
99b97858
...
...
@@ -43,6 +43,10 @@ func GetItemsPtr(list Object) (interface{}, error) {
}
switch
items
.
Kind
()
{
case
reflect
.
Interface
,
reflect
.
Ptr
:
target
:=
reflect
.
TypeOf
(
items
.
Interface
())
.
Elem
()
if
target
.
Kind
()
!=
reflect
.
Slice
{
return
nil
,
fmt
.
Errorf
(
"items: Expected slice, got %s"
,
target
.
Kind
())
}
return
items
.
Interface
(),
nil
case
reflect
.
Slice
:
return
items
.
Addr
()
.
Interface
(),
nil
...
...
pkg/runtime/helper_test.go
View file @
99b97858
...
...
@@ -86,14 +86,14 @@ func TestExtractListGeneric(t *testing.T) {
}
type
fakePtrInterfaceList
struct
{
Items
[]
*
runtime
.
Object
Items
*
[]
runtime
.
Object
}
func
(
f
fakePtrInterfaceList
)
IsAnAPIObject
()
{}
func
TestExtractListOfInterfacePtrs
(
t
*
testing
.
T
)
{
pl
:=
&
fakePtrInterfaceList
{
Items
:
[]
*
runtime
.
Object
{},
Items
:
&
[]
runtime
.
Object
{},
}
list
,
err
:=
runtime
.
ExtractList
(
pl
)
if
err
!=
nil
{
...
...
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