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
239613b5
Commit
239613b5
authored
Jun 11, 2017
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
manually fix kubectl openapi unit test
parent
83235f94
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
13 deletions
+18
-13
openapi.go
pkg/kubectl/cmd/util/openapi/openapi.go
+1
-1
openapi_test.go
pkg/kubectl/cmd/util/openapi/openapi_test.go
+12
-10
openapi_test.go
...rc/k8s.io/apiserver/pkg/endpoints/openapi/openapi_test.go
+5
-2
No files found.
pkg/kubectl/cmd/util/openapi/openapi.go
View file @
239613b5
...
@@ -77,7 +77,7 @@ type Kind struct {
...
@@ -77,7 +77,7 @@ type Kind struct {
// Name is the lookup key given to this Kind by the open API spec.
// Name is the lookup key given to this Kind by the open API spec.
// May not contain any semantic meaning or relation to the API definition,
// May not contain any semantic meaning or relation to the API definition,
// simply must be unique for each object definition in the Open API spec.
// simply must be unique for each object definition in the Open API spec.
// e.g. io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.Deployment
// e.g. io.k8s.
api
.apps.v1beta1.Deployment
Name
string
Name
string
// IsResource is true if the Kind is a Resource (it has API endpoints)
// IsResource is true if the Kind is a Resource (it has API endpoints)
...
...
pkg/kubectl/cmd/util/openapi/openapi_test.go
View file @
239613b5
...
@@ -34,9 +34,10 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
...
@@ -34,9 +34,10 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
Expect
(
err
)
.
To
(
BeNil
())
Expect
(
err
)
.
To
(
BeNil
())
instance
,
err
=
openapi
.
NewOpenAPIData
(
s
)
instance
,
err
=
openapi
.
NewOpenAPIData
(
s
)
Expect
(
err
)
.
To
(
BeNil
())
Expect
(
err
)
.
To
(
BeNil
())
fmt
.
Fprintf
(
GinkgoWriter
,
fmt
.
Sprintf
(
"CHAO: instance.GroupVersionKindToName=%#v
\n
"
,
instance
.
GroupVersionKindToName
))
})
})
deploymentName
:=
"io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.Deployment"
deploymentName
:=
"io.k8s.
api
.apps.v1beta1.Deployment"
gvk
:=
schema
.
GroupVersionKind
{
gvk
:=
schema
.
GroupVersionKind
{
Kind
:
"Deployment"
,
Kind
:
"Deployment"
,
Version
:
"v1beta1"
,
Version
:
"v1beta1"
,
...
@@ -45,6 +46,7 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
...
@@ -45,6 +46,7 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
It
(
"should find the name by its GroupVersionKind"
,
func
()
{
It
(
"should find the name by its GroupVersionKind"
,
func
()
{
name
,
found
:=
instance
.
GroupVersionKindToName
[
gvk
]
name
,
found
:=
instance
.
GroupVersionKindToName
[
gvk
]
fmt
.
Fprintf
(
GinkgoWriter
,
fmt
.
Sprintf
(
"CHAO: instance.GroupVersionKindToName=%#v
\n
"
,
instance
.
GroupVersionKindToName
))
Expect
(
found
)
.
To
(
BeTrue
())
Expect
(
found
)
.
To
(
BeTrue
())
Expect
(
name
)
.
To
(
Equal
(
deploymentName
))
Expect
(
name
)
.
To
(
Equal
(
deploymentName
))
})
})
...
@@ -93,13 +95,13 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
...
@@ -93,13 +95,13 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
By
(
"for 'spec'"
)
By
(
"for 'spec'"
)
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"spec"
,
openapi
.
Type
{
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"spec"
,
openapi
.
Type
{
TypeName
:
"io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.DeploymentSpec"
,
TypeName
:
"io.k8s.
api
.apps.v1beta1.DeploymentSpec"
,
IsKind
:
true
,
IsKind
:
true
,
}))
}))
By
(
"for 'status'"
)
By
(
"for 'status'"
)
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"status"
,
openapi
.
Type
{
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"status"
,
openapi
.
Type
{
TypeName
:
"io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.DeploymentStatus"
,
TypeName
:
"io.k8s.
api
.apps.v1beta1.DeploymentStatus"
,
IsKind
:
true
,
IsKind
:
true
,
}))
}))
})
})
...
@@ -114,7 +116,7 @@ var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func(
...
@@ -114,7 +116,7 @@ var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func(
Expect
(
err
)
.
To
(
BeNil
())
Expect
(
err
)
.
To
(
BeNil
())
})
})
deploymentStatusName
:=
"io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.DeploymentStatus"
deploymentStatusName
:=
"io.k8s.
api
.apps.v1beta1.DeploymentStatus"
var
definition
openapi
.
Kind
var
definition
openapi
.
Kind
It
(
"should find the definition by name"
,
func
()
{
It
(
"should find the definition by name"
,
func
()
{
...
@@ -143,10 +145,10 @@ var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func(
...
@@ -143,10 +145,10 @@ var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func(
By
(
"for 'conditions'"
)
By
(
"for 'conditions'"
)
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"conditions"
,
openapi
.
Type
{
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"conditions"
,
openapi
.
Type
{
TypeName
:
"io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.DeploymentCondition array"
,
TypeName
:
"io.k8s.
api
.apps.v1beta1.DeploymentCondition array"
,
IsArray
:
true
,
IsArray
:
true
,
ElementType
:
&
openapi
.
Type
{
ElementType
:
&
openapi
.
Type
{
TypeName
:
"io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.DeploymentCondition"
,
TypeName
:
"io.k8s.
api
.apps.v1beta1.DeploymentCondition"
,
IsKind
:
true
,
IsKind
:
true
,
},
},
Extensions
:
spec
.
Extensions
{
Extensions
:
spec
.
Extensions
{
...
@@ -166,7 +168,7 @@ var _ = Describe("Reading apps/v1beta1/DeploymentSpec from openAPIData", func()
...
@@ -166,7 +168,7 @@ var _ = Describe("Reading apps/v1beta1/DeploymentSpec from openAPIData", func()
Expect
(
err
)
.
To
(
BeNil
())
Expect
(
err
)
.
To
(
BeNil
())
})
})
deploymentSpecName
:=
"io.k8s.
kubernetes.pkg.apis
.apps.v1beta1.DeploymentSpec"
deploymentSpecName
:=
"io.k8s.
api
.apps.v1beta1.DeploymentSpec"
var
definition
openapi
.
Kind
var
definition
openapi
.
Kind
It
(
"should find the definition by name"
,
func
()
{
It
(
"should find the definition by name"
,
func
()
{
...
@@ -189,7 +191,7 @@ var _ = Describe("Reading apps/v1beta1/DeploymentSpec from openAPIData", func()
...
@@ -189,7 +191,7 @@ var _ = Describe("Reading apps/v1beta1/DeploymentSpec from openAPIData", func()
It
(
"should find the definition fields"
,
func
()
{
It
(
"should find the definition fields"
,
func
()
{
By
(
"for 'template'"
)
By
(
"for 'template'"
)
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"template"
,
openapi
.
Type
{
Expect
(
definition
.
Fields
)
.
To
(
HaveKeyWithValue
(
"template"
,
openapi
.
Type
{
TypeName
:
"io.k8s.
kubernetes.pkg.api
.v1.PodTemplateSpec"
,
TypeName
:
"io.k8s.
api.core
.v1.PodTemplateSpec"
,
IsKind
:
true
,
IsKind
:
true
,
}))
}))
})
})
...
@@ -273,7 +275,7 @@ var _ = Describe("Reading v1/NodeStatus from openAPIData", func() {
...
@@ -273,7 +275,7 @@ var _ = Describe("Reading v1/NodeStatus from openAPIData", func() {
Expect
(
err
)
.
To
(
BeNil
())
Expect
(
err
)
.
To
(
BeNil
())
})
})
nodeStatusName
:=
"io.k8s.
kubernetes.pkg.api
.v1.NodeStatus"
nodeStatusName
:=
"io.k8s.
api.core
.v1.NodeStatus"
var
definition
openapi
.
Kind
var
definition
openapi
.
Kind
It
(
"should find the definition by name"
,
func
()
{
It
(
"should find the definition by name"
,
func
()
{
...
@@ -378,7 +380,7 @@ var _ = Describe("Reading authorization/v1/SubjectAccessReviewSpec from openAPID
...
@@ -378,7 +380,7 @@ var _ = Describe("Reading authorization/v1/SubjectAccessReviewSpec from openAPID
Expect
(
err
)
.
To
(
BeNil
())
Expect
(
err
)
.
To
(
BeNil
())
})
})
subjectAccessReviewSpecName
:=
"io.k8s.
kubernetes.pkg.apis
.authorization.v1.SubjectAccessReviewSpec"
subjectAccessReviewSpecName
:=
"io.k8s.
api
.authorization.v1.SubjectAccessReviewSpec"
var
definition
openapi
.
Kind
var
definition
openapi
.
Kind
It
(
"should find the definition by name"
,
func
()
{
It
(
"should find the definition by name"
,
func
()
{
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/openapi/openapi_test.go
View file @
239613b5
...
@@ -60,8 +60,11 @@ func assertEqual(t *testing.T, expected, actual interface{}) {
...
@@ -60,8 +60,11 @@ func assertEqual(t *testing.T, expected, actual interface{}) {
func
TestGetDefinitionName
(
t
*
testing
.
T
)
{
func
TestGetDefinitionName
(
t
*
testing
.
T
)
{
testType
:=
TestType
{}
testType
:=
TestType
{}
typePkgName
:=
"k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/endpoints/openapi.TestType"
// in production, the name is stripped of ".*vendor/" prefix before passed
typeFriendlyName
:=
"io.k8s.kubernetes.vendor.k8s.io.apiserver.pkg.endpoints.openapi.TestType"
// to GetDefinitionName, so here typePkgName does not have the
// "k8s.io/kubernetes/vendor" prefix.
typePkgName
:=
"k8s.io/apiserver/pkg/endpoints/openapi.TestType"
typeFriendlyName
:=
"io.k8s.apiserver.pkg.endpoints.openapi.TestType"
if
strings
.
HasSuffix
(
reflect
.
TypeOf
(
testType
)
.
PkgPath
(),
"go_default_test"
)
{
if
strings
.
HasSuffix
(
reflect
.
TypeOf
(
testType
)
.
PkgPath
(),
"go_default_test"
)
{
// the test is running inside bazel where the package name is changed and
// the test is running inside bazel where the package name is changed and
// "go_default_test" will add to package path.
// "go_default_test" will add to package path.
...
...
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