Bumping k8s dependencies to 1.13
This commit is contained in:
40
vendor/k8s.io/kube-openapi/test/integration/README.md
generated
vendored
Normal file
40
vendor/k8s.io/kube-openapi/test/integration/README.md
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# Kube OpenAPI Integration Tests
|
||||
|
||||
## Running the integration tests
|
||||
|
||||
Within the current directory:
|
||||
|
||||
```bash
|
||||
$ go test -v .
|
||||
```
|
||||
|
||||
## Generating the golden Swagger definition file and API rule violation report
|
||||
|
||||
First, run the generator to create `openapi_generated.go` file which specifies
|
||||
the `OpenAPIDefinition` for each type, and generate the golden API rule
|
||||
violation report file . Note that if you do not pass a report
|
||||
filename (`./testdata/golden.report` in the command below) to let the generator
|
||||
to print API rule violations to the file, the generator will return error to stderr
|
||||
on API rule violations.
|
||||
|
||||
```bash
|
||||
$ go run ../../cmd/openapi-gen/openapi-gen.go -i "./testdata/listtype,./testdata/dummytype" -o pkg -p generated -O openapi_generated -r ./testdata/golden.report
|
||||
```
|
||||
The generated file `pkg/generated/openapi_generated.go` should have been created.
|
||||
|
||||
Next, run the OpenAPI builder to create the Swagger file which includes
|
||||
the definitions. The output file named `golden.json` will be output in
|
||||
the current directory.
|
||||
|
||||
```bash
|
||||
$ go run builder/main.go testdata/golden.json
|
||||
```
|
||||
|
||||
After the golden spec is generated, please clean up the generated file
|
||||
`pkg/generated/openapi_generated.go` before you commit. It's an intermediate product that doesn't need to be updated in kube-openapi repository. The checked-in file is kept minimum to make sure that `test/integration/builder` compiles. Please run:
|
||||
|
||||
```base
|
||||
$ git checkout pkg/generated/openapi_generated.go
|
||||
```
|
||||
|
||||
to discard any local change.
|
116
vendor/k8s.io/kube-openapi/test/integration/builder/main.go
generated
vendored
Normal file
116
vendor/k8s.io/kube-openapi/test/integration/builder/main.go
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/emicklei/go-restful"
|
||||
"github.com/go-openapi/spec"
|
||||
"k8s.io/kube-openapi/pkg/builder"
|
||||
"k8s.io/kube-openapi/pkg/common"
|
||||
"k8s.io/kube-openapi/test/integration/pkg/generated"
|
||||
)
|
||||
|
||||
// TODO: Change this to output the generated swagger to stdout.
|
||||
const defaultSwaggerFile = "generated.json"
|
||||
|
||||
func main() {
|
||||
// Get the name of the generated swagger file from the args
|
||||
// if it exists; otherwise use the default file name.
|
||||
swaggerFilename := defaultSwaggerFile
|
||||
if len(os.Args) > 1 {
|
||||
swaggerFilename = os.Args[1]
|
||||
}
|
||||
|
||||
// Generate the definition names from the map keys returned
|
||||
// from GetOpenAPIDefinitions. Anonymous function returning empty
|
||||
// Ref is not used.
|
||||
var defNames []string
|
||||
for name, _ := range generated.GetOpenAPIDefinitions(func(name string) spec.Ref {
|
||||
return spec.Ref{}
|
||||
}) {
|
||||
defNames = append(defNames, name)
|
||||
}
|
||||
|
||||
// Create a minimal builder config, then call the builder with the definition names.
|
||||
config := createOpenAPIBuilderConfig()
|
||||
config.GetDefinitions = generated.GetOpenAPIDefinitions
|
||||
// Build the Paths using a simple WebService for the final spec
|
||||
swagger, serr := builder.BuildOpenAPISpec(createWebServices(), config)
|
||||
if serr != nil {
|
||||
log.Fatalf("ERROR: %s", serr.Error())
|
||||
}
|
||||
// Generate the definitions for the passed type names to put in the final spec.
|
||||
// Note that in reality one should run BuildOpenAPISpec to build the entire spec. We
|
||||
// separate the steps of building Paths and building Definitions here, because we
|
||||
// only have a simple WebService which doesn't wire the definitions up.
|
||||
definitionSwagger, err := builder.BuildOpenAPIDefinitionsForResources(config, defNames...)
|
||||
if err != nil {
|
||||
log.Fatalf("ERROR: %s", err.Error())
|
||||
}
|
||||
// Copy the generated definitions into the final swagger.
|
||||
swagger.Definitions = definitionSwagger.Definitions
|
||||
|
||||
// Marshal the swagger spec into JSON, then write it out.
|
||||
specBytes, err := json.MarshalIndent(swagger, " ", " ")
|
||||
if err != nil {
|
||||
log.Fatalf("json marshal error: %s", err.Error())
|
||||
}
|
||||
err = ioutil.WriteFile(swaggerFilename, specBytes, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("stdout write error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// CreateOpenAPIBuilderConfig hard-codes some values in the API builder
|
||||
// config for testing.
|
||||
func createOpenAPIBuilderConfig() *common.Config {
|
||||
return &common.Config{
|
||||
ProtocolList: []string{"https"},
|
||||
IgnorePrefixes: []string{"/swaggerapi"},
|
||||
Info: &spec.Info{
|
||||
InfoProps: spec.InfoProps{
|
||||
Title: "Integration Test",
|
||||
Version: "1.0",
|
||||
},
|
||||
},
|
||||
ResponseDefinitions: map[string]spec.Response{
|
||||
"NotFound": spec.Response{
|
||||
ResponseProps: spec.ResponseProps{
|
||||
Description: "Entity not found.",
|
||||
},
|
||||
},
|
||||
},
|
||||
CommonResponses: map[int]spec.Response{
|
||||
404: *spec.ResponseRef("#/responses/NotFound"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// createWebServices hard-codes a simple WebService which only defines a GET path
|
||||
// for testing.
|
||||
func createWebServices() []*restful.WebService {
|
||||
w := new(restful.WebService)
|
||||
// Define a dummy GET /test endpoint
|
||||
w = w.Route(w.GET("test").
|
||||
To(func(*restful.Request, *restful.Response) {}))
|
||||
return []*restful.WebService{w}
|
||||
}
|
159
vendor/k8s.io/kube-openapi/test/integration/integration_suite_test.go
generated
vendored
Normal file
159
vendor/k8s.io/kube-openapi/test/integration/integration_suite_test.go
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
const (
|
||||
testdataDir = "./testdata"
|
||||
inputDir = testdataDir + "/listtype" + "," + testdataDir + "/dummytype"
|
||||
outputBase = "pkg"
|
||||
outputPackage = "generated"
|
||||
outputBaseFileName = "openapi_generated"
|
||||
generatedSwaggerFileName = "generated.json"
|
||||
generatedReportFileName = "generated.report"
|
||||
goldenSwaggerFileName = "golden.json"
|
||||
goldenReportFileName = "golden.report"
|
||||
timeoutSeconds = 5.0
|
||||
)
|
||||
|
||||
func TestGenerators(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Integration Test Suite")
|
||||
}
|
||||
|
||||
var _ = Describe("Open API Definitions Generation", func() {
|
||||
|
||||
var (
|
||||
workingDirectory string
|
||||
tempDir string
|
||||
terr error
|
||||
openAPIGenPath string
|
||||
)
|
||||
|
||||
testdataFile := func(filename string) string { return filepath.Join(testdataDir, filename) }
|
||||
generatedFile := func(filename string) string { return filepath.Join(tempDir, filename) }
|
||||
|
||||
BeforeSuite(func() {
|
||||
// Explicitly manage working directory
|
||||
abs, err := filepath.Abs("")
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
workingDirectory = abs
|
||||
|
||||
// Create a temporary directory for generated swagger files.
|
||||
tempDir, terr = ioutil.TempDir("./", "openapi")
|
||||
Expect(terr).ShouldNot(HaveOccurred())
|
||||
|
||||
// Build the OpenAPI code generator.
|
||||
By("building openapi-gen")
|
||||
binary_path, berr := gexec.Build("../../cmd/openapi-gen/openapi-gen.go")
|
||||
Expect(berr).ShouldNot(HaveOccurred())
|
||||
openAPIGenPath = binary_path
|
||||
|
||||
// Run the OpenAPI code generator, creating OpenAPIDefinition code
|
||||
// to be compiled into builder.
|
||||
By("processing go idl with openapi-gen")
|
||||
gr := generatedFile(generatedReportFileName)
|
||||
command := exec.Command(openAPIGenPath,
|
||||
"-i", inputDir,
|
||||
"-o", outputBase,
|
||||
"-p", outputPackage,
|
||||
"-O", outputBaseFileName,
|
||||
"-r", gr,
|
||||
)
|
||||
command.Dir = workingDirectory
|
||||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
Eventually(session, timeoutSeconds).Should(gexec.Exit(0))
|
||||
|
||||
By("writing swagger")
|
||||
// Create the OpenAPI swagger builder.
|
||||
binary_path, berr = gexec.Build("./builder/main.go")
|
||||
Expect(berr).ShouldNot(HaveOccurred())
|
||||
|
||||
// Execute the builder, generating an OpenAPI swagger file with definitions.
|
||||
gs := generatedFile(generatedSwaggerFileName)
|
||||
By("writing swagger to " + gs)
|
||||
command = exec.Command(binary_path, gs)
|
||||
command.Dir = workingDirectory
|
||||
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
Eventually(session, timeoutSeconds).Should(gexec.Exit(0))
|
||||
})
|
||||
|
||||
AfterSuite(func() {
|
||||
os.RemoveAll(tempDir)
|
||||
gexec.CleanupBuildArtifacts()
|
||||
})
|
||||
|
||||
Describe("openapi-gen --verify", func() {
|
||||
It("Verifies that the existing files are correct", func() {
|
||||
command := exec.Command(openAPIGenPath,
|
||||
"-i", inputDir,
|
||||
"-o", outputBase,
|
||||
"-p", outputPackage,
|
||||
"-O", outputBaseFileName,
|
||||
"-r", testdataFile(goldenReportFileName),
|
||||
"--verify-only",
|
||||
)
|
||||
command.Dir = workingDirectory
|
||||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
Eventually(session, timeoutSeconds).Should(gexec.Exit(0))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Validating OpenAPI Definition Generation", func() {
|
||||
It("Generated OpenAPI swagger definitions should match golden files", func() {
|
||||
// Diff the generated swagger against the golden swagger. Exit code should be zero.
|
||||
command := exec.Command(
|
||||
"diff",
|
||||
testdataFile(goldenSwaggerFileName),
|
||||
generatedFile(generatedSwaggerFileName),
|
||||
)
|
||||
command.Dir = workingDirectory
|
||||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
Eventually(session, timeoutSeconds).Should(gexec.Exit(0))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Validating API Rule Violation Reporting", func() {
|
||||
It("Generated API rule violations should match golden report files", func() {
|
||||
// Diff the generated report against the golden report. Exit code should be zero.
|
||||
command := exec.Command(
|
||||
"diff",
|
||||
testdataFile(goldenReportFileName),
|
||||
generatedFile(generatedReportFileName),
|
||||
)
|
||||
command.Dir = workingDirectory
|
||||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
Eventually(session, timeoutSeconds).Should(gexec.Exit(0))
|
||||
})
|
||||
})
|
||||
})
|
278
vendor/k8s.io/kube-openapi/test/integration/pkg/generated/openapi_generated.go
generated
vendored
Normal file
278
vendor/k8s.io/kube-openapi/test/integration/pkg/generated/openapi_generated.go
generated
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by openapi-gen.go. DO NOT EDIT.
|
||||
|
||||
// This file was autogenerated by openapi-gen. Do not edit it manually!
|
||||
|
||||
package generated
|
||||
|
||||
import (
|
||||
spec "github.com/go-openapi/spec"
|
||||
common "k8s.io/kube-openapi/pkg/common"
|
||||
)
|
||||
|
||||
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
|
||||
return map[string]common.OpenAPIDefinition{
|
||||
"./testdata/dummytype.Bar": schema__testdata_dummytype_Bar(ref),
|
||||
"./testdata/dummytype.Baz": schema__testdata_dummytype_Baz(ref),
|
||||
"./testdata/dummytype.Foo": schema__testdata_dummytype_Foo(ref),
|
||||
"./testdata/dummytype.Waldo": schema__testdata_dummytype_Waldo(ref),
|
||||
"./testdata/listtype.AtomicList": schema__testdata_listtype_AtomicList(ref),
|
||||
"./testdata/listtype.Item": schema__testdata_listtype_Item(ref),
|
||||
"./testdata/listtype.MapList": schema__testdata_listtype_MapList(ref),
|
||||
"./testdata/listtype.SetList": schema__testdata_listtype_SetList(ref),
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_dummytype_Bar(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"ViolationBehind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"Violation": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"ViolationBehind", "Violation"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_dummytype_Baz(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"Violation": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"ViolationBehind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"Violation", "ViolationBehind"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_dummytype_Foo(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"Second": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"First": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"integer"},
|
||||
Format: "int32",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"Second", "First"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_dummytype_Waldo(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"First": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"integer"},
|
||||
Format: "int32",
|
||||
},
|
||||
},
|
||||
"Second": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"First", "Second"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_listtype_AtomicList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"Field": {
|
||||
VendorExtensible: spec.VendorExtensible{
|
||||
Extensions: spec.Extensions{
|
||||
"x-kubernetes-list-type": "atomic",
|
||||
},
|
||||
},
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"Field"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_listtype_Item(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"Protocol": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"Port": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"integer"},
|
||||
Format: "int32",
|
||||
},
|
||||
},
|
||||
"a": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"integer"},
|
||||
Format: "int32",
|
||||
},
|
||||
},
|
||||
"b": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"integer"},
|
||||
Format: "int32",
|
||||
},
|
||||
},
|
||||
"c": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"integer"},
|
||||
Format: "int32",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"Protocol", "Port"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_listtype_MapList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"Field": {
|
||||
VendorExtensible: spec.VendorExtensible{
|
||||
Extensions: spec.Extensions{
|
||||
"x-kubernetes-list-map-keys": "port",
|
||||
"x-kubernetes-list-type": "map",
|
||||
},
|
||||
},
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Ref: ref("./testdata/listtype.Item"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"Field"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"./testdata/listtype.Item"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema__testdata_listtype_SetList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"Field": {
|
||||
VendorExtensible: spec.VendorExtensible{
|
||||
Extensions: spec.Extensions{
|
||||
"x-kubernetes-list-type": "set",
|
||||
},
|
||||
},
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"Field"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
36
vendor/k8s.io/kube-openapi/test/integration/testdata/dummytype/alpha.go
generated
vendored
Normal file
36
vendor/k8s.io/kube-openapi/test/integration/testdata/dummytype/alpha.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// The package is intended for testing the openapi-gen API rule
|
||||
// checker. The API rule violations are in format of:
|
||||
//
|
||||
// `{rule-name},{package},{type},{(optional) field}`
|
||||
//
|
||||
// The checker should sort the violations before
|
||||
// reporting to a file or stderr.
|
||||
//
|
||||
// We have the dummytype package separately from the listtype
|
||||
// package to test the sorting behavior on package level, e.g.
|
||||
//
|
||||
// -i "./testdata/listtype,./testdata/dummytype"
|
||||
// -i "./testdata/dummytype,./testdata/listtype"
|
||||
//
|
||||
// The violations from dummytype should always come first in
|
||||
// report.
|
||||
|
||||
package dummytype
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Foo struct {
|
||||
Second string
|
||||
First int
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Bar struct {
|
||||
ViolationBehind bool
|
||||
Violation bool
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Baz struct {
|
||||
Violation bool
|
||||
ViolationBehind bool
|
||||
}
|
24
vendor/k8s.io/kube-openapi/test/integration/testdata/dummytype/beta.go
generated
vendored
Normal file
24
vendor/k8s.io/kube-openapi/test/integration/testdata/dummytype/beta.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// The package is intended for testing the openapi-gen API rule
|
||||
// checker. The API rule violations are in format of:
|
||||
//
|
||||
// `{rule-name},{package},{type},{(optional) field}`
|
||||
//
|
||||
// The checker should sort the violations before
|
||||
// reporting to a file or stderr.
|
||||
//
|
||||
// We have the dummytype package separately from the listtype
|
||||
// package to test the sorting behavior on package level, e.g.
|
||||
//
|
||||
// -i "./testdata/listtype,./testdata/dummytype"
|
||||
// -i "./testdata/dummytype,./testdata/listtype"
|
||||
//
|
||||
// The violations from dummytype should always come first in
|
||||
// report.
|
||||
|
||||
package dummytype
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Waldo struct {
|
||||
First int
|
||||
Second string
|
||||
}
|
157
vendor/k8s.io/kube-openapi/test/integration/testdata/golden.json
generated
vendored
Normal file
157
vendor/k8s.io/kube-openapi/test/integration/testdata/golden.json
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Integration Test",
|
||||
"version": "1.0"
|
||||
},
|
||||
"paths": {
|
||||
"/test": {
|
||||
"get": {
|
||||
"schemes": [
|
||||
"https"
|
||||
],
|
||||
"operationId": "func1",
|
||||
"responses": {
|
||||
"404": {
|
||||
"$ref": "#/responses/NotFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"dummytype.Bar": {
|
||||
"required": [
|
||||
"ViolationBehind",
|
||||
"Violation"
|
||||
],
|
||||
"properties": {
|
||||
"Violation": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ViolationBehind": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dummytype.Baz": {
|
||||
"required": [
|
||||
"Violation",
|
||||
"ViolationBehind"
|
||||
],
|
||||
"properties": {
|
||||
"Violation": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ViolationBehind": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dummytype.Foo": {
|
||||
"required": [
|
||||
"Second",
|
||||
"First"
|
||||
],
|
||||
"properties": {
|
||||
"First": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"Second": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dummytype.Waldo": {
|
||||
"required": [
|
||||
"First",
|
||||
"Second"
|
||||
],
|
||||
"properties": {
|
||||
"First": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"Second": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listtype.AtomicList": {
|
||||
"required": [
|
||||
"Field"
|
||||
],
|
||||
"properties": {
|
||||
"Field": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-kubernetes-list-type": "atomic"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listtype.Item": {
|
||||
"required": [
|
||||
"Protocol",
|
||||
"Port"
|
||||
],
|
||||
"properties": {
|
||||
"Port": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"Protocol": {
|
||||
"type": "string"
|
||||
},
|
||||
"a": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"b": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"c": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listtype.MapList": {
|
||||
"required": [
|
||||
"Field"
|
||||
],
|
||||
"properties": {
|
||||
"Field": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/listtype.Item"
|
||||
},
|
||||
"x-kubernetes-list-map-keys": "port",
|
||||
"x-kubernetes-list-type": "map"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listtype.SetList": {
|
||||
"required": [
|
||||
"Field"
|
||||
],
|
||||
"properties": {
|
||||
"Field": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-kubernetes-list-type": "set"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"NotFound": {
|
||||
"description": "Entity not found."
|
||||
}
|
||||
}
|
||||
}
|
14
vendor/k8s.io/kube-openapi/test/integration/testdata/golden.report
generated
vendored
Normal file
14
vendor/k8s.io/kube-openapi/test/integration/testdata/golden.report
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
API rule violation: names_match,./testdata/dummytype,Bar,Violation
|
||||
API rule violation: names_match,./testdata/dummytype,Bar,ViolationBehind
|
||||
API rule violation: names_match,./testdata/dummytype,Baz,Violation
|
||||
API rule violation: names_match,./testdata/dummytype,Baz,ViolationBehind
|
||||
API rule violation: names_match,./testdata/dummytype,Foo,First
|
||||
API rule violation: names_match,./testdata/dummytype,Foo,Second
|
||||
API rule violation: names_match,./testdata/dummytype,Waldo,First
|
||||
API rule violation: names_match,./testdata/dummytype,Waldo,Second
|
||||
API rule violation: names_match,./testdata/listtype,AtomicList,Field
|
||||
API rule violation: names_match,./testdata/listtype,Item,Port
|
||||
API rule violation: names_match,./testdata/listtype,Item,Protocol
|
||||
API rule violation: names_match,./testdata/listtype,MapList,Field
|
||||
API rule violation: names_match,./testdata/listtype,SetList,Field
|
||||
API rule violation: omitempty_match_case,./testdata/listtype,Item,C
|
7
vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/atomic-list.go
generated
vendored
Normal file
7
vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/atomic-list.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package listtype
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type AtomicList struct {
|
||||
// +listType=atomic
|
||||
Field []string
|
||||
}
|
20
vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/map-list.go
generated
vendored
Normal file
20
vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/map-list.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package listtype
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type MapList struct {
|
||||
// +listType=map
|
||||
// +listMapKey=port
|
||||
Field []Item
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Item struct {
|
||||
Protocol string
|
||||
Port int
|
||||
// +optional
|
||||
A int `json:"a"`
|
||||
// +optional
|
||||
B int `json:"b,omitempty"`
|
||||
// +optional
|
||||
C int `json:"c,omitEmpty"`
|
||||
}
|
7
vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/set-list.go
generated
vendored
Normal file
7
vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/set-list.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package listtype
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type SetList struct {
|
||||
// +listType=set
|
||||
Field []string
|
||||
}
|
Reference in New Issue
Block a user