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
7c024284
Unverified
Commit
7c024284
authored
Sep 28, 2018
by
k8s-ci-robot
Committed by
GitHub
Sep 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69172 from seans3/test-small-fix
kubectl replace legacyscheme with kubectl scheme in two tests
parents
d204a90d
a20ba98b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
44 deletions
+43
-44
BUILD
pkg/kubectl/BUILD
+0
-1
BUILD
pkg/kubectl/cmd/auth/BUILD
+1
-1
cani_test.go
pkg/kubectl/cmd/auth/cani_test.go
+2
-2
sorter_test.go
pkg/kubectl/sorter_test.go
+40
-40
No files found.
pkg/kubectl/BUILD
View file @
7c024284
...
@@ -36,7 +36,6 @@ go_test(
...
@@ -36,7 +36,6 @@ go_test(
],
],
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
"//pkg/api/legacyscheme:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/testing:go_default_library",
"//pkg/api/testing:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
...
...
pkg/kubectl/cmd/auth/BUILD
View file @
7c024284
...
@@ -57,8 +57,8 @@ go_test(
...
@@ -57,8 +57,8 @@ go_test(
srcs = ["cani_test.go"],
srcs = ["cani_test.go"],
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
"//pkg/api/legacyscheme:go_default_library",
"//pkg/kubectl/cmd/testing:go_default_library",
"//pkg/kubectl/cmd/testing:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/client-go/rest/fake:go_default_library",
"//staging/src/k8s.io/client-go/rest/fake:go_default_library",
...
...
pkg/kubectl/cmd/auth/cani_test.go
View file @
7c024284
...
@@ -27,8 +27,8 @@ import (
...
@@ -27,8 +27,8 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
restclient
"k8s.io/client-go/rest"
restclient
"k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
"k8s.io/client-go/rest/fake"
"k8s.io/kubernetes/pkg/api/legacyscheme"
cmdtesting
"k8s.io/kubernetes/pkg/kubectl/cmd/testing"
cmdtesting
"k8s.io/kubernetes/pkg/kubectl/cmd/testing"
"k8s.io/kubernetes/pkg/kubectl/scheme"
)
)
func
TestRunAccessCheck
(
t
*
testing
.
T
)
{
func
TestRunAccessCheck
(
t
*
testing
.
T
)
{
...
@@ -124,7 +124,7 @@ func TestRunAccessCheck(t *testing.T) {
...
@@ -124,7 +124,7 @@ func TestRunAccessCheck(t *testing.T) {
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
tf
:=
cmdtesting
.
NewTestFactory
()
.
WithNamespace
(
"test"
)
defer
tf
.
Cleanup
()
defer
tf
.
Cleanup
()
ns
:=
legacy
scheme
.
Codecs
ns
:=
scheme
.
Codecs
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
GroupVersion
:
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
},
GroupVersion
:
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
},
...
...
pkg/kubectl/sorter_test.go
View file @
7c024284
...
@@ -21,16 +21,16 @@ import (
...
@@ -21,16 +21,16 @@ import (
"strings"
"strings"
"testing"
"testing"
api
"k8s.io/api/core/v1"
corev1
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/
api/legacy
scheme"
"k8s.io/kubernetes/pkg/
kubectl/
scheme"
)
)
func
encodeOrDie
(
obj
runtime
.
Object
)
[]
byte
{
func
encodeOrDie
(
obj
runtime
.
Object
)
[]
byte
{
data
,
err
:=
runtime
.
Encode
(
legacyscheme
.
Codecs
.
LegacyCodec
(
api
.
SchemeGroupVersion
),
obj
)
data
,
err
:=
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
corev1
.
SchemeGroupVersion
),
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
.
Error
())
panic
(
err
.
Error
())
}
}
...
@@ -40,19 +40,19 @@ func encodeOrDie(obj runtime.Object) []byte {
...
@@ -40,19 +40,19 @@ func encodeOrDie(obj runtime.Object) []byte {
func
TestSortingPrinter
(
t
*
testing
.
T
)
{
func
TestSortingPrinter
(
t
*
testing
.
T
)
{
intPtr
:=
func
(
val
int32
)
*
int32
{
return
&
val
}
intPtr
:=
func
(
val
int32
)
*
int32
{
return
&
val
}
a
:=
&
api
.
Pod
{
a
:=
&
corev1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"a"
,
Name
:
"a"
,
},
},
}
}
b
:=
&
api
.
Pod
{
b
:=
&
corev1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"b"
,
Name
:
"b"
,
},
},
}
}
c
:=
&
api
.
Pod
{
c
:=
&
corev1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"c"
,
Name
:
"c"
,
},
},
...
@@ -67,8 +67,8 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -67,8 +67,8 @@ func TestSortingPrinter(t *testing.T) {
}{
}{
{
{
name
:
"in-order-already"
,
name
:
"in-order-already"
,
obj
:
&
api
.
PodList
{
obj
:
&
corev1
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
corev1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"a"
,
Name
:
"a"
,
...
@@ -86,8 +86,8 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -86,8 +86,8 @@ func TestSortingPrinter(t *testing.T) {
},
},
},
},
},
},
sort
:
&
api
.
PodList
{
sort
:
&
corev1
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
corev1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"a"
,
Name
:
"a"
,
...
@@ -109,8 +109,8 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -109,8 +109,8 @@ func TestSortingPrinter(t *testing.T) {
},
},
{
{
name
:
"reverse-order"
,
name
:
"reverse-order"
,
obj
:
&
api
.
PodList
{
obj
:
&
corev1
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
corev1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"b"
,
Name
:
"b"
,
...
@@ -128,8 +128,8 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -128,8 +128,8 @@ func TestSortingPrinter(t *testing.T) {
},
},
},
},
},
},
sort
:
&
api
.
PodList
{
sort
:
&
corev1
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
corev1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"a"
,
Name
:
"a"
,
...
@@ -151,8 +151,8 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -151,8 +151,8 @@ func TestSortingPrinter(t *testing.T) {
},
},
{
{
name
:
"random-order-timestamp"
,
name
:
"random-order-timestamp"
,
obj
:
&
api
.
PodList
{
obj
:
&
corev1
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
corev1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
CreationTimestamp
:
metav1
.
Unix
(
300
,
0
),
CreationTimestamp
:
metav1
.
Unix
(
300
,
0
),
...
@@ -170,8 +170,8 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -170,8 +170,8 @@ func TestSortingPrinter(t *testing.T) {
},
},
},
},
},
},
sort
:
&
api
.
PodList
{
sort
:
&
corev1
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
corev1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
CreationTimestamp
:
metav1
.
Unix
(
100
,
0
),
CreationTimestamp
:
metav1
.
Unix
(
100
,
0
),
...
@@ -193,39 +193,39 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -193,39 +193,39 @@ func TestSortingPrinter(t *testing.T) {
},
},
{
{
name
:
"random-order-numbers"
,
name
:
"random-order-numbers"
,
obj
:
&
api
.
ReplicationControllerList
{
obj
:
&
corev1
.
ReplicationControllerList
{
Items
:
[]
api
.
ReplicationController
{
Items
:
[]
corev1
.
ReplicationController
{
{
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
corev1
.
ReplicationControllerSpec
{
Replicas
:
intPtr
(
5
),
Replicas
:
intPtr
(
5
),
},
},
},
},
{
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
corev1
.
ReplicationControllerSpec
{
Replicas
:
intPtr
(
1
),
Replicas
:
intPtr
(
1
),
},
},
},
},
{
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
corev1
.
ReplicationControllerSpec
{
Replicas
:
intPtr
(
9
),
Replicas
:
intPtr
(
9
),
},
},
},
},
},
},
},
},
sort
:
&
api
.
ReplicationControllerList
{
sort
:
&
corev1
.
ReplicationControllerList
{
Items
:
[]
api
.
ReplicationController
{
Items
:
[]
corev1
.
ReplicationController
{
{
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
corev1
.
ReplicationControllerSpec
{
Replicas
:
intPtr
(
1
),
Replicas
:
intPtr
(
1
),
},
},
},
},
{
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
corev1
.
ReplicationControllerSpec
{
Replicas
:
intPtr
(
5
),
Replicas
:
intPtr
(
5
),
},
},
},
},
{
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
corev1
.
ReplicationControllerSpec
{
Replicas
:
intPtr
(
9
),
Replicas
:
intPtr
(
9
),
},
},
},
},
...
@@ -235,14 +235,14 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -235,14 +235,14 @@ func TestSortingPrinter(t *testing.T) {
},
},
{
{
name
:
"v1.List in order"
,
name
:
"v1.List in order"
,
obj
:
&
api
.
List
{
obj
:
&
corev1
.
List
{
Items
:
[]
runtime
.
RawExtension
{
Items
:
[]
runtime
.
RawExtension
{
{
Raw
:
encodeOrDie
(
a
)},
{
Raw
:
encodeOrDie
(
a
)},
{
Raw
:
encodeOrDie
(
b
)},
{
Raw
:
encodeOrDie
(
b
)},
{
Raw
:
encodeOrDie
(
c
)},
{
Raw
:
encodeOrDie
(
c
)},
},
},
},
},
sort
:
&
api
.
List
{
sort
:
&
corev1
.
List
{
Items
:
[]
runtime
.
RawExtension
{
Items
:
[]
runtime
.
RawExtension
{
{
Raw
:
encodeOrDie
(
a
)},
{
Raw
:
encodeOrDie
(
a
)},
{
Raw
:
encodeOrDie
(
b
)},
{
Raw
:
encodeOrDie
(
b
)},
...
@@ -253,14 +253,14 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -253,14 +253,14 @@ func TestSortingPrinter(t *testing.T) {
},
},
{
{
name
:
"v1.List in reverse"
,
name
:
"v1.List in reverse"
,
obj
:
&
api
.
List
{
obj
:
&
corev1
.
List
{
Items
:
[]
runtime
.
RawExtension
{
Items
:
[]
runtime
.
RawExtension
{
{
Raw
:
encodeOrDie
(
c
)},
{
Raw
:
encodeOrDie
(
c
)},
{
Raw
:
encodeOrDie
(
b
)},
{
Raw
:
encodeOrDie
(
b
)},
{
Raw
:
encodeOrDie
(
a
)},
{
Raw
:
encodeOrDie
(
a
)},
},
},
},
},
sort
:
&
api
.
List
{
sort
:
&
corev1
.
List
{
Items
:
[]
runtime
.
RawExtension
{
Items
:
[]
runtime
.
RawExtension
{
{
Raw
:
encodeOrDie
(
a
)},
{
Raw
:
encodeOrDie
(
a
)},
{
Raw
:
encodeOrDie
(
b
)},
{
Raw
:
encodeOrDie
(
b
)},
...
@@ -372,16 +372,16 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -372,16 +372,16 @@ func TestSortingPrinter(t *testing.T) {
},
},
{
{
name
:
"model-invalid-fields"
,
name
:
"model-invalid-fields"
,
obj
:
&
api
.
ReplicationControllerList
{
obj
:
&
corev1
.
ReplicationControllerList
{
Items
:
[]
api
.
ReplicationController
{
Items
:
[]
corev1
.
ReplicationController
{
{
{
Status
:
api
.
ReplicationControllerStatus
{},
Status
:
corev1
.
ReplicationControllerStatus
{},
},
},
{
{
Status
:
api
.
ReplicationControllerStatus
{},
Status
:
corev1
.
ReplicationControllerStatus
{},
},
},
{
{
Status
:
api
.
ReplicationControllerStatus
{},
Status
:
corev1
.
ReplicationControllerStatus
{},
},
},
},
},
},
},
...
@@ -391,7 +391,7 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -391,7 +391,7 @@ func TestSortingPrinter(t *testing.T) {
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
sort
:=
&
SortingPrinter
{
SortField
:
tt
.
field
,
Decoder
:
legacy
scheme
.
Codecs
.
UniversalDecoder
()}
sort
:=
&
SortingPrinter
{
SortField
:
tt
.
field
,
Decoder
:
scheme
.
Codecs
.
UniversalDecoder
()}
err
:=
sort
.
sortObj
(
tt
.
obj
)
err
:=
sort
.
sortObj
(
tt
.
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
if
len
(
tt
.
expectedErr
)
>
0
{
if
len
(
tt
.
expectedErr
)
>
0
{
...
@@ -415,8 +415,8 @@ func TestSortingPrinter(t *testing.T) {
...
@@ -415,8 +415,8 @@ func TestSortingPrinter(t *testing.T) {
func
TestRuntimeSortLess
(
t
*
testing
.
T
)
{
func
TestRuntimeSortLess
(
t
*
testing
.
T
)
{
var
testobj
runtime
.
Object
var
testobj
runtime
.
Object
testobj
=
&
api
.
PodList
{
testobj
=
&
corev1
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
corev1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"b"
,
Name
:
"b"
,
...
...
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