mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
manually fix kubectl openapi unit test
This commit is contained in:
parent
83235f940a
commit
239613b521
@ -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)
|
||||||
|
@ -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() {
|
|||||||
|
|
||||||
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() {
|
|||||||
|
|
||||||
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(
|
|||||||
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(
|
|||||||
|
|
||||||
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()
|
|||||||
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()
|
|||||||
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() {
|
|||||||
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
|
|||||||
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() {
|
||||||
|
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user