mirror of https://github.com/k3s-io/k3s
Print a newline after ginkgo tests so the test infra doesn't think that they fail
Fixes #45279pull/6/head
parent
f84b61b4b1
commit
83ff8f2d6c
|
@ -8,24 +8,6 @@ load(
|
||||||
"go_test",
|
"go_test",
|
||||||
)
|
)
|
||||||
|
|
||||||
go_test(
|
|
||||||
name = "go_default_test",
|
|
||||||
srcs = [
|
|
||||||
"openapi_cache_test.go",
|
|
||||||
"openapi_getter_test.go",
|
|
||||||
"openapi_test.go",
|
|
||||||
],
|
|
||||||
library = ":go_default_library",
|
|
||||||
tags = ["automanaged"],
|
|
||||||
deps = [
|
|
||||||
"//vendor/github.com/go-openapi/loads:go_default_library",
|
|
||||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
|
||||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
|
||||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
@ -47,11 +29,24 @@ go_library(
|
||||||
|
|
||||||
go_test(
|
go_test(
|
||||||
name = "go_default_xtest",
|
name = "go_default_xtest",
|
||||||
srcs = ["openapi_suite_test.go"],
|
size = "small",
|
||||||
|
srcs = [
|
||||||
|
"openapi_cache_test.go",
|
||||||
|
"openapi_getter_test.go",
|
||||||
|
"openapi_suite_test.go",
|
||||||
|
"openapi_test.go",
|
||||||
|
],
|
||||||
|
data = ["//api/openapi-spec:swagger-spec"],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//pkg/kubectl/cmd/util/openapi:go_default_library",
|
||||||
|
"//vendor/github.com/go-openapi/loads:go_default_library",
|
||||||
|
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||||
|
"//vendor/github.com/onsi/ginkgo/config:go_default_library",
|
||||||
|
"//vendor/github.com/onsi/ginkgo/types:go_default_library",
|
||||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,3 +62,8 @@ filegroup(
|
||||||
srcs = [":package-srcs"],
|
srcs = [":package-srcs"],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "testdata",
|
||||||
|
srcs = glob(["testdata/*"]),
|
||||||
|
)
|
||||||
|
|
|
@ -133,8 +133,8 @@ type Type struct {
|
||||||
Extensions spec.Extensions
|
Extensions spec.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
// newOpenAPIData parses the resource definitions in openapi data by groupversionkind and name
|
// NewOpenAPIData parses the resource definitions in openapi data by groupversionkind and name
|
||||||
func newOpenAPIData(s *spec.Swagger) (*Resources, error) {
|
func NewOpenAPIData(s *spec.Swagger) (*Resources, error) {
|
||||||
o := &Resources{
|
o := &Resources{
|
||||||
GroupVersionKindToName: map[schema.GroupVersionKind]string{},
|
GroupVersionKindToName: map[schema.GroupVersionKind]string{},
|
||||||
NameToDefinition: map[string]Kind{},
|
NameToDefinition: map[string]Kind{},
|
||||||
|
@ -338,7 +338,7 @@ func (o *Resources) nameForDefinitionField(s spec.Schema) string {
|
||||||
return strings.Replace(p, "/definitions/", "", -1)
|
return strings.Replace(p, "/definitions/", "", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getGroupVersionKind implements openAPIData
|
// getGroupVersionKind implements OpenAPIData
|
||||||
// getGVK parses the gropuversionkind for a resource definition from the x-kubernetes
|
// getGVK parses the gropuversionkind for a resource definition from the x-kubernetes
|
||||||
// extensions
|
// extensions
|
||||||
// Expected format for s.Extensions: map[string][]map[string]string
|
// Expected format for s.Extensions: map[string][]map[string]string
|
||||||
|
|
|
@ -37,31 +37,31 @@ func init() {
|
||||||
|
|
||||||
const openapiFileName = "openapi_cache"
|
const openapiFileName = "openapi_cache"
|
||||||
|
|
||||||
type cachingOpenAPIClient struct {
|
type CachingOpenAPIClient struct {
|
||||||
version string
|
version string
|
||||||
client discovery.OpenAPISchemaInterface
|
client discovery.OpenAPISchemaInterface
|
||||||
cacheDirName string
|
cacheDirName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// newCachingOpenAPIClient returns a new discovery.OpenAPISchemaInterface
|
// NewCachingOpenAPIClient returns a new discovery.OpenAPISchemaInterface
|
||||||
// that will read the openapi spec from a local cache if it exists, and
|
// that will read the openapi spec from a local cache if it exists, and
|
||||||
// if not will then fetch an openapi spec using a client.
|
// if not will then fetch an openapi spec using a client.
|
||||||
// client: used to fetch a new openapi spec if a local cache is not found
|
// client: used to fetch a new openapi spec if a local cache is not found
|
||||||
// version: the server version and used as part of the cache file location
|
// version: the server version and used as part of the cache file location
|
||||||
// cacheDir: the directory under which the cache file will be written
|
// cacheDir: the directory under which the cache file will be written
|
||||||
func newCachingOpenAPIClient(client discovery.OpenAPISchemaInterface, version, cacheDir string) *cachingOpenAPIClient {
|
func NewCachingOpenAPIClient(client discovery.OpenAPISchemaInterface, version, cacheDir string) *CachingOpenAPIClient {
|
||||||
return &cachingOpenAPIClient{
|
return &CachingOpenAPIClient{
|
||||||
client: client,
|
client: client,
|
||||||
version: version,
|
version: version,
|
||||||
cacheDirName: cacheDir,
|
cacheDirName: cacheDir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// openAPIData returns an openapi spec.
|
// OpenAPIData returns an openapi spec.
|
||||||
// It will first attempt to read the spec from a local cache
|
// It will first attempt to read the spec from a local cache
|
||||||
// If it cannot read a local cache, it will read the file
|
// If it cannot read a local cache, it will read the file
|
||||||
// using the client and then write the cache.
|
// using the client and then write the cache.
|
||||||
func (c *cachingOpenAPIClient) openAPIData() (*Resources, error) {
|
func (c *CachingOpenAPIClient) OpenAPIData() (*Resources, error) {
|
||||||
// Try to use the cached version
|
// Try to use the cached version
|
||||||
if c.useCache() {
|
if c.useCache() {
|
||||||
doc, err := c.readOpenAPICache()
|
doc, err := c.readOpenAPICache()
|
||||||
|
@ -77,7 +77,7 @@ func (c *cachingOpenAPIClient) openAPIData() (*Resources, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
oa, err := newOpenAPIData(s)
|
oa, err := NewOpenAPIData(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(2).Infof("Failed to parse openapi data %v", err)
|
glog.V(2).Infof("Failed to parse openapi data %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -97,12 +97,12 @@ func (c *cachingOpenAPIClient) openAPIData() (*Resources, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// useCache returns true if the client should try to use the cache file
|
// useCache returns true if the client should try to use the cache file
|
||||||
func (c *cachingOpenAPIClient) useCache() bool {
|
func (c *CachingOpenAPIClient) useCache() bool {
|
||||||
return len(c.version) > 0 && len(c.cacheDirName) > 0
|
return len(c.version) > 0 && len(c.cacheDirName) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// readOpenAPICache tries to read the openapi spec from the local file cache
|
// readOpenAPICache tries to read the openapi spec from the local file cache
|
||||||
func (c *cachingOpenAPIClient) readOpenAPICache() (*Resources, error) {
|
func (c *CachingOpenAPIClient) readOpenAPICache() (*Resources, error) {
|
||||||
// Get the filename to read
|
// Get the filename to read
|
||||||
filename := c.openAPICacheFilename()
|
filename := c.openAPICacheFilename()
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ func (c *cachingOpenAPIClient) readOpenAPICache() (*Resources, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// decodeSpec binary decodes the openapi spec
|
// decodeSpec binary decodes the openapi spec
|
||||||
func (c *cachingOpenAPIClient) decodeSpec(data []byte) (*Resources, error) {
|
func (c *CachingOpenAPIClient) decodeSpec(data []byte) (*Resources, error) {
|
||||||
b := bytes.NewBuffer(data)
|
b := bytes.NewBuffer(data)
|
||||||
d := gob.NewDecoder(b)
|
d := gob.NewDecoder(b)
|
||||||
parsed := &Resources{}
|
parsed := &Resources{}
|
||||||
|
@ -128,7 +128,7 @@ func (c *cachingOpenAPIClient) decodeSpec(data []byte) (*Resources, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeSpec binary encodes the openapi spec
|
// encodeSpec binary encodes the openapi spec
|
||||||
func (c *cachingOpenAPIClient) encodeSpec(parsed *Resources) ([]byte, error) {
|
func (c *CachingOpenAPIClient) encodeSpec(parsed *Resources) ([]byte, error) {
|
||||||
b := &bytes.Buffer{}
|
b := &bytes.Buffer{}
|
||||||
e := gob.NewEncoder(b)
|
e := gob.NewEncoder(b)
|
||||||
err := e.Encode(parsed)
|
err := e.Encode(parsed)
|
||||||
|
@ -138,7 +138,7 @@ func (c *cachingOpenAPIClient) encodeSpec(parsed *Resources) ([]byte, error) {
|
||||||
|
|
||||||
// writeToCache tries to write the openapi spec to the local file cache.
|
// writeToCache tries to write the openapi spec to the local file cache.
|
||||||
// writes the data to a new tempfile, and then links the cache file and the tempfile
|
// writes the data to a new tempfile, and then links the cache file and the tempfile
|
||||||
func (c *cachingOpenAPIClient) writeToCache(parsed *Resources) error {
|
func (c *CachingOpenAPIClient) writeToCache(parsed *Resources) error {
|
||||||
// Get the constant filename used to read the cache.
|
// Get the constant filename used to read the cache.
|
||||||
cacheFile := c.openAPICacheFilename()
|
cacheFile := c.openAPICacheFilename()
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ func (c *cachingOpenAPIClient) writeToCache(parsed *Resources) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// openAPICacheFilename returns the filename to read the cache from
|
// openAPICacheFilename returns the filename to read the cache from
|
||||||
func (c *cachingOpenAPIClient) openAPICacheFilename() string {
|
func (c *CachingOpenAPIClient) openAPICacheFilename() string {
|
||||||
// Cache using the client and server versions
|
// Cache using the client and server versions
|
||||||
return filepath.Join(c.cacheDirName, c.version, version.Get().GitVersion, openapiFileName)
|
return filepath.Join(c.cacheDirName, c.version, version.Get().GitVersion, openapiFileName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package openapi_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -27,25 +27,27 @@ import (
|
||||||
"github.com/go-openapi/spec"
|
"github.com/go-openapi/spec"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("When reading openAPIData", func() {
|
var _ = Describe("When reading openAPIData", func() {
|
||||||
var tmpDir string
|
var tmpDir string
|
||||||
var err error
|
var err error
|
||||||
var client *fakeOpenAPIClient
|
var client *fakeOpenAPIClient
|
||||||
var instance *cachingOpenAPIClient
|
var instance *openapi.CachingOpenAPIClient
|
||||||
var expectedData *Resources
|
var expectedData *openapi.Resources
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
tmpDir, err = ioutil.TempDir("", "openapi_cache_test")
|
tmpDir, err = ioutil.TempDir("", "openapi_cache_test")
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
client = &fakeOpenAPIClient{}
|
client = &fakeOpenAPIClient{}
|
||||||
instance = newCachingOpenAPIClient(client, "v1.6", tmpDir)
|
instance = openapi.NewCachingOpenAPIClient(client, "v1.6", tmpDir)
|
||||||
|
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
expectedData, err = newOpenAPIData(d)
|
expectedData, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ var _ = Describe("When reading openAPIData", func() {
|
||||||
|
|
||||||
It("should write to the cache", func() {
|
It("should write to the cache", func() {
|
||||||
By("getting the live openapi spec from the server")
|
By("getting the live openapi spec from the server")
|
||||||
result, err := instance.openAPIData()
|
result, err := instance.OpenAPIData()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
expectEqual(result, expectedData)
|
expectEqual(result, expectedData)
|
||||||
Expect(client.calls).To(Equal(1))
|
Expect(client.calls).To(Equal(1))
|
||||||
|
@ -77,13 +79,13 @@ var _ = Describe("When reading openAPIData", func() {
|
||||||
|
|
||||||
It("should read from the cache", func() {
|
It("should read from the cache", func() {
|
||||||
// First call should use the client
|
// First call should use the client
|
||||||
result, err := instance.openAPIData()
|
result, err := instance.OpenAPIData()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
expectEqual(result, expectedData)
|
expectEqual(result, expectedData)
|
||||||
Expect(client.calls).To(Equal(1))
|
Expect(client.calls).To(Equal(1))
|
||||||
|
|
||||||
// Second call shouldn't use the client
|
// Second call shouldn't use the client
|
||||||
result, err = instance.openAPIData()
|
result, err = instance.OpenAPIData()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
expectEqual(result, expectedData)
|
expectEqual(result, expectedData)
|
||||||
Expect(client.calls).To(Equal(1))
|
Expect(client.calls).To(Equal(1))
|
||||||
|
@ -96,7 +98,7 @@ var _ = Describe("When reading openAPIData", func() {
|
||||||
It("propagate errors that are encountered", func() {
|
It("propagate errors that are encountered", func() {
|
||||||
// Expect an error
|
// Expect an error
|
||||||
client.err = fmt.Errorf("expected error")
|
client.err = fmt.Errorf("expected error")
|
||||||
result, err := instance.openAPIData()
|
result, err := instance.OpenAPIData()
|
||||||
Expect(err.Error()).To(Equal(client.err.Error()))
|
Expect(err.Error()).To(Equal(client.err.Error()))
|
||||||
Expect(result).To(BeNil())
|
Expect(result).To(BeNil())
|
||||||
Expect(client.calls).To(Equal(1))
|
Expect(client.calls).To(Equal(1))
|
||||||
|
@ -107,7 +109,7 @@ var _ = Describe("When reading openAPIData", func() {
|
||||||
Expect(files).To(HaveLen(0))
|
Expect(files).To(HaveLen(0))
|
||||||
|
|
||||||
// Client error is not cached
|
// Client error is not cached
|
||||||
result, err = instance.openAPIData()
|
result, err = instance.OpenAPIData()
|
||||||
Expect(err.Error()).To(Equal(client.err.Error()))
|
Expect(err.Error()).To(Equal(client.err.Error()))
|
||||||
Expect(result).To(BeNil())
|
Expect(result).To(BeNil())
|
||||||
Expect(client.calls).To(Equal(2))
|
Expect(client.calls).To(Equal(2))
|
||||||
|
@ -138,16 +140,16 @@ var _ = Describe("Reading openAPIData", func() {
|
||||||
It("should not cache the result", func() {
|
It("should not cache the result", func() {
|
||||||
client := &fakeOpenAPIClient{}
|
client := &fakeOpenAPIClient{}
|
||||||
|
|
||||||
instance := newCachingOpenAPIClient(client, serverVersion, cacheDir)
|
instance := openapi.NewCachingOpenAPIClient(client, serverVersion, cacheDir)
|
||||||
|
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
expectedData, err := newOpenAPIData(d)
|
expectedData, err := openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
By("getting the live openapi schema")
|
By("getting the live openapi schema")
|
||||||
result, err := instance.openAPIData()
|
result, err := instance.OpenAPIData()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
expectEqual(result, expectedData)
|
expectEqual(result, expectedData)
|
||||||
Expect(client.calls).To(Equal(1))
|
Expect(client.calls).To(Equal(1))
|
||||||
|
@ -166,16 +168,16 @@ var _ = Describe("Reading openAPIData", func() {
|
||||||
It("should not cache the result", func() {
|
It("should not cache the result", func() {
|
||||||
client := &fakeOpenAPIClient{}
|
client := &fakeOpenAPIClient{}
|
||||||
|
|
||||||
instance := newCachingOpenAPIClient(client, serverVersion, cacheDir)
|
instance := openapi.NewCachingOpenAPIClient(client, serverVersion, cacheDir)
|
||||||
|
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
expectedData, err := newOpenAPIData(d)
|
expectedData, err := openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
By("getting the live openapi schema")
|
By("getting the live openapi schema")
|
||||||
result, err := instance.openAPIData()
|
result, err := instance.OpenAPIData()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
expectEqual(result, expectedData)
|
expectEqual(result, expectedData)
|
||||||
Expect(client.calls).To(Equal(1))
|
Expect(client.calls).To(Equal(1))
|
||||||
|
@ -200,7 +202,7 @@ func getFilenames(path string) ([]string, error) {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func expectEqual(a *Resources, b *Resources) {
|
func expectEqual(a *openapi.Resources, b *openapi.Resources) {
|
||||||
Expect(a.NameToDefinition).To(HaveLen(len(b.NameToDefinition)))
|
Expect(a.NameToDefinition).To(HaveLen(len(b.NameToDefinition)))
|
||||||
for k, v := range a.NameToDefinition {
|
for k, v := range a.NameToDefinition {
|
||||||
Expect(v).To(Equal(b.NameToDefinition[k]),
|
Expect(v).To(Equal(b.NameToDefinition[k]),
|
||||||
|
|
|
@ -38,7 +38,7 @@ var _ Getter = &synchronizedOpenAPIGetter{}
|
||||||
|
|
||||||
// Getter is an interface for fetching openapi specs and parsing them into an Resources struct
|
// Getter is an interface for fetching openapi specs and parsing them into an Resources struct
|
||||||
type Getter interface {
|
type Getter interface {
|
||||||
// openAPIData returns the parsed openAPIData
|
// OpenAPIData returns the parsed OpenAPIData
|
||||||
Get() (*Resources, error)
|
Get() (*Resources, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ func NewOpenAPIGetter(cacheDir, serverVersion string, openAPIClient discovery.Op
|
||||||
// Resources implements Getter
|
// Resources implements Getter
|
||||||
func (g *synchronizedOpenAPIGetter) Get() (*Resources, error) {
|
func (g *synchronizedOpenAPIGetter) Get() (*Resources, error) {
|
||||||
g.Do(func() {
|
g.Do(func() {
|
||||||
client := newCachingOpenAPIClient(g.openAPIClient, g.serverVersion, g.cacheDir)
|
client := NewCachingOpenAPIClient(g.openAPIClient, g.serverVersion, g.cacheDir)
|
||||||
result, err := client.openAPIData()
|
result, err := client.OpenAPIData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.err = err
|
g.err = err
|
||||||
return
|
return
|
||||||
|
|
|
@ -14,29 +14,31 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package openapi_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Getting the Resources", func() {
|
var _ = Describe("Getting the Resources", func() {
|
||||||
var client *fakeOpenAPIClient
|
var client *fakeOpenAPIClient
|
||||||
var expectedData *Resources
|
var expectedData *openapi.Resources
|
||||||
var instance Getter
|
var instance openapi.Getter
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
client = &fakeOpenAPIClient{}
|
client = &fakeOpenAPIClient{}
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
expectedData, err = newOpenAPIData(d)
|
expectedData, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
instance = NewOpenAPIGetter("", "", client)
|
instance = openapi.NewOpenAPIGetter("", "", client)
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("when the server returns a successful result", func() {
|
Context("when the server returns a successful result", func() {
|
||||||
|
|
|
@ -18,12 +18,32 @@ package openapi_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/ginkgo/config"
|
||||||
|
. "github.com/onsi/ginkgo/types"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOpenapi(t *testing.T) {
|
func TestOpenapi(t *testing.T) {
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
RunSpecs(t, "Openapi Suite")
|
RunSpecsWithDefaultAndCustomReporters(t, "Openapi Suite", []Reporter{newlineReporter{}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print a newline after the default newlineReporter due to issue
|
||||||
|
// https://github.com/jstemmer/go-junit-report/issues/31
|
||||||
|
type newlineReporter struct{}
|
||||||
|
|
||||||
|
func (newlineReporter) SpecSuiteWillBegin(config GinkgoConfigType, summary *SuiteSummary) {}
|
||||||
|
|
||||||
|
func (newlineReporter) BeforeSuiteDidRun(setupSummary *SetupSummary) {}
|
||||||
|
|
||||||
|
func (newlineReporter) AfterSuiteDidRun(setupSummary *SetupSummary) {}
|
||||||
|
|
||||||
|
func (newlineReporter) SpecWillRun(specSummary *SpecSummary) {}
|
||||||
|
|
||||||
|
func (newlineReporter) SpecDidComplete(specSummary *SpecSummary) {}
|
||||||
|
|
||||||
|
// SpecSuiteDidEnd Prints a newline between "35 Passed | 0 Failed | 0 Pending | 0 Skipped" and "--- PASS:"
|
||||||
|
func (newlineReporter) SpecSuiteDidEnd(summary *SuiteSummary) { fmt.Printf("\n") }
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package openapi
|
package openapi_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -24,14 +24,15 @@ import (
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
|
var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
s, err := data.OpenAPISchema()
|
s, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(s)
|
instance, err = openapi.NewOpenAPIData(s)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
|
||||||
Expect(name).To(Equal(deploymentName))
|
Expect(name).To(Equal(deploymentName))
|
||||||
})
|
})
|
||||||
|
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
var found bool
|
var found bool
|
||||||
definition, found = instance.NameToDefinition[deploymentName]
|
definition, found = instance.NameToDefinition[deploymentName]
|
||||||
|
@ -73,31 +74,31 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
|
||||||
|
|
||||||
It("should find the definition fields", func() {
|
It("should find the definition fields", func() {
|
||||||
By("for 'kind'")
|
By("for 'kind'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("kind", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("kind", openapi.Type{
|
||||||
TypeName: "string",
|
TypeName: "string",
|
||||||
IsPrimitive: true,
|
IsPrimitive: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
By("for 'apiVersion'")
|
By("for 'apiVersion'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("apiVersion", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("apiVersion", openapi.Type{
|
||||||
TypeName: "string",
|
TypeName: "string",
|
||||||
IsPrimitive: true,
|
IsPrimitive: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
By("for 'metadata'")
|
By("for 'metadata'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("metadata", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("metadata", openapi.Type{
|
||||||
TypeName: "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
|
TypeName: "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
|
||||||
IsKind: true,
|
IsKind: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
By("for 'spec'")
|
By("for 'spec'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("spec", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("spec", openapi.Type{
|
||||||
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentSpec",
|
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentSpec",
|
||||||
IsKind: true,
|
IsKind: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
By("for 'status'")
|
By("for 'status'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("status", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("status", openapi.Type{
|
||||||
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentStatus",
|
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentStatus",
|
||||||
IsKind: true,
|
IsKind: true,
|
||||||
}))
|
}))
|
||||||
|
@ -105,17 +106,17 @@ var _ = Describe("Reading apps/v1beta1/Deployment from openAPIData", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func() {
|
var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(d)
|
instance, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
deploymentStatusName := "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentStatus"
|
deploymentStatusName := "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentStatus"
|
||||||
|
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
var found bool
|
var found bool
|
||||||
definition, found = instance.NameToDefinition[deploymentStatusName]
|
definition, found = instance.NameToDefinition[deploymentStatusName]
|
||||||
|
@ -135,16 +136,16 @@ var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func(
|
||||||
|
|
||||||
It("should find the definition fields", func() {
|
It("should find the definition fields", func() {
|
||||||
By("for 'availableReplicas'")
|
By("for 'availableReplicas'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("availableReplicas", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("availableReplicas", openapi.Type{
|
||||||
TypeName: "integer",
|
TypeName: "integer",
|
||||||
IsPrimitive: true,
|
IsPrimitive: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
By("for 'conditions'")
|
By("for 'conditions'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("conditions", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("conditions", openapi.Type{
|
||||||
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentCondition array",
|
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentCondition array",
|
||||||
IsArray: true,
|
IsArray: true,
|
||||||
ElementType: &Type{
|
ElementType: &openapi.Type{
|
||||||
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentCondition",
|
TypeName: "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentCondition",
|
||||||
IsKind: true,
|
IsKind: true,
|
||||||
},
|
},
|
||||||
|
@ -157,17 +158,17 @@ var _ = Describe("Reading apps/v1beta1/DeploymentStatus from openAPIData", func(
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("Reading apps/v1beta1/DeploymentSpec from openAPIData", func() {
|
var _ = Describe("Reading apps/v1beta1/DeploymentSpec from openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(d)
|
instance, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
deploymentSpecName := "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentSpec"
|
deploymentSpecName := "io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentSpec"
|
||||||
|
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
var found bool
|
var found bool
|
||||||
definition, found = instance.NameToDefinition[deploymentSpecName]
|
definition, found = instance.NameToDefinition[deploymentSpecName]
|
||||||
|
@ -187,7 +188,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", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("template", openapi.Type{
|
||||||
TypeName: "io.k8s.kubernetes.pkg.api.v1.PodTemplateSpec",
|
TypeName: "io.k8s.kubernetes.pkg.api.v1.PodTemplateSpec",
|
||||||
IsKind: true,
|
IsKind: true,
|
||||||
}))
|
}))
|
||||||
|
@ -195,17 +196,17 @@ var _ = Describe("Reading apps/v1beta1/DeploymentSpec from openAPIData", func()
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("Reading v1/ObjectMeta from openAPIData", func() {
|
var _ = Describe("Reading v1/ObjectMeta from openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(d)
|
instance, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
objectMetaName := "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta"
|
objectMetaName := "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta"
|
||||||
|
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
var found bool
|
var found bool
|
||||||
definition, found = instance.NameToDefinition[objectMetaName]
|
definition, found = instance.NameToDefinition[objectMetaName]
|
||||||
|
@ -225,10 +226,10 @@ var _ = Describe("Reading v1/ObjectMeta from openAPIData", func() {
|
||||||
|
|
||||||
It("should find the definition fields", func() {
|
It("should find the definition fields", func() {
|
||||||
By("for 'finalizers'")
|
By("for 'finalizers'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("finalizers", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("finalizers", openapi.Type{
|
||||||
TypeName: "string array",
|
TypeName: "string array",
|
||||||
IsArray: true,
|
IsArray: true,
|
||||||
ElementType: &Type{
|
ElementType: &openapi.Type{
|
||||||
TypeName: "string",
|
TypeName: "string",
|
||||||
IsPrimitive: true,
|
IsPrimitive: true,
|
||||||
},
|
},
|
||||||
|
@ -238,10 +239,10 @@ var _ = Describe("Reading v1/ObjectMeta from openAPIData", func() {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
By("for 'ownerReferences'")
|
By("for 'ownerReferences'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("ownerReferences", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("ownerReferences", openapi.Type{
|
||||||
TypeName: "io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference array",
|
TypeName: "io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference array",
|
||||||
IsArray: true,
|
IsArray: true,
|
||||||
ElementType: &Type{
|
ElementType: &openapi.Type{
|
||||||
TypeName: "io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference",
|
TypeName: "io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference",
|
||||||
IsKind: true,
|
IsKind: true,
|
||||||
},
|
},
|
||||||
|
@ -252,10 +253,10 @@ var _ = Describe("Reading v1/ObjectMeta from openAPIData", func() {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
By("for 'labels'")
|
By("for 'labels'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("labels", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("labels", openapi.Type{
|
||||||
TypeName: "string map",
|
TypeName: "string map",
|
||||||
IsMap: true,
|
IsMap: true,
|
||||||
ElementType: &Type{
|
ElementType: &openapi.Type{
|
||||||
TypeName: "string",
|
TypeName: "string",
|
||||||
IsPrimitive: true,
|
IsPrimitive: true,
|
||||||
},
|
},
|
||||||
|
@ -264,17 +265,17 @@ var _ = Describe("Reading v1/ObjectMeta from openAPIData", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("Reading v1/NodeStatus from openAPIData", func() {
|
var _ = Describe("Reading v1/NodeStatus from openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(d)
|
instance, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
nodeStatusName := "io.k8s.kubernetes.pkg.api.v1.NodeStatus"
|
nodeStatusName := "io.k8s.kubernetes.pkg.api.v1.NodeStatus"
|
||||||
|
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
var found bool
|
var found bool
|
||||||
definition, found = instance.NameToDefinition[nodeStatusName]
|
definition, found = instance.NameToDefinition[nodeStatusName]
|
||||||
|
@ -294,10 +295,10 @@ var _ = Describe("Reading v1/NodeStatus from openAPIData", func() {
|
||||||
|
|
||||||
It("should find the definition fields", func() {
|
It("should find the definition fields", func() {
|
||||||
By("for 'allocatable'")
|
By("for 'allocatable'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("allocatable", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("allocatable", openapi.Type{
|
||||||
TypeName: "io.k8s.apimachinery.pkg.api.resource.Quantity map",
|
TypeName: "io.k8s.apimachinery.pkg.api.resource.Quantity map",
|
||||||
IsMap: true,
|
IsMap: true,
|
||||||
ElementType: &Type{
|
ElementType: &openapi.Type{
|
||||||
TypeName: "io.k8s.apimachinery.pkg.api.resource.Quantity",
|
TypeName: "io.k8s.apimachinery.pkg.api.resource.Quantity",
|
||||||
IsKind: true,
|
IsKind: true,
|
||||||
},
|
},
|
||||||
|
@ -306,16 +307,16 @@ var _ = Describe("Reading v1/NodeStatus from openAPIData", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("Reading Utility Definitions from openAPIData", func() {
|
var _ = Describe("Reading Utility Definitions from openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(d)
|
instance, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("for util.intstr.IntOrString", func() {
|
Context("for util.intstr.IntOrString", func() {
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
intOrStringName := "io.k8s.apimachinery.pkg.util.intstr.IntOrString"
|
intOrStringName := "io.k8s.apimachinery.pkg.util.intstr.IntOrString"
|
||||||
var found bool
|
var found bool
|
||||||
|
@ -327,7 +328,7 @@ var _ = Describe("Reading Utility Definitions from openAPIData", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("for apis.meta.v1.Time", func() {
|
Context("for apis.meta.v1.Time", func() {
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
intOrStringName := "io.k8s.apimachinery.pkg.apis.meta.v1.Time"
|
intOrStringName := "io.k8s.apimachinery.pkg.apis.meta.v1.Time"
|
||||||
var found bool
|
var found bool
|
||||||
|
@ -340,11 +341,11 @@ var _ = Describe("Reading Utility Definitions from openAPIData", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("When parsing the openAPIData", func() {
|
var _ = Describe("When parsing the openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(d)
|
instance, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -369,17 +370,17 @@ var _ = Describe("When parsing the openAPIData", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = Describe("Reading authorization/v1/SubjectAccessReviewSpec from openAPIData", func() {
|
var _ = Describe("Reading authorization/v1/SubjectAccessReviewSpec from openAPIData", func() {
|
||||||
var instance *Resources
|
var instance *openapi.Resources
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
d, err := data.OpenAPISchema()
|
d, err := data.OpenAPISchema()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
instance, err = newOpenAPIData(d)
|
instance, err = openapi.NewOpenAPIData(d)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
subjectAccessReviewSpecName := "io.k8s.kubernetes.pkg.apis.authorization.v1.SubjectAccessReviewSpec"
|
subjectAccessReviewSpecName := "io.k8s.kubernetes.pkg.apis.authorization.v1.SubjectAccessReviewSpec"
|
||||||
|
|
||||||
var definition Kind
|
var definition openapi.Kind
|
||||||
It("should find the definition by name", func() {
|
It("should find the definition by name", func() {
|
||||||
var found bool
|
var found bool
|
||||||
definition, found = instance.NameToDefinition[subjectAccessReviewSpecName]
|
definition, found = instance.NameToDefinition[subjectAccessReviewSpecName]
|
||||||
|
@ -390,13 +391,13 @@ var _ = Describe("Reading authorization/v1/SubjectAccessReviewSpec from openAPID
|
||||||
|
|
||||||
It("should find the definition fields", func() {
|
It("should find the definition fields", func() {
|
||||||
By("for 'allocatable'")
|
By("for 'allocatable'")
|
||||||
Expect(definition.Fields).To(HaveKeyWithValue("extra", Type{
|
Expect(definition.Fields).To(HaveKeyWithValue("extra", openapi.Type{
|
||||||
TypeName: "string array map",
|
TypeName: "string array map",
|
||||||
IsMap: true,
|
IsMap: true,
|
||||||
ElementType: &Type{
|
ElementType: &openapi.Type{
|
||||||
TypeName: "string array",
|
TypeName: "string array",
|
||||||
IsArray: true,
|
IsArray: true,
|
||||||
ElementType: &Type{
|
ElementType: &openapi.Type{
|
||||||
TypeName: "string",
|
TypeName: "string",
|
||||||
IsPrimitive: true,
|
IsPrimitive: true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue