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
706823aa
Commit
706823aa
authored
Mar 31, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make unstructured items correspond to other items for storage
parent
f5052024
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
21 additions
and
21 deletions
+21
-21
api_meta_help_test.go
pkg/apimachinery/tests/api_meta_help_test.go
+1
-1
apis_meta_v1_unstructed_unstructure_test.go
...chinery/tests/apis_meta_v1_unstructed_unstructure_test.go
+1
-1
edit.go
pkg/kubectl/cmd/edit.go
+1
-1
get.go
pkg/kubectl/cmd/get.go
+2
-2
get_test.go
pkg/kubectl/cmd/get_test.go
+3
-3
sorting_printer_test.go
pkg/kubectl/sorting_printer_test.go
+3
-3
unstructured.go
...pimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
+2
-2
unstructured_test.go
...hinery/pkg/apis/meta/v1/unstructured/unstructured_test.go
+1
-1
client_test.go
staging/src/k8s.io/client-go/dynamic/client_test.go
+6
-6
dynamic_client_test.go
test/integration/client/dynamic_client_test.go
+1
-1
No files found.
pkg/apimachinery/tests/api_meta_help_test.go
View file @
706823aa
...
@@ -316,7 +316,7 @@ func TestSetListToMatchingType(t *testing.T) {
...
@@ -316,7 +316,7 @@ func TestSetListToMatchingType(t *testing.T) {
t
.
Fatalf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Fatalf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
for
i
:=
range
list
{
for
i
:=
range
list
{
if
e
,
a
:=
list
[
i
],
pl
.
Items
[
i
];
e
!=
a
{
if
e
,
a
:=
list
[
i
],
&
pl
.
Items
[
i
];
!
reflect
.
DeepEqual
(
e
,
a
)
{
t
.
Fatalf
(
"%d: unmatched: %s"
,
i
,
diff
.
ObjectDiff
(
e
,
a
))
t
.
Fatalf
(
"%d: unmatched: %s"
,
i
,
diff
.
ObjectDiff
(
e
,
a
))
}
}
}
}
...
...
pkg/apimachinery/tests/apis_meta_v1_unstructed_unstructure_test.go
View file @
706823aa
...
@@ -89,7 +89,7 @@ func TestDecode(t *testing.T) {
...
@@ -89,7 +89,7 @@ func TestDecode(t *testing.T) {
json
:
[]
byte
(
`{"items": [{"metadata": {"name": "object1"}, "apiVersion": "test", "kind": "test_kind"}, {"metadata": {"name": "object2"}, "apiVersion": "test", "kind": "test_kind"}], "apiVersion": "test", "kind": "test_list"}`
),
json
:
[]
byte
(
`{"items": [{"metadata": {"name": "object1"}, "apiVersion": "test", "kind": "test_kind"}, {"metadata": {"name": "object2"}, "apiVersion": "test", "kind": "test_kind"}], "apiVersion": "test", "kind": "test_list"}`
),
want
:
&
unstructured
.
UnstructuredList
{
want
:
&
unstructured
.
UnstructuredList
{
Object
:
map
[
string
]
interface
{}{
"apiVersion"
:
"test"
,
"kind"
:
"test_list"
},
Object
:
map
[
string
]
interface
{}{
"apiVersion"
:
"test"
,
"kind"
:
"test_list"
},
Items
:
[]
*
unstructured
.
Unstructured
{
Items
:
[]
unstructured
.
Unstructured
{
{
{
Object
:
map
[
string
]
interface
{}{
Object
:
map
[
string
]
interface
{}{
"metadata"
:
map
[
string
]
interface
{}{
"name"
:
"object1"
},
"metadata"
:
map
[
string
]
interface
{}{
"name"
:
"object1"
},
...
...
pkg/kubectl/cmd/edit.go
View file @
706823aa
...
@@ -182,7 +182,7 @@ func runEdit(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
...
@@ -182,7 +182,7 @@ func runEdit(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
},
},
}
}
for
_
,
info
:=
range
infos
{
for
_
,
info
:=
range
infos
{
l
.
Items
=
append
(
l
.
Items
,
info
.
Object
.
(
*
unstructured
.
Unstructured
))
l
.
Items
=
append
(
l
.
Items
,
*
info
.
Object
.
(
*
unstructured
.
Unstructured
))
}
}
originalObj
=
l
originalObj
=
l
}
}
...
...
pkg/kubectl/cmd/get.go
View file @
706823aa
...
@@ -339,7 +339,7 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
...
@@ -339,7 +339,7 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
},
},
}
}
for
_
,
info
:=
range
infos
{
for
_
,
info
:=
range
infos
{
list
.
Items
=
append
(
list
.
Items
,
info
.
Object
.
(
*
unstructured
.
Unstructured
))
list
.
Items
=
append
(
list
.
Items
,
*
info
.
Object
.
(
*
unstructured
.
Unstructured
))
}
}
obj
=
list
obj
=
list
}
else
{
}
else
{
...
@@ -367,7 +367,7 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
...
@@ -367,7 +367,7 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
}
}
for
_
,
item
:=
range
items
{
for
_
,
item
:=
range
items
{
list
.
Items
=
append
(
list
.
Items
,
item
.
(
*
unstructured
.
Unstructured
))
list
.
Items
=
append
(
list
.
Items
,
*
item
.
(
*
unstructured
.
Unstructured
))
}
}
if
err
:=
printer
.
PrintObj
(
list
,
out
);
err
!=
nil
{
if
err
:=
printer
.
PrintObj
(
list
,
out
);
err
!=
nil
{
errs
=
append
(
errs
,
err
)
errs
=
append
(
errs
,
err
)
...
...
pkg/kubectl/cmd/get_test.go
View file @
706823aa
...
@@ -590,7 +590,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
...
@@ -590,7 +590,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
cmd
.
Run
(
cmd
,
[]
string
{
"pods,services"
})
cmd
.
Run
(
cmd
,
[]
string
{
"pods,services"
})
actual
:=
tf
.
CommandPrinter
.
(
*
testPrinter
)
.
Objects
actual
:=
tf
.
CommandPrinter
.
(
*
testPrinter
)
.
Objects
fn
:=
func
(
obj
runtime
.
Object
)
*
unstructured
.
Unstructured
{
fn
:=
func
(
obj
runtime
.
Object
)
unstructured
.
Unstructured
{
data
,
err
:=
runtime
.
Encode
(
api
.
Codecs
.
LegacyCodec
(
schema
.
GroupVersion
{
Version
:
"v1"
}),
obj
)
data
,
err
:=
runtime
.
Encode
(
api
.
Codecs
.
LegacyCodec
(
schema
.
GroupVersion
{
Version
:
"v1"
}),
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
@@ -599,12 +599,12 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
...
@@ -599,12 +599,12 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
if
err
:=
encjson
.
Unmarshal
(
data
,
&
out
.
Object
);
err
!=
nil
{
if
err
:=
encjson
.
Unmarshal
(
data
,
&
out
.
Object
);
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
return
out
return
*
out
}
}
expected
:=
&
unstructured
.
UnstructuredList
{
expected
:=
&
unstructured
.
UnstructuredList
{
Object
:
map
[
string
]
interface
{}{
"kind"
:
"List"
,
"apiVersion"
:
"v1"
,
"metadata"
:
map
[
string
]
interface
{}{},
"selfLink"
:
""
,
"resourceVersion"
:
""
},
Object
:
map
[
string
]
interface
{}{
"kind"
:
"List"
,
"apiVersion"
:
"v1"
,
"metadata"
:
map
[
string
]
interface
{}{},
"selfLink"
:
""
,
"resourceVersion"
:
""
},
Items
:
[]
*
unstructured
.
Unstructured
{
Items
:
[]
unstructured
.
Unstructured
{
fn
(
&
pods
.
Items
[
0
]),
fn
(
&
pods
.
Items
[
0
]),
fn
(
&
pods
.
Items
[
1
]),
fn
(
&
pods
.
Items
[
1
]),
fn
(
&
svc
.
Items
[
0
]),
fn
(
&
svc
.
Items
[
0
]),
...
...
pkg/kubectl/sorting_printer_test.go
View file @
706823aa
...
@@ -275,7 +275,7 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -275,7 +275,7 @@ func TestSortingPrinter(t *testing.T) {
"kind"
:
"List"
,
"kind"
:
"List"
,
"apiVersion"
:
"v1"
,
"apiVersion"
:
"v1"
,
},
},
Items
:
[]
*
unstructured
.
Unstructured
{
Items
:
[]
unstructured
.
Unstructured
{
{
{
Object
:
map
[
string
]
interface
{}{
Object
:
map
[
string
]
interface
{}{
"kind"
:
"ReplicationController"
,
"kind"
:
"ReplicationController"
,
...
@@ -308,7 +308,7 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -308,7 +308,7 @@ func TestSortingPrinter(t *testing.T) {
"kind"
:
"List"
,
"kind"
:
"List"
,
"apiVersion"
:
"v1"
,
"apiVersion"
:
"v1"
,
},
},
Items
:
[]
*
unstructured
.
Unstructured
{
Items
:
[]
unstructured
.
Unstructured
{
{
{
Object
:
map
[
string
]
interface
{}{
Object
:
map
[
string
]
interface
{}{
"kind"
:
"ReplicationController"
,
"kind"
:
"ReplicationController"
,
...
@@ -345,7 +345,7 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -345,7 +345,7 @@ func TestSortingPrinter(t *testing.T) {
"kind"
:
"List"
,
"kind"
:
"List"
,
"apiVersion"
:
"v1"
,
"apiVersion"
:
"v1"
,
},
},
Items
:
[]
*
unstructured
.
Unstructured
{
Items
:
[]
unstructured
.
Unstructured
{
{
{
Object
:
map
[
string
]
interface
{}{
Object
:
map
[
string
]
interface
{}{
"kind"
:
"ReplicationController"
,
"kind"
:
"ReplicationController"
,
...
...
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
View file @
706823aa
...
@@ -441,7 +441,7 @@ type UnstructuredList struct {
...
@@ -441,7 +441,7 @@ type UnstructuredList struct {
Object
map
[
string
]
interface
{}
Object
map
[
string
]
interface
{}
// Items is a list of unstructured objects.
// Items is a list of unstructured objects.
Items
[]
*
Unstructured
`json:"items"`
Items
[]
Unstructured
`json:"items"`
}
}
// MarshalJSON ensures that the unstructured list object produces proper
// MarshalJSON ensures that the unstructured list object produces proper
...
@@ -642,7 +642,7 @@ func (s unstructuredJSONScheme) decodeToList(data []byte, list *UnstructuredList
...
@@ -642,7 +642,7 @@ func (s unstructuredJSONScheme) decodeToList(data []byte, list *UnstructuredList
unstruct
.
SetKind
(
itemKind
)
unstruct
.
SetKind
(
itemKind
)
unstruct
.
SetAPIVersion
(
listAPIVersion
)
unstruct
.
SetAPIVersion
(
listAPIVersion
)
}
}
list
.
Items
=
append
(
list
.
Items
,
unstruct
)
list
.
Items
=
append
(
list
.
Items
,
*
unstruct
)
}
}
return
nil
return
nil
}
}
...
...
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured_test.go
View file @
706823aa
...
@@ -21,7 +21,7 @@ import "testing"
...
@@ -21,7 +21,7 @@ import "testing"
func
TestUnstructuredList
(
t
*
testing
.
T
)
{
func
TestUnstructuredList
(
t
*
testing
.
T
)
{
list
:=
&
UnstructuredList
{
list
:=
&
UnstructuredList
{
Object
:
map
[
string
]
interface
{}{
"kind"
:
"List"
,
"apiVersion"
:
"v1"
},
Object
:
map
[
string
]
interface
{}{
"kind"
:
"List"
,
"apiVersion"
:
"v1"
},
Items
:
[]
*
Unstructured
{
Items
:
[]
Unstructured
{
{
Object
:
map
[
string
]
interface
{}{
"kind"
:
"Pod"
,
"apiVersion"
:
"v1"
,
"metadata"
:
map
[
string
]
interface
{}{
"name"
:
"test"
}}},
{
Object
:
map
[
string
]
interface
{}{
"kind"
:
"Pod"
,
"apiVersion"
:
"v1"
,
"metadata"
:
map
[
string
]
interface
{}{
"name"
:
"test"
}}},
},
},
}
}
...
...
staging/src/k8s.io/client-go/dynamic/client_test.go
View file @
706823aa
...
@@ -90,9 +90,9 @@ func TestList(t *testing.T) {
...
@@ -90,9 +90,9 @@ func TestList(t *testing.T) {
"apiVersion"
:
"vTest"
,
"apiVersion"
:
"vTest"
,
"kind"
:
"rTestList"
,
"kind"
:
"rTestList"
,
},
},
Items
:
[]
*
unstructured
.
Unstructured
{
Items
:
[]
unstructured
.
Unstructured
{
getObject
(
"vTest"
,
"rTest"
,
"item1"
),
*
getObject
(
"vTest"
,
"rTest"
,
"item1"
),
getObject
(
"vTest"
,
"rTest"
,
"item2"
),
*
getObject
(
"vTest"
,
"rTest"
,
"item2"
),
},
},
},
},
},
},
...
@@ -108,9 +108,9 @@ func TestList(t *testing.T) {
...
@@ -108,9 +108,9 @@ func TestList(t *testing.T) {
"apiVersion"
:
"vTest"
,
"apiVersion"
:
"vTest"
,
"kind"
:
"rTestList"
,
"kind"
:
"rTestList"
,
},
},
Items
:
[]
*
unstructured
.
Unstructured
{
Items
:
[]
unstructured
.
Unstructured
{
getObject
(
"vTest"
,
"rTest"
,
"item1"
),
*
getObject
(
"vTest"
,
"rTest"
,
"item1"
),
getObject
(
"vTest"
,
"rTest"
,
"item2"
),
*
getObject
(
"vTest"
,
"rTest"
,
"item2"
),
},
},
},
},
},
},
...
...
test/integration/client/dynamic_client_test.go
View file @
706823aa
...
@@ -106,7 +106,7 @@ func TestDynamicClient(t *testing.T) {
...
@@ -106,7 +106,7 @@ func TestDynamicClient(t *testing.T) {
t
.
Fatalf
(
"expected one pod, got %d"
,
len
(
unstructuredList
.
Items
))
t
.
Fatalf
(
"expected one pod, got %d"
,
len
(
unstructuredList
.
Items
))
}
}
got
,
err
:=
unstructuredToPod
(
unstructuredList
.
Items
[
0
])
got
,
err
:=
unstructuredToPod
(
&
unstructuredList
.
Items
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error converting Unstructured to v1.Pod: %v"
,
err
)
t
.
Fatalf
(
"unexpected error converting Unstructured to v1.Pod: %v"
,
err
)
}
}
...
...
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