diff --git a/glide.lock b/glide.lock index 39e43f5b5..ab551da83 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: 79ae05b2540363f6d931f419325a57ffed20ab6692dd81fbbec4aa92713daafe -updated: 2018-11-28T13:01:34.526151+01:00 +updated: 2019-01-09T13:10:40.376831+01:00 imports: - name: github.com/davecgh/go-spew version: 782f4967f2dc4564575ca782fe2d04090b5faca8 @@ -51,7 +51,7 @@ imports: - name: github.com/modern-go/reflect2 version: 05fbef0ca5da472bbf96c9322b84a53edc03c9fd - name: github.com/openshift/library-go - version: a1ed078fcc8923663018a68dd66acb7e080d3f19 + version: 0f19d7d6215353efcd2e7c6e16f29a3da5a79c0b - name: github.com/peterbourgon/diskv version: 5f041e8faa004a95c88a202771f4cc3e991971e6 - name: github.com/spf13/cobra @@ -61,8 +61,6 @@ imports: - name: golang.org/x/crypto version: 49796115aa4b964c318aad4f3084fdb41e9aa067 subpackages: - - bcrypt - - blowfish - ssh/terminal - name: golang.org/x/net version: 1c05540f6879653db88113bc4a2b70aec4bd491f @@ -127,11 +125,6 @@ imports: - storage/v1 - storage/v1alpha1 - storage/v1beta1 -- name: k8s.io/apiextensions-apiserver - version: 3de98c57bc05a81cf463e0ad7a0af4cec8a5b510 - subpackages: - - pkg/apis/apiextensions - - pkg/apis/apiextensions/v1beta1 - name: k8s.io/apimachinery version: 103fd098999dc9c0c88536f5c9ad2e5da39373ae subpackages: @@ -163,20 +156,25 @@ imports: - pkg/util/framer - pkg/util/intstr - pkg/util/json + - pkg/util/mergepatch - pkg/util/net - pkg/util/runtime - pkg/util/sets + - pkg/util/strategicpatch - pkg/util/validation - pkg/util/validation/field - pkg/util/wait - pkg/util/yaml - pkg/version - pkg/watch + - third_party/forked/golang/json - third_party/forked/golang/reflect - name: k8s.io/client-go version: 7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65 subpackages: - discovery + - dynamic + - dynamic/fake - kubernetes - kubernetes/scheme - kubernetes/typed/admissionregistration/v1alpha1 @@ -215,6 +213,7 @@ imports: - plugin/pkg/client/auth/exec - rest - rest/watch + - testing - tools/auth - tools/cache - tools/clientcmd @@ -232,4 +231,8 @@ imports: - util/homedir - util/integer - util/retry +- name: k8s.io/kube-openapi + version: 91cfa479c814065e420cee7ed227db0f63a5854e + subpackages: + - pkg/util/proto testImports: [] diff --git a/pkg/start/create.go b/pkg/start/create.go index 4fa43fc17..9c63cc743 100644 --- a/pkg/start/create.go +++ b/pkg/start/create.go @@ -1,11 +1,8 @@ package start import ( - "bufio" - "bytes" - "encoding/json" "fmt" - "io" + "io/ioutil" "net/http" "os" "path/filepath" @@ -14,18 +11,17 @@ import ( "sync" "time" + "github.com/ghodss/yaml" "github.com/golang/glog" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/apimachinery/pkg/util/yaml" "k8s.io/client-go/discovery" + "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" ) @@ -34,21 +30,28 @@ const ( crdRolloutTimeout = 2 * time.Minute ) -func CreateAssets(config clientcmd.ClientConfig, manifestDir string, timeout time.Duration, strict bool) error { +func CreateAssets(config clientcmd.ClientConfig, manifestDir string, timeout time.Duration) error { if _, err := os.Stat(manifestDir); os.IsNotExist(err) { UserOutput(fmt.Sprintf("WARNING: %v does not exist, not creating any self-hosted assets.\n", manifestDir)) return nil } - c, err := config.ClientConfig() + clientConfig, err := config.ClientConfig() if err != nil { return err } - creater, err := newCreater(c, strict) + + discoveryClient, err := discovery.NewDiscoveryClientForConfig(clientConfig) + if err != nil { + return err + } + dynamicClient, err := dynamic.NewForConfig(clientConfig) if err != nil { return err } - m, err := loadManifests(manifestDir) + creater := newCreater(dynamicClient, discoveryClient) + + manifests, err := creater.loadManifests(manifestDir) if err != nil { return fmt.Errorf("loading manifests: %v", err) } @@ -69,16 +72,10 @@ func CreateAssets(config clientcmd.ClientConfig, manifestDir string, timeout tim } UserOutput("Creating self-hosted assets...\n") - if ok := creater.createManifests(m); !ok { + if err := creater.createManifests(manifests); err != nil { UserOutput("\nNOTE: Bootkube failed to create some cluster assets. It is important that manifest errors are resolved and resubmitted to the apiserver.\n") UserOutput("For example, after resolving issues: kubectl create -f \n\n") - - // Don't fail on manifest creation. It's easier to debug a cluster with a failed - // manifest than exiting and tearing down the control plane. If strict - // mode is enabled, then error out. - if strict { - return fmt.Errorf("Self-hosted assets could not be created") - } + UserOutput("Errors:\n%v\n\n", err) } return nil @@ -106,193 +103,200 @@ func apiTest(c clientcmd.ClientConfig) error { return err } -type manifest struct { - kind string - apiVersion string - namespace string - name string - raw []byte +type errorReporter struct { + errors []error +} - filepath string +func (r *errorReporter) errorf(format string, obj ...interface{}) { + err := fmt.Errorf(format, obj...) + UserOutput("ERROR: %v\n", err) + r.errors = append(r.errors, err) } -func (m manifest) String() string { - if m.namespace == "" { - return fmt.Sprintf("%s %s %s", m.filepath, m.kind, m.name) +func (r *errorReporter) warningf(format string, obj ...interface{}) { + UserOutput("WARNING: %v\n", fmt.Errorf("%v", obj...)) +} + +func (r *errorReporter) allErrors() error { + if !r.hasErrors() { + return nil + } + var msgs []string + for _, err := range r.errors { + msgs = append(msgs, err.Error()) } - return fmt.Sprintf("%s %s %s/%s", m.filepath, m.kind, m.namespace, m.name) + return fmt.Errorf("%s", strings.Join(msgs, "\n")) } -type creater struct { - client *rest.RESTClient - strict bool +func (r *errorReporter) hasErrors() bool { + return len(r.errors) > 0 +} +type creater struct { + client dynamic.Interface // mapper maps resource kinds ("ConfigMap") with their pluralized URL // path ("configmaps") using the discovery APIs. mapper *resourceMapper } -func newCreater(c *rest.Config, strict bool) (*creater, error) { - c.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} - client, err := rest.UnversionedRESTClientFor(c) - if err != nil { - return nil, err - } - - discoveryClient, err := discovery.NewDiscoveryClientForConfig(c) - if err != nil { - return nil, err - } - +func newCreater(client dynamic.Interface, discoveryClient *discovery.DiscoveryClient) *creater { return &creater{ - mapper: newResourceMapper(discoveryClient), client: client, - strict: strict, - }, nil + mapper: newResourceMapper(discoveryClient), + } } -func (c *creater) createManifests(manifests []manifest) (ok bool) { - ok = true +func (c *creater) createManifests(manifests map[string]*unstructured.Unstructured) error { // Bootkube used to create manifests in named order ("01-foo" before "02-foo"). // Maintain this behavior for everything except CRDs and NSs, which have strict ordering // that we should always respect. - sort.Slice(manifests, func(i, j int) bool { - return manifests[i].filepath < manifests[j].filepath - }) - - var namespaces, crds, other []manifest - for _, m := range manifests { - if m.kind == "CustomResourceDefinition" && strings.HasPrefix(m.apiVersion, "apiextensions.k8s.io/") { - crds = append(crds, m) - } else if m.kind == "Namespace" && m.apiVersion == "v1" { - namespaces = append(namespaces, m) - } else { - other = append(other, m) - } + var sortedManifests []string + for key := range manifests { + sortedManifests = append(sortedManifests, key) } + sort.Strings(sortedManifests) - create := func(m manifest) error { - if err := c.create(m); err != nil { - ok = false - UserOutput("Failed creating %s: %v\n", m, err) - return err + var ( + namespaces []*unstructured.Unstructured + crds []*unstructured.Unstructured + others []*unstructured.Unstructured + ) + + for _, path := range sortedManifests { + // fmt.Printf("got: %+v\n", c.mapper.groupVersionResource(manifests[path])) + switch c.mapper.groupVersionResource(manifests[path]) { + case schema.GroupVersionResource{Version: "v1", Resource: "namespaces"}: + namespaces = append(namespaces, manifests[path]) + case schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1beta1", Resource: "customresourcedefinitions"}: + crds = append(crds, manifests[path]) + default: + others = append(others, manifests[path]) } - UserOutput("Created %s\n", m) - return nil } + report := errorReporter{} + // Create all namespaces first - for _, m := range namespaces { - if err := create(m); err != nil && c.strict { - return false + for _, namespace := range namespaces { + UserOutput("Creating %s %q ...\n", namespace.GroupVersionKind(), namespace.GetName()) + if _, err := c.client.Resource(c.mapper.groupVersionResource(namespace)).Create(namespace); err != nil { + if errors.IsAlreadyExists(err) { + report.warningf("%s: %v", err) + continue + } + report.errorf("Failed to create %s %q: %v", namespace.GroupVersionKind(), namespace.GetName(), err) + return err } } - // Create the custom resource definition before creating the actual custom resources. - for _, m := range crds { - if err := create(m); err != nil && c.strict { - return false - } + // We can't continue when namespaces failed to created + if report.hasErrors() { + return report.allErrors() } - // Wait until the API server registers the CRDs. Until then it's not safe to create the - // manifests for those custom resources. + // Create the custom resource definition before creating the actual custom resources. for _, crd := range crds { - if err := c.waitForCRD(crd); err != nil { - ok = false - UserOutput("Failed waiting for %s: %v", crd, err) - if c.strict { - return false + UserOutput("Creating %s %q ...\n", crd.GroupVersionKind(), crd.GetName()) + if _, err := c.client.Resource(c.mapper.groupVersionResource(crd)).Create(crd); err != nil { + if errors.IsAlreadyExists(err) { + report.warningf("%s: %v", crd, err) + continue } + report.errorf("Failed to create %s %q: %v", crd.GroupVersionKind(), crd.GetName(), err) + continue } - } - - for _, m := range other { - if err := create(m); err != nil && c.strict { - return false + crdGroup, _, err := unstructured.NestedString(crd.UnstructuredContent(), "spec", "group") + if err != nil { + report.errorf("Expected spec.group field in %s: %v", crd, err) + continue + } + crdPlural, _, err := unstructured.NestedString(crd.UnstructuredContent(), "spec", "names", "plural") + if err != nil { + report.errorf("Expected spec.names.plural field in %s: %v", crd, err) + continue } - } - return ok -} -// waitForCRD blocks until the API server begins serving the custom resource this -// manifest defines. This is determined by listing the custom resource in a loop. -func (c *creater) waitForCRD(m manifest) error { - var crd apiextensionsv1beta1.CustomResourceDefinition - if err := json.Unmarshal(m.raw, &crd); err != nil { - return fmt.Errorf("failed to unmarshal manifest: %v", err) - } + crdVersion := "" + crdVersions, _, err := unstructured.NestedSlice(crd.UnstructuredContent(), "spec", "versions") + if err != nil { + report.errorf("Expected spec.versions field in %s: %v", crd, err) + continue + } - // get first served version - firstVer := "" - if len(crd.Spec.Versions) > 0 { - for _, v := range crd.Spec.Versions { - if v.Served { - firstVer = v.Name - break + if len(crdVersions) > 0 { + for i, v := range crdVersions { + version := v.(map[string]interface{}) + if isServed, _, _ := unstructured.NestedBool(version, "served"); isServed { + versionName, _, err := unstructured.NestedString(version, "name") + if err != nil { + report.errorf("Expected spec.versions[%d].name field in %s: %v", i, crd, err) + continue + } + crdVersion = versionName + } } + } else { + // TODO: This field is deprecated. + crdSpecVersion, _, err := unstructured.NestedString(crd.UnstructuredContent(), "spec", "version") + if err != nil { + report.errorf("Expected spec.version field in %s: %v", crd, err) + continue + } + crdVersion = crdSpecVersion } - } else { - firstVer = crd.Spec.Version - } - if len(firstVer) == 0 { - return fmt.Errorf("expected at least one served version") - } - return wait.PollImmediate(crdRolloutDuration, crdRolloutTimeout, func() (bool, error) { - // get all resources, giving a 200 result with empty list on success, 404 before the CRD is active. - namespaceLessURI := allCustomResourcesURI(schema.GroupVersionResource{Group: crd.Spec.Group, Version: firstVer, Resource: crd.Spec.Names.Plural}) - res := c.client.Get().RequestURI(namespaceLessURI).Do() - if res.Error() != nil { - if errors.IsNotFound(res.Error()) { + crGVR := schema.GroupVersionResource{Group: crdGroup, Version: crdVersion, Resource: crdPlural} + + // Wait for the CRD to be available + UserOutput("Waiting for %s %q to be available ...\n", crGVR.GroupVersion(), crGVR.Resource) + waitErr := wait.PollImmediate(crdRolloutDuration, crdRolloutTimeout, func() (bool, error) { + _, err := c.client.Resource(crGVR).List(metav1.ListOptions{}) + if errors.IsNotFound(err) { return false, nil } - return false, res.Error() + if err != nil { + return false, err + } + return true, nil + }) + if waitErr != nil { + report.errorf("Failed to wait for %q to be available: %v", crGVR.Resource, waitErr) } - return true, nil - }) -} - -// allCustomResourcesURI returns the URI for the CRD resource without a namespace, listing -// all objects of that GroupVersionResource. -func allCustomResourcesURI(gvr schema.GroupVersionResource) string { - return fmt.Sprintf("/apis/%s/%s/%s", - strings.ToLower(gvr.Group), - strings.ToLower(gvr.Version), - strings.ToLower(gvr.Resource), - ) -} - -func (c *creater) create(m manifest) error { - info, err := c.mapper.resourceInfo(m.apiVersion, m.kind) - if err != nil { - return fmt.Errorf("dicovery failed: %v", err) } - return c.client.Post(). - AbsPath(m.urlPath(info.Name, info.Namespaced)). - Body(m.raw). - SetHeader("Content-Type", "application/json"). - Do().Error() -} - -func (m manifest) urlPath(plural string, namespaced bool) string { - u := "/apis" - if m.apiVersion == "v1" { - u = "/api" + // If some CRDs failed to create, do not continue + if report.hasErrors() { + return report.allErrors() } - u = u + "/" + m.apiVersion - // NOTE(ericchiang): Some of our non-namespaced manifests have a "namespace" field. - // Since kubectl create accepts this, also accept this. - if m.namespace != "" && namespaced { - u = u + "/namespaces/" + m.namespace + + // Create other resources + for _, resource := range others { + UserOutput("Creating %s %q ...\n", resource.GroupVersionKind(), resource.GetName()) + if c.mapper.isNamespaced(resource) { + if _, err := c.client.Resource(c.mapper.groupVersionResource(resource)).Namespace(resource.GetNamespace()).Create(resource); err != nil { + if errors.IsAlreadyExists(err) { + report.warningf("%s: %v", err) + continue + } + report.errorf("Failed to create %s %q: %v", resource.GroupVersionKind(), resource.GetName(), err) + } + continue + } + if _, err := c.client.Resource(c.mapper.groupVersionResource(resource)).Create(resource); err != nil { + if errors.IsAlreadyExists(err) { + report.warningf("%s: %v", err) + continue + } + report.errorf("Failed to create %s %q: %v", resource.GroupVersionKind(), resource.GetName(), err) + } } - return u + "/" + plural + + return report.allErrors() } // loadManifests parses a directory of YAML Kubernetes manifest. -func loadManifests(p string) ([]manifest, error) { - var manifests []manifest +func (c *creater) loadManifests(p string) (map[string]*unstructured.Unstructured, error) { + manifests := map[string]*unstructured.Unstructured{} err := filepath.Walk(p, func(path string, info os.FileInfo, err error) error { if err != nil { return err @@ -306,78 +310,27 @@ func loadManifests(p string) ([]manifest, error) { return nil } - f, err := os.Open(path) + manifestBytes, err := ioutil.ReadFile(path) if err != nil { - return fmt.Errorf("open %s: %v", path, err) + return err } - defer f.Close() - - ms, err := parseManifests(f) + manifestJSON, err := yaml.YAMLToJSON(manifestBytes) if err != nil { - return fmt.Errorf("parse file %s: %v", path, err) - } - for i := range ms { - ms[i].filepath = path - } - manifests = append(manifests, ms...) - return nil - }) - return manifests, err -} - -// parseManifests parses a YAML or JSON document that may contain one or more -// kubernetes resoures. -func parseManifests(r io.Reader) ([]manifest, error) { - reader := yaml.NewYAMLReader(bufio.NewReader(r)) - var manifests []manifest - for { - yamlManifest, err := reader.Read() - if err != nil { - if err == io.EOF { - if len(manifests) == 0 { - return nil, fmt.Errorf("no resources found") - } - return manifests, nil - } - return nil, err - } - yamlManifest = bytes.TrimSpace(yamlManifest) - if len(yamlManifest) == 0 { - continue + return err } - - jsonManifest, err := yaml.ToJSON(yamlManifest) + manifestObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, manifestJSON) if err != nil { - return nil, fmt.Errorf("invalid manifest: %v", err) + return err } - m, err := parseJSONManifest(jsonManifest) - if err != nil { - return nil, fmt.Errorf("parse manifest: %v", err) + manifestObject, ok := manifestObj.(*unstructured.Unstructured) + if !ok { + return fmt.Errorf("unable to convert %+v to unstructed", manifestObj) } - manifests = append(manifests, m) - } -} -// parseJSONManifest parses a single JSON Kubernetes resource. -func parseJSONManifest(data []byte) (manifest, error) { - var m struct { - APIVersion string `json:"apiVersion"` - Kind string `json:"kind"` - Metadata struct { - Name string `json:"name"` - Namespace string `json:"namespace"` - } `json:"metadata"` - } - if err := json.Unmarshal(data, &m); err != nil { - return manifest{}, fmt.Errorf("parse manifest: %v", err) - } - return manifest{ - kind: m.Kind, - apiVersion: m.APIVersion, - namespace: m.Metadata.Namespace, - name: m.Metadata.Name, - raw: data, - }, nil + manifests[path] = manifestObject + return nil + }) + return manifests, err } func newResourceMapper(d discovery.DiscoveryInterface) *resourceMapper { @@ -428,3 +381,30 @@ func (m *resourceMapper) resourceInfo(groupVersion, kind string) (*metav1.APIRes } return nil, fmt.Errorf("resource %s %s not found", groupVersion, kind) } + +func (m *resourceMapper) isNamespaced(obj *unstructured.Unstructured) bool { + apiResource, err := m.resourceInfo(obj.GetAPIVersion(), obj.GetKind()) + if err != nil { + panic(err) + } + return apiResource.Namespaced +} + +func (m *resourceMapper) groupVersionResource(obj *unstructured.Unstructured) schema.GroupVersionResource { + apiResource, err := m.resourceInfo(obj.GetAPIVersion(), obj.GetKind()) + if err != nil { + panic(err) + } + return schema.GroupVersionResource{ + Group: apiResource.Group, + Version: apiResource.Version, + Resource: apiResource.Name, + } +} + +func (m *resourceMapper) toString(resource *unstructured.Unstructured) string { + if m.isNamespaced(resource) { + return fmt.Sprintf("%s %s", resource.GetKind(), resource.GetName()) + } + return fmt.Sprintf("%s %s/%s", resource.GetKind(), resource.GetNamespace(), resource.GetName()) +} diff --git a/pkg/start/create_test.go b/pkg/start/create_test.go index b298a6d89..d450275aa 100644 --- a/pkg/start/create_test.go +++ b/pkg/start/create_test.go @@ -1,155 +1,132 @@ package start import ( - "reflect" - "strings" + "sync" "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/version" + "k8s.io/client-go/discovery/fake" + dynamicfake "k8s.io/client-go/dynamic/fake" + clienttesting "k8s.io/client-go/testing" ) -func TestParseManifests(t *testing.T) { - tests := []struct { - name string - raw string - want []manifest - }{ +func TestCreateLoadManifests(t *testing.T) { + c := &creater{} + result, err := c.loadManifests("testdata") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(result) != 12 { + t.Fatalf("expected 12 loaded manifests, got %d", len(result)) + } +} + +func TestCreateManifests(t *testing.T) { + fakeScheme := runtime.NewScheme() + + // TODO: This is a workaround for dynamic fake client bug where the List kind is enforced and duplicated in object reactor. + fakeScheme.AddKnownTypeWithName(schema.GroupVersionKind{Version: "v1", Kind: "ListList"}, &unstructured.UnstructuredList{}) + + dynamicClient := dynamicfake.NewSimpleDynamicClient(fakeScheme) + fakeDiscovery := &fake.FakeDiscovery{ + Fake: &dynamicClient.Fake, + FakedServerVersion: &version.Info{}, + } + + fakeDiscovery.Resources = []*metav1.APIResourceList{ { - name: "ingress", - raw: ` -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: test-ingress - namespace: test-namespace -spec: - rules: - - http: - paths: - - path: /testpath - backend: - serviceName: test - servicePort: 80 -`, - want: []manifest{ + GroupVersion: "kubeapiserver.operator.openshift.io/v1alpha1", + APIResources: []metav1.APIResource{ { - kind: "Ingress", - apiVersion: "extensions/v1beta1", - namespace: "test-namespace", - name: "test-ingress", + Kind: "KubeAPIServerOperatorConfig", + Name: "kubeapiserveroperatorconfigs", + Version: "v1alpha1", + Group: "kubeapiserver.operator.openshift.io", }, }, }, { - name: "configmap", - raw: ` -apiVersion: v1 -kind: ConfigMap -metadata: - name: a-config - namespace: default -data: - color: "red" - multi-line: | - hello world - how are you? -`, - want: []manifest{ + GroupVersion: "apiextensions.k8s.io/v1beta1", + APIResources: []metav1.APIResource{ { - kind: "ConfigMap", - apiVersion: "v1", - namespace: "default", - name: "a-config", + Kind: "CustomResourceDefinition", + Name: "customresourcedefinitions", + Version: "v1beta1", + Group: "apiextensions.k8s.io", }, }, }, { - name: "two-resources", - raw: ` -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: test-ingress - namespace: test-namespace -spec: - rules: - - http: - paths: - - path: /testpath - backend: - serviceName: test - servicePort: 80 ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: a-config - namespace: default -data: - color: "red" - multi-line: | - hello world - how are you? -`, - want: []manifest{ + GroupVersion: "v1", + APIResources: []metav1.APIResource{ + { + Version: "v1", + Kind: "Namespace", + Name: "namespaces", + }, { - kind: "Ingress", - apiVersion: "extensions/v1beta1", - namespace: "test-namespace", - name: "test-ingress", + Version: "v1", + Kind: "ConfigMap", + Name: "configmaps", + Namespaced: true, }, { - kind: "ConfigMap", - apiVersion: "v1", - namespace: "default", - name: "a-config", + Version: "v1", + Kind: "Secret", + Name: "secrets", + Namespaced: true, + }, + }, + }, + { + GroupVersion: "rbac.authorization.k8s.io/v1", + APIResources: []metav1.APIResource{ + { + Version: "v1", + Group: "rbac.authorization.k8s.io", + Name: "clusterrolebindings", + Kind: "ClusterRoleBinding", + }, + { + Version: "v1", + Group: "rbac.authorization.k8s.io", + Name: "clusterroles", + Kind: "ClusterRole", }, }, }, } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got, err := parseManifests(strings.NewReader(test.raw)) - if err != nil { - t.Fatalf("failed to parse manifest: %v", err) - } - for i := range got { - got[i].raw = nil - } - if !reflect.DeepEqual(test.want, got) { - t.Errorf("wanted %#v, got %#v", test.want, got) - } - }) - } - -} -func TestManifestURLPath(t *testing.T) { - tests := []struct { - apiVersion string - namespace string - - plural string - namespaced bool + c := newCreater(dynamicClient, nil) + c.mapper = &resourceMapper{ + discoveryClient: fakeDiscovery, + mu: sync.Mutex{}, + cache: make(map[string]*metav1.APIResourceList), + } - want string - }{ - {"v1", "my-ns", "pods", true, "/api/v1/namespaces/my-ns/pods"}, - {"apps.k8s.io/v1beta1", "my-ns", "deployments", true, "/apis/apps.k8s.io/v1beta1/namespaces/my-ns/deployments"}, - {"v1", "", "nodes", false, "/api/v1/nodes"}, - {"apiextensions.k8s.io/v1beta1", "", "customresourcedefinitions", false, "/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions"}, - // If non-namespaced, ignore the namespace field. This is to mimic kubectl create - // behavior, which allows this but drops the namespace. - {"apiextensions.k8s.io/v1beta1", "my-ns", "customresourcedefinitions", false, "/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions"}, + result, _ := c.loadManifests("testdata") + if len(result) != 12 { + t.Fatalf("expected 12 loaded manifests, got %d", len(result)) + } + if err := c.createManifests(result); err != nil { + t.Fatalf("unexpected error: %v", err) } - for _, test := range tests { - m := manifest{ - apiVersion: test.apiVersion, - namespace: test.namespace, - } - got := m.urlPath(test.plural, test.namespaced) - if test.want != got { - t.Errorf("{&manifest{apiVersion:%q, namespace: %q}).urlPath(%q, %t); wanted=%q, got=%q", - test.apiVersion, test.namespace, test.plural, test.namespaced, test.want, got) + createActions := []clienttesting.CreateAction{} + for _, action := range dynamicClient.Actions() { + if createAction, ok := action.(clienttesting.CreateAction); ok { + createActions = append(createActions, createAction) } } + if len(createActions) != 12 { + t.Fatalf("expected 12 create actions, got %d", len(createActions)) + } + + if createActions[0].GetResource().Resource != "namespaces" { + t.Fatalf("expected to create namespace first, got %+v", createActions[0]) + } } diff --git a/pkg/start/start.go b/pkg/start/start.go index aecba89df..bcf0c1910 100644 --- a/pkg/start/start.go +++ b/pkg/start/start.go @@ -20,7 +20,6 @@ type Config struct { type startCommand struct { podManifestPath string assetDir string - strict bool requiredPods []string } @@ -28,7 +27,6 @@ func NewStartCommand(config Config) (*startCommand, error) { return &startCommand{ assetDir: config.AssetDir, podManifestPath: config.PodManifestPath, - strict: config.Strict, requiredPods: config.RequiredPods, }, nil } @@ -61,7 +59,7 @@ func (b *startCommand) Run() error { return err } - if err = CreateAssets(kubeConfig, filepath.Join(b.assetDir, AssetPathManifests), assetTimeout, b.strict); err != nil { + if err = CreateAssets(kubeConfig, filepath.Join(b.assetDir, AssetPathManifests), assetTimeout); err != nil { return err } diff --git a/pkg/start/testdata/0000_10_kube-apiserver-operator_01_config.crd.yaml b/pkg/start/testdata/0000_10_kube-apiserver-operator_01_config.crd.yaml new file mode 100644 index 000000000..bea8b9a59 --- /dev/null +++ b/pkg/start/testdata/0000_10_kube-apiserver-operator_01_config.crd.yaml @@ -0,0 +1,16 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: kubeapiserveroperatorconfigs.kubeapiserver.operator.openshift.io +spec: + scope: Cluster + group: kubeapiserver.operator.openshift.io + version: v1alpha1 + names: + kind: KubeAPIServerOperatorConfig + plural: kubeapiserveroperatorconfigs + singular: kubeapiserveroperatorconfig + categories: + - coreoperators + subresources: + status: {} diff --git a/pkg/start/testdata/00_openshift-kube-apiserver-ns.yaml b/pkg/start/testdata/00_openshift-kube-apiserver-ns.yaml new file mode 100644 index 000000000..d208ba4ee --- /dev/null +++ b/pkg/start/testdata/00_openshift-kube-apiserver-ns.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: openshift-kube-apiserver + labels: + openshift.io/run-level: "0" \ No newline at end of file diff --git a/pkg/start/testdata/cluster-role-binding-kube-apiserver.yaml b/pkg/start/testdata/cluster-role-binding-kube-apiserver.yaml new file mode 100644 index 000000000..c97bba1ee --- /dev/null +++ b/pkg/start/testdata/cluster-role-binding-kube-apiserver.yaml @@ -0,0 +1,15 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: kube-apiserver +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kube-apiserver +subjects: +- apiGroup: rbac.authorization.k8s.io + kind: User + name: kube-apiserver +- apiGroup: rbac.authorization.k8s.io + kind: User + name: system:kube-apiserver diff --git a/pkg/start/testdata/cluster-role-kube-apiserver.yaml b/pkg/start/testdata/cluster-role-kube-apiserver.yaml new file mode 100644 index 000000000..a18ceb007 --- /dev/null +++ b/pkg/start/testdata/cluster-role-kube-apiserver.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: kube-apiserver +rules: +- apiGroups: + - "" + resources: + - nodes/proxy + verbs: + - get + - create diff --git a/pkg/start/testdata/configmap-aggregator-client-ca.yaml b/pkg/start/testdata/configmap-aggregator-client-ca.yaml new file mode 100644 index 000000000..c3f63e8c7 --- /dev/null +++ b/pkg/start/testdata/configmap-aggregator-client-ca.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: aggregator-client-ca + namespace: openshift-kube-apiserver +data: + ca-bundle.crt: diff --git a/pkg/start/testdata/configmap-kube-apiserver-client-ca.yaml b/pkg/start/testdata/configmap-kube-apiserver-client-ca.yaml new file mode 100644 index 000000000..d16cce4db --- /dev/null +++ b/pkg/start/testdata/configmap-kube-apiserver-client-ca.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: client-ca + namespace: openshift-kube-apiserver +data: + ca-bundle.crt: + diff --git a/pkg/start/testdata/configmap-kubelet-serving-ca.yaml b/pkg/start/testdata/configmap-kubelet-serving-ca.yaml new file mode 100644 index 000000000..f54be246b --- /dev/null +++ b/pkg/start/testdata/configmap-kubelet-serving-ca.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: kubelet-serving-ca + namespace: openshift-kube-apiserver +data: + ca-bundle.crt: diff --git a/pkg/start/testdata/configmap-sa-token-signing-certs.yaml b/pkg/start/testdata/configmap-sa-token-signing-certs.yaml new file mode 100644 index 000000000..41e5f4d04 --- /dev/null +++ b/pkg/start/testdata/configmap-sa-token-signing-certs.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: sa-token-signing-certs + namespace: openshift-kube-apiserver +data: + ca-bundle.crt: diff --git a/pkg/start/testdata/operator-config.yaml b/pkg/start/testdata/operator-config.yaml new file mode 100644 index 000000000..fafd307b3 --- /dev/null +++ b/pkg/start/testdata/operator-config.yaml @@ -0,0 +1,6 @@ +apiVersion: kubeapiserver.operator.openshift.io/v1alpha1 +kind: KubeAPIServerOperatorConfig +metadata: + name: instance +spec: + managementState: Managed diff --git a/pkg/start/testdata/secret-aggregator-client.yaml b/pkg/start/testdata/secret-aggregator-client.yaml new file mode 100644 index 000000000..9b8da64a0 --- /dev/null +++ b/pkg/start/testdata/secret-aggregator-client.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: aggregator-client + namespace: openshift-kube-apiserver +type: SecretTypeTLS +data: diff --git a/pkg/start/testdata/secret-kubelet-client.yaml b/pkg/start/testdata/secret-kubelet-client.yaml new file mode 100644 index 000000000..dddccefd0 --- /dev/null +++ b/pkg/start/testdata/secret-kubelet-client.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: kubelet-client + namespace: openshift-kube-apiserver +type: SecretTypeTLS +data: diff --git a/pkg/start/testdata/secret-serving-cert.yaml b/pkg/start/testdata/secret-serving-cert.yaml new file mode 100644 index 000000000..3be32ee64 --- /dev/null +++ b/pkg/start/testdata/secret-serving-cert.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: serving-cert + namespace: openshift-kube-apiserver +type: SecretTypeTLS +data: diff --git a/vendor/github.com/openshift/library-go/Makefile b/vendor/github.com/openshift/library-go/Makefile index b0c6d4a43..14bb31deb 100644 --- a/vendor/github.com/openshift/library-go/Makefile +++ b/vendor/github.com/openshift/library-go/Makefile @@ -5,6 +5,9 @@ include alpha-build-machinery/make/golang.mk include alpha-build-machinery/make/targets/openshift/deps.mk include alpha-build-machinery/make/targets/openshift/bindata.mk -$(call add-bindata,staticpod,./pkg/operator/staticpod/controller/backingresource/manifests/...,bindata,bindata,./pkg/operator/staticpod/controller/backingresource/bindata/bindata.go) +$(call add-bindata,backingresources,./pkg/operator/staticpod/controller/backingresource/manifests/...,bindata,bindata,./pkg/operator/staticpod/controller/backingresource/bindata/bindata.go) +$(call add-bindata,monitoring,./pkg/operator/staticpod/controller/monitoring/manifests/...,bindata,bindata,./pkg/operator/staticpod/controller/monitoring/bindata/bindata.go) +$(call add-bindata,installer,./pkg/operator/staticpod/controller/installer/manifests/...,bindata,bindata,./pkg/operator/staticpod/controller/installer/bindata/bindata.go) +$(call add-bindata,staticpod,./pkg/operator/staticpod/controller/prune/manifests/...,bindata,bindata,./pkg/operator/staticpod/controller/prune/bindata/bindata.go) GO_BUILD_PACKAGES :=./pkg/... diff --git a/vendor/github.com/openshift/library-go/glide.lock b/vendor/github.com/openshift/library-go/glide.lock index 91b8de6a4..ff5d3a7c1 100644 --- a/vendor/github.com/openshift/library-go/glide.lock +++ b/vendor/github.com/openshift/library-go/glide.lock @@ -1,5 +1,5 @@ -hash: a011273e6065c920c4d383319b0a69ec2de1d80dc10634fb1d78c33c04e756a2 -updated: 2018-11-16T10:32:14.335159616-05:00 +hash: be554cc57be62b801fadab65f1ebaec34046b7d913e559b61eccf809ca1c9092 +updated: 2018-12-06T15:57:15.466410788-05:00 imports: - name: bitbucket.org/ww/goautoneg version: 75cd24fc2f2c2a2088577d12123ddee5f54e0675 @@ -185,7 +185,7 @@ imports: - name: github.com/NYTimes/gziphandler version: 56545f4a5d46df9a6648819d1664c3a03a13ffdb - name: github.com/openshift/api - version: 6ccc79544967d4508d87a35901e734990c547ffb + version: 83b2fe56301417028bd52e56edd75768e2ea051c subpackages: - apps - apps/v1 @@ -230,6 +230,14 @@ imports: - user/v1 - webconsole - webconsole/v1 +- name: github.com/openshift/client-go + version: 960f72aa32a8e9b4dd769b90ff1cb5bd4c898eec + subpackages: + - config/clientset/versioned + - config/clientset/versioned/fake + - config/clientset/versioned/scheme + - config/clientset/versioned/typed/config/v1 + - config/clientset/versioned/typed/config/v1/fake - name: github.com/pborman/uuid version: ca53cad383cad2479bbba7f7a1a05797ec1386e4 - name: github.com/peterbourgon/diskv @@ -382,6 +390,8 @@ imports: subpackages: - pkg/apis/apiextensions - pkg/apis/apiextensions/v1beta1 + - pkg/client/clientset/clientset/scheme + - pkg/client/clientset/clientset/typed/apiextensions/v1beta1 - name: k8s.io/apimachinery version: 103fd098999dc9c0c88536f5c9ad2e5da39373ae subpackages: @@ -704,4 +714,8 @@ imports: - pkg/handler - pkg/util - pkg/util/proto -testImports: [] +testImports: +- name: vbom.ml/util + version: db5cfe13f5cc80a4990d98e2e1b0707a4d1a5394 + subpackages: + - sortorder diff --git a/vendor/github.com/openshift/library-go/glide.yaml b/vendor/github.com/openshift/library-go/glide.yaml index 090b8a8a6..30f72a530 100644 --- a/vendor/github.com/openshift/library-go/glide.yaml +++ b/vendor/github.com/openshift/library-go/glide.yaml @@ -14,6 +14,8 @@ import: version: kubernetes-1.11.1 - package: github.com/openshift/api version: master +- package: github.com/openshift/client-go + version: master # sig-master - needed for file observer @@ -40,3 +42,5 @@ import: version: 89742aefa4b206dcf400792f3bd35b542998eb3b - package: github.com/blang/semver version: b38d23b8782a487059e8fc8773e9a5b228a77cb6 +- package: github.com/imdario/mergo + version: 6633656539c1639d9d78127b7d47c622b5d7b6dc diff --git a/vendor/github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers/status.go b/vendor/github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers/status.go new file mode 100644 index 000000000..b87658beb --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers/status.go @@ -0,0 +1,119 @@ +package v1 + +import ( + "fmt" + "strings" + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + configv1 "github.com/openshift/api/config/v1" +) + +// SetStatusCondition sets the corresponding condition in conditions to newCondition. +func SetStatusCondition(conditions *[]configv1.ClusterOperatorStatusCondition, newCondition configv1.ClusterOperatorStatusCondition) { + if conditions == nil { + conditions = &[]configv1.ClusterOperatorStatusCondition{} + } + existingCondition := FindStatusCondition(*conditions, newCondition.Type) + if existingCondition == nil { + newCondition.LastTransitionTime = metav1.NewTime(time.Now()) + *conditions = append(*conditions, newCondition) + return + } + + if existingCondition.Status != newCondition.Status { + existingCondition.Status = newCondition.Status + existingCondition.LastTransitionTime = newCondition.LastTransitionTime + } + + existingCondition.Reason = newCondition.Reason + existingCondition.Message = newCondition.Message +} + +// RemoveStatusCondition removes the corresponding conditionType from conditions. +func RemoveStatusCondition(conditions *[]configv1.ClusterOperatorStatusCondition, conditionType configv1.ClusterStatusConditionType) { + if conditions == nil { + conditions = &[]configv1.ClusterOperatorStatusCondition{} + } + newConditions := []configv1.ClusterOperatorStatusCondition{} + for _, condition := range *conditions { + if condition.Type != conditionType { + newConditions = append(newConditions, condition) + } + } + + *conditions = newConditions +} + +// FindStatusCondition finds the conditionType in conditions. +func FindStatusCondition(conditions []configv1.ClusterOperatorStatusCondition, conditionType configv1.ClusterStatusConditionType) *configv1.ClusterOperatorStatusCondition { + for i := range conditions { + if conditions[i].Type == conditionType { + return &conditions[i] + } + } + + return nil +} + +// GetStatusConditionDiff returns a string representing change in condition status in human readable form. +func GetStatusConditionDiff(oldConditions []configv1.ClusterOperatorStatusCondition, newConditions []configv1.ClusterOperatorStatusCondition) string { + messages := []string{} + for _, newCondition := range newConditions { + existingStatusCondition := FindStatusCondition(oldConditions, newCondition.Type) + if existingStatusCondition == nil { + messages = append(messages, fmt.Sprintf("%s set to %s (%q)", newCondition.Type, newCondition.Status, newCondition.Message)) + continue + } + if existingStatusCondition.Status != newCondition.Status { + messages = append(messages, fmt.Sprintf("%s changed from %s to %s (%q)", existingStatusCondition.Type, existingStatusCondition.Status, newCondition.Status, newCondition.Message)) + continue + } + if existingStatusCondition.Message != newCondition.Message { + messages = append(messages, fmt.Sprintf("%s message changed from %q to %q", existingStatusCondition.Type, existingStatusCondition.Message, newCondition.Message)) + } + } + for _, oldCondition := range oldConditions { + // This should not happen. It means we removed old condition entirely instead of just changing its status + if c := FindStatusCondition(newConditions, oldCondition.Type); c == nil { + messages = append(messages, fmt.Sprintf("%s was removed", oldCondition.Type)) + } + } + return strings.Join(messages, ",") +} + +// IsStatusConditionTrue returns true when the conditionType is present and set to `configv1.ConditionTrue` +func IsStatusConditionTrue(conditions []configv1.ClusterOperatorStatusCondition, conditionType configv1.ClusterStatusConditionType) bool { + return IsStatusConditionPresentAndEqual(conditions, conditionType, configv1.ConditionTrue) +} + +// IsStatusConditionFalse returns true when the conditionType is present and set to `configv1.ConditionFalse` +func IsStatusConditionFalse(conditions []configv1.ClusterOperatorStatusCondition, conditionType configv1.ClusterStatusConditionType) bool { + return IsStatusConditionPresentAndEqual(conditions, conditionType, configv1.ConditionFalse) +} + +// IsStatusConditionPresentAndEqual returns true when conditionType is present and equal to status. +func IsStatusConditionPresentAndEqual(conditions []configv1.ClusterOperatorStatusCondition, conditionType configv1.ClusterStatusConditionType, status configv1.ConditionStatus) bool { + for _, condition := range conditions { + if condition.Type == conditionType { + return condition.Status == status + } + } + return false +} + +// IsStatusConditionNotIn returns true when the conditionType does not match the status. +func IsStatusConditionNotIn(conditions []configv1.ClusterOperatorStatusCondition, conditionType configv1.ClusterStatusConditionType, status ...configv1.ConditionStatus) bool { + for _, condition := range conditions { + if condition.Type == conditionType { + for _, s := range status { + if s == condition.Status { + return false + } + } + return true + } + } + return true +} diff --git a/vendor/github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers/status_test.go b/vendor/github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers/status_test.go new file mode 100644 index 000000000..3f25a5945 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers/status_test.go @@ -0,0 +1,85 @@ +package v1 + +import ( + "reflect" + "strings" + "testing" + + configv1 "github.com/openshift/api/config/v1" +) + +func TestGetStatusConditionDiff(t *testing.T) { + tests := []struct { + name string + newConditions []configv1.ClusterOperatorStatusCondition + oldConditions []configv1.ClusterOperatorStatusCondition + expectedMessages []string + }{ + { + name: "new condition", + newConditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.RetrievedUpdates, + Status: configv1.ConditionTrue, + Message: "test", + }, + }, + expectedMessages: []string{`RetrievedUpdates set to True ("test")`}, + }, + { + name: "condition status change", + newConditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.RetrievedUpdates, + Status: configv1.ConditionFalse, + Message: "test", + }, + }, + oldConditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.RetrievedUpdates, + Status: configv1.ConditionTrue, + Message: "test", + }, + }, + expectedMessages: []string{`RetrievedUpdates changed from True to False ("test")`}, + }, + { + name: "condition message change", + newConditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.RetrievedUpdates, + Status: configv1.ConditionTrue, + Message: "foo", + }, + }, + oldConditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.RetrievedUpdates, + Status: configv1.ConditionTrue, + Message: "bar", + }, + }, + expectedMessages: []string{`RetrievedUpdates message changed from "bar" to "foo"`}, + }, + { + name: "condition message deleted", + oldConditions: []configv1.ClusterOperatorStatusCondition{ + { + Type: configv1.RetrievedUpdates, + Status: configv1.ConditionTrue, + Message: "test", + }, + }, + expectedMessages: []string{"RetrievedUpdates was removed"}, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + result := GetStatusConditionDiff(test.oldConditions, test.newConditions) + if !reflect.DeepEqual(test.expectedMessages, strings.Split(result, ",")) { + t.Errorf("expected %#v, got %#v", test.expectedMessages, result) + } + }) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go index 000d0fb43..54f01b974 100644 --- a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go +++ b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go @@ -3,6 +3,7 @@ package controllercmd import ( "fmt" "io/ioutil" + "sync" "time" "github.com/golang/glog" @@ -79,10 +80,13 @@ func (b *ControllerBuilder) WithRestartOnChange(stopCh chan<- struct{}, files .. } b.fileObserver = observer } + var once sync.Once b.fileObserverReactorFn = func(filename string, action fileobserver.ActionType) error { - defer close(stopCh) - glog.Warning(fmt.Sprintf("Restart triggered because of %s", action.String(filename))) + once.Do(func() { + glog.Warning(fmt.Sprintf("Restart triggered because of %s", action.String(filename))) + close(stopCh) + }) return nil } @@ -146,7 +150,7 @@ func (b *ControllerBuilder) Run(config *unstructured.Unstructured, stopCh <-chan if err != nil { panic("unable to read the namespace") } - controllerRef, err := events.GetControllerReferenceForCurrentPod(kubeClient.CoreV1().Pods(namespace)) + controllerRef, err := events.GetControllerReferenceForCurrentPod(kubeClient, namespace, nil) if err != nil { panic(fmt.Sprintf("unable to obtain replicaset reference for events: %v", err)) } diff --git a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go index d69a7d75a..204188f05 100644 --- a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go +++ b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go @@ -169,5 +169,5 @@ func (c *ControllerCommandConfig) StartController(stopCh <-chan struct{}) error WithLeaderElection(config.LeaderElection, "", c.componentName+"-lock"). WithServer(config.ServingInfo, config.Authentication, config.Authorization). WithRestartOnChange(exitOnChangeReactorCh, observedFiles...). - Run(unstructuredConfig, stopCh) + Run(unstructuredConfig, stopChannelCombined) } diff --git a/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/OWNERS b/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/OWNERS new file mode 100644 index 000000000..bf630bd07 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/OWNERS @@ -0,0 +1,6 @@ +reviewers: + - deads2k + - sttts + - mfojtik +approvers: + - mfojtik diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/crypto.go b/vendor/github.com/openshift/library-go/pkg/crypto/crypto.go index 3ee7d0005..635892397 100644 --- a/vendor/github.com/openshift/library-go/pkg/crypto/crypto.go +++ b/vendor/github.com/openshift/library-go/pkg/crypto/crypto.go @@ -267,7 +267,7 @@ func (c *TLSCertificateConfig) WriteCertConfig(certFile, keyFile io.Writer) erro } func (c *TLSCertificateConfig) GetPEMBytes() ([]byte, []byte, error) { - certBytes, err := encodeCertificates(c.Certs...) + certBytes, err := EncodeCertificates(c.Certs...) if err != nil { return nil, nil, err } @@ -309,6 +309,28 @@ func GetTLSCertificateConfig(certFile, keyFile string) (*TLSCertificateConfig, e return &TLSCertificateConfig{certs, key}, nil } +func GetTLSCertificateConfigFromBytes(certBytes, keyBytes []byte) (*TLSCertificateConfig, error) { + if len(certBytes) == 0 { + return nil, errors.New("certFile missing") + } + if len(keyBytes) == 0 { + return nil, errors.New("keyFile missing") + } + + certs, err := cert.ParseCertsPEM(certBytes) + if err != nil { + return nil, fmt.Errorf("Error reading cert: %s", err) + } + + keyPairCert, err := tls.X509KeyPair(certBytes, keyBytes) + if err != nil { + return nil, err + } + key := keyPairCert.PrivateKey + + return &TLSCertificateConfig{certs, key}, nil +} + const ( DefaultCertificateLifetimeInDays = 365 * 2 // 2 years DefaultCACertificateLifetimeInDays = 365 * 5 // 5 years @@ -454,6 +476,18 @@ func GetCA(certFile, keyFile, serialFile string) (*CA, error) { }, nil } +func GetCAFromBytes(certBytes, keyBytes []byte) (*CA, error) { + caConfig, err := GetTLSCertificateConfigFromBytes(certBytes, keyBytes) + if err != nil { + return nil, err + } + + return &CA{ + SerialGenerator: &RandomSerialGenerator{}, + Config: caConfig, + }, nil +} + // if serialFile is empty, a RandomSerialGenerator will be used func MakeCA(certFile, keyFile, serialFile, name string, expireDays int) (*CA, error) { glog.V(2).Infof("Generating new CA for %s cert, and key in %s, %s", name, certFile, keyFile) @@ -487,12 +521,27 @@ func MakeCA(certFile, keyFile, serialFile, name string, expireDays int) (*CA, er } func MakeCAConfig(name string, expireDays int) (*TLSCertificateConfig, error) { + var caLifetimeInDays = DefaultCACertificateLifetimeInDays + if expireDays > 0 { + caLifetimeInDays = expireDays + } + + if caLifetimeInDays > DefaultCACertificateLifetimeInDays { + warnAboutCertificateLifeTime(name, DefaultCACertificateLifetimeInDays) + } + + caLifetime := time.Duration(caLifetimeInDays) * 24 * time.Hour + + return MakeCAConfigForDuration(name, caLifetime) +} + +func MakeCAConfigForDuration(name string, caLifetime time.Duration) (*TLSCertificateConfig, error) { // Create CA cert rootcaPublicKey, rootcaPrivateKey, err := NewKeyPair() if err != nil { return nil, err } - rootcaTemplate := newSigningCertificateTemplate(pkix.Name{CommonName: name}, expireDays, time.Now) + rootcaTemplate := newSigningCertificateTemplateForDuration(pkix.Name{CommonName: name}, caLifetime, time.Now) rootcaCert, err := signCertificate(rootcaTemplate, rootcaPublicKey, rootcaTemplate, rootcaPrivateKey) if err != nil { return nil, err @@ -568,6 +617,25 @@ func (ca *CA) MakeServerCert(hostnames sets.String, expireDays int, fns ...Certi return server, nil } +func (ca *CA) MakeServerCertForDuration(hostnames sets.String, lifetime time.Duration, fns ...CertificateExtensionFunc) (*TLSCertificateConfig, error) { + serverPublicKey, serverPrivateKey, _ := NewKeyPair() + serverTemplate := newServerCertificateTemplateForDuration(pkix.Name{CommonName: hostnames.List()[0]}, hostnames.List(), lifetime, time.Now) + for _, fn := range fns { + if err := fn(serverTemplate); err != nil { + return nil, err + } + } + serverCrt, err := ca.signCertificate(serverTemplate, serverPublicKey) + if err != nil { + return nil, err + } + server := &TLSCertificateConfig{ + Certs: append([]*x509.Certificate{serverCrt}, ca.Config.Certs...), + Key: serverPrivateKey, + } + return server, nil +} + func (ca *CA) EnsureClientCertificate(certFile, keyFile string, u user.Info, expireDays int) (*TLSCertificateConfig, bool, error) { certConfig, err := GetTLSCertificateConfig(certFile, keyFile) if err != nil { @@ -595,7 +663,7 @@ func (ca *CA) MakeClientCertificate(certFile, keyFile string, u user.Info, expir return nil, err } - certData, err := encodeCertificates(clientCrt) + certData, err := EncodeCertificates(clientCrt) if err != nil { return nil, err } @@ -614,6 +682,26 @@ func (ca *CA) MakeClientCertificate(certFile, keyFile string, u user.Info, expir return GetTLSCertificateConfig(certFile, keyFile) } +func (ca *CA) MakeClientCertificateForDuration(u user.Info, lifetime time.Duration) (*TLSCertificateConfig, error) { + clientPublicKey, clientPrivateKey, _ := NewKeyPair() + clientTemplate := newClientCertificateTemplateForDuration(userToSubject(u), lifetime, time.Now) + clientCrt, err := ca.signCertificate(clientTemplate, clientPublicKey) + if err != nil { + return nil, err + } + + certData, err := EncodeCertificates(clientCrt) + if err != nil { + return nil, err + } + keyData, err := encodeKey(clientPrivateKey) + if err != nil { + return nil, err + } + + return GetTLSCertificateConfigFromBytes(certData, keyData) +} + type sortedForDER []string func (s sortedForDER) Len() int { @@ -676,18 +764,7 @@ func NewKeyPair() (crypto.PublicKey, crypto.PrivateKey, error) { } // Can be used for CA or intermediate signing certs -func newSigningCertificateTemplate(subject pkix.Name, expireDays int, currentTime func() time.Time) *x509.Certificate { - var caLifetimeInDays = DefaultCACertificateLifetimeInDays - if expireDays > 0 { - caLifetimeInDays = expireDays - } - - if caLifetimeInDays > DefaultCACertificateLifetimeInDays { - warnAboutCertificateLifeTime(subject.CommonName, DefaultCACertificateLifetimeInDays) - } - - caLifetime := time.Duration(caLifetimeInDays) * 24 * time.Hour - +func newSigningCertificateTemplateForDuration(subject pkix.Name, caLifetime time.Duration, currentTime func() time.Time) *x509.Certificate { return &x509.Certificate{ Subject: subject, @@ -716,6 +793,11 @@ func newServerCertificateTemplate(subject pkix.Name, hosts []string, expireDays lifetime := time.Duration(lifetimeInDays) * 24 * time.Hour + return newServerCertificateTemplateForDuration(subject, hosts, lifetime, currentTime) +} + +// Can be used for ListenAndServeTLS +func newServerCertificateTemplateForDuration(subject pkix.Name, hosts []string, lifetime time.Duration, currentTime func() time.Time) *x509.Certificate { template := &x509.Certificate{ Subject: subject, @@ -797,6 +879,11 @@ func newClientCertificateTemplate(subject pkix.Name, expireDays int, currentTime lifetime := time.Duration(lifetimeInDays) * 24 * time.Hour + return newClientCertificateTemplateForDuration(subject, lifetime, currentTime) +} + +// Can be used as a certificate in http.Transport TLSClientConfig +func newClientCertificateTemplateForDuration(subject pkix.Name, lifetime time.Duration, currentTime func() time.Time) *x509.Certificate { return &x509.Certificate{ Subject: subject, @@ -833,7 +920,7 @@ func signCertificate(template *x509.Certificate, requestKey crypto.PublicKey, is return certs[0], nil } -func encodeCertificates(certs ...*x509.Certificate) ([]byte, error) { +func EncodeCertificates(certs ...*x509.Certificate) ([]byte, error) { b := bytes.Buffer{} for _, cert := range certs { if err := pem.Encode(&b, &pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw}); err != nil { @@ -865,7 +952,7 @@ func encodeKey(key crypto.PrivateKey) ([]byte, error) { } func writeCertificates(f io.Writer, certs ...*x509.Certificate) error { - bytes, err := encodeCertificates(certs...) + bytes, err := EncodeCertificates(certs...) if err != nil { return err } diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/crypto_test.go b/vendor/github.com/openshift/library-go/pkg/crypto/crypto_test.go index 842c75eea..98f9eb8f9 100644 --- a/vendor/github.com/openshift/library-go/pkg/crypto/crypto_test.go +++ b/vendor/github.com/openshift/library-go/pkg/crypto/crypto_test.go @@ -118,6 +118,22 @@ func TestCrypto(t *testing.T) { }, true, 4) } +// Can be used for CA or intermediate signing certs +func newSigningCertificateTemplate(subject pkix.Name, expireDays int, currentTime func() time.Time) *x509.Certificate { + var caLifetimeInDays = DefaultCACertificateLifetimeInDays + if expireDays > 0 { + caLifetimeInDays = expireDays + } + + if caLifetimeInDays > DefaultCACertificateLifetimeInDays { + warnAboutCertificateLifeTime(subject.CommonName, DefaultCACertificateLifetimeInDays) + } + + caLifetime := time.Duration(caLifetimeInDays) * 24 * time.Hour + + return newSigningCertificateTemplateForDuration(subject, caLifetime, currentTime) +} + func buildCA(t *testing.T) (crypto.PrivateKey, *x509.Certificate) { caPublicKey, caPrivateKey, err := NewKeyPair() if err != nil { diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/rotation.go b/vendor/github.com/openshift/library-go/pkg/crypto/rotation.go new file mode 100644 index 000000000..0aa127037 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/crypto/rotation.go @@ -0,0 +1,20 @@ +package crypto + +import ( + "crypto/x509" + "time" +) + +// FilterExpiredCerts checks are all certificates in the bundle valid, i.e. they have not expired. +// The function returns new bundle with only valid certificates or error if no valid certificate is found. +func FilterExpiredCerts(certs ...*x509.Certificate) []*x509.Certificate { + currentTime := time.Now() + var validCerts []*x509.Certificate + for _, c := range certs { + if c.NotAfter.After(currentTime) { + validCerts = append(validCerts, c) + } + } + + return validCerts +} diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/rotation_test.go b/vendor/github.com/openshift/library-go/pkg/crypto/rotation_test.go new file mode 100644 index 000000000..9bfb47935 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/crypto/rotation_test.go @@ -0,0 +1,93 @@ +package crypto + +import ( + "crypto/x509" + "crypto/x509/pkix" + "io/ioutil" + "math/big" + "testing" + "time" + + "k8s.io/client-go/util/cert" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestValidateCertificates(t *testing.T) { + c, err := newTestCACertificate(pkix.Name{CommonName: "test"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + if err != nil { + t.Fatal(err) + } + + if len(c.Config.Certs) != 1 { + t.Fatalf("expected 1 certificate in the chain, but got %d", len(c.Config.Certs)) + } + + validCerts := FilterExpiredCerts(c.Config.Certs...) + if len(validCerts) != 1 { + t.Fatalf("expected 1 valid certificate in the chain, but got %d", len(validCerts)) + } +} + +func TestValidateCertificatesExpired(t *testing.T) { + certBytes, err := ioutil.ReadFile("./testfiles/tls-expired.crt") + if err != nil { + t.Fatal(err) + } + if err != nil { + t.Fatal(err) + } + certs, err := cert.ParseCertsPEM(certBytes) + if err != nil { + t.Fatal(err) + } + + newCert, err := newTestCACertificate(pkix.Name{CommonName: "etcdproxy-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + if err != nil { + t.Fatal(err) + } + certs = append(certs, newCert.Config.Certs...) + + if len(certs) != 2 { + t.Fatalf("expected 2 certificate in the chain, but got %d", len(certs)) + } + + validCerts := FilterExpiredCerts(certs...) + if len(validCerts) != 1 { + t.Fatalf("expected 1 valid certificate in the chain, but got %d", len(validCerts)) + } +} + +// NewCACertificate generates and signs new CA certificate and key. +func newTestCACertificate(subject pkix.Name, serialNumber int64, validity metav1.Duration, currentTime func() time.Time) (*CA, error) { + caPublicKey, caPrivateKey, err := NewKeyPair() + if err != nil { + return nil, err + } + + caCert := &x509.Certificate{ + Subject: subject, + + SignatureAlgorithm: x509.SHA256WithRSA, + + NotBefore: currentTime().Add(-1 * time.Second), + NotAfter: currentTime().Add(validity.Duration), + SerialNumber: big.NewInt(serialNumber), + + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, + BasicConstraintsValid: true, + IsCA: true, + } + + cert, err := signCertificate(caCert, caPublicKey, caCert, caPrivateKey) + if err != nil { + return nil, err + } + + return &CA{ + Config: &TLSCertificateConfig{ + Certs: []*x509.Certificate{cert}, + Key: caPrivateKey, + }, + }, nil +} diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls-expired.crt b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls-expired.crt new file mode 100644 index 000000000..b6140c7ab --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls-expired.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICMjCCAdmgAwIBAgIUdTpx2/qycBZJltbEdfTyfKyJjG0wCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTIwODAwWhcN +MTgwNzMwMTIwOTAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABMlJR5tWK7vgCytCxBQov1xNp+R9RG2wI1w9 +SXIn+Za97Nf6krdyUDd+P6QSSJDkRTQZDsGiCpJhgd5kAzFNUkajgZgwgZUwDgYD +VR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFOERFpshmIXspqXoox9gnSFGmm3PMB8GA1UdIwQYMBaAFCtdC7xd +NJKjmyiwhZJH7LBLOLrgMCAGA1UdEQQZMBeCFWV0Y2Rwcm94eS10ZXN0cy5sb2Nh +bDAKBggqhkjOPQQDAgNHADBEAiAvsq9L5uk0jg3v2z1xemAUwPXrEIAcbJhXFfC0 +QmVGGgIgFT9d/inKJcm/NfAgDGkoXSvHGv0NKAZpR32Dqriobh4= +-----END CERTIFICATE----- diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls-multiple.crt b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls-multiple.crt new file mode 100644 index 000000000..b321982a7 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls-multiple.crt @@ -0,0 +1,39 @@ +-----BEGIN CERTIFICATE----- +MIICADCCAaagAwIBAgIUQ0hq1Lmd6ujao+8Iy6LfpMdyNI8wCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTExMDAwWhcN +MjMwNzI5MTExMDAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABGoowUY2eQdvaHG4S/UMYD6mjs6/P7mmhizl +KWO03gq2eVSsbiYAnCJok3o2WQ01GtcS6bOUJ1DOG0gLTRfQ/lWjZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBQmqCeN+suT +0JjgSxtCqTln7zonHjAfBgNVHSMEGDAWgBQmqCeN+suT0JjgSxtCqTln7zonHjAK +BggqhkjOPQQDAgNIADBFAiAUKV8vkiIoCiqtHQsp3PrUUV3He2B9K1tQgA8loTa+ +IQIhANPbCDVoPSFsX0I5iG/DQl/MmTo/tlsmNkN99j1j2JIM +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICADCCAaagAwIBAgIUU8ZsD37pcA1UYkgwhR6d/KjdGeAwCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTExMTAwWhcN +MjMwNzI5MTExMTAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABLupsOF50q6GE7z2US77t5iLGe9wdOFwHssC +jUjCEGvJ/d2sGMxdiABJrrB8gau6TilrJCy9ZTYj56fzdReUnsKjZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBRhaKyklrnI +wd2kg84t1D8CvDVtdjAfBgNVHSMEGDAWgBRhaKyklrnIwd2kg84t1D8CvDVtdjAK +BggqhkjOPQQDAgNIADBFAiAOCYqtOamRapNc+XxR7IFzlr7Si7EvjQ+ej5SKHb7g +rgIhAIBd1dtMc0KJSFsoxnQZailkFi5Nlea2eHU1wEDKVb40 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIB/zCCAaagAwIBAgIUVCSMefpK8uxDKy87jKnwc97DseIwCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTExMTAwWhcN +MjMwNzI5MTExMTAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABOhGVuxW0nEQ5REqQdRF1eJ7OUOdXB/oDJed +Jr1ezcyhJyCRvD9DfadSBvMHFyzw7ssBIIMm4C3Eufj96M3tSACjZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBTLR9qOF3Hh +if8KUbkrRYUK13xSSDAfBgNVHSMEGDAWgBTLR9qOF3Hhif8KUbkrRYUK13xSSDAK +BggqhkjOPQQDAgNHADBEAiAFD2zRXnp40wVeffwpkU+ToFF6Nts/HJk02iMr/+km +RgIgRLZxonlkyLlUHucMKC2V+4UJ9akEbu/bhCXKuQb2DgY= +-----END CERTIFICATE----- diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls.crt b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls.crt new file mode 100644 index 000000000..862bdbc2d --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls.crt @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIICADCCAaagAwIBAgIUWke4fSfaCH+2MLSFeTHBpoi+h1YwCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTA1MDAwWhcN +MjMwNzI5MTA1MDAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABHoqBfTXFdWRATfdrr/v5UriZBxmzL5aiwLZ +VRUg2UZNnoH2JLUcDkqx3IQakjoVijweiQeqxAai3mxjtgxbh+ajZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBSgDE3RpOiH +Gv7AEnYKRk46zVIkbzAfBgNVHSMEGDAWgBSgDE3RpOiHGv7AEnYKRk46zVIkbzAK +BggqhkjOPQQDAgNIADBFAiA3Gg/gwiEfjclpQYyd3qTgdCWzud8GKRdjVK3Z2BXW +swIhANMuxi0Y41mwcmh3a2icpdeGHGyGNdNDe8uF+5csuNUp +-----END CERTIFICATE----- diff --git a/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls.key b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls.key new file mode 100644 index 000000000..83cf18be6 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/crypto/testfiles/tls.key @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIC+UyR59JEbt/qjWZG/87ZYzk0pOgTBmpx5R0w6uG66JoAoGCCqGSM49 +AwEHoUQDQgAEeioF9NcV1ZEBN92uv+/lSuJkHGbMvlqLAtlVFSDZRk2egfYktRwO +SrHchBqSOhWKPB6JB6rEBqLebGO2DFuH5g== +-----END EC PRIVATE KEY----- diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/cabundle.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/cabundle.go new file mode 100644 index 000000000..a160db703 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/cabundle.go @@ -0,0 +1,104 @@ +package certrotation + +import ( + "crypto/x509" + "reflect" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1informers "k8s.io/client-go/informers/core/v1" + corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + corev1listers "k8s.io/client-go/listers/core/v1" + "k8s.io/client-go/util/cert" + + "github.com/openshift/library-go/pkg/crypto" + "github.com/openshift/library-go/pkg/operator/events" +) + +type CABundleRotation struct { + Namespace string + Name string + + Informer corev1informers.ConfigMapInformer + Lister corev1listers.ConfigMapLister + Client corev1client.ConfigMapsGetter + EventRecorder events.Recorder +} + +func (c CABundleRotation) ensureConfigMapCABundle(signingCertKeyPair *crypto.CA) error { + // by this point we have current signing cert/key pair. We now need to make sure that the ca-bundle configmap has this cert and + // doesn't have any expired certs + originalCABundleConfigMap, err := c.Lister.ConfigMaps(c.Namespace).Get(c.Name) + if err != nil && !apierrors.IsNotFound(err) { + return err + } + caBundleConfigMap := originalCABundleConfigMap.DeepCopy() + if apierrors.IsNotFound(err) { + // create an empty one + caBundleConfigMap = &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Namespace: c.Namespace, Name: c.Name}} + } + if err := manageCABundleConfigMap(caBundleConfigMap, signingCertKeyPair.Config.Certs[0]); err != nil { + return err + } + if originalCABundleConfigMap == nil || originalCABundleConfigMap.Data == nil || !equality.Semantic.DeepEqual(originalCABundleConfigMap.Data, caBundleConfigMap.Data) { + c.EventRecorder.Eventf("CABundleUpdateRequired", "%q in %q requires a new cert", c.Namespace, c.Name) + actualCABundleConfigMap, err := c.Client.ConfigMaps(c.Namespace).Update(caBundleConfigMap) + if apierrors.IsNotFound(err) { + actualCABundleConfigMap, err = c.Client.ConfigMaps(c.Namespace).Create(caBundleConfigMap) + if err != nil { + return err + } + } + if err != nil { + return err + } + caBundleConfigMap = actualCABundleConfigMap + } + + return nil +} + +// manageCABundleConfigMap adds the new certificate to the list of cabundles, eliminates duplicates, and prunes the list of expired +// certs to trust as signers +func manageCABundleConfigMap(caBundleConfigMap *corev1.ConfigMap, currentSigner *x509.Certificate) error { + if caBundleConfigMap.Data == nil { + caBundleConfigMap.Data = map[string]string{} + } + + certificates := []*x509.Certificate{} + caBundle := caBundleConfigMap.Data["ca-bundle.crt"] + if len(caBundle) > 0 { + var err error + certificates, err = cert.ParseCertsPEM([]byte(caBundle)) + if err != nil { + return err + } + } + certificates = append([]*x509.Certificate{currentSigner}, certificates...) + certificates = crypto.FilterExpiredCerts(certificates...) + + finalCertificates := []*x509.Certificate{} + // now check for duplicates. n^2, but super simple + for i := range certificates { + found := false + for j := range finalCertificates { + if reflect.DeepEqual(certificates[i].Raw, finalCertificates[j].Raw) { + found = true + break + } + } + if !found { + finalCertificates = append(finalCertificates, certificates[i]) + } + } + + caBytes, err := crypto.EncodeCertificates(finalCertificates...) + if err != nil { + return err + } + caBundleConfigMap.Data["ca-bundle.crt"] = string(caBytes) + + return nil +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/cabundle_test.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/cabundle_test.go new file mode 100644 index 000000000..18b3558b0 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/cabundle_test.go @@ -0,0 +1,289 @@ +package certrotation + +import ( + gcrypto "crypto" + "crypto/rand" + "crypto/x509" + "crypto/x509/pkix" + "errors" + "io/ioutil" + "math/big" + "strings" + "testing" + "time" + + "k8s.io/client-go/util/cert" + + "github.com/davecgh/go-spew/spew" + + "github.com/openshift/library-go/pkg/crypto" + "github.com/openshift/library-go/pkg/operator/events" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kubefake "k8s.io/client-go/kubernetes/fake" + corev1listers "k8s.io/client-go/listers/core/v1" + clienttesting "k8s.io/client-go/testing" + "k8s.io/client-go/tools/cache" +) + +func TestEnsureConfigMapCABundle(t *testing.T) { + tests := []struct { + name string + + initialConfigMapFn func() *corev1.ConfigMap + caFn func() (*crypto.CA, error) + + verifyActions func(t *testing.T, client *kubefake.Clientset) + expectedError string + }{ + { + name: "initial create", + caFn: func() (*crypto.CA, error) { + return newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + }, + initialConfigMapFn: func() *corev1.ConfigMap { return nil }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + actions := client.Actions() + if len(actions) != 2 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "configmaps") { + t.Error(actions[0]) + } + if !actions[1].Matches("create", "configmaps") { + t.Error(actions[1]) + } + + actual := actions[1].(clienttesting.CreateAction).GetObject().(*corev1.ConfigMap) + if len(actual.Data["ca-bundle.crt"]) == 0 { + t.Error(actual.Data) + } + }, + }, + { + name: "update keep both", + caFn: func() (*crypto.CA, error) { + return newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + }, + initialConfigMapFn: func() *corev1.ConfigMap { + caBundleConfigMap := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "trust-bundle"}, + Data: map[string]string{}, + } + certs, err := newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + if err != nil { + t.Fatal(err) + } + caBytes, err := crypto.EncodeCertificates(certs.Config.Certs...) + if err != nil { + t.Fatal(err) + } + caBundleConfigMap.Data["ca-bundle.crt"] = string(caBytes) + return caBundleConfigMap + }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + actions := client.Actions() + if len(actions) != 1 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "configmaps") { + t.Error(actions[0]) + } + + actual := actions[0].(clienttesting.UpdateAction).GetObject().(*corev1.ConfigMap) + if len(actual.Data["ca-bundle.crt"]) == 0 { + t.Error(actual.Data) + } + result, err := cert.ParseCertsPEM([]byte(actual.Data["ca-bundle.crt"])) + if err != nil { + t.Fatal(err) + } + if len(result) != 2 { + t.Error(len(result)) + } + }, + }, + { + name: "update remove old", + caFn: func() (*crypto.CA, error) { + return newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + }, + initialConfigMapFn: func() *corev1.ConfigMap { + caBundleConfigMap := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "trust-bundle"}, + Data: map[string]string{}, + } + certs, err := newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + if err != nil { + t.Fatal(err) + } + caBytes, err := crypto.EncodeCertificates(certs.Config.Certs[0], certs.Config.Certs[0]) + if err != nil { + t.Fatal(err) + } + caBundleConfigMap.Data["ca-bundle.crt"] = string(caBytes) + return caBundleConfigMap + }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + actions := client.Actions() + if len(actions) != 1 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "configmaps") { + t.Error(actions[0]) + } + + actual := actions[0].(clienttesting.UpdateAction).GetObject().(*corev1.ConfigMap) + if len(actual.Data["ca-bundle.crt"]) == 0 { + t.Error(actual.Data) + } + result, err := cert.ParseCertsPEM([]byte(actual.Data["ca-bundle.crt"])) + if err != nil { + t.Fatal(err) + } + if len(result) != 2 { + t.Error(len(result)) + } + }, + }, + { + name: "update remove duplicate", + caFn: func() (*crypto.CA, error) { + return newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + }, + initialConfigMapFn: func() *corev1.ConfigMap { + caBundleConfigMap := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "trust-bundle"}, + Data: map[string]string{}, + } + certBytes, err := ioutil.ReadFile("./testfiles/tls-expired.crt") + if err != nil { + t.Fatal(err) + } + certs, err := cert.ParseCertsPEM(certBytes) + if err != nil { + t.Fatal(err) + } + caBytes, err := crypto.EncodeCertificates(certs...) + if err != nil { + t.Fatal(err) + } + caBundleConfigMap.Data["ca-bundle.crt"] = string(caBytes) + return caBundleConfigMap + }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + actions := client.Actions() + if len(actions) != 1 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "configmaps") { + t.Error(actions[0]) + } + + actual := actions[0].(clienttesting.UpdateAction).GetObject().(*corev1.ConfigMap) + if len(actual.Data["ca-bundle.crt"]) == 0 { + t.Error(actual.Data) + } + result, err := cert.ParseCertsPEM([]byte(actual.Data["ca-bundle.crt"])) + if err != nil { + t.Fatal(err) + } + if len(result) != 1 { + t.Error(len(result)) + } + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) + + client := kubefake.NewSimpleClientset() + if startingObj := test.initialConfigMapFn(); startingObj != nil { + indexer.Add(startingObj) + client = kubefake.NewSimpleClientset(startingObj) + } + + c := &CABundleRotation{ + Namespace: "ns", + Name: "trust-bundle", + + Client: client.CoreV1(), + Lister: corev1listers.NewConfigMapLister(indexer), + EventRecorder: events.NewInMemoryRecorder("test"), + } + + newCA, err := test.caFn() + if err != nil { + t.Fatal(err) + } + err = c.ensureConfigMapCABundle(newCA) + switch { + case err != nil && len(test.expectedError) == 0: + t.Error(err) + case err != nil && !strings.Contains(err.Error(), test.expectedError): + t.Error(err) + case err == nil && len(test.expectedError) != 0: + t.Errorf("missing %q", test.expectedError) + } + + test.verifyActions(t, client) + }) + } +} + +// NewCACertificate generates and signs new CA certificate and key. +func newTestCACertificate(subject pkix.Name, serialNumber int64, validity metav1.Duration, currentTime func() time.Time) (*crypto.CA, error) { + caPublicKey, caPrivateKey, err := crypto.NewKeyPair() + if err != nil { + return nil, err + } + + caCert := &x509.Certificate{ + Subject: subject, + + SignatureAlgorithm: x509.SHA256WithRSA, + + NotBefore: currentTime().Add(-1 * time.Second), + NotAfter: currentTime().Add(validity.Duration), + SerialNumber: big.NewInt(serialNumber), + + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, + BasicConstraintsValid: true, + IsCA: true, + } + + cert, err := signCertificate(caCert, caPublicKey, caCert, caPrivateKey) + if err != nil { + return nil, err + } + + return &crypto.CA{ + Config: &crypto.TLSCertificateConfig{ + Certs: []*x509.Certificate{cert}, + Key: caPrivateKey, + }, + SerialGenerator: &crypto.RandomSerialGenerator{}, + }, nil +} + +func signCertificate(template *x509.Certificate, requestKey gcrypto.PublicKey, issuer *x509.Certificate, issuerKey gcrypto.PrivateKey) (*x509.Certificate, error) { + derBytes, err := x509.CreateCertificate(rand.Reader, template, issuer, requestKey, issuerKey) + if err != nil { + return nil, err + } + certs, err := x509.ParseCertificates(derBytes) + if err != nil { + return nil, err + } + if len(certs) != 1 { + return nil, errors.New("Expected a single certificate") + } + return certs[0], nil +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/client_cert_rotation_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/client_cert_rotation_controller.go new file mode 100644 index 000000000..ae762ef8c --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/client_cert_rotation_controller.go @@ -0,0 +1,151 @@ +package certrotation + +import ( + "fmt" + "time" + + "github.com/golang/glog" + + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" +) + +const ( + // CertificateExpiryAnnotation contains the certificate expiration date in RFC3339 format. + CertificateExpiryAnnotation = "auth.openshift.io/certificate-expiry-date" + // CertificateSignedBy contains the common name of the certificate that signed another certificate. + CertificateSignedBy = "auth.openshift.io/certificate-signed-by" +) + +const workQueueKey = "key" + +type CertRotationController struct { + name string + + SigningRotation SigningRotation + CABundleRotation CABundleRotation + TargetRotation TargetRotation + + cachesSynced []cache.InformerSynced + + // queue only ever has one item, but it has nice error handling backoff/retry semantics + queue workqueue.RateLimitingInterface +} + +func NewCertRotationController( + name string, + signingRotation SigningRotation, + caBundleRotation CABundleRotation, + targetRotation TargetRotation, +) *CertRotationController { + ret := &CertRotationController{ + SigningRotation: signingRotation, + CABundleRotation: caBundleRotation, + TargetRotation: targetRotation, + + cachesSynced: []cache.InformerSynced{ + signingRotation.Informer.Informer().HasSynced, + caBundleRotation.Informer.Informer().HasSynced, + targetRotation.Informer.Informer().HasSynced, + }, + + queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), name), + } + + signingRotation.Informer.Informer().AddEventHandler(ret.eventHandler()) + caBundleRotation.Informer.Informer().AddEventHandler(ret.eventHandler()) + targetRotation.Informer.Informer().AddEventHandler(ret.eventHandler()) + + return ret +} + +func (c CertRotationController) sync() error { + signingCertKeyPair, err := c.SigningRotation.ensureSigningCertKeyPair() + if err != nil { + return err + } + + if err := c.CABundleRotation.ensureConfigMapCABundle(signingCertKeyPair); err != nil { + return err + } + + if err := c.TargetRotation.ensureTargetCertKeyPair(signingCertKeyPair); err != nil { + return err + } + + return nil +} + +func needNewCertKeyPairForTime(annotations map[string]string, validity time.Duration, renewalPercentage float32) bool { + signingCertKeyPairExpiry := annotations[CertificateExpiryAnnotation] + if len(signingCertKeyPairExpiry) == 0 { + return true + } + certExpiry, err := time.Parse(time.RFC3339, signingCertKeyPairExpiry) + if err != nil { + glog.Infof("bad expiry: %q", signingCertKeyPairExpiry) + // just create a new one + return true + } + + // If Certificate is not-expired, skip this iteration. + renewalDuration := -1 * float32(validity) * (1 - renewalPercentage) + if certExpiry.Add(time.Duration(renewalDuration)).After(time.Now()) { + return false + } + + return true +} + +func (c *CertRotationController) Run(workers int, stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + defer c.queue.ShutDown() + + glog.Infof("Starting CertRotationController - %q", c.name) + defer glog.Infof("Shutting down CertRotationController - %q", c.name) + + if !cache.WaitForCacheSync(stopCh, c.cachesSynced...) { + utilruntime.HandleError(fmt.Errorf("caches did not sync")) + return + } + + // doesn't matter what workers say, only start one. + go wait.Until(c.runWorker, time.Second, stopCh) + + <-stopCh +} + +func (c *CertRotationController) runWorker() { + for c.processNextWorkItem() { + } +} + +func (c *CertRotationController) processNextWorkItem() bool { + dsKey, quit := c.queue.Get() + if quit { + return false + } + defer c.queue.Done(dsKey) + + err := c.sync() + if err == nil { + c.queue.Forget(dsKey) + return true + } + + utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err)) + c.queue.AddRateLimited(dsKey) + + return true +} + +// eventHandler queues the operator to check spec and status +func (c *CertRotationController) eventHandler() cache.ResourceEventHandler { + return cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { c.queue.Add(workQueueKey) }, + UpdateFunc: func(old, new interface{}) { c.queue.Add(workQueueKey) }, + DeleteFunc: func(obj interface{}) { c.queue.Add(workQueueKey) }, + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/signer.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/signer.go new file mode 100644 index 000000000..6c48d493c --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/signer.go @@ -0,0 +1,98 @@ +package certrotation + +import ( + "bytes" + "fmt" + "time" + + "github.com/openshift/library-go/pkg/crypto" + "github.com/openshift/library-go/pkg/operator/events" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1informers "k8s.io/client-go/informers/core/v1" + corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + corev1listers "k8s.io/client-go/listers/core/v1" +) + +type SigningRotation struct { + Namespace string + Name string + Validity time.Duration + RefreshPercentage float32 + + Informer corev1informers.SecretInformer + Lister corev1listers.SecretLister + Client corev1client.SecretsGetter + EventRecorder events.Recorder +} + +func (c SigningRotation) ensureSigningCertKeyPair() (*crypto.CA, error) { + originalSigningCertKeyPairSecret, err := c.Lister.Secrets(c.Namespace).Get(c.Name) + if err != nil && !apierrors.IsNotFound(err) { + return nil, err + } + signingCertKeyPairSecret := originalSigningCertKeyPairSecret.DeepCopy() + if apierrors.IsNotFound(err) { + // create an empty one + signingCertKeyPairSecret = &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Namespace: c.Namespace, Name: c.Name}} + } + signingCertKeyPairSecret.Type = corev1.SecretTypeTLS + + if needNewSigningCertKeyPair(signingCertKeyPairSecret.Annotations, c.Validity, c.RefreshPercentage) { + c.EventRecorder.Eventf("SignerUpdateRequired", "%q in %q requires a new signing cert/key pair", c.Name, c.Namespace) + if err := setSigningCertKeyPairSecret(signingCertKeyPairSecret, c.Validity); err != nil { + return nil, err + } + + actualSigningCertKeyPairSecret, err := c.Client.Secrets(c.Namespace).Update(signingCertKeyPairSecret) + if apierrors.IsNotFound(err) { + actualSigningCertKeyPairSecret, err = c.Client.Secrets(c.Namespace).Create(signingCertKeyPairSecret) + if err != nil { + return nil, err + } + } + if err != nil { + return nil, err + } + signingCertKeyPairSecret = actualSigningCertKeyPairSecret + } + // at this point, the secret has the correct signer, so we should read that signer to be able to sign + signingCertKeyPair, err := crypto.GetCAFromBytes(signingCertKeyPairSecret.Data["tls.crt"], signingCertKeyPairSecret.Data["tls.key"]) + if err != nil { + return nil, err + } + + return signingCertKeyPair, nil +} + +func needNewSigningCertKeyPair(annotations map[string]string, validity time.Duration, renewalPercentage float32) bool { + return needNewCertKeyPairForTime(annotations, validity, renewalPercentage) +} + +// setSigningCertKeyPairSecret creates a new signing cert/key pair and sets them in the secret +func setSigningCertKeyPairSecret(signingCertKeyPairSecret *corev1.Secret, validity time.Duration) error { + signerName := fmt.Sprintf("%s_%s@%d", signingCertKeyPairSecret.Namespace, signingCertKeyPairSecret.Name, time.Now().Unix()) + ca, err := crypto.MakeCAConfigForDuration(signerName, validity) + if err != nil { + return err + } + + certBytes := &bytes.Buffer{} + keyBytes := &bytes.Buffer{} + if err := ca.WriteCertConfig(certBytes, keyBytes); err != nil { + return err + } + + if signingCertKeyPairSecret.Annotations == nil { + signingCertKeyPairSecret.Annotations = map[string]string{} + } + if signingCertKeyPairSecret.Data == nil { + signingCertKeyPairSecret.Data = map[string][]byte{} + } + signingCertKeyPairSecret.Data["tls.crt"] = certBytes.Bytes() + signingCertKeyPairSecret.Data["tls.key"] = keyBytes.Bytes() + signingCertKeyPairSecret.Annotations[CertificateExpiryAnnotation] = ca.Certs[0].NotAfter.Format(time.RFC3339) + + return nil +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/signer_test.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/signer_test.go new file mode 100644 index 000000000..9c0cae4f2 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/signer_test.go @@ -0,0 +1,125 @@ +package certrotation + +import ( + "strings" + "testing" + "time" + + "github.com/davecgh/go-spew/spew" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kubefake "k8s.io/client-go/kubernetes/fake" + corev1listers "k8s.io/client-go/listers/core/v1" + clienttesting "k8s.io/client-go/testing" + "k8s.io/client-go/tools/cache" + + "github.com/openshift/library-go/pkg/operator/events" +) + +func TestEnsureSigningCertKeyPair(t *testing.T) { + tests := []struct { + name string + + initialSecret *corev1.Secret + + verifyActions func(t *testing.T, client *kubefake.Clientset) + expectedError string + }{ + { + name: "initial create", + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + t.Helper() + actions := client.Actions() + if len(actions) != 2 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "secrets") { + t.Error(actions[0]) + } + if !actions[1].Matches("create", "secrets") { + t.Error(actions[1]) + } + + actual := actions[1].(clienttesting.CreateAction).GetObject().(*corev1.Secret) + if len(actual.Data["tls.crt"]) == 0 || len(actual.Data["tls.key"]) == 0 { + t.Error(actual.Data) + } + }, + }, + { + name: "update no annotations", + initialSecret: &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "signer"}, + }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + t.Helper() + actions := client.Actions() + if len(actions) != 1 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "secrets") { + t.Error(actions[0]) + } + + actual := actions[0].(clienttesting.UpdateAction).GetObject().(*corev1.Secret) + if len(actual.Data["tls.crt"]) == 0 || len(actual.Data["tls.key"]) == 0 { + t.Error(actual.Data) + } + }, + }, + { + name: "update no work", + initialSecret: &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "signer", + Annotations: map[string]string{ + "auth.openshift.io/certificate-expiry-date": "2108-09-08T22:47:31-07:00", + }}, + }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + t.Helper() + actions := client.Actions() + if len(actions) != 0 { + t.Fatal(spew.Sdump(actions)) + } + }, + expectedError: "certFile missing", // this means we tried to read the cert from the existing secret. If we created one, we fail in the client check + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) + + client := kubefake.NewSimpleClientset() + if test.initialSecret != nil { + indexer.Add(test.initialSecret) + client = kubefake.NewSimpleClientset(test.initialSecret) + } + + c := &SigningRotation{ + Namespace: "ns", + Name: "signer", + Validity: 24 * time.Hour, + RefreshPercentage: .50, + Client: client.CoreV1(), + Lister: corev1listers.NewSecretLister(indexer), + EventRecorder: events.NewInMemoryRecorder("test"), + } + + _, err := c.ensureSigningCertKeyPair() + switch { + case err != nil && len(test.expectedError) == 0: + t.Error(err) + case err != nil && !strings.Contains(err.Error(), test.expectedError): + t.Error(err) + case err == nil && len(test.expectedError) != 0: + t.Errorf("missing %q", test.expectedError) + } + + test.verifyActions(t, client) + }) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target.go new file mode 100644 index 000000000..cbdce1e04 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target.go @@ -0,0 +1,129 @@ +package certrotation + +import ( + "fmt" + "time" + + "github.com/openshift/library-go/pkg/operator/events" + corev1informers "k8s.io/client-go/informers/core/v1" + corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + corev1listers "k8s.io/client-go/listers/core/v1" + + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apiserver/pkg/authentication/user" + + "github.com/openshift/library-go/pkg/crypto" +) + +type TargetRotation struct { + Namespace string + Name string + Validity time.Duration + RefreshPercentage float32 + + ClientRotation *ClientRotation + ServingRotation *ServingRotation + + Informer corev1informers.SecretInformer + Lister corev1listers.SecretLister + Client corev1client.SecretsGetter + EventRecorder events.Recorder +} + +type ClientRotation struct { + UserInfo user.Info +} + +type ServingRotation struct { + Hostnames []string + CertificateExtensionFn []crypto.CertificateExtensionFunc +} + +func (c TargetRotation) ensureTargetCertKeyPair(signingCertKeyPair *crypto.CA) error { + // at this point our trust bundle has been updated. We don't know for sure that consumers have updated, but that's why we have a second + // validity percentage. We always check to see if we need to sign. Often we are signing with an old key or we have no target + // and need to mint one + // TODO do the cross signing thing, but this shows the API consumers want and a very simple impl. + originalTargetCertKeyPairSecret, err := c.Lister.Secrets(c.Namespace).Get(c.Name) + if err != nil && !apierrors.IsNotFound(err) { + return err + } + targetCertKeyPairSecret := originalTargetCertKeyPairSecret.DeepCopy() + if apierrors.IsNotFound(err) { + // create an empty one + targetCertKeyPairSecret = &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Namespace: c.Namespace, Name: c.Name}} + } + targetCertKeyPairSecret.Type = corev1.SecretTypeTLS + + if needNewTargetCertKeyPair(targetCertKeyPairSecret.Annotations, signingCertKeyPair, c.Validity, c.RefreshPercentage) { + c.EventRecorder.Eventf("TargetUpdateRequired", "%q in %q requires a new target cert/key pair", c.Name, c.Namespace) + if err := setTargetCertKeyPairSecret(targetCertKeyPairSecret, c.Validity, signingCertKeyPair, c.ClientRotation, c.ServingRotation); err != nil { + return err + } + + actualTargetCertKeyPairSecret, err := c.Client.Secrets(c.Namespace).Update(targetCertKeyPairSecret) + if apierrors.IsNotFound(err) { + actualTargetCertKeyPairSecret, err = c.Client.Secrets(c.Namespace).Create(targetCertKeyPairSecret) + if err != nil { + return err + } + } + if err != nil { + return err + } + targetCertKeyPairSecret = actualTargetCertKeyPairSecret + } + + return nil +} + +func needNewTargetCertKeyPair(annotations map[string]string, signer *crypto.CA, validity time.Duration, renewalPercentage float32) bool { + if needNewCertKeyPairForTime(annotations, validity, renewalPercentage) { + return true + } + signerCommonName := annotations[CertificateSignedBy] + if len(signerCommonName) == 0 { + return true + } + if signerCommonName != signer.Config.Certs[0].Subject.CommonName { + return true + } + + return false +} + +// setTargetCertKeyPairSecret creates a new cert/key pair and sets them in the secret +func setTargetCertKeyPairSecret(targetCertKeyPairSecret *corev1.Secret, validity time.Duration, signer *crypto.CA, clientRotation *ClientRotation, servingRotation *ServingRotation) error { + if (servingRotation != nil) == (clientRotation != nil) { + return fmt.Errorf("must be one of server or client cert") + } + if targetCertKeyPairSecret.Annotations == nil { + targetCertKeyPairSecret.Annotations = map[string]string{} + } + if targetCertKeyPairSecret.Data == nil { + targetCertKeyPairSecret.Data = map[string][]byte{} + } + + var certKeyPair *crypto.TLSCertificateConfig + var err error + if servingRotation != nil { + certKeyPair, err = signer.MakeServerCertForDuration(sets.NewString(servingRotation.Hostnames...), validity, servingRotation.CertificateExtensionFn...) + } else { + certKeyPair, err = signer.MakeClientCertificateForDuration(clientRotation.UserInfo, validity) + } + if err != nil { + return err + } + + targetCertKeyPairSecret.Data["tls.crt"], targetCertKeyPairSecret.Data["tls.key"], err = certKeyPair.GetPEMBytes() + if err != nil { + return err + } + targetCertKeyPairSecret.Annotations[CertificateExpiryAnnotation] = certKeyPair.Certs[0].NotAfter.Format(time.RFC3339) + targetCertKeyPairSecret.Annotations[CertificateSignedBy] = signer.Config.Certs[0].Subject.CommonName + + return nil +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target_test.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target_test.go new file mode 100644 index 000000000..808dfb2f7 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target_test.go @@ -0,0 +1,129 @@ +package certrotation + +import ( + "crypto/x509/pkix" + "strings" + "testing" + "time" + + "github.com/davecgh/go-spew/spew" + + "github.com/openshift/library-go/pkg/crypto" + "github.com/openshift/library-go/pkg/operator/events" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kubefake "k8s.io/client-go/kubernetes/fake" + corev1listers "k8s.io/client-go/listers/core/v1" + clienttesting "k8s.io/client-go/testing" + "k8s.io/client-go/tools/cache" +) + +func TestEnsureTargetCertKeyPair(t *testing.T) { + tests := []struct { + name string + + initialSecretFn func() *corev1.Secret + caFn func() (*crypto.CA, error) + + verifyActions func(t *testing.T, client *kubefake.Clientset) + expectedError string + }{ + { + name: "initial create", + caFn: func() (*crypto.CA, error) { + return newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + }, + initialSecretFn: func() *corev1.Secret { return nil }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + actions := client.Actions() + if len(actions) != 2 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "secrets") { + t.Error(actions[0]) + } + if !actions[1].Matches("create", "secrets") { + t.Error(actions[1]) + } + + actual := actions[1].(clienttesting.CreateAction).GetObject().(*corev1.Secret) + if len(actual.Data["tls.crt"]) == 0 || len(actual.Data["tls.key"]) == 0 { + t.Error(actual.Data) + } + }, + }, + { + name: "update write", + caFn: func() (*crypto.CA, error) { + return newTestCACertificate(pkix.Name{CommonName: "signer-tests"}, int64(1), metav1.Duration{Duration: time.Hour * 24 * 60}, time.Now) + }, + initialSecretFn: func() *corev1.Secret { + caBundleSecret := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "target-secret"}, + Data: map[string][]byte{}, + } + return caBundleSecret + }, + verifyActions: func(t *testing.T, client *kubefake.Clientset) { + actions := client.Actions() + if len(actions) != 1 { + t.Fatal(spew.Sdump(actions)) + } + + if !actions[0].Matches("update", "secrets") { + t.Error(actions[0]) + } + + actual := actions[0].(clienttesting.UpdateAction).GetObject().(*corev1.Secret) + if len(actual.Data["tls.crt"]) == 0 || len(actual.Data["tls.key"]) == 0 { + t.Error(actual.Data) + } + + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) + + client := kubefake.NewSimpleClientset() + if startingObj := test.initialSecretFn(); startingObj != nil { + indexer.Add(startingObj) + client = kubefake.NewSimpleClientset(startingObj) + } + + c := &TargetRotation{ + Namespace: "ns", + Validity: 24 * time.Hour, + RefreshPercentage: .50, + Name: "target-secret", + ServingRotation: &ServingRotation{ + Hostnames: []string{"foo"}, + }, + + Client: client.CoreV1(), + Lister: corev1listers.NewSecretLister(indexer), + EventRecorder: events.NewInMemoryRecorder("test"), + } + + newCA, err := test.caFn() + if err != nil { + t.Fatal(err) + } + err = c.ensureTargetCertKeyPair(newCA) + switch { + case err != nil && len(test.expectedError) == 0: + t.Error(err) + case err != nil && !strings.Contains(err.Error(), test.expectedError): + t.Error(err) + case err == nil && len(test.expectedError) != 0: + t.Errorf("missing %q", test.expectedError) + } + + test.verifyActions(t, client) + }) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls-expired.crt b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls-expired.crt new file mode 100644 index 000000000..b6140c7ab --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls-expired.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICMjCCAdmgAwIBAgIUdTpx2/qycBZJltbEdfTyfKyJjG0wCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTIwODAwWhcN +MTgwNzMwMTIwOTAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABMlJR5tWK7vgCytCxBQov1xNp+R9RG2wI1w9 +SXIn+Za97Nf6krdyUDd+P6QSSJDkRTQZDsGiCpJhgd5kAzFNUkajgZgwgZUwDgYD +VR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAwGA1UdEwEB/wQCMAAw +HQYDVR0OBBYEFOERFpshmIXspqXoox9gnSFGmm3PMB8GA1UdIwQYMBaAFCtdC7xd +NJKjmyiwhZJH7LBLOLrgMCAGA1UdEQQZMBeCFWV0Y2Rwcm94eS10ZXN0cy5sb2Nh +bDAKBggqhkjOPQQDAgNHADBEAiAvsq9L5uk0jg3v2z1xemAUwPXrEIAcbJhXFfC0 +QmVGGgIgFT9d/inKJcm/NfAgDGkoXSvHGv0NKAZpR32Dqriobh4= +-----END CERTIFICATE----- diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls-multiple.crt b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls-multiple.crt new file mode 100644 index 000000000..b321982a7 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls-multiple.crt @@ -0,0 +1,39 @@ +-----BEGIN CERTIFICATE----- +MIICADCCAaagAwIBAgIUQ0hq1Lmd6ujao+8Iy6LfpMdyNI8wCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTExMDAwWhcN +MjMwNzI5MTExMDAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABGoowUY2eQdvaHG4S/UMYD6mjs6/P7mmhizl +KWO03gq2eVSsbiYAnCJok3o2WQ01GtcS6bOUJ1DOG0gLTRfQ/lWjZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBQmqCeN+suT +0JjgSxtCqTln7zonHjAfBgNVHSMEGDAWgBQmqCeN+suT0JjgSxtCqTln7zonHjAK +BggqhkjOPQQDAgNIADBFAiAUKV8vkiIoCiqtHQsp3PrUUV3He2B9K1tQgA8loTa+ +IQIhANPbCDVoPSFsX0I5iG/DQl/MmTo/tlsmNkN99j1j2JIM +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICADCCAaagAwIBAgIUU8ZsD37pcA1UYkgwhR6d/KjdGeAwCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTExMTAwWhcN +MjMwNzI5MTExMTAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABLupsOF50q6GE7z2US77t5iLGe9wdOFwHssC +jUjCEGvJ/d2sGMxdiABJrrB8gau6TilrJCy9ZTYj56fzdReUnsKjZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBRhaKyklrnI +wd2kg84t1D8CvDVtdjAfBgNVHSMEGDAWgBRhaKyklrnIwd2kg84t1D8CvDVtdjAK +BggqhkjOPQQDAgNIADBFAiAOCYqtOamRapNc+XxR7IFzlr7Si7EvjQ+ej5SKHb7g +rgIhAIBd1dtMc0KJSFsoxnQZailkFi5Nlea2eHU1wEDKVb40 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIB/zCCAaagAwIBAgIUVCSMefpK8uxDKy87jKnwc97DseIwCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTExMTAwWhcN +MjMwNzI5MTExMTAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABOhGVuxW0nEQ5REqQdRF1eJ7OUOdXB/oDJed +Jr1ezcyhJyCRvD9DfadSBvMHFyzw7ssBIIMm4C3Eufj96M3tSACjZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBTLR9qOF3Hh +if8KUbkrRYUK13xSSDAfBgNVHSMEGDAWgBTLR9qOF3Hhif8KUbkrRYUK13xSSDAK +BggqhkjOPQQDAgNHADBEAiAFD2zRXnp40wVeffwpkU+ToFF6Nts/HJk02iMr/+km +RgIgRLZxonlkyLlUHucMKC2V+4UJ9akEbu/bhCXKuQb2DgY= +-----END CERTIFICATE----- diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls.crt b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls.crt new file mode 100644 index 000000000..862bdbc2d --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls.crt @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIICADCCAaagAwIBAgIUWke4fSfaCH+2MLSFeTHBpoi+h1YwCgYIKoZIzj0EAwIw +TDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lzY28xCzAJBgNVBAcT +AkNBMRgwFgYDVQQDEw9ldGNkcHJveHktdGVzdHMwHhcNMTgwNzMwMTA1MDAwWhcN +MjMwNzI5MTA1MDAwWjBMMQswCQYDVQQGEwJVUzEWMBQGA1UECBMNU2FuIEZyYW5j +aXNjbzELMAkGA1UEBxMCQ0ExGDAWBgNVBAMTD2V0Y2Rwcm94eS10ZXN0czBZMBMG +ByqGSM49AgEGCCqGSM49AwEHA0IABHoqBfTXFdWRATfdrr/v5UriZBxmzL5aiwLZ +VRUg2UZNnoH2JLUcDkqx3IQakjoVijweiQeqxAai3mxjtgxbh+ajZjBkMA4GA1Ud +DwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1UdDgQWBBSgDE3RpOiH +Gv7AEnYKRk46zVIkbzAfBgNVHSMEGDAWgBSgDE3RpOiHGv7AEnYKRk46zVIkbzAK +BggqhkjOPQQDAgNIADBFAiA3Gg/gwiEfjclpQYyd3qTgdCWzud8GKRdjVK3Z2BXW +swIhANMuxi0Y41mwcmh3a2icpdeGHGyGNdNDe8uF+5csuNUp +-----END CERTIFICATE----- diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls.key b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls.key new file mode 100644 index 000000000..83cf18be6 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/testfiles/tls.key @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIC+UyR59JEbt/qjWZG/87ZYzk0pOgTBmpx5R0w6uG66JoAoGCCqGSM49 +AwEHoUQDQgAEeioF9NcV1ZEBN92uv+/lSuJkHGbMvlqLAtlVFSDZRk2egfYktRwO +SrHchBqSOhWKPB6JB6rEBqLebGO2DFuH5g== +-----END EC PRIVATE KEY----- diff --git a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller.go index 09e6ca0f7..4f3a68c96 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "strings" "time" "github.com/golang/glog" @@ -23,19 +22,13 @@ import ( operatorv1 "github.com/openshift/api/operator/v1" "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" "github.com/openshift/library-go/pkg/operator/v1helpers" ) const operatorStatusTypeConfigObservationFailing = "ConfigObservationFailing" -const configObservationErrorConditionReason = "ConfigObservationError" const configObserverWorkKey = "key" -type OperatorClient interface { - GetOperatorState() (spec *operatorv1.OperatorSpec, status *operatorv1.OperatorStatus, resourceVersion string, err error) - UpdateOperatorSpec(string, *operatorv1.OperatorSpec) (spec *operatorv1.OperatorSpec, resourceVersion string, err error) - UpdateOperatorStatus(string, *operatorv1.OperatorStatus) (status *operatorv1.OperatorStatus, resourceVersion string, err error) -} - // Listers is an interface which will be passed to the config observer funcs. It is expected to be hard-cast to the "correct" type type Listers interface { PreRunHasSynced() []cache.InformerSynced @@ -45,11 +38,11 @@ type Listers interface { // observedConfig that would cause the service being managed by the operator to crash. For example, if a required // configuration key cannot be observed, consider reusing the configuration key's previous value. Errors that occur // while attempting to generate the observedConfig should be returned in the errs slice. -type ObserveConfigFunc func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) +type ObserveConfigFunc func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) type ConfigObserver struct { - operatorClient OperatorClient - eventRecorder events.Recorder + operatorConfigClient v1helpers.OperatorClient + eventRecorder events.Recorder // queue only ever has one item, but it has nice error handling backoff/retry semantics queue workqueue.RateLimitingInterface @@ -64,14 +57,14 @@ type ConfigObserver struct { } func NewConfigObserver( - operatorClient OperatorClient, + operatorClient v1helpers.OperatorClient, eventRecorder events.Recorder, listers Listers, observers ...ObserveConfigFunc, ) *ConfigObserver { return &ConfigObserver{ - operatorClient: operatorClient, - eventRecorder: eventRecorder, + operatorConfigClient: operatorClient, + eventRecorder: eventRecorder, queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "ConfigObserver"), @@ -84,11 +77,12 @@ func NewConfigObserver( // sync reacts to a change in prereqs by finding information that is required to match another value in the cluster. This // must be information that is logically "owned" by another component. func (c ConfigObserver) sync() error { - originalSpec, originalStatus, resourceVersion, err := c.operatorClient.GetOperatorState() + originalSpec, _, resourceVersion, err := c.operatorConfigClient.GetOperatorState() if err != nil { return err } spec := originalSpec.DeepCopy() + // don't worry about errors. If we can't decode, we'll simply stomp over the field. existingConfig := map[string]interface{}{} if err := json.NewDecoder(bytes.NewBuffer(spec.ObservedConfig.Raw)).Decode(&existingConfig); err != nil { @@ -99,7 +93,7 @@ func (c ConfigObserver) sync() error { var observedConfigs []map[string]interface{} for _, i := range rand.Perm(len(c.observers)) { var currErrs []error - observedConfig, currErrs := c.observers[i](c.listers, existingConfig) + observedConfig, currErrs := c.observers[i](c.listers, c.eventRecorder, existingConfig) observedConfigs = append(observedConfigs, observedConfig) errs = append(errs, currErrs...) } @@ -114,7 +108,7 @@ func (c ConfigObserver) sync() error { if !equality.Semantic.DeepEqual(existingConfig, mergedObservedConfig) { glog.Infof("writing updated observedConfig: %v", diff.ObjectDiff(existingConfig, mergedObservedConfig)) spec.ObservedConfig = runtime.RawExtension{Object: &unstructured.Unstructured{Object: mergedObservedConfig}} - _, resourceVersion, err = c.operatorClient.UpdateOperatorSpec(resourceVersion, spec) + _, resourceVersion, err = c.operatorConfigClient.UpdateOperatorSpec(resourceVersion, spec) if err != nil { errs = append(errs, fmt.Errorf("error writing updated observed config: %v", err)) c.eventRecorder.Warningf("ObservedConfigWriteError", "Failed to write observed config: %v", err) @@ -122,34 +116,23 @@ func (c ConfigObserver) sync() error { c.eventRecorder.Eventf("ObservedConfigChanged", "Writing updated observed config") } } + err = common.NewMultiLineAggregate(errs) - status := originalStatus.DeepCopy() - if len(errs) > 0 { - var messages []string - for _, currentError := range errs { - messages = append(messages, currentError.Error()) - } - v1helpers.SetOperatorCondition(&status.Conditions, operatorv1.OperatorCondition{ - Type: operatorStatusTypeConfigObservationFailing, - Status: operatorv1.ConditionTrue, - Reason: configObservationErrorConditionReason, - Message: strings.Join(messages, "\n"), - }) - - } else { - v1helpers.SetOperatorCondition(&status.Conditions, operatorv1.OperatorCondition{ - Type: operatorStatusTypeConfigObservationFailing, - Status: operatorv1.ConditionFalse, - }) + // update failing condition + cond := operatorv1.OperatorCondition{ + Type: operatorStatusTypeConfigObservationFailing, + Status: operatorv1.ConditionFalse, } - - if !equality.Semantic.DeepEqual(originalStatus, status) { - _, _, err = c.operatorClient.UpdateOperatorStatus(resourceVersion, status) - if err != nil { - return err - } + if err != nil { + cond.Status = operatorv1.ConditionTrue + cond.Reason = "Error" + cond.Message = err.Error() + } + if _, updateError := v1helpers.UpdateStatus(c.operatorConfigClient, v1helpers.UpdateConditionFn(cond)); updateError != nil { + return updateError } + // explicitly ignore errs, we are requeued by input changes anyway return nil } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller_test.go b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller_test.go index aa08db9ef..901520624 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller_test.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/config_observer_controller_test.go @@ -7,6 +7,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/ghodss/yaml" + "github.com/imdario/mergo" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -73,13 +74,13 @@ func TestSyncStatus(t *testing.T) { {"ObservedConfigChanged", "Writing updated observed config"}, }, observers: []ObserveConfigFunc{ - func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { + func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { return map[string]interface{}{"foo": "one"}, nil }, - func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { + func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { return map[string]interface{}{"bar": "two"}, nil }, - func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { + func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { return map[string]interface{}{"baz": "three"}, nil }, }, @@ -106,13 +107,13 @@ func TestSyncStatus(t *testing.T) { {"ObservedConfigChanged", "Writing updated observed config"}, }, observers: []ObserveConfigFunc{ - func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { + func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { return map[string]interface{}{"foo": "one"}, nil }, - func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { + func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { return map[string]interface{}{"bar": "two"}, nil }, - func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { + func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { errs = append(errs, fmt.Errorf("some failure")) return observedConfig, errs }, @@ -126,7 +127,7 @@ func TestSyncStatus(t *testing.T) { expectedCondition: &operatorv1.OperatorCondition{ Type: operatorStatusTypeConfigObservationFailing, Status: operatorv1.ConditionTrue, - Reason: configObservationErrorConditionReason, + Reason: "Error", Message: "some failure", }, }, @@ -142,7 +143,7 @@ func TestSyncStatus(t *testing.T) { {"ObservedConfigWriteError", "Failed to write observed config: update spec failure"}, }, observers: []ObserveConfigFunc{ - func(listers Listers, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { + func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error) { return map[string]interface{}{"foo": "one"}, nil }, }, @@ -152,7 +153,7 @@ func TestSyncStatus(t *testing.T) { expectedCondition: &operatorv1.OperatorCondition{ Type: operatorStatusTypeConfigObservationFailing, Status: operatorv1.ConditionTrue, - Reason: configObservationErrorConditionReason, + Reason: "Error", Message: "error writing updated observed config: update spec failure", }, }, @@ -164,10 +165,10 @@ func TestSyncStatus(t *testing.T) { eventClient := fake.NewSimpleClientset() configObserver := ConfigObserver{ - listers: &fakeLister{}, - operatorClient: operatorConfigClient, - observers: tc.observers, - eventRecorder: events.NewRecorder(eventClient.CoreV1().Events("test"), "test-operator", &corev1.ObjectReference{}), + listers: &fakeLister{}, + operatorConfigClient: operatorConfigClient, + observers: tc.observers, + eventRecorder: events.NewRecorder(eventClient.CoreV1().Events("test"), "test-operator", &corev1.ObjectReference{}), } err := configObserver.sync() if tc.expectError && err == nil { @@ -229,6 +230,16 @@ func TestSyncStatus(t *testing.T) { } } +func TestMergoVersion(t *testing.T) { + type test struct{ A string } + src := test{"src"} + dest := test{"dest"} + mergo.Merge(&dest, &src) + if dest.A != "src" { + t.Errorf("incompatible version of github.com/imdario/mergo found") + } +} + func toYAML(o interface{}) string { b, e := yaml.Marshal(o) if e != nil { diff --git a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/OWNERS b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/OWNERS new file mode 100644 index 000000000..ce2862b87 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/OWNERS @@ -0,0 +1,10 @@ +reviewers: + - squeed + - dcbw + - danwinship + - knobunc +approvers: + - squeed + - dcbw + - danwinship + - knobunc \ No newline at end of file diff --git a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/observe_network.go b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/observe_network.go new file mode 100644 index 000000000..af15f8d7e --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/observe_network.go @@ -0,0 +1,112 @@ +package network + +import ( + "fmt" + + "github.com/ghodss/yaml" + "github.com/golang/glog" + + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/client-go/listers/core/v1" + + "github.com/openshift/library-go/pkg/operator/events" +) + +const ( + clusterConfigNamespace = "kube-system" + clusterConfigName = "cluster-config-v1" +) + +// GetClusterCIDRs reads the cluster CIDRs from the install-config ConfigMap in the cluster. +func GetClusterCIDRs(lister v1.ConfigMapLister, recorder events.Recorder) ([]string, error) { + clusterConfig, err := lister.ConfigMaps(clusterConfigNamespace).Get(clusterConfigName) + if errors.IsNotFound(err) { + recorder.Warningf("ObserveClusterCIDRFailed", "Required %s/%s config map not found", clusterConfigNamespace, clusterConfigName) + glog.Warning("configmap/cluster-config-v1.kube-system: not found") + return nil, nil + } + if err != nil { + return nil, err + } + + installConfigYaml, ok := clusterConfig.Data["install-config"] + if !ok { + glog.Warning("configmap/cluster-config-v1.kube-system: install-config not found") + recorder.Warningf("ObserveClusterCIDRFailed", "ConfigMap %s/%s does not have required 'install-config'", clusterConfigNamespace, clusterConfigName) + return nil, nil + } + installConfig := map[string]interface{}{} + err = yaml.Unmarshal([]byte(installConfigYaml), &installConfig) + if err != nil { + recorder.Warningf("ObserveRestrictedCIDRFailed", "Unable to decode install config: %v'", err) + return nil, fmt.Errorf("unable to parse install-config: %s", err) + } + + var clusterCIDRs []string + clusterNetworks, _, err := unstructured.NestedSlice(installConfig, "networking", "clusterNetworks") + if err != nil { + return nil, fmt.Errorf("unabled to parse install-config: %s", err) + } + for i, n := range clusterNetworks { + obj, ok := n.(map[string]interface{}) + if !ok { + recorder.Warningf("ObserveRestrictedCIDRFailed", "Required networking.clusterNetworks field is not set in install-config") + return nil, fmt.Errorf("unabled to parse install-config: expected networking.clusterNetworks[%d] to be an object, got: %#v", i, n) + } + cidr, _, err := unstructured.NestedString(obj, "cidr") + if err != nil { + return nil, fmt.Errorf("unabled to parse install-config: %v", err) + } + clusterCIDRs = append(clusterCIDRs, cidr) + } + // fallback to podCIDR + if clusterNetworks == nil { + podCIDR, _, err := unstructured.NestedString(installConfig, "networking", "podCIDR") + if err != nil { + return nil, fmt.Errorf("unable to parse install-config: %v", err) + } + if len(podCIDR) == 0 { + return nil, fmt.Errorf("configmap/cluster-config-v1.kube-system: install-config.networking.clusterNetworks and install-config.networking.podCIDR not found") + } + clusterCIDRs = append(clusterCIDRs, podCIDR) + } + + return clusterCIDRs, nil +} + +// GetServiceCIDR reads the service IP range from the install-config ConfigMap in the cluster. +func GetServiceCIDR(lister v1.ConfigMapLister, recorder events.Recorder) (string, error) { + clusterConfig, err := lister.ConfigMaps(clusterConfigNamespace).Get(clusterConfigName) + if errors.IsNotFound(err) { + glog.Warning("configmap/cluster-config-v1.kube-system: not found") + recorder.Warningf("ObserveServiceClusterIPRangesFailed", "Required %s/%s config map not found", clusterConfigNamespace, clusterConfigName) + return "", nil + } + if err != nil { + return "", err + } + + installConfigYaml, ok := clusterConfig.Data["install-config"] + if !ok { + glog.Warning("configmap/cluster-config-v1.kube-system: install-config not found") + recorder.Warningf("ObserveServiceClusterIPRangesFailed", "ConfigMap %s/%s does not have required 'install-config'", clusterConfigNamespace, clusterConfigName) + return "", nil + } + installConfig := map[string]interface{}{} + err = yaml.Unmarshal([]byte(installConfigYaml), &installConfig) + if err != nil { + return "", fmt.Errorf("unable to parse install-config: %v", err) + } + + serviceCIDR, _, err := unstructured.NestedString(installConfig, "networking", "serviceCIDR") + if err != nil { + return "", fmt.Errorf("unable to parse install-config: %v", err) + } + if len(serviceCIDR) == 0 { + recorder.Warningf("ObserveServiceClusterIPRangesFailed", "Required networking.serviceCIDR field is not set in install-config") + return "", fmt.Errorf("configmap/cluster-config-v1.kube-system: install-config.networking.serviceCIDR not found") + } + + return serviceCIDR, nil +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/observe_networking_test.go b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/observe_networking_test.go new file mode 100644 index 000000000..23bea7cd8 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/network/observe_networking_test.go @@ -0,0 +1,160 @@ +package network + +import ( + "reflect" + "testing" + + "github.com/ghodss/yaml" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corelistersv1 "k8s.io/client-go/listers/core/v1" + "k8s.io/client-go/tools/cache" + + "github.com/openshift/library-go/pkg/operator/events" +) + +func TestObserveClusterCIDRs(t *testing.T) { + type Test struct { + name string + config *corev1.ConfigMap + expected []string + expectedError bool + } + tests := []Test{ + { + "podCIDR, empty old config", + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-config-v1", + Namespace: "kube-system", + }, + Data: map[string]string{ + "install-config": "networking:\n podCIDR: podCIDR", + }, + }, + []string{"podCIDR"}, + false, + }, + { + "podCIDR, existing config", + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-config-v1", + Namespace: "kube-system", + }, + Data: map[string]string{ + "install-config": "networking:\n podCIDR: podCIDR", + }, + }, + []string{"podCIDR"}, + false, + }, + { + "clusterNetworks", + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-config-v1", + Namespace: "kube-system", + }, + Data: map[string]string{ + "install-config": "networking:\n clusterNetworks:\n - cidr: podCIDR1\n - cidr: podCIDR2", + }, + }, + []string{"podCIDR1", "podCIDR2"}, + false, + }, + { + "both podCIDR and clusterNetworks", + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-config-v1", + Namespace: "kube-system", + }, + Data: map[string]string{ + "install-config": "networking:\n clusterNetworks:\n - cidr: podCIDR1\n - cidr: podCIDR2\n podCIDR: podCIDR", + }, + }, + []string{"podCIDR1", "podCIDR2"}, + false, + }, + { + "none, no old config", + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-config-v1", + Namespace: "kube-system", + }, + Data: map[string]string{ + "install-config": "networking: {}\n", + }, + }, + nil, + true, + }, + { + "none, existing config", + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-config-v1", + Namespace: "kube-system", + }, + Data: map[string]string{ + "install-config": "networking: {}\n", + }, + }, + nil, + true, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{}) + if err := indexer.Add(test.config); err != nil { + t.Fatal(err.Error()) + } + result, err := GetClusterCIDRs(corelistersv1.NewConfigMapLister(indexer), events.NewInMemoryRecorder("network")) + if err != nil && !test.expectedError { + t.Fatal(err) + } else if err == nil { + if test.expectedError { + t.Fatalf("expected error, but got none") + } + if !reflect.DeepEqual(test.expected, result) { + t.Errorf("\n===== observed config expected:\n%v\n===== observed config actual:\n%v", toYAML(test.expected), toYAML(result)) + } + } + }) + } +} + +func TestObserveServiceClusterIPRanges(t *testing.T) { + indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{}) + if err := indexer.Add(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-config-v1", + Namespace: "kube-system", + }, + Data: map[string]string{ + "install-config": "networking:\n serviceCIDR: serviceCIDR", + }, + }); err != nil { + t.Fatal(err.Error()) + } + result, err := GetServiceCIDR(corelistersv1.NewConfigMapLister(indexer), events.NewInMemoryRecorder("network")) + if err != nil { + t.Fatal(err) + } + + if expected := "serviceCIDR"; !reflect.DeepEqual(expected, result) { + t.Errorf("\n===== observed config expected:\n%v\n===== observed config actual:\n%v", toYAML(expected), toYAML(result)) + } +} + +func toYAML(o interface{}) string { + b, e := yaml.Marshal(o) + if e != nil { + return e.Error() + } + return string(b) +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/events/eventstesting/recorder_testing.go b/vendor/github.com/openshift/library-go/pkg/operator/events/eventstesting/recorder_testing.go new file mode 100644 index 000000000..0d08ff177 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/events/eventstesting/recorder_testing.go @@ -0,0 +1,33 @@ +package eventstesting + +import ( + "fmt" + "testing" + + "github.com/openshift/library-go/pkg/operator/events" +) + +type TestingEventRecorder struct { + t *testing.T +} + +// NewTestingEventRecorder provides event recorder that will log all recorded events to the error log. +func NewTestingEventRecorder(t *testing.T) events.Recorder { + return &TestingEventRecorder{t: t} +} + +func (r *TestingEventRecorder) Event(reason, message string) { + r.t.Logf("Event: %v: %v", reason, message) +} + +func (r *TestingEventRecorder) Eventf(reason, messageFmt string, args ...interface{}) { + r.Event(reason, fmt.Sprintf(messageFmt, args...)) +} + +func (r *TestingEventRecorder) Warning(reason, message string) { + r.t.Logf("Warning: %v: %v", reason, message) +} + +func (r *TestingEventRecorder) Warningf(reason, messageFmt string, args ...interface{}) { + r.Warning(reason, fmt.Sprintf(messageFmt, args...)) +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go index 025aff920..f627816d7 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go @@ -6,6 +6,7 @@ import ( "time" "github.com/golang/glog" + "k8s.io/client-go/kubernetes" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -31,23 +32,56 @@ var podNameEnvFunc = func() string { // GetControllerReferenceForCurrentPod provides an object reference to a controller managing the pod/container where this process runs. // The pod name must be provided via the POD_NAME name. -func GetControllerReferenceForCurrentPod(client corev1client.PodInterface) (*corev1.ObjectReference, error) { - podName := podNameEnvFunc() - if len(podName) == 0 { - return guessControllerReferenceForNamespace(client) +func GetControllerReferenceForCurrentPod(client kubernetes.Interface, targetNamespace string, reference *corev1.ObjectReference) (*corev1.ObjectReference, error) { + if reference == nil { + // Try to get the pod name via POD_NAME environment variable + reference := &corev1.ObjectReference{Kind: "Pod", Name: podNameEnvFunc(), Namespace: targetNamespace} + if len(reference.Name) != 0 { + return GetControllerReferenceForCurrentPod(client, targetNamespace, reference) + } + // If that fails, lets try to guess the pod by listing all pods in namespaces and using the first pod in the list + reference, err := guessControllerReferenceForNamespace(client.CoreV1().Pods(targetNamespace)) + if err != nil { + return nil, err + } + return GetControllerReferenceForCurrentPod(client, targetNamespace, reference) } - pod, err := client.Get(podName, metav1.GetOptions{}) - if err != nil { - return nil, err + + switch reference.Kind { + case "Pod": + pod, err := client.CoreV1().Pods(reference.Namespace).Get(reference.Name, metav1.GetOptions{}) + if err != nil { + return nil, err + } + if podController := metav1.GetControllerOf(pod); podController != nil { + return GetControllerReferenceForCurrentPod(client, targetNamespace, makeObjectReference(podController, targetNamespace)) + } + // This is a bare pod without any ownerReference + return makeObjectReference(&metav1.OwnerReference{Kind: "Pod", Name: pod.Name, UID: pod.UID, APIVersion: "v1"}, pod.Namespace), nil + case "ReplicaSet": + rs, err := client.AppsV1().ReplicaSets(reference.Namespace).Get(reference.Name, metav1.GetOptions{}) + if err != nil { + return nil, err + } + if rsController := metav1.GetControllerOf(rs); rsController != nil { + return GetControllerReferenceForCurrentPod(client, targetNamespace, makeObjectReference(rsController, targetNamespace)) + } + // This is a replicaSet without any ownerReference + return reference, nil + default: + return reference, nil } - ownerRef := metav1.GetControllerOf(pod) +} + +// makeObjectReference makes object reference from ownerReference and target namespace +func makeObjectReference(owner *metav1.OwnerReference, targetNamespace string) *corev1.ObjectReference { return &corev1.ObjectReference{ - Kind: ownerRef.Kind, - Namespace: pod.Namespace, - Name: ownerRef.Name, - UID: ownerRef.UID, - APIVersion: ownerRef.APIVersion, - }, nil + Kind: owner.Kind, + Namespace: targetNamespace, + Name: owner.Name, + UID: owner.UID, + APIVersion: owner.APIVersion, + } } // guessControllerReferenceForNamespace tries to guess what resource to reference. diff --git a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_test.go b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_test.go index 51fe1982e..b3fe15ffd 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_test.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_test.go @@ -3,6 +3,7 @@ package events import ( "testing" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/fake" @@ -13,10 +14,11 @@ func fakeControllerRef(t *testing.T) *corev1.ObjectReference { podNameEnvFunc = func() string { return "test" } - client := fake.NewSimpleClientset(fakePod("test-namespace", "test")) - ref, err := GetControllerReferenceForCurrentPod(client.CoreV1().Pods("test-namespace")) + client := fake.NewSimpleClientset(fakePod("test-namespace", "test"), fakeReplicaSet("test-namespace", "test")) + + ref, err := GetControllerReferenceForCurrentPod(client, "test-namespace", nil) if err != nil { - t.Fatalf("unable to get replicaset object reference: %v", err) + t.Fatalf("unable to get object reference: %v", err) } return ref } @@ -28,9 +30,9 @@ func fakePod(namespace, name string) *corev1.Pod { truePtr := true pod.SetOwnerReferences([]metav1.OwnerReference{ { - APIVersion: "apps/corev1", + APIVersion: "apps/v1", Kind: "ReplicaSet", - Name: "test-766b85794f", + Name: "test", UID: "05022234-d394-11e8-8169-42010a8e0003", Controller: &truePtr, BlockOwnerDeletion: &truePtr, @@ -39,6 +41,24 @@ func fakePod(namespace, name string) *corev1.Pod { return pod } +func fakeReplicaSet(namespace, name string) *appsv1.ReplicaSet { + rs := &appsv1.ReplicaSet{} + rs.Name = name + rs.Namespace = namespace + truePtr := true + rs.SetOwnerReferences([]metav1.OwnerReference{ + { + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "test", + UID: "15022234-d394-11e8-8169-42010a8e0003", + Controller: &truePtr, + BlockOwnerDeletion: &truePtr, + }, + }) + return rs +} + func TestRecorder(t *testing.T) { client := fake.NewSimpleClientset() r := NewRecorder(client.CoreV1().Events("test-namespace"), "test-operator", fakeControllerRef(t)) @@ -57,8 +77,8 @@ func TestRecorder(t *testing.T) { if createdEvent == nil { t.Fatalf("expected event to be created") } - if createdEvent.InvolvedObject.Kind != "ReplicaSet" { - t.Errorf("expected involved object kind ReplicaSet, got: %q", createdEvent.InvolvedObject.Kind) + if createdEvent.InvolvedObject.Kind != "Deployment" { + t.Errorf("expected involved object kind Deployment, got: %q", createdEvent.InvolvedObject.Kind) } if createdEvent.InvolvedObject.Namespace != "test-namespace" { t.Errorf("expected involved object namespace test-namespace, got: %q", createdEvent.InvolvedObject.Namespace) @@ -77,23 +97,69 @@ func TestRecorder(t *testing.T) { } } -func TestGetControllerReferenceForCurrentPod(t *testing.T) { - client := fake.NewSimpleClientset(fakePod("test", "foo")) +func TestGetControllerReferenceForCurrentPodIsPod(t *testing.T) { + pod := fakePod("test", "test") + pod.OwnerReferences = []metav1.OwnerReference{} + client := fake.NewSimpleClientset(pod) + + podNameEnvFunc = func() string { + return "test" + } + + objectReference, err := GetControllerReferenceForCurrentPod(client, "test", nil) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if objectReference.Name != "test" { + t.Errorf("expected objectReference name to be 'test', got %q", objectReference.Name) + } + + if objectReference.GroupVersionKind().String() != "/v1, Kind=Pod" { + t.Errorf("expected objectReference to be Pod, got %q", objectReference.GroupVersionKind().String()) + } +} + +func TestGetControllerReferenceForCurrentPodIsReplicaSet(t *testing.T) { + rs := fakeReplicaSet("test", "test") + rs.OwnerReferences = []metav1.OwnerReference{} + client := fake.NewSimpleClientset(fakePod("test", "test"), rs) podNameEnvFunc = func() string { - return "foo" + return "test" } - objectReference, err := GetControllerReferenceForCurrentPod(client.CoreV1().Pods("test")) + objectReference, err := GetControllerReferenceForCurrentPod(client, "test", nil) if err != nil { t.Fatalf("unexpected error: %v", err) } - if objectReference.Name != "test-766b85794f" { - t.Errorf("expected objectReference name to be 'test-766b85794f', got %q", objectReference.Name) + if objectReference.Name != "test" { + t.Errorf("expected objectReference name to be 'test', got %q", objectReference.Name) } - if objectReference.GroupVersionKind().String() != "apps/corev1, Kind=ReplicaSet" { + if objectReference.GroupVersionKind().String() != "apps/v1, Kind=ReplicaSet" { t.Errorf("expected objectReference to be ReplicaSet, got %q", objectReference.GroupVersionKind().String()) } } + +func TestGetControllerReferenceForCurrentPod(t *testing.T) { + client := fake.NewSimpleClientset(fakePod("test", "test"), fakeReplicaSet("test", "test")) + + podNameEnvFunc = func() string { + return "test" + } + + objectReference, err := GetControllerReferenceForCurrentPod(client, "test", nil) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if objectReference.Name != "test" { + t.Errorf("expected objectReference name to be 'test', got %q", objectReference.Name) + } + + if objectReference.GroupVersionKind().String() != "apps/v1, Kind=Deployment" { + t.Errorf("expected objectReference to be Deployment, got %q", objectReference.GroupVersionKind().String()) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/apiextensions.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/apiextensions.go new file mode 100644 index 000000000..99fff2483 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/apiextensions.go @@ -0,0 +1,34 @@ +package resourceapply + +import ( + apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apiextclientv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/resource/resourcemerge" +) + +// ApplyCustomResourceDefinition applies the required CustomResourceDefinition to the cluster. +func ApplyCustomResourceDefinition(client apiextclientv1beta1.CustomResourceDefinitionsGetter, recorder events.Recorder, required *apiextv1beta1.CustomResourceDefinition) (*apiextv1beta1.CustomResourceDefinition, bool, error) { + existing, err := client.CustomResourceDefinitions().Get(required.Name, metav1.GetOptions{}) + if apierrors.IsNotFound(err) { + actual, err := client.CustomResourceDefinitions().Create(required) + reportCreateEvent(recorder, required, err) + return actual, true, err + } + if err != nil { + return nil, false, err + } + + modified := resourcemerge.BoolPtr(false) + resourcemerge.EnsureCustomResourceDefinition(modified, existing, *required) + if !*modified { + return existing, false, nil + } + + actual, err := client.CustomResourceDefinitions().Update(existing) + reportUpdateEvent(recorder, required, err) + return actual, true, err +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go index c15533bb2..d9dd22f76 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go @@ -71,6 +71,29 @@ func ApplyService(client coreclientv1.ServicesGetter, recorder events.Recorder, return actual, true, err } +// ApplyPod merges objectmeta, does not worry about anything else +func ApplyPod(client coreclientv1.PodsGetter, recorder events.Recorder, required *corev1.Pod) (*corev1.Pod, bool, error) { + existing, err := client.Pods(required.Namespace).Get(required.Name, metav1.GetOptions{}) + if apierrors.IsNotFound(err) { + actual, err := client.Pods(required.Namespace).Create(required) + reportCreateEvent(recorder, required, err) + return actual, true, err + } + if err != nil { + return nil, false, err + } + + modified := resourcemerge.BoolPtr(false) + resourcemerge.EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) + if !*modified { + return existing, false, nil + } + + actual, err := client.Pods(required.Namespace).Update(existing) + reportUpdateEvent(recorder, required, err) + return actual, true, err +} + // ApplyServiceAccount merges objectmeta, does not worry about anything else func ApplyServiceAccount(client coreclientv1.ServiceAccountsGetter, recorder events.Recorder, required *corev1.ServiceAccount) (*corev1.ServiceAccount, bool, error) { existing, err := client.ServiceAccounts(required.Namespace).Get(required.Name, metav1.GetOptions{}) diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/event_helpers.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/event_helpers.go index afe490953..3fa975176 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/event_helpers.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/event_helpers.go @@ -7,42 +7,75 @@ import ( "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" + kubescheme "k8s.io/client-go/kubernetes/scheme" + openshiftapi "github.com/openshift/api" "github.com/openshift/library-go/pkg/operator/events" ) +var ( + openshiftScheme = runtime.NewScheme() +) + +func init() { + if err := openshiftapi.Install(openshiftScheme); err != nil { + panic(err) + } +} + +// guessObjectKind returns a human name for the passed runtime object. +func guessObjectGroupKind(object runtime.Object) (string, string) { + if gvk := object.GetObjectKind().GroupVersionKind(); len(gvk.Kind) > 0 { + return gvk.Group, gvk.Kind + } + if kinds, _, _ := kubescheme.Scheme.ObjectKinds(object); len(kinds) > 0 { + return kinds[0].Group, kinds[0].Kind + } + if kinds, _, _ := openshiftScheme.ObjectKinds(object); len(kinds) > 0 { + return kinds[0].Group, kinds[0].Kind + } + return "unknown", "Object" + +} + func reportCreateEvent(recorder events.Recorder, obj runtime.Object, originalErr error) { - gvk := obj.GetObjectKind().GroupVersionKind() + reportingGroup, reportingKind := guessObjectGroupKind(obj) + if len(reportingGroup) != 0 { + reportingGroup += "." + } accessor, err := meta.Accessor(obj) if err != nil { glog.Errorf("Failed to get accessor for %+v", obj) return } - objName := fmt.Sprintf("%s/%s", accessor.GetNamespace(), accessor.GetName()) - if len(accessor.GetNamespace()) == 0 { - objName = accessor.GetName() + namespace := "" + if len(accessor.GetNamespace()) > 0 { + namespace = " -n " + accessor.GetNamespace() } if originalErr == nil { - recorder.Eventf(fmt.Sprintf("%sCreated", gvk.Kind), "Created %s %q because it was missing", gvk.Kind, objName) + recorder.Eventf(fmt.Sprintf("%sCreated", reportingKind), "Created %s%s/%s%s because it was missing", reportingKind, reportingGroup, accessor.GetName(), namespace) return } - recorder.Warningf(fmt.Sprintf("%sCreateFailed", gvk.Kind), "Failed to create %s %q: %v", gvk.Kind, objName, originalErr) + recorder.Warningf(fmt.Sprintf("%sCreateFailed", reportingKind), "Failed to create %s%s/%s%s: %v", reportingKind, reportingGroup, accessor.GetName(), namespace, originalErr) } func reportUpdateEvent(recorder events.Recorder, obj runtime.Object, originalErr error) { - gvk := obj.GetObjectKind().GroupVersionKind() + reportingGroup, reportingKind := guessObjectGroupKind(obj) + if len(reportingGroup) != 0 { + reportingGroup += "." + } accessor, err := meta.Accessor(obj) if err != nil { glog.Errorf("Failed to get accessor for %+v", obj) return } - objName := fmt.Sprintf("%s/%s", accessor.GetNamespace(), accessor.GetName()) - if len(accessor.GetNamespace()) == 0 { - objName = accessor.GetName() + namespace := "" + if len(accessor.GetNamespace()) > 0 { + namespace = " -n " + accessor.GetNamespace() } if originalErr == nil { - recorder.Eventf(fmt.Sprintf("%sUpdated", gvk.Kind), "Updated %s %q because it changed", gvk.Kind, objName) + recorder.Eventf(fmt.Sprintf("%sUpdated", reportingKind), "Updated %s%s/%s%s because it changed", reportingKind, reportingGroup, accessor.GetName(), namespace) return } - recorder.Warningf(fmt.Sprintf("%sUpdateFailed", gvk.Kind), "Failed to update %s %q: %v", gvk.Kind, objName, originalErr) + recorder.Warningf(fmt.Sprintf("%sUpdateFailed", reportingKind), "Failed to update %s%s/%s%s: %v", reportingKind, reportingGroup, accessor.GetName(), namespace, originalErr) } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/event_helpers_test.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/event_helpers_test.go new file mode 100644 index 000000000..2268c4e72 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/event_helpers_test.go @@ -0,0 +1,128 @@ +package resourceapply + +import ( + "errors" + "testing" + + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "github.com/openshift/library-go/pkg/operator/events" +) + +func TestReportCreateEvent(t *testing.T) { + testErr := errors.New("test") + tests := []struct { + name string + object runtime.Object + err error + expectedEventMessage string + expectedEventReason string + }{ + { + name: "pod-with-error", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName"}}, + err: testErr, + expectedEventReason: "PodCreateFailed", + expectedEventMessage: "Failed to create Pod/podName: test", + }, + { + name: "pod-with-namespace", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName", Namespace: "nsName"}}, + err: testErr, + expectedEventReason: "PodCreateFailed", + expectedEventMessage: "Failed to create Pod/podName -n nsName: test", + }, + { + name: "pod-without-error", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName"}}, + expectedEventReason: "PodCreated", + expectedEventMessage: "Created Pod/podName because it was missing", + }, + { + name: "pod-with-namespace-without-error", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName", Namespace: "nsName"}}, + expectedEventReason: "PodCreated", + expectedEventMessage: "Created Pod/podName -n nsName because it was missing", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + recorder := events.NewInMemoryRecorder("test") + reportCreateEvent(recorder, test.object, test.err) + recordedEvents := recorder.Events() + + if eventCount := len(recordedEvents); eventCount != 1 { + t.Errorf("expected one event to be recorded, got %d", eventCount) + } + + if recordedEvents[0].Message != test.expectedEventMessage { + t.Errorf("expected one event message %q, got %q", test.expectedEventMessage, recordedEvents[0].Message) + } + + if recordedEvents[0].Reason != test.expectedEventReason { + t.Errorf("expected one event reason %q, got %q", test.expectedEventReason, recordedEvents[0].Reason) + } + }) + } +} + +func TestReportUpdateEvent(t *testing.T) { + testErr := errors.New("test") + tests := []struct { + name string + object runtime.Object + err error + expectedEventMessage string + expectedEventReason string + }{ + { + name: "pod-with-error", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName"}}, + err: testErr, + expectedEventReason: "PodUpdateFailed", + expectedEventMessage: "Failed to update Pod/podName: test", + }, + { + name: "pod-with-namespace", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName", Namespace: "nsName"}}, + err: testErr, + expectedEventReason: "PodUpdateFailed", + expectedEventMessage: "Failed to update Pod/podName -n nsName: test", + }, + { + name: "pod-without-error", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName"}}, + expectedEventReason: "PodUpdated", + expectedEventMessage: "Updated Pod/podName because it changed", + }, + { + name: "pod-with-namespace-without-error", + object: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "podName", Namespace: "nsName"}}, + expectedEventReason: "PodUpdated", + expectedEventMessage: "Updated Pod/podName -n nsName because it changed", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + recorder := events.NewInMemoryRecorder("test") + reportUpdateEvent(recorder, test.object, test.err) + recordedEvents := recorder.Events() + + if eventCount := len(recordedEvents); eventCount != 1 { + t.Errorf("expected one event to be recorded, got %d", eventCount) + } + + if recordedEvents[0].Message != test.expectedEventMessage { + t.Errorf("expected one event message %q, got %q", test.expectedEventMessage, recordedEvents[0].Message) + } + + if recordedEvents[0].Reason != test.expectedEventReason { + t.Errorf("expected one event reason %q, got %q", test.expectedEventReason, recordedEvents[0].Reason) + } + }) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic.go index f3af86fe5..df014ea13 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic.go @@ -58,6 +58,8 @@ func ApplyDirectly(client kubernetes.Interface, recorder events.Recorder, manife result.Result, result.Changed, result.Error = ApplyNamespace(client.CoreV1(), recorder, t) case *corev1.Service: result.Result, result.Changed, result.Error = ApplyService(client.CoreV1(), recorder, t) + case *corev1.Pod: + result.Result, result.Changed, result.Error = ApplyPod(client.CoreV1(), recorder, t) case *corev1.ServiceAccount: result.Result, result.Changed, result.Error = ApplyServiceAccount(client.CoreV1(), recorder, t) case *corev1.ConfigMap: diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic_test.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic_test.go index eeb3c48b7..4a73c57b5 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic_test.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/generic_test.go @@ -28,18 +28,18 @@ func TestApplyDirectlyUnhandledType(t *testing.T) { fakeClient := fake.NewSimpleClientset() content := func(name string) ([]byte, error) { return []byte(`apiVersion: v1 -kind: Pod +kind: PersistentVolumeClaim metadata: - name: openshift-apiserver + name: sample-claim labels: openshift.io/run-level: "1" `), nil } recorder := events.NewInMemoryRecorder("") - ret := ApplyDirectly(fakeClient, recorder, content, "pod") + ret := ApplyDirectly(fakeClient, recorder, content, "pvc") if ret[0].Error == nil { t.Fatal("missing expected error") - } else if ret[0].Error.Error() != "unhandled type *v1.Pod" { + } else if ret[0].Error.Error() != "unhandled type *v1.PersistentVolumeClaim" { t.Fatal(ret[0].Error) } } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/monitoring.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/monitoring.go new file mode 100644 index 000000000..5612b99d4 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/monitoring.go @@ -0,0 +1,94 @@ +package resourceapply + +import ( + "fmt" + + "github.com/ghodss/yaml" + "github.com/imdario/mergo" + + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/dynamic" + + "github.com/openshift/library-go/pkg/operator/events" +) + +var serviceMonitorGVR = schema.GroupVersionResource{Group: "monitoring.coreos.com", Version: "v1", Resource: "servicemonitors"} + +func ensureServiceMonitorSpec(required, existing *unstructured.Unstructured) (*unstructured.Unstructured, bool, error) { + requiredSpec, _, err := unstructured.NestedMap(required.UnstructuredContent(), "spec") + if err != nil { + return nil, false, err + } + existingSpec, _, err := unstructured.NestedMap(existing.UnstructuredContent(), "spec") + if err != nil { + return nil, false, err + } + + if err := mergo.Merge(&existingSpec, &requiredSpec); err != nil { + return nil, false, err + } + + if equality.Semantic.DeepEqual(existingSpec, requiredSpec) { + return existing, false, nil + } + + existingCopy := existing.DeepCopy() + if err := unstructured.SetNestedMap(existingCopy.UnstructuredContent(), existingSpec, "spec"); err != nil { + return nil, true, err + } + + return existingCopy, true, nil +} + +// ApplyServiceMonitor applies the Prometheus service monitor. +func ApplyServiceMonitor(client dynamic.Interface, recorder events.Recorder, serviceMonitorBytes []byte) (bool, error) { + monitorJSON, err := yaml.YAMLToJSON(serviceMonitorBytes) + if err != nil { + return false, err + } + + monitorObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, monitorJSON) + if err != nil { + return false, err + } + + required, ok := monitorObj.(*unstructured.Unstructured) + if !ok { + return false, fmt.Errorf("unexpected object in %t", monitorObj) + } + + namespace := required.GetNamespace() + + existing, err := client.Resource(serviceMonitorGVR).Namespace(namespace).Get(required.GetName(), metav1.GetOptions{}) + if errors.IsNotFound(err) { + _, createErr := client.Resource(serviceMonitorGVR).Namespace(namespace).Create(required) + if createErr != nil { + recorder.Warningf("ServiceMonitorCreateFailed", "Failed to create ServiceMonitor.monitoring.coreos.com/v1: %v", createErr) + return true, createErr + } + recorder.Eventf("ServiceMonitorCreated", "Created ServiceMonitor.monitoring.coreos.com/v1 because it was missing") + return true, nil + } + + updated, endpointsModified, err := ensureServiceMonitorSpec(required, existing) + if err != nil { + return false, err + } + + if !endpointsModified { + return false, nil + } + + if _, err = client.Resource(serviceMonitorGVR).Namespace(namespace).Update(updated); err != nil { + recorder.Warningf("ServiceMonitorUpdateFailed", "Failed to update ServiceMonitor.monitoring.coreos.com/v1: %v", err) + return true, err + } + + recorder.Eventf("ServiceMonitorUpdated", "Updated ServiceMonitor.monitoring.coreos.com/v1 because it changed") + return true, err +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/monitoring_test.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/monitoring_test.go new file mode 100644 index 000000000..52cff2db8 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/monitoring_test.go @@ -0,0 +1,148 @@ +package resourceapply + +import ( + "reflect" + "sort" + "testing" + + "github.com/ghodss/yaml" + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/diff" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + dynamicfake "k8s.io/client-go/dynamic/fake" + clienttesting "k8s.io/client-go/testing" + + "github.com/openshift/library-go/pkg/operator/events" +) + +const ( + fakeServiceMonitor = `apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: cluster-kube-apiserver + namespace: openshift-kube-apiserver +spec: + endpoints: + - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token + interval: 30s + metricRelabelings: + - action: drop + regex: etcd_(debugging|disk|request|server).* + sourceLabels: + - __name__ + port: https + scheme: https + tlsConfig: + caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt + serverName: apiserver.openshift-kube-apiserver.svc + jobLabel: component + namespaceSelector: + matchNames: + - openshift-kube-apiserver + selector: + matchLabels: + app: openshift-kube-apiserver +` + fakeIncompleteServiceMonitor = `apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: cluster-kube-apiserver + namespace: openshift-kube-apiserver +spec: + endpoints: + - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token + interval: 30s + metricRelabelings: + - action: drop + regex: etcd_(debugging|disk|request|server).* + sourceLabels: + - __name__ + port: https + scheme: https + jobLabel: component + namespaceSelector: + matchNames: + - wrong-name + selector: + matchLabels: + custom: custom-label + app: openshift-kube-apiserver +` +) + +func readServiceMonitorFromBytes(monitorBytes []byte) *unstructured.Unstructured { + monitorJSON, err := yaml.YAMLToJSON(monitorBytes) + if err != nil { + panic(err) + } + monitorObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, monitorJSON) + if err != nil { + panic(err) + } + required, ok := monitorObj.(*unstructured.Unstructured) + if !ok { + panic("unexpected object") + } + return required +} + +func TestApplyServiceMonitor(t *testing.T) { + dynamicScheme := runtime.NewScheme() + dynamicScheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "monitoring.coreos.com", Version: "v1", Kind: "ServiceMonitor"}, &unstructured.Unstructured{}) + + dynamicClient := dynamicfake.NewSimpleDynamicClient(dynamicScheme, readServiceMonitorFromBytes([]byte(fakeServiceMonitor))) + + modified, err := ApplyServiceMonitor(dynamicClient, events.NewInMemoryRecorder("monitor-test"), []byte(fakeIncompleteServiceMonitor)) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if !modified { + t.Fatalf("expected the service monitor will be modified, it was not") + } + + if len(dynamicClient.Actions()) != 2 { + t.Fatalf("expected 2 actions, got %d", len(dynamicClient.Actions())) + } + + _, isUpdate := dynamicClient.Actions()[1].(clienttesting.UpdateAction) + if !isUpdate { + t.Fatalf("expected second action to be update, got %+v", dynamicClient.Actions()[1]) + } + + updatedMonitorObj, err := dynamicClient.Resource(schema.GroupVersionResource{ + Group: "monitoring.coreos.com", + Version: "v1", + Resource: "servicemonitors", + }).Namespace("openshift-kube-apiserver").Get("cluster-kube-apiserver", metav1.GetOptions{}) + if err != nil { + t.Fatalf("expected to get update monitor, got: %v", err) + } + + labels, _, err := unstructured.NestedStringMap(updatedMonitorObj.UnstructuredContent(), "spec", "selector", "matchLabels") + if err != nil { + t.Fatalf("unable to get selector: %v", err) + } + + expectedKeys := []string{"app", "custom"} + resultKeys := []string{} + for key := range labels { + resultKeys = append(resultKeys, key) + } + sort.Strings(resultKeys) + + if !reflect.DeepEqual(resultKeys, expectedKeys) { + t.Fatalf("expected %#v selectors, got %#v", expectedKeys, resultKeys) + } + + requiredMonitorSpec, _, _ := unstructured.NestedMap(readServiceMonitorFromBytes([]byte(fakeServiceMonitor)).UnstructuredContent(), "spec", "endpoints") + existingMonitorSpec, _, _ := unstructured.NestedMap(updatedMonitorObj.UnstructuredContent(), "spec", "endpoints") + + if !equality.Semantic.DeepEqual(requiredMonitorSpec, existingMonitorSpec) { + t.Fatalf("expected resulting service monitor spec endpoints to match required spec: %s", diff.ObjectDiff(requiredMonitorSpec, existingMonitorSpec)) + } + +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourcehash/as_configmap.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourcehash/as_configmap.go new file mode 100644 index 000000000..7e2c886fb --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourcehash/as_configmap.go @@ -0,0 +1,101 @@ +package resourcehash + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "hash/fnv" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/kubernetes" +) + +// GetConfigMapHash returns a hash of the configmap data +func GetConfigMapHash(obj *corev1.ConfigMap) (string, error) { + hasher := fnv.New32() + if err := json.NewEncoder(hasher).Encode(obj.Data); err != nil { + return "", err + } + return base64.URLEncoding.EncodeToString(hasher.Sum(nil)), nil +} + +// GetSecretHash returns a hash of the secret data +func GetSecretHash(obj *corev1.Secret) (string, error) { + hasher := fnv.New32() + if err := json.NewEncoder(hasher).Encode(obj.Data); err != nil { + return "", err + } + return base64.URLEncoding.EncodeToString(hasher.Sum(nil)), nil +} + +// MultipleObjectHashStringMap returns a map of key/hash pairs suitable for merging into a configmap +func MultipleObjectHashStringMap(objs ...runtime.Object) (map[string]string, error) { + ret := map[string]string{} + + for _, obj := range objs { + switch t := obj.(type) { + case *corev1.ConfigMap: + hash, err := GetConfigMapHash(t) + if err != nil { + return nil, err + } + // this string coercion is lossy, but it should be fairly controlled and must be an allowed name + ret[mapKeyFor("configmap", t.Namespace, t.Name)] = hash + + case *corev1.Secret: + hash, err := GetSecretHash(t) + if err != nil { + return nil, err + } + // this string coercion is lossy, but it should be fairly controlled and must be an allowed name + ret[mapKeyFor("secret", t.Namespace, t.Name)] = hash + + default: + return nil, fmt.Errorf("%T is not handled", t) + } + } + + return ret, nil +} + +func mapKeyFor(resource, namespace, name string) string { + return fmt.Sprintf("%s.%s.%s", namespace, name, resource) +} + +// ObjectReference can be used to reference a particular resource. Not all group resources are respected by all methods. +type ObjectReference struct { + Resource schema.GroupResource + Namespace string + Name string +} + +// MultipleObjectHashStringMapForObjectReferences returns a map of key/hash pairs suitable for merging into a configmap +func MultipleObjectHashStringMapForObjectReferences(client kubernetes.Interface, objRefs ...ObjectReference) (map[string]string, error) { + objs := []runtime.Object{} + + for _, objRef := range objRefs { + switch objRef.Resource { + case schema.GroupResource{Resource: "configmap"}, schema.GroupResource{Resource: "configmaps"}: + obj, err := client.CoreV1().ConfigMaps(objRef.Namespace).Get(objRef.Name, metav1.GetOptions{}) + if err != nil { + return nil, err + } + objs = append(objs, obj) + + case schema.GroupResource{Resource: "secret"}, schema.GroupResource{Resource: "secrets"}: + obj, err := client.CoreV1().Secrets(objRef.Namespace).Get(objRef.Name, metav1.GetOptions{}) + if err != nil { + return nil, err + } + objs = append(objs, obj) + + default: + return nil, fmt.Errorf("%v is not handled", objRef.Resource) + } + } + + return MultipleObjectHashStringMap(objs...) +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourcemerge/apiextensions.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourcemerge/apiextensions.go new file mode 100644 index 000000000..32e4043f6 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourcemerge/apiextensions.go @@ -0,0 +1,18 @@ +package resourcemerge + +import ( + apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + "k8s.io/apimachinery/pkg/api/equality" +) + +// EnsureCustomResourceDefinition ensures that the existing matches the required. +// modified is set to true when existing had to be updated with required. +func EnsureCustomResourceDefinition(modified *bool, existing *apiextv1beta1.CustomResourceDefinition, required apiextv1beta1.CustomResourceDefinition) { + EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) + + // we stomp everything + if !equality.Semantic.DeepEqual(existing.Spec, required.Spec) { + *modified = true + existing.Spec = required.Spec + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/interfaces.go b/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/interfaces.go new file mode 100644 index 000000000..308360745 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/interfaces.go @@ -0,0 +1,19 @@ +package resourcesynccontroller + +// ResourceLocation describes coordinates for a resource to be synced +type ResourceLocation struct { + Namespace string + Name string +} + +var emptyResourceLocation = ResourceLocation{} + +// ResourceSyncer allows changes to syncing rules by this controller +type ResourceSyncer interface { + // SyncConfigMap indicates that a configmap should be copied from the source to the destination. It will also + // mirror a deletion from the source. If the source is a zero object the destination will be deleted. + SyncConfigMap(destination, source ResourceLocation) error + // SyncSecret indicates that a secret should be copied from the source to the destination. It will also + // mirror a deletion from the source. If the source is a zero object the destination will be deleted. + SyncSecret(destination, source ResourceLocation) error +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/resourcesync_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/resourcesync_controller.go new file mode 100644 index 000000000..5fdc5492c --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/resourcesync_controller.go @@ -0,0 +1,237 @@ +package resourcesynccontroller + +import ( + "fmt" + "sync" + "time" + + "github.com/golang/glog" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" + + operatorv1 "github.com/openshift/api/operator/v1" + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/resource/resourceapply" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" +) + +const ( + operatorStatusResourceSyncControllerFailing = "ResourceSyncControllerFailing" + controllerWorkQueueKey = "key" +) + +// ResourceSyncController is a controller that will copy source configmaps and secrets to their destinations. +// It will also mirror deletions by deleting destinations. +type ResourceSyncController struct { + // syncRuleLock is used to ensure we avoid races on changes to syncing rules + syncRuleLock sync.RWMutex + // configMapSyncRules is a map from destination location to source location + configMapSyncRules map[ResourceLocation]ResourceLocation + // secretSyncRules is a map from destination location to source location + secretSyncRules map[ResourceLocation]ResourceLocation + + // knownNamespaces is the list of namespaces we are watching. + knownNamespaces sets.String + + preRunCachesSynced []cache.InformerSynced + + // queue only ever has one item, but it has nice error handling backoff/retry semantics + queue workqueue.RateLimitingInterface + + kubeClient kubernetes.Interface + operatorConfigClient common.OperatorClient + eventRecorder events.Recorder +} + +var _ ResourceSyncer = &ResourceSyncController{} + +// NewResourceSyncController creates ResourceSyncController. +func NewResourceSyncController( + operatorConfigClient common.OperatorClient, + kubeInformersForNamespaces map[string]informers.SharedInformerFactory, + kubeClient kubernetes.Interface, + eventRecorder events.Recorder, +) *ResourceSyncController { + c := &ResourceSyncController{ + operatorConfigClient: operatorConfigClient, + eventRecorder: eventRecorder, + + configMapSyncRules: map[ResourceLocation]ResourceLocation{}, + secretSyncRules: map[ResourceLocation]ResourceLocation{}, + knownNamespaces: sets.StringKeySet(kubeInformersForNamespaces), + + queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "ResourceSyncController"), + kubeClient: kubeClient, + } + + for _, informers := range kubeInformersForNamespaces { + informers.Core().V1().ConfigMaps().Informer().AddEventHandler(c.eventHandler()) + informers.Core().V1().Secrets().Informer().AddEventHandler(c.eventHandler()) + c.preRunCachesSynced = append(c.preRunCachesSynced, informers.Core().V1().ConfigMaps().Informer().HasSynced) + c.preRunCachesSynced = append(c.preRunCachesSynced, informers.Core().V1().Secrets().Informer().HasSynced) + } + + // we watch this just in case someone messes with our status + operatorConfigClient.Informer().AddEventHandler(c.eventHandler()) + + return c +} + +func (c *ResourceSyncController) SyncConfigMap(destination, source ResourceLocation) error { + if !c.knownNamespaces.Has(destination.Namespace) { + return fmt.Errorf("not watching namespace %q", destination.Namespace) + } + if source != emptyResourceLocation && !c.knownNamespaces.Has(source.Namespace) { + return fmt.Errorf("not watching namespace %q", source.Namespace) + } + + c.syncRuleLock.Lock() + defer c.syncRuleLock.Unlock() + c.configMapSyncRules[destination] = source + + // make sure the new rule is picked up + c.queue.Add(controllerWorkQueueKey) + return nil +} + +func (c *ResourceSyncController) SyncSecret(destination, source ResourceLocation) error { + if !c.knownNamespaces.Has(destination.Namespace) { + return fmt.Errorf("not watching namespace %q", destination.Namespace) + } + if source != emptyResourceLocation && !c.knownNamespaces.Has(source.Namespace) { + return fmt.Errorf("not watching namespace %q", source.Namespace) + } + + c.syncRuleLock.Lock() + defer c.syncRuleLock.Unlock() + c.secretSyncRules[destination] = source + + // make sure the new rule is picked up + c.queue.Add(controllerWorkQueueKey) + return nil +} + +func (c *ResourceSyncController) sync() error { + operatorSpec, _, _, err := c.operatorConfigClient.Get() + if err != nil { + return err + } + + switch operatorSpec.ManagementState { + case operatorv1.Unmanaged: + return nil + case operatorv1.Removed: + // TODO: Should we try to actively remove the resources created by this controller here? + return nil + } + + c.syncRuleLock.RLock() + defer c.syncRuleLock.RUnlock() + + errors := []error{} + + for destination, source := range c.configMapSyncRules { + if source == emptyResourceLocation { + if err := c.kubeClient.CoreV1().ConfigMaps(destination.Namespace).Delete(destination.Name, nil); err != nil && !apierrors.IsNotFound(err) { + errors = append(errors, err) + } + continue + } + + _, _, err := resourceapply.SyncConfigMap(c.kubeClient.CoreV1(), c.eventRecorder, source.Namespace, source.Name, destination.Namespace, destination.Name) + if err != nil { + errors = append(errors, err) + } + } + for destination, source := range c.secretSyncRules { + if source == emptyResourceLocation { + if err := c.kubeClient.CoreV1().Secrets(destination.Namespace).Delete(destination.Name, nil); err != nil && !apierrors.IsNotFound(err) { + errors = append(errors, err) + } + continue + } + + _, _, err := resourceapply.SyncSecret(c.kubeClient.CoreV1(), c.eventRecorder, source.Namespace, source.Name, destination.Namespace, destination.Name) + if err != nil { + errors = append(errors, err) + } + } + + if len(errors) > 0 { + cond := operatorv1.OperatorCondition{ + Type: operatorStatusResourceSyncControllerFailing, + Status: operatorv1.ConditionTrue, + Reason: "Error", + Message: common.NewMultiLineAggregate(errors).Error(), + } + if _, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond)); updateError != nil { + return updateError + } + return nil + } + + cond := operatorv1.OperatorCondition{ + Type: operatorStatusResourceSyncControllerFailing, + Status: operatorv1.ConditionFalse, + } + if _, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond)); updateError != nil { + return updateError + } + return nil +} + +func (c *ResourceSyncController) Run(workers int, stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + defer c.queue.ShutDown() + + glog.Infof("Starting ResourceSyncController") + defer glog.Infof("Shutting down ResourceSyncController") + if !cache.WaitForCacheSync(stopCh, c.preRunCachesSynced...) { + return + } + + // doesn't matter what workers say, only start one. + go wait.Until(c.runWorker, time.Second, stopCh) + + <-stopCh +} + +func (c *ResourceSyncController) runWorker() { + for c.processNextWorkItem() { + } +} + +func (c *ResourceSyncController) processNextWorkItem() bool { + dsKey, quit := c.queue.Get() + if quit { + return false + } + defer c.queue.Done(dsKey) + + err := c.sync() + if err == nil { + c.queue.Forget(dsKey) + return true + } + + utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err)) + c.queue.AddRateLimited(dsKey) + + return true +} + +// eventHandler queues the operator to check spec and status +func (c *ResourceSyncController) eventHandler() cache.ResourceEventHandler { + return cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { c.queue.Add(controllerWorkQueueKey) }, + UpdateFunc: func(old, new interface{}) { c.queue.Add(controllerWorkQueueKey) }, + DeleteFunc: func(obj interface{}) { c.queue.Add(controllerWorkQueueKey) }, + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/resourcesync_controller_test.go b/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/resourcesync_controller_test.go new file mode 100644 index 000000000..8f333b85d --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/resourcesynccontroller/resourcesync_controller_test.go @@ -0,0 +1,117 @@ +package resourcesynccontroller + +import ( + "testing" + "time" + + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes/fake" + + operatorv1 "github.com/openshift/api/operator/v1" + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" +) + +func TestSyncConfigMap(t *testing.T) { + kubeClient := fake.NewSimpleClientset( + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Namespace: "other", Name: "foo"}, + }, + &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{Namespace: "other", Name: "foo"}, + }, + &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{Namespace: "config", Name: "bar"}, + }, + &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Namespace: "config-managed", Name: "pear"}, + }, + ) + + configInformers := informers.NewSharedInformerFactoryWithOptions(kubeClient, 1*time.Minute, informers.WithNamespace("config")) + configManagedInformers := informers.NewSharedInformerFactoryWithOptions(kubeClient, 1*time.Minute, informers.WithNamespace("config-managed")) + operatorInformers := informers.NewSharedInformerFactoryWithOptions(kubeClient, 1*time.Minute, informers.WithNamespace("operator")) + + fakeStaticPodOperatorClient := common.NewFakeStaticPodOperatorClient( + &operatorv1.OperatorSpec{ + ManagementState: operatorv1.Managed, + }, + &operatorv1.OperatorStatus{}, + &operatorv1.StaticPodOperatorStatus{ + LatestAvailableRevision: 1, + NodeStatuses: []operatorv1.NodeStatus{ + { + NodeName: "test-node-1", + CurrentRevision: 0, + TargetRevision: 0, + }, + }, + }, + nil, + ) + eventRecorder := events.NewRecorder(kubeClient.CoreV1().Events("test"), "test-operator", &corev1.ObjectReference{}) + + c := NewResourceSyncController( + fakeStaticPodOperatorClient, + map[string]informers.SharedInformerFactory{ + "config": configInformers, + "config-managed": configManagedInformers, + "operator": operatorInformers, + }, + kubeClient, + eventRecorder, + ) + + // sync ones for namespaces we don't have + if err := c.SyncSecret(ResourceLocation{Namespace: "other", Name: "foo"}, ResourceLocation{Namespace: "operator", Name: "foo"}); err == nil || err.Error() != `not watching namespace "other"` { + t.Error(err) + } + if err := c.SyncSecret(ResourceLocation{Namespace: "config", Name: "foo"}, ResourceLocation{Namespace: "other", Name: "foo"}); err == nil || err.Error() != `not watching namespace "other"` { + t.Error(err) + } + if err := c.SyncConfigMap(ResourceLocation{Namespace: "other", Name: "foo"}, ResourceLocation{Namespace: "operator", Name: "foo"}); err == nil || err.Error() != `not watching namespace "other"` { + t.Error(err) + } + if err := c.SyncConfigMap(ResourceLocation{Namespace: "config", Name: "foo"}, ResourceLocation{Namespace: "other", Name: "foo"}); err == nil || err.Error() != `not watching namespace "other"` { + t.Error(err) + } + + // register + kubeClient.ClearActions() + if err := c.SyncSecret(ResourceLocation{Namespace: "operator", Name: "foo"}, ResourceLocation{Namespace: "config", Name: "bar"}); err != nil { + t.Fatal(err) + } + if err := c.SyncConfigMap(ResourceLocation{Namespace: "operator", Name: "apple"}, ResourceLocation{Namespace: "config-managed", Name: "pear"}); err != nil { + t.Fatal(err) + } + if err := c.sync(); err != nil { + t.Fatal(err) + } + if _, err := kubeClient.CoreV1().Secrets("operator").Get("foo", metav1.GetOptions{}); err != nil { + t.Error(err) + } + if _, err := kubeClient.CoreV1().ConfigMaps("operator").Get("apple", metav1.GetOptions{}); err != nil { + t.Error(err) + } + + // clear + kubeClient.ClearActions() + if err := c.SyncSecret(ResourceLocation{Namespace: "operator", Name: "foo"}, ResourceLocation{}); err != nil { + t.Fatal(err) + } + if err := c.SyncConfigMap(ResourceLocation{Namespace: "operator", Name: "apple"}, ResourceLocation{}); err != nil { + t.Fatal(err) + } + if err := c.sync(); err != nil { + t.Fatal(err) + } + if _, err := kubeClient.CoreV1().Secrets("operator").Get("foo", metav1.GetOptions{}); !apierrors.IsNotFound(err) { + t.Error(err) + } + if _, err := kubeClient.CoreV1().ConfigMaps("operator").Get("apple", metav1.GetOptions{}); !apierrors.IsNotFound(err) { + t.Error(err) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller.go index d8b728c6c..f000632b1 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller.go @@ -3,8 +3,6 @@ package backingresource import ( "fmt" "path/filepath" - "reflect" - "strings" "time" "github.com/golang/glog" @@ -24,15 +22,17 @@ import ( "github.com/openshift/library-go/pkg/operator/resource/resourceapply" "github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/bindata" "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" - "github.com/openshift/library-go/pkg/operator/v1helpers" ) const ( - controllerWorkQueueKey = "key" - manifestDir = "pkg/operator/staticpod/controller/backingresource" + operatorStatusBackingResourceControllerFailing = "BackingResourceControllerFailing" + controllerWorkQueueKey = "key" + manifestDir = "pkg/operator/staticpod/controller/backingresource" ) -// BackingResourceController watches +// BackingResourceController is a controller that watches the operator config and updates +// service accounts and RBAC rules in the target namespace according to the bindata manifests +// (templated with the config) if they differ. type BackingResourceController struct { targetNamespace string operatorConfigClient common.OperatorClient @@ -50,6 +50,7 @@ type BackingResourceController struct { eventRecorder events.Recorder } +// NewBackingResourceController creates a new backing resource controller. func NewBackingResourceController( targetNamespace string, operatorConfigClient common.OperatorClient, @@ -80,20 +81,6 @@ func NewBackingResourceController( return c } -// resetFailingConditionForReason reset the failing operator condition status to false for the specified reason. -func (c BackingResourceController) resetFailingConditionForReason(status *operatorv1.StaticPodOperatorStatus, resourceVersion, reason string) error { - failingCondition := v1helpers.FindOperatorCondition(status.Conditions, operatorv1.OperatorStatusTypeFailing) - if failingCondition == nil || failingCondition.Reason != reason { - return nil - } - - failingCondition.Status = operatorv1.ConditionFalse - v1helpers.SetOperatorCondition(&status.Conditions, *failingCondition) - - _, err := c.operatorConfigClient.UpdateStatus(resourceVersion, status) - return err -} - func (c BackingResourceController) mustTemplateAsset(name string) ([]byte, error) { config := struct { TargetNamespace string @@ -104,12 +91,11 @@ func (c BackingResourceController) mustTemplateAsset(name string) ([]byte, error } func (c BackingResourceController) sync() error { - operatorSpec, originalOperatorStatus, resourceVersion, err := c.operatorConfigClient.Get() + operatorSpec, _, _, err := c.operatorConfigClient.Get() if err != nil { return err } - operatorStatus := originalOperatorStatus.DeepCopy() switch operatorSpec.ManagementState { case operatorv1.Unmanaged: return nil @@ -118,38 +104,36 @@ func (c BackingResourceController) sync() error { return nil } - errors := []string{} directResourceResults := resourceapply.ApplyDirectly(c.kubeClient, c.eventRecorder, c.mustTemplateAsset, "manifests/installer-sa.yaml", "manifests/installer-cluster-rolebinding.yaml", ) + errs := []error{} for _, currResult := range directResourceResults { if currResult.Error != nil { - errors = append(errors, fmt.Sprintf("%q (%T): %v", currResult.File, currResult.Type, currResult.Error)) + errs = append(errs, fmt.Errorf("%q (%T): %v", currResult.File, currResult.Type, currResult.Error)) } } + err = common.NewMultiLineAggregate(errs) - // No errors, means we succeeded. Reset the state of the failing condition (if exists) as a result. - // TODO: This will be replaced by something smarter in near future. - if len(errors) == 0 { - return c.resetFailingConditionForReason(operatorStatus, resourceVersion, "CreateBackingResourcesError") + // update failing condition + cond := operatorv1.OperatorCondition{ + Type: operatorStatusBackingResourceControllerFailing, + Status: operatorv1.ConditionFalse, } - - v1helpers.SetOperatorCondition(&operatorStatus.Conditions, operatorv1.OperatorCondition{ - Type: operatorv1.OperatorStatusTypeFailing, - Status: operatorv1.ConditionTrue, - Reason: "CreateBackingResourcesError", - Message: strings.Join(errors, ","), - }) - - if !reflect.DeepEqual(originalOperatorStatus, operatorStatus) { - if _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus); updateError != nil { - glog.Error(updateError) + if err != nil { + cond.Status = operatorv1.ConditionTrue + cond.Reason = "Error" + cond.Message = err.Error() + } + if _, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond)); updateError != nil { + if err == nil { + return updateError } } - return fmt.Errorf("synthetic requeue (errs: %q)", strings.Join(errors, ",")) + return err } // Run starts the kube-apiserver and blocks until stopCh is closed. diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller_test.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller_test.go index 60b53c491..f8fdd63b3 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller_test.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/backingresource/backing_resource_controller_test.go @@ -157,11 +157,11 @@ func TestBackingResourceController(t *testing.T) { ), expectSyncError: `test error`, validateStatus: func(t *testing.T, status *operatorv1.StaticPodOperatorStatus) { - if status.Conditions[0].Type != operatorv1.OperatorStatusTypeFailing { + if status.Conditions[0].Type != operatorStatusBackingResourceControllerFailing { t.Errorf("expected status condition to be failing, got %v", status.Conditions[0].Type) } - if status.Conditions[0].Reason != "CreateBackingResourcesError" { - t.Errorf("expected status condition reason to be 'CreateBackingResourcesError', got %v", status.Conditions[0].Reason) + if status.Conditions[0].Reason != "Error" { + t.Errorf("expected status condition reason to be 'Error', got %v", status.Conditions[0].Reason) } if !strings.Contains(status.Conditions[0].Message, "test error") { t.Errorf("expected status condition message to contain 'test error', got: %s", status.Conditions[0].Message) diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/common/helpers.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/common/helpers.go new file mode 100644 index 000000000..4597979d4 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/common/helpers.go @@ -0,0 +1,83 @@ +package common + +import ( + "strings" + + "github.com/openshift/library-go/pkg/operator/v1helpers" + "k8s.io/apimachinery/pkg/api/equality" + errutils "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/client-go/util/retry" + + operatorv1 "github.com/openshift/api/operator/v1" +) + +// UpdateStatusFunc is a func that mutates an operator status. +type UpdateStatusFunc func(status *operatorv1.StaticPodOperatorStatus) error + +// UpdateStatus applies the update funcs to the oldStatus abd tries to update via the client. +func UpdateStatus(client OperatorClient, updateFuncs ...UpdateStatusFunc) (bool, error) { + updated := false + err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { + _, oldStatus, resourceVersion, err := client.Get() + if err != nil { + return err + } + + newStatus := oldStatus.DeepCopy() + for _, update := range updateFuncs { + if err := update(newStatus); err != nil { + return err + } + } + + if equality.Semantic.DeepEqual(oldStatus, newStatus) { + return nil + } + + _, err = client.UpdateStatus(resourceVersion, newStatus) + updated = err == nil + return err + }) + + return updated, err +} + +// UpdateConditionFunc returns a func to update a condition. +func UpdateConditionFn(cond operatorv1.OperatorCondition) UpdateStatusFunc { + return func(oldStatus *operatorv1.StaticPodOperatorStatus) error { + v1helpers.SetOperatorCondition(&oldStatus.Conditions, cond) + return nil + } +} + +type aggregate []error + +var _ errutils.Aggregate = aggregate{} + +// NewMultiLineAggregate returns an aggregate error with multi-line output +func NewMultiLineAggregate(errList []error) error { + var errs []error + for _, e := range errList { + if e != nil { + errs = append(errs, e) + } + } + if len(errs) == 0 { + return nil + } + return aggregate(errs) +} + +// Error is part of the error interface. +func (agg aggregate) Error() string { + msgs := make([]string, len(agg)) + for i := range agg { + msgs[i] = agg[i].Error() + } + return strings.Join(msgs, "\n") +} + +// Errors is part of the Aggregate interface. +func (agg aggregate) Errors() []error { + return []error(agg) +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/common/test_utils.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/common/test_utils.go index cca6d632a..b7ea86543 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/common/test_utils.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/common/test_utils.go @@ -1,11 +1,15 @@ package common import ( + "fmt" + "strconv" "time" "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" corelisterv1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" @@ -79,11 +83,18 @@ func (c *fakeStaticPodOperatorClient) Informer() cache.SharedIndexInformer { } func (c *fakeStaticPodOperatorClient) Get() (*operatorv1.OperatorSpec, *operatorv1.StaticPodOperatorStatus, string, error) { - return c.fakeOperatorSpec, c.fakeStaticPodOperatorStatus, "1", nil + return c.fakeOperatorSpec, c.fakeStaticPodOperatorStatus, c.resourceVersion, nil } func (c *fakeStaticPodOperatorClient) UpdateStatus(resourceVersion string, status *operatorv1.StaticPodOperatorStatus) (*operatorv1.StaticPodOperatorStatus, error) { - c.resourceVersion = resourceVersion + if c.resourceVersion != resourceVersion { + return nil, errors.NewConflict(schema.GroupResource{Group: operatorv1.GroupName, Resource: "TestOperatorConfig"}, "instance", fmt.Errorf("invalid resourceVersion")) + } + rv, err := strconv.Atoi(resourceVersion) + if err != nil { + return nil, err + } + c.resourceVersion = strconv.Itoa(rv + 1) if c.triggerStatusUpdateError != nil { if err := c.triggerStatusUpdateError(resourceVersion, status); err != nil { return nil, err diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/bindata/bindata.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/bindata/bindata.go new file mode 100644 index 000000000..a64dc6f6e --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/bindata/bindata.go @@ -0,0 +1,250 @@ +// Code generated by go-bindata. +// sources: +// pkg/operator/staticpod/controller/installer/manifests/installer-pod.yaml +// DO NOT EDIT! + +package bindata + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _pkgOperatorStaticpodControllerInstallerManifestsInstallerPodYaml = []byte(`apiVersion: v1 +kind: Pod +metadata: + namespace: # Value set by operator + name: # Value set by operator + labels: + app: installer +spec: + serviceAccountName: installer-sa + nodeName: # Value set by operator + containers: + - name: installer + command: # Value set by operator + args: # Value set by operator + image: # Value set by operator + imagePullPolicy: Always + securityContext: + privileged: true + runAsUser: 0 + terminationMessagePolicy: FallbackToLogsOnError + volumeMounts: + - mountPath: /etc/kubernetes/ + name: kubelet-dir + restartPolicy: Never + securityContext: + runAsUser: 0 + volumes: + - hostPath: + path: /etc/kubernetes/ + name: kubelet-dir`) + +func pkgOperatorStaticpodControllerInstallerManifestsInstallerPodYamlBytes() ([]byte, error) { + return _pkgOperatorStaticpodControllerInstallerManifestsInstallerPodYaml, nil +} + +func pkgOperatorStaticpodControllerInstallerManifestsInstallerPodYaml() (*asset, error) { + bytes, err := pkgOperatorStaticpodControllerInstallerManifestsInstallerPodYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "pkg/operator/staticpod/controller/installer/manifests/installer-pod.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "pkg/operator/staticpod/controller/installer/manifests/installer-pod.yaml": pkgOperatorStaticpodControllerInstallerManifestsInstallerPodYaml, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} + +var _bintree = &bintree{nil, map[string]*bintree{ + "pkg": {nil, map[string]*bintree{ + "operator": {nil, map[string]*bintree{ + "staticpod": {nil, map[string]*bintree{ + "controller": {nil, map[string]*bintree{ + "installer": {nil, map[string]*bintree{ + "manifests": {nil, map[string]*bintree{ + "installer-pod.yaml": {pkgOperatorStaticpodControllerInstallerManifestsInstallerPodYaml, map[string]*bintree{}}, + }}, + }}, + }}, + }}, + }}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller.go index ea6be9b00..55c203090 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller.go @@ -3,12 +3,13 @@ package installer import ( "fmt" "os" - "reflect" + "path/filepath" "strconv" "time" "github.com/davecgh/go-spew/spew" "github.com/golang/glog" + "github.com/openshift/library-go/pkg/operator/resource/resourceread" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -23,13 +24,24 @@ import ( operatorv1 "github.com/openshift/api/operator/v1" "github.com/openshift/library-go/pkg/operator/events" - "github.com/openshift/library-go/pkg/operator/resource/resourceread" + "github.com/openshift/library-go/pkg/operator/resource/resourceapply" "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/bindata" "github.com/openshift/library-go/pkg/operator/v1helpers" ) -const installerControllerWorkQueueKey = "key" +const ( + operatorStatusInstallerControllerFailing = "InstallerControllerFailing" + installerControllerWorkQueueKey = "key" + manifestDir = "pkg/operator/staticpod/controller/installer" + manifestInstallerPodPath = "manifests/installer-pod.yaml" + + hostResourceDirDir = "/etc/kubernetes/static-pod-resources" + hostPodManifestDir = "/etc/kubernetes/manifests" +) +// InstallerController is a controller that watches the currentRevision and targetRevision fields for each node and spawn +// installer pods to update the static pods on the master nodes. type InstallerController struct { targetNamespace, staticPodName string // configMaps is the list of configmaps that are directly copied.A different actor/controller modifies these. @@ -67,6 +79,7 @@ const ( const revisionLabel = "revision" +// NewBackingResourceController creates a new installer controller. func NewInstallerController( targetNamespace, staticPodName string, configMaps []string, @@ -121,34 +134,50 @@ func (c *InstallerController) getStaticPodState(nodeName string) (state staticPo return staticPodStatePending, "", nil, nil } -func (c *InstallerController) nodeToStartRevisionWith(nodes []operatorv1.NodeStatus) (int, error) { +// nodeToStartRevisionWith returns a node index i and guarantees for every node < i that it is +// - not updating +// - ready +// - at the revision claimed in CurrentRevision. +func nodeToStartRevisionWith(getStaticPodState func(nodeName string) (state staticPodState, revision string, errors []string, err error), nodes []operatorv1.NodeStatus) (int, error) { + if len(nodes) == 0 { + return 0, fmt.Errorf("nodes array cannot be empty") + } + // find upgrading node as this will be the first to start new revision (to minimize number of down nodes) - startNode := 0 - foundUpgradingNode := false for i := range nodes { if nodes[i].TargetRevision != 0 { - startNode = i - foundUpgradingNode = true - break + return i, nil } } - // otherwise try to find a node that is not ready regarding its currently reported revision - if !foundUpgradingNode { - for i := range nodes { - currNodeState := &nodes[i] - state, revision, _, err := c.getStaticPodState(currNodeState.NodeName) - if err != nil { - return 0, err - } - if state != staticPodStateReady || revision != strconv.Itoa(int(currNodeState.CurrentRevision)) { - startNode = i - break - } + // otherwise try to find a node that is not ready + for i := range nodes { + currNodeState := &nodes[i] + state, _, _, err := getStaticPodState(currNodeState.NodeName) + if err != nil && apierrors.IsNotFound(err) { + return i, nil + } + if err != nil { + return 0, err + } + if state != staticPodStateReady { + return i, nil } } - return startNode, nil + // last but not least, find a node that is has the wrong revision + for i := range nodes { + currNodeState := &nodes[i] + _, revision, _, err := getStaticPodState(currNodeState.NodeName) + if err != nil { + return 0, err + } + if revision != strconv.Itoa(int(currNodeState.CurrentRevision)) { + return i, nil + } + } + + return 0, nil } // manageInstallationPods takes care of creating content for the static pods to install. @@ -161,7 +190,7 @@ func (c *InstallerController) manageInstallationPods(operatorSpec *operatorv1.Op } // start with node which is in worst state (instead of terminating healthy pods first) - startNode, err := c.nodeToStartRevisionWith(operatorStatus.NodeStatuses) + startNode, err := nodeToStartRevisionWith(c.getStaticPodState, operatorStatus.NodeStatuses) if err != nil { return true, err } @@ -195,17 +224,13 @@ func (c *InstallerController) manageInstallationPods(operatorSpec *operatorv1.Op // it's an extra write/read, but it makes the state debuggable from outside this process if !equality.Semantic.DeepEqual(newCurrNodeState, currNodeState) { glog.Infof("%q moving to %v", currNodeState.NodeName, spew.Sdump(*newCurrNodeState)) - operatorStatus.NodeStatuses[i] = *newCurrNodeState - if !reflect.DeepEqual(originalOperatorStatus, operatorStatus) { - _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus) - if updateError == nil { - if currNodeState.CurrentRevision != newCurrNodeState.CurrentRevision { - c.eventRecorder.Eventf("NodeCurrentRevisionChanged", "Updated node %q from revision %d to %d", currNodeState.NodeName, - currNodeState.CurrentRevision, newCurrNodeState.CurrentRevision) - } - } + if updated, updateError := common.UpdateStatus(c.operatorConfigClient, setNodeStatusFn(newCurrNodeState), setAvailableProgressingConditions); updateError != nil { return false, updateError + } else if updated && currNodeState.CurrentRevision != newCurrNodeState.CurrentRevision { + c.eventRecorder.Eventf("NodeCurrentRevisionChanged", "Updated node %q from revision %d to %d", currNodeState.NodeName, + currNodeState.CurrentRevision, newCurrNodeState.CurrentRevision) } + return false, nil } else { glog.V(2).Infof("%q is in transition to %d, but has not made progress", currNodeState.NodeName, currNodeState.TargetRevision) } @@ -228,35 +253,77 @@ func (c *InstallerController) manageInstallationPods(operatorSpec *operatorv1.Op // it's an extra write/read, but it makes the state debuggable from outside this process if !equality.Semantic.DeepEqual(newCurrNodeState, currNodeState) { glog.Infof("%q moving to %v", currNodeState.NodeName, spew.Sdump(*newCurrNodeState)) - operatorStatus.NodeStatuses[i] = *newCurrNodeState - if !reflect.DeepEqual(originalOperatorStatus, operatorStatus) { - _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus) - - if updateError == nil { - if currNodeState.TargetRevision != newCurrNodeState.TargetRevision && newCurrNodeState.TargetRevision != 0 { - c.eventRecorder.Eventf("NodeTargetRevisionChanged", "Updating node %q from revision %d to %d", currNodeState.NodeName, - currNodeState.CurrentRevision, newCurrNodeState.TargetRevision) - } - } - + if updated, updateError := common.UpdateStatus(c.operatorConfigClient, setNodeStatusFn(newCurrNodeState), setAvailableProgressingConditions); updateError != nil { return false, updateError + } else if updated && currNodeState.TargetRevision != newCurrNodeState.TargetRevision && newCurrNodeState.TargetRevision != 0 { + c.eventRecorder.Eventf("NodeTargetRevisionChanged", "Updating node %q from revision %d to %d", currNodeState.NodeName, + currNodeState.CurrentRevision, newCurrNodeState.TargetRevision) } + + return false, nil } break } - v1helpers.SetOperatorCondition(&operatorStatus.Conditions, operatorv1.OperatorCondition{ - Type: "InstallerControllerFailing", - Status: operatorv1.ConditionFalse, - }) - if !reflect.DeepEqual(originalOperatorStatus, operatorStatus) { - _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus) - if updateError != nil { - return true, updateError + return false, nil +} + +func setNodeStatusFn(status *operatorv1.NodeStatus) common.UpdateStatusFunc { + return func(operatorStatus *operatorv1.StaticPodOperatorStatus) error { + for i := range operatorStatus.NodeStatuses { + if operatorStatus.NodeStatuses[i].NodeName == status.NodeName { + operatorStatus.NodeStatuses[i] = *status + break + } } + return nil } +} - return false, nil +// setAvailableProgressingConditions sets the Available and Progressing conditions +func setAvailableProgressingConditions(newStatus *operatorv1.StaticPodOperatorStatus) error { + // Available means that we have at least one pod at the latest level + numAvailable := 0 + numProgressing := 0 + for _, currNodeStatus := range newStatus.NodeStatuses { + if newStatus.LatestAvailableRevision == currNodeStatus.CurrentRevision { + numAvailable += 1 + } else { + numProgressing += 1 + } + } + if numAvailable > 0 { + v1helpers.SetOperatorCondition(&newStatus.Conditions, operatorv1.OperatorCondition{ + Type: operatorv1.OperatorStatusTypeAvailable, + Status: operatorv1.ConditionTrue, + Message: fmt.Sprintf("%d of %d nodes are at revision %d", numAvailable, len(newStatus.NodeStatuses), newStatus.LatestAvailableRevision), + }) + } else { + v1helpers.SetOperatorCondition(&newStatus.Conditions, operatorv1.OperatorCondition{ + Type: operatorv1.OperatorStatusTypeAvailable, + Status: operatorv1.ConditionFalse, + Reason: "ZeroNodesAtLatestRevision", + Message: fmt.Sprintf("%d of %d nodes are at revision %d", numAvailable, len(newStatus.NodeStatuses), newStatus.LatestAvailableRevision), + }) + } + + // Progressing means that the any node is not at the latest available revision + if numProgressing > 0 { + v1helpers.SetOperatorCondition(&newStatus.Conditions, operatorv1.OperatorCondition{ + Type: operatorv1.OperatorStatusTypeProgressing, + Status: operatorv1.ConditionTrue, + Message: fmt.Sprintf("%d of %d nodes are at revision %d, %d are not", len(newStatus.NodeStatuses)-numProgressing, len(newStatus.NodeStatuses), newStatus.LatestAvailableRevision, numProgressing), + }) + } else { + v1helpers.SetOperatorCondition(&newStatus.Conditions, operatorv1.OperatorCondition{ + Type: operatorv1.OperatorStatusTypeProgressing, + Status: operatorv1.ConditionFalse, + Reason: "AllNodesAtLatestRevision", + Message: fmt.Sprintf("%d of %d nodes are at revision %d", len(newStatus.NodeStatuses)-numProgressing, len(newStatus.NodeStatuses), newStatus.LatestAvailableRevision), + }) + } + + return nil } // newNodeStateForInstallInProgress returns the new NodeState or error @@ -362,33 +429,32 @@ func getInstallerPodName(revision int32, nodeName string) string { // ensureInstallerPod creates the installer pod with the secrets required to if it does not exist already func (c *InstallerController) ensureInstallerPod(nodeName string, operatorSpec *operatorv1.OperatorSpec, revision int32) error { - required := resourceread.ReadPodV1OrDie([]byte(installerPod)) - required.Name = getInstallerPodName(revision, nodeName) - required.Namespace = c.targetNamespace - required.Spec.NodeName = nodeName - required.Spec.Containers[0].Image = c.installerPodImageFn() - required.Spec.Containers[0].Command = c.command - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, - fmt.Sprintf("-v=%d", 4), + pod := resourceread.ReadPodV1OrDie(bindata.MustAsset(filepath.Join(manifestDir, manifestInstallerPodPath))) + + pod.Namespace = c.targetNamespace + pod.Name = getInstallerPodName(revision, nodeName) + pod.Spec.NodeName = nodeName + pod.Spec.Containers[0].Image = c.installerPodImageFn() + pod.Spec.Containers[0].Command = c.command + + args := []string{ + "-v=4", // TODO: Make this configurable? fmt.Sprintf("--revision=%d", revision), - fmt.Sprintf("--namespace=%s", c.targetNamespace), + fmt.Sprintf("--namespace=%s", pod.Namespace), fmt.Sprintf("--pod=%s", c.configMaps[0]), - fmt.Sprintf("--resource-dir=%s", "/etc/kubernetes/static-pod-resources"), - fmt.Sprintf("--pod-manifest-dir=%s", "/etc/kubernetes/manifests"), - ) + fmt.Sprintf("--resource-dir=%s", hostResourceDirDir), + fmt.Sprintf("--pod-manifest-dir=%s", hostPodManifestDir), + } for _, name := range c.configMaps { - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("--configmaps=%s", name)) + args = append(args, fmt.Sprintf("--configmaps=%s", name)) } for _, name := range c.secrets { - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("--secrets=%s", name)) - } - - if _, err := c.kubeClient.CoreV1().Pods(c.targetNamespace).Create(required); err != nil && !apierrors.IsAlreadyExists(err) { - glog.Errorf("failed to create pod on node %q for %s: %v", nodeName, resourceread.WritePodV1OrDie(required), err) - return err + args = append(args, fmt.Sprintf("--secrets=%s", name)) } + pod.Spec.Containers[0].Args = args - return nil + _, _, err := resourceapply.ApplyPod(c.kubeClient.CoreV1(), c.eventRecorder, pod) + return err } func getInstallerPodImageFromEnv() string { @@ -415,22 +481,23 @@ func (c InstallerController) sync() error { } err = syncErr + // update failing condition + cond := operatorv1.OperatorCondition{ + Type: operatorStatusInstallerControllerFailing, + Status: operatorv1.ConditionFalse, + } if err != nil { - v1helpers.SetOperatorCondition(&operatorStatus.Conditions, operatorv1.OperatorCondition{ - Type: operatorv1.OperatorStatusTypeFailing, - Status: operatorv1.ConditionTrue, - Reason: "StatusUpdateError", - Message: err.Error(), - }) - if !reflect.DeepEqual(originalOperatorStatus, operatorStatus) { - if _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus); updateError != nil { - glog.Error(updateError) - } + cond.Status = operatorv1.ConditionTrue + cond.Reason = "Error" + cond.Message = err.Error() + } + if _, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond), setAvailableProgressingConditions); updateError != nil { + if err == nil { + return updateError } - return err } - return nil + return err } // Run starts the kube-apiserver and blocks until stopCh is closed. @@ -483,32 +550,3 @@ func (c *InstallerController) eventHandler() cache.ResourceEventHandler { func mirrorPodNameForNode(staticPodName, nodeName string) string { return staticPodName + "-" + nodeName } - -const installerPod = `apiVersion: v1 -kind: Pod -metadata: - namespace: - name: installer-- - labels: - app: installer -spec: - serviceAccountName: installer-sa - containers: - - name: installer - image: ${IMAGE} - imagePullPolicy: Always - securityContext: - privileged: true - runAsUser: 0 - terminationMessagePolicy: FallbackToLogsOnError - volumeMounts: - - mountPath: /etc/kubernetes/ - name: kubelet-dir - restartPolicy: Never - securityContext: - runAsUser: 0 - volumes: - - hostPath: - path: /etc/kubernetes/ - name: kubelet-dir -` diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller_test.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller_test.go index 1c1b87075..98af22b87 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller_test.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/installer_controller_test.go @@ -2,6 +2,7 @@ package installer import ( "fmt" + "reflect" "strconv" "strings" "testing" @@ -13,12 +14,15 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" ktesting "k8s.io/client-go/testing" + "k8s.io/client-go/util/workqueue" operatorv1 "github.com/openshift/api/operator/v1" "github.com/openshift/library-go/pkg/operator/events" "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" + "github.com/openshift/library-go/pkg/operator/v1helpers" ) func TestNewNodeStateForInstallInProgress(t *testing.T) { @@ -55,12 +59,12 @@ func TestNewNodeStateForInstallInProgress(t *testing.T) { ) eventRecorder := events.NewRecorder(kubeClient.CoreV1().Events("test"), "test-operator", &v1.ObjectReference{}) - + podCommand := []string{"/bin/true", "--foo=test", "--bar"} c := NewInstallerController( "test", "test-pod", []string{"test-config"}, []string{"test-secret"}, - []string{"/bin/true"}, + podCommand, kubeInformers, fakeStaticPodOperatorClient, kubeClient, @@ -91,6 +95,29 @@ func TestNewNodeStateForInstallInProgress(t *testing.T) { t.Fatalf("expected to create installer pod") } + t.Run("VerifyPodCommand", func(t *testing.T) { + cmd := installerPod.Spec.Containers[0].Command + if !reflect.DeepEqual(podCommand, cmd) { + t.Errorf("expected pod command %#v to match resulting installer pod command: %#v", podCommand, cmd) + } + }) + + t.Run("VerifyPodArguments", func(t *testing.T) { + args := installerPod.Spec.Containers[0].Args + if len(args) == 0 { + t.Errorf("pod args should not be empty") + } + foundRevision := false + for _, arg := range args { + if arg == "--revision=1" { + foundRevision = true + } + } + if !foundRevision { + t.Errorf("revision installer argument not found") + } + }) + t.Log("synching again, nothing happens") if err := c.sync(); err != nil { t.Fatal(err) @@ -188,6 +215,13 @@ func TestNewNodeStateForInstallInProgress(t *testing.T) { } else { t.Errorf("expected errors to be not empty") } + + if v1helpers.FindOperatorCondition(currStatus.Conditions, operatorv1.OperatorStatusTypeProgressing) == nil { + t.Error("missing Progressing") + } + if v1helpers.FindOperatorCondition(currStatus.Conditions, operatorv1.OperatorStatusTypeAvailable) == nil { + t.Error("missing Available") + } } func getPodsReactor(pods ...*v1.Pod) ktesting.ReactionFunc { @@ -432,7 +466,7 @@ func TestCreateInstallerPodMultiNode(t *testing.T) { }, } - for _, test := range tests { + for i, test := range tests { t.Run(test.name, func(t *testing.T) { createdInstallerPods := []*v1.Pod{} updatedStaticPods := map[string]*v1.Pod{} @@ -511,7 +545,7 @@ func TestCreateInstallerPodMultiNode(t *testing.T) { eventRecorder := events.NewRecorder(kubeClient.CoreV1().Events("test"), "test-operator", &v1.ObjectReference{}) c := NewInstallerController( - "test-"+test.name, "test-pod", + fmt.Sprintf("test-%d", i), "test-pod", []string{"test-config"}, []string{"test-secret"}, []string{"/bin/true"}, @@ -553,3 +587,278 @@ func TestCreateInstallerPodMultiNode(t *testing.T) { } } + +func TestInstallerController_manageInstallationPods(t *testing.T) { + type fields struct { + targetNamespace string + staticPodName string + configMaps []string + secrets []string + command []string + operatorConfigClient common.OperatorClient + kubeClient kubernetes.Interface + eventRecorder events.Recorder + queue workqueue.RateLimitingInterface + installerPodImageFn func() string + } + type args struct { + operatorSpec *operatorv1.OperatorSpec + originalOperatorStatus *operatorv1.StaticPodOperatorStatus + resourceVersion string + } + tests := []struct { + name string + fields fields + args args + want bool + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := &InstallerController{ + targetNamespace: tt.fields.targetNamespace, + staticPodName: tt.fields.staticPodName, + configMaps: tt.fields.configMaps, + secrets: tt.fields.secrets, + command: tt.fields.command, + operatorConfigClient: tt.fields.operatorConfigClient, + kubeClient: tt.fields.kubeClient, + eventRecorder: tt.fields.eventRecorder, + queue: tt.fields.queue, + installerPodImageFn: tt.fields.installerPodImageFn, + } + got, err := c.manageInstallationPods(tt.args.operatorSpec, tt.args.originalOperatorStatus, tt.args.resourceVersion) + if (err != nil) != tt.wantErr { + t.Errorf("InstallerController.manageInstallationPods() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("InstallerController.manageInstallationPods() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestNodeToStartRevisionWith(t *testing.T) { + type StaticPod struct { + name string + state staticPodState + revision int32 + } + type Test struct { + name string + nodes []operatorv1.NodeStatus + pods []StaticPod + expected int + expectedErr bool + } + + newNode := func(name string, current, target int32) operatorv1.NodeStatus { + return operatorv1.NodeStatus{NodeName: name, CurrentRevision: current, TargetRevision: target} + } + + for _, test := range []Test{ + { + name: "empty", + expectedErr: true, + }, + { + name: "no pods", + pods: nil, + nodes: []operatorv1.NodeStatus{ + newNode("a", 0, 0), + newNode("b", 0, 0), + newNode("c", 0, 0), + }, + expected: 0, + }, + { + name: "all ready", + pods: []StaticPod{ + {"a", staticPodStateReady, 1}, + {"b", staticPodStateReady, 1}, + {"c", staticPodStateReady, 1}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 1, 0), + newNode("b", 1, 0), + newNode("c", 1, 0), + }, + expected: 0, + }, + { + name: "one failed", + pods: []StaticPod{ + {"a", staticPodStateReady, 1}, + {"b", staticPodStateReady, 1}, + {"c", staticPodStateFailed, 1}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 1, 0), + newNode("b", 1, 0), + newNode("c", 1, 0), + }, + expected: 2, + }, + { + name: "one pending", + pods: []StaticPod{ + {"a", staticPodStateReady, 1}, + {"b", staticPodStateReady, 1}, + {"c", staticPodStatePending, 1}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 1, 0), + newNode("b", 1, 0), + newNode("c", 0, 0), + }, + expected: 2, + }, + { + name: "multiple pending", + pods: []StaticPod{ + {"a", staticPodStateReady, 1}, + {"b", staticPodStatePending, 1}, + {"c", staticPodStatePending, 1}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 1, 0), + newNode("b", 0, 0), + newNode("c", 0, 0), + }, + expected: 1, + }, + { + name: "one updating", + pods: []StaticPod{ + {"a", staticPodStateReady, 1}, + {"b", staticPodStatePending, 0}, + {"c", staticPodStateReady, 0}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 1, 0), + newNode("b", 0, 1), + newNode("c", 0, 0), + }, + expected: 1, + }, + { + name: "pods missing", + pods: []StaticPod{ + {"a", staticPodStateReady, 1}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 1, 0), + newNode("b", 0, 0), + newNode("c", 0, 0), + }, + expected: 1, + }, + { + name: "one old", + pods: []StaticPod{ + {"a", staticPodStateReady, 2}, + {"b", staticPodStateReady, 1}, + {"c", staticPodStateReady, 2}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 2, 0), + newNode("b", 2, 0), + newNode("c", 2, 0), + }, + expected: 1, + }, + { + name: "one behind, but as stated", + pods: []StaticPod{ + {"a", staticPodStateReady, 2}, + {"b", staticPodStateReady, 1}, + {"c", staticPodStateReady, 2}, + }, + nodes: []operatorv1.NodeStatus{ + newNode("a", 2, 0), + newNode("b", 1, 0), + newNode("c", 2, 0), + }, + expected: 0, + }, + } { + t.Run(test.name, func(t *testing.T) { + fakeGetStaticPodState := func(nodeName string) (state staticPodState, revision string, errs []string, err error) { + for _, p := range test.pods { + if p.name == nodeName { + return p.state, strconv.Itoa(int(p.revision)), nil, nil + } + } + return staticPodStatePending, "", nil, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, nodeName) + } + i, err := nodeToStartRevisionWith(fakeGetStaticPodState, test.nodes) + if err == nil && test.expectedErr { + t.Fatalf("expected error, got none") + } + if err != nil && !test.expectedErr { + t.Fatalf("unexpected error: %v", err) + } + if i != test.expected { + t.Errorf("expected node ID %d, got %d", test.expected, i) + } + }) + } +} + +func TestSetConditions(t *testing.T) { + + type TestCase struct { + name string + latestAvailableRevision int32 + currentRevisions []int32 + expectedAvailableStatus operatorv1.ConditionStatus + expectedPendingStatus operatorv1.ConditionStatus + } + + testCase := func(name string, available, pending bool, latest int32, current ...int32) TestCase { + availableStatus := operatorv1.ConditionFalse + pendingStatus := operatorv1.ConditionFalse + if available { + availableStatus = operatorv1.ConditionTrue + } + if pending { + pendingStatus = operatorv1.ConditionTrue + } + return TestCase{name, latest, current, availableStatus, pendingStatus} + } + + testCases := []TestCase{ + testCase("AvailablePending", true, true, 2, 2, 1, 2, 1), + testCase("AvailableNotPending", true, false, 2, 2, 2, 2), + testCase("NotAvailablePending", false, true, 2, 1, 1), + testCase("NotAvailableNotPending", false, false, 2), + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + status := &operatorv1.StaticPodOperatorStatus{ + LatestAvailableRevision: tc.latestAvailableRevision, + } + for _, current := range tc.currentRevisions { + status.NodeStatuses = append(status.NodeStatuses, operatorv1.NodeStatus{CurrentRevision: current}) + } + setAvailableProgressingConditions(status) + availableCondition := v1helpers.FindOperatorCondition(status.Conditions, operatorv1.OperatorStatusTypeAvailable) + if availableCondition == nil { + t.Error("Available condition: not found") + } else if availableCondition.Status != tc.expectedAvailableStatus { + t.Errorf("Available condition: expected status %v, actual status %v", tc.expectedAvailableStatus, availableCondition.Status) + } + pendingCondition := v1helpers.FindOperatorCondition(status.Conditions, operatorv1.OperatorStatusTypeProgressing) + if pendingCondition == nil { + t.Error("Pending condition: not found") + } else if pendingCondition.Status != tc.expectedPendingStatus { + t.Errorf("Pending condition: expected status %v, actual status %v", tc.expectedPendingStatus, pendingCondition.Status) + } + }) + } + +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/manifests/installer-pod.yaml b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/manifests/installer-pod.yaml new file mode 100644 index 000000000..2966a5796 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/installer/manifests/installer-pod.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Pod +metadata: + namespace: # Value set by operator + name: # Value set by operator + labels: + app: installer +spec: + serviceAccountName: installer-sa + nodeName: # Value set by operator + containers: + - name: installer + command: # Value set by operator + args: # Value set by operator + image: # Value set by operator + imagePullPolicy: Always + securityContext: + privileged: true + runAsUser: 0 + terminationMessagePolicy: FallbackToLogsOnError + volumeMounts: + - mountPath: /etc/kubernetes/ + name: kubelet-dir + restartPolicy: Never + securityContext: + runAsUser: 0 + volumes: + - hostPath: + path: /etc/kubernetes/ + name: kubelet-dir \ No newline at end of file diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/bindata/bindata.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/bindata/bindata.go new file mode 100644 index 000000000..70489277c --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/bindata/bindata.go @@ -0,0 +1,314 @@ +// Code generated by go-bindata. +// sources: +// pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role-binding.yaml +// pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role.yaml +// pkg/operator/staticpod/controller/monitoring/manifests/service-monitor.yaml +// DO NOT EDIT! + +package bindata + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleBindingYaml = []byte(`apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: prometheus-k8s + namespace: {{ .TargetNamespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: prometheus-k8s +subjects: + - kind: ServiceAccount + name: prometheus-k8s + namespace: openshift-monitoring`) + +func pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleBindingYamlBytes() ([]byte, error) { + return _pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleBindingYaml, nil +} + +func pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleBindingYaml() (*asset, error) { + bytes, err := pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleBindingYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role-binding.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleYaml = []byte(`apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + # TODO this should be a clusterrole + name: prometheus-k8s + namespace: {{ .TargetNamespace }} +rules: + - apiGroups: + - "" + resources: + - services + - endpoints + - pods + verbs: + - get + - list + - watch`) + +func pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleYamlBytes() ([]byte, error) { + return _pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleYaml, nil +} + +func pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleYaml() (*asset, error) { + bytes, err := pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _pkgOperatorStaticpodControllerMonitoringManifestsServiceMonitorYaml = []byte(`apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: monitor + namespace: {{ .TargetNamespace }} +spec: + endpoints: + - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token + interval: 30s + metricRelabelings: + - action: drop + regex: etcd_(debugging|disk|request|server).* + sourceLabels: + - __name__ + port: https + scheme: https + tlsConfig: + caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt + serverName: apiserver.{{ .TargetNamespace }}.svc + jobLabel: component + namespaceSelector: + matchNames: + - {{ .TargetNamespace }} + selector: + matchLabels: + app: {{ .TargetNamespace }}`) + +func pkgOperatorStaticpodControllerMonitoringManifestsServiceMonitorYamlBytes() ([]byte, error) { + return _pkgOperatorStaticpodControllerMonitoringManifestsServiceMonitorYaml, nil +} + +func pkgOperatorStaticpodControllerMonitoringManifestsServiceMonitorYaml() (*asset, error) { + bytes, err := pkgOperatorStaticpodControllerMonitoringManifestsServiceMonitorYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "pkg/operator/staticpod/controller/monitoring/manifests/service-monitor.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role-binding.yaml": pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleBindingYaml, + "pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role.yaml": pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleYaml, + "pkg/operator/staticpod/controller/monitoring/manifests/service-monitor.yaml": pkgOperatorStaticpodControllerMonitoringManifestsServiceMonitorYaml, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} + +var _bintree = &bintree{nil, map[string]*bintree{ + "pkg": {nil, map[string]*bintree{ + "operator": {nil, map[string]*bintree{ + "staticpod": {nil, map[string]*bintree{ + "controller": {nil, map[string]*bintree{ + "monitoring": {nil, map[string]*bintree{ + "manifests": {nil, map[string]*bintree{ + "prometheus-role-binding.yaml": {pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleBindingYaml, map[string]*bintree{}}, + "prometheus-role.yaml": {pkgOperatorStaticpodControllerMonitoringManifestsPrometheusRoleYaml, map[string]*bintree{}}, + "service-monitor.yaml": {pkgOperatorStaticpodControllerMonitoringManifestsServiceMonitorYaml, map[string]*bintree{}}, + }}, + }}, + }}, + }}, + }}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role-binding.yaml b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role-binding.yaml new file mode 100644 index 000000000..2b3289912 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role-binding.yaml @@ -0,0 +1,13 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: prometheus-k8s + namespace: {{ .TargetNamespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: prometheus-k8s +subjects: + - kind: ServiceAccount + name: prometheus-k8s + namespace: openshift-monitoring \ No newline at end of file diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role.yaml b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role.yaml new file mode 100644 index 000000000..55957ab8e --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/prometheus-role.yaml @@ -0,0 +1,17 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + # TODO this should be a clusterrole + name: prometheus-k8s + namespace: {{ .TargetNamespace }} +rules: + - apiGroups: + - "" + resources: + - services + - endpoints + - pods + verbs: + - get + - list + - watch \ No newline at end of file diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/service-monitor.yaml b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/service-monitor.yaml new file mode 100644 index 000000000..17f93e2c6 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/manifests/service-monitor.yaml @@ -0,0 +1,26 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: monitor + namespace: {{ .TargetNamespace }} +spec: + endpoints: + - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token + interval: 30s + metricRelabelings: + - action: drop + regex: etcd_(debugging|disk|request|server).* + sourceLabels: + - __name__ + port: https + scheme: https + tlsConfig: + caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt + serverName: apiserver.{{ .TargetNamespace }}.svc + jobLabel: component + namespaceSelector: + matchNames: + - {{ .TargetNamespace }} + selector: + matchLabels: + app: {{ .TargetNamespace }} \ No newline at end of file diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/monitoring_resource_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/monitoring_resource_controller.go new file mode 100644 index 000000000..a6f77e5b1 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/monitoring_resource_controller.go @@ -0,0 +1,199 @@ +package monitoring + +import ( + "fmt" + "path/filepath" + "time" + + "github.com/golang/glog" + + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes" + corelisterv1 "k8s.io/client-go/listers/core/v1" + rbaclisterv1 "k8s.io/client-go/listers/rbac/v1" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" + + operatorv1 "github.com/openshift/api/operator/v1" + "github.com/openshift/library-go/pkg/assets" + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/resource/resourceapply" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/bindata" +) + +const ( + operatorStatusMonitoringResourceControllerFailing = "MonitoringResourceControllerFailing" + controllerWorkQueueKey = "key" + manifestDir = "pkg/operator/staticpod/controller/monitoring" +) + +type MonitoringResourceController struct { + targetNamespace string + serviceMonitorName string + + saListerSynced cache.InformerSynced + saLister corelisterv1.ServiceAccountLister + + clusterRoleBindingLister rbaclisterv1.ClusterRoleBindingLister + clusterRoleBindingListerSynced cache.InformerSynced + + // queue only ever has one item, but it has nice error handling backoff/retry semantics + queue workqueue.RateLimitingInterface + + kubeClient kubernetes.Interface + dynamicClient dynamic.Interface + operatorConfigClient common.OperatorClient + eventRecorder events.Recorder +} + +// NewMonitoringResourceController creates a new backing resource controller. +func NewMonitoringResourceController( + targetNamespace string, + serviceMonitorName string, + operatorConfigClient common.OperatorClient, + kubeInformersForTargetNamespace informers.SharedInformerFactory, + kubeClient kubernetes.Interface, + dynamicClient dynamic.Interface, + eventRecorder events.Recorder, +) *MonitoringResourceController { + c := &MonitoringResourceController{ + targetNamespace: targetNamespace, + operatorConfigClient: operatorConfigClient, + eventRecorder: eventRecorder, + serviceMonitorName: serviceMonitorName, + + clusterRoleBindingListerSynced: kubeInformersForTargetNamespace.Core().V1().ServiceAccounts().Informer().HasSynced, + clusterRoleBindingLister: kubeInformersForTargetNamespace.Rbac().V1().ClusterRoleBindings().Lister(), + + queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "MonitoringResourceController"), + kubeClient: kubeClient, + dynamicClient: dynamicClient, + } + + operatorConfigClient.Informer().AddEventHandler(c.eventHandler()) + + // TODO: We need a dynamic informer here to observe changes to ServiceMonitor resource. + + kubeInformersForTargetNamespace.Rbac().V1().ClusterRoleBindings().Informer().AddEventHandler(c.eventHandler()) + return c +} + +func (c MonitoringResourceController) mustTemplateAsset(name string) ([]byte, error) { + config := struct { + TargetNamespace string + }{ + TargetNamespace: c.targetNamespace, + } + return assets.MustCreateAssetFromTemplate(name, bindata.MustAsset(filepath.Join(manifestDir, name)), config).Data, nil +} + +func (c MonitoringResourceController) sync() error { + operatorSpec, _, _, err := c.operatorConfigClient.Get() + if err != nil { + return err + } + + switch operatorSpec.ManagementState { + case operatorv1.Unmanaged: + return nil + case operatorv1.Removed: + // TODO: Should we try to actively remove the resources created by this controller here? + return nil + } + + directResourceResults := resourceapply.ApplyDirectly(c.kubeClient, c.eventRecorder, c.mustTemplateAsset, + "manifests/prometheus-role.yaml", + "manifests/prometheus-role-binding.yaml", + ) + + errs := []error{} + for _, currResult := range directResourceResults { + if currResult.Error != nil { + errs = append(errs, fmt.Errorf("%q (%T): %v", currResult.File, currResult.Type, currResult.Error)) + } + } + + serviceMonitorBytes, err := c.mustTemplateAsset("manifests/service-monitor.yaml") + if err != nil { + errs = append(errs, fmt.Errorf("manifests/service-monitor.yaml: %v", err)) + } else { + _, serviceMonitorErr := resourceapply.ApplyServiceMonitor(c.dynamicClient, c.eventRecorder, serviceMonitorBytes) + errs = append(errs, serviceMonitorErr) + } + + err = common.NewMultiLineAggregate(errs) + + // NOTE: Failing to create the monitoring resources should not lead to operator failed state. + cond := operatorv1.OperatorCondition{ + Type: operatorStatusMonitoringResourceControllerFailing, + Status: operatorv1.ConditionFalse, + } + if err != nil { + cond.Status = operatorv1.ConditionTrue + cond.Reason = "Error" + cond.Message = err.Error() + } + if _, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond)); updateError != nil { + if err == nil { + return updateError + } + } + + return err +} + +func (c *MonitoringResourceController) Run(workers int, stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + defer c.queue.ShutDown() + + glog.Infof("Starting MonitoringResourceController") + defer glog.Infof("Shutting down MonitoringResourceController") + if !cache.WaitForCacheSync(stopCh, c.saListerSynced) { + return + } + if !cache.WaitForCacheSync(stopCh, c.clusterRoleBindingListerSynced) { + return + } + + // doesn't matter what workers say, only start one. + go wait.Until(c.runWorker, time.Second, stopCh) + + <-stopCh +} + +func (c *MonitoringResourceController) runWorker() { + for c.processNextWorkItem() { + } +} + +func (c *MonitoringResourceController) processNextWorkItem() bool { + dsKey, quit := c.queue.Get() + if quit { + return false + } + defer c.queue.Done(dsKey) + + err := c.sync() + if err == nil { + c.queue.Forget(dsKey) + return true + } + + utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err)) + c.queue.AddRateLimited(dsKey) + + return true +} + +// eventHandler queues the operator to check spec and status +func (c *MonitoringResourceController) eventHandler() cache.ResourceEventHandler { + return cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { c.queue.Add(controllerWorkQueueKey) }, + UpdateFunc: func(old, new interface{}) { c.queue.Add(controllerWorkQueueKey) }, + DeleteFunc: func(obj interface{}) { c.queue.Add(controllerWorkQueueKey) }, + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/monitoring_resource_controller_test.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/monitoring_resource_controller_test.go new file mode 100644 index 000000000..3ec00c434 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/monitoring_resource_controller_test.go @@ -0,0 +1,146 @@ +package monitoring + +import ( + "path/filepath" + "testing" + "time" + + "github.com/ghodss/yaml" + "github.com/openshift/library-go/pkg/operator/events" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + dynamicfake "k8s.io/client-go/dynamic/fake" + "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes/fake" + clienttesting "k8s.io/client-go/testing" + + operatorv1 "github.com/openshift/api/operator/v1" + "github.com/openshift/library-go/pkg/assets" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring/bindata" +) + +func mustAssetServiceMonitor(namespace string) runtime.Object { + config := struct { + TargetNamespace string + }{ + TargetNamespace: namespace, + } + monitorBytes := assets.MustCreateAssetFromTemplate("manifests/service-monitor.yaml", bindata.MustAsset(filepath.Join(manifestDir, "manifests/service-monitor.yaml")), config).Data + monitorJSON, err := yaml.YAMLToJSON(monitorBytes) + if err != nil { + panic(err) + } + monitorObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, monitorJSON) + if err != nil { + panic(err) + } + required, ok := monitorObj.(*unstructured.Unstructured) + if !ok { + panic("unexpected object") + } + return required +} + +func TestNewMonitoringResourcesController(t *testing.T) { + tests := []struct { + name string + startingObjects []runtime.Object + startingDynamicObjects []runtime.Object + staticPodOperatorClient common.OperatorClient + validateActions func(t *testing.T, actions []clienttesting.Action) + validateDynamicActions func(t *testing.T, actions []clienttesting.Action) + validateStatus func(t *testing.T, status *operatorv1.StaticPodOperatorStatus) + expectSyncError string + }{ + { + name: "create when not exists", + staticPodOperatorClient: common.NewFakeStaticPodOperatorClient( + &operatorv1.OperatorSpec{ + ManagementState: operatorv1.Managed, + }, + &operatorv1.OperatorStatus{}, + &operatorv1.StaticPodOperatorStatus{}, + nil, + ), + validateActions: func(t *testing.T, actions []clienttesting.Action) { + if len(actions) != 4 { + t.Errorf("expected 4 actions, got %d", len(actions)) + } + if actions[1].GetVerb() != "create" || actions[1].GetResource().Resource != "roles" { + t.Errorf("expected to create service monitor (%+v)", actions[1]) + } + }, + validateDynamicActions: func(t *testing.T, actions []clienttesting.Action) { + if len(actions) != 2 { + t.Errorf("expected 2 actions, got %d", len(actions)) + } + if actions[1].GetVerb() != "create" || actions[1].GetResource().Resource != "servicemonitors" { + t.Errorf("expected to create service monitor (%+v)", actions[1]) + } + serviceMonitor := actions[1].(clienttesting.CreateAction).GetObject().(*unstructured.Unstructured) + if serviceMonitor.GetNamespace() != "target-namespace" { + t.Errorf("expected 'target-namespace', got %s", serviceMonitor.GetNamespace()) + } + }, + }, + { + name: "skip when exists", + staticPodOperatorClient: common.NewFakeStaticPodOperatorClient( + &operatorv1.OperatorSpec{ + ManagementState: operatorv1.Managed, + }, + &operatorv1.OperatorStatus{}, + &operatorv1.StaticPodOperatorStatus{}, + nil, + ), + startingDynamicObjects: []runtime.Object{mustAssetServiceMonitor("target-namespace")}, + validateActions: func(t *testing.T, actions []clienttesting.Action) {}, + validateDynamicActions: func(t *testing.T, actions []clienttesting.Action) { + if len(actions) != 1 { + t.Errorf("expected 1 action, got %d (%#v)", len(actions), actions) + } + }, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + kubeClient := fake.NewSimpleClientset(tc.startingObjects...) + eventRecorder := events.NewInMemoryRecorder("") + + dynamicScheme := runtime.NewScheme() + dynamicScheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "monitoring.coreos.com", Version: "v1", Kind: "ServiceMonitor"}, &unstructured.Unstructured{}) + + dynamicClient := dynamicfake.NewSimpleDynamicClient(dynamicScheme, tc.startingDynamicObjects...) + + c := NewMonitoringResourceController( + "target-namespace", + "openshift-monitoring", + tc.staticPodOperatorClient, + informers.NewSharedInformerFactoryWithOptions(kubeClient, 1*time.Minute, informers.WithNamespace("target-namespace")), + kubeClient, + dynamicClient, + eventRecorder, + ) + + syncErr := c.sync() + if len(tc.expectSyncError) > 0 && syncErr == nil { + t.Errorf("expected %q error", tc.expectSyncError) + return + } + if len(tc.expectSyncError) > 0 && syncErr != nil && syncErr.Error() != tc.expectSyncError { + t.Errorf("expected %q error, got %q", tc.expectSyncError, syncErr.Error()) + return + } + if syncErr != nil { + t.Errorf("unexpected sync error: %v", syncErr) + return + } + + tc.validateActions(t, kubeClient.Actions()) + tc.validateDynamicActions(t, dynamicClient.Actions()) + }) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/node/node_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/node/node_controller.go index 0ff403252..54e060d0f 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/node/node_controller.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/node/node_controller.go @@ -2,11 +2,11 @@ package node import ( "fmt" - "reflect" "time" "github.com/golang/glog" + "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -23,7 +23,7 @@ import ( const nodeControllerWorkQueueKey = "key" -// NodeController watches for new master nodes and adds them to the list for an operator +// NodeController watches for new master nodes and adds them to the node status list in the operator config status. type NodeController struct { operatorConfigClient common.OperatorClient eventRecorder events.Recorder @@ -35,6 +35,7 @@ type NodeController struct { queue workqueue.RateLimitingInterface } +// NewNodeController creates a new node controller. func NewNodeController( operatorConfigClient common.OperatorClient, kubeInformersClusterScoped informers.SharedInformerFactory, @@ -102,11 +103,12 @@ func (c NodeController) sync() error { c.eventRecorder.Eventf("MasterNodeObserved", "Observed new master node %s", node.Name) newTargetNodeStates = append(newTargetNodeStates, operatorv1.NodeStatus{NodeName: node.Name}) } - operatorStatus.NodeStatuses = newTargetNodeStates - if !reflect.DeepEqual(originalOperatorStatus, operatorStatus) { - _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus) - return updateError + operatorStatus.NodeStatuses = newTargetNodeStates + if !equality.Semantic.DeepEqual(originalOperatorStatus, operatorStatus) { + if _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus); updateError != nil { + return updateError + } } return nil diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/bindata/bindata.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/bindata/bindata.go new file mode 100644 index 000000000..ca47815f7 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/bindata/bindata.go @@ -0,0 +1,251 @@ +// Code generated by go-bindata. +// sources: +// pkg/operator/staticpod/controller/prune/manifests/pruner-pod.yaml +// DO NOT EDIT! + +package bindata + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +func (fi bindataFileInfo) Name() string { + return fi.name +} +func (fi bindataFileInfo) Size() int64 { + return fi.size +} +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} +func (fi bindataFileInfo) IsDir() bool { + return false +} +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _pkgOperatorStaticpodControllerPruneManifestsPrunerPodYaml = []byte(`apiVersion: v1 +kind: Pod +metadata: + namespace: # Value set by operator + name: # Value set by operator + labels: + app: pruner +spec: + serviceAccountName: installer-sa + nodeName: # Value set by operator + containers: + - name: pruner + command: # Value set by operator + args: # Value set by operator + image: # Value set by operator + imagePullPolicy: Always + securityContext: + privileged: true + runAsUser: 0 + terminationMessagePolicy: FallbackToLogsOnError + volumeMounts: + - mountPath: /etc/kubernetes/ + name: kubelet-dir + restartPolicy: Never + securityContext: + runAsUser: 0 + volumes: + - hostPath: + path: /etc/kubernetes/ + name: kubelet-dir +`) + +func pkgOperatorStaticpodControllerPruneManifestsPrunerPodYamlBytes() ([]byte, error) { + return _pkgOperatorStaticpodControllerPruneManifestsPrunerPodYaml, nil +} + +func pkgOperatorStaticpodControllerPruneManifestsPrunerPodYaml() (*asset, error) { + bytes, err := pkgOperatorStaticpodControllerPruneManifestsPrunerPodYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "pkg/operator/staticpod/controller/prune/manifests/pruner-pod.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "pkg/operator/staticpod/controller/prune/manifests/pruner-pod.yaml": pkgOperatorStaticpodControllerPruneManifestsPrunerPodYaml, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} + +var _bintree = &bintree{nil, map[string]*bintree{ + "pkg": {nil, map[string]*bintree{ + "operator": {nil, map[string]*bintree{ + "staticpod": {nil, map[string]*bintree{ + "controller": {nil, map[string]*bintree{ + "prune": {nil, map[string]*bintree{ + "manifests": {nil, map[string]*bintree{ + "pruner-pod.yaml": {pkgOperatorStaticpodControllerPruneManifestsPrunerPodYaml, map[string]*bintree{}}, + }}, + }}, + }}, + }}, + }}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/manifests/pruner-pod.yaml b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/manifests/pruner-pod.yaml new file mode 100644 index 000000000..89d9a167f --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/manifests/pruner-pod.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Pod +metadata: + namespace: # Value set by operator + name: # Value set by operator + labels: + app: pruner +spec: + serviceAccountName: installer-sa + nodeName: # Value set by operator + containers: + - name: pruner + command: # Value set by operator + args: # Value set by operator + image: # Value set by operator + imagePullPolicy: Always + securityContext: + privileged: true + runAsUser: 0 + terminationMessagePolicy: FallbackToLogsOnError + volumeMounts: + - mountPath: /etc/kubernetes/ + name: kubelet-dir + restartPolicy: Never + securityContext: + runAsUser: 0 + volumes: + - hostPath: + path: /etc/kubernetes/ + name: kubelet-dir diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/prune_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/prune_controller.go new file mode 100644 index 000000000..67e6c9299 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/prune_controller.go @@ -0,0 +1,240 @@ +package prune + +import ( + "fmt" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "time" + + "github.com/golang/glog" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" + + operatorv1 "github.com/openshift/api/operator/v1" + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/resource/resourceapply" + "github.com/openshift/library-go/pkg/operator/resource/resourceread" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/bindata" +) + +// PruneController is a controller that watches static installer pod revision statuses and spawns +// a pruner pod to delete old revision resources from disk +type PruneController struct { + targetNamespace, podResourcePrefix string + failedRevisionLimit, succeededRevisionLimit int + + // command is the string to use for the pruning pod command + command []string + // queue only ever has one item, but it has nice error handling backoff/retry semantics + queue workqueue.RateLimitingInterface + // prunerPodImageFn returns the image name for the pruning pod + prunerPodImageFn func() string + + operatorConfigClient common.OperatorClient + + kubeClient kubernetes.Interface + eventRecorder events.Recorder +} + +const ( + pruneControllerWorkQueueKey = "key" + statusConfigMapName = "revision-status-" +) + +// NewPruneController creates a new pruning controller +func NewPruneController( + targetNamespace string, + podResourcePrefix string, + command []string, + kubeClient kubernetes.Interface, + operatorConfigClient common.OperatorClient, + eventRecorder events.Recorder, +) *PruneController { + c := &PruneController{ + targetNamespace: targetNamespace, + podResourcePrefix: podResourcePrefix, + command: command, + failedRevisionLimit: 5, + succeededRevisionLimit: 5, + + operatorConfigClient: operatorConfigClient, + kubeClient: kubeClient, + eventRecorder: eventRecorder, + + queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "PruneController"), + prunerPodImageFn: getPrunerPodImageFromEnv, + } + + operatorConfigClient.Informer().AddEventHandler(c.eventHandler()) + + return c +} + +func (c *PruneController) pruneRevisionHistory(operatorStatus *operatorv1.StaticPodOperatorStatus) error { + var succeededRevisionIDs, failedRevisionIDs []int + + configMaps, err := c.kubeClient.CoreV1().ConfigMaps(c.targetNamespace).List(metav1.ListOptions{}) + if err != nil { + return err + } + for _, configMap := range configMaps.Items { + if !strings.HasPrefix(configMap.Name, statusConfigMapName) { + continue + } + + if revision, ok := configMap.Data["revision"]; ok { + revisionID, err := strconv.Atoi(revision) + if err != nil { + return err + } + switch configMap.Data["phase"] { + case string(corev1.PodSucceeded): + succeededRevisionIDs = append(succeededRevisionIDs, revisionID) + case string(corev1.PodFailed): + failedRevisionIDs = append(failedRevisionIDs, revisionID) + default: + return fmt.Errorf("unknown pod status phase for revision %d: %v", revisionID, configMap.Data["phase"]) + } + } + } + + // Return early if nothing to prune + if len(succeededRevisionIDs)+len(failedRevisionIDs) == 0 { + return nil + } + + // Get list of protected IDs + protectedSucceededRevisionIDs := protectedIDs(succeededRevisionIDs, c.succeededRevisionLimit) + protectedFailedRevisionIDs := protectedIDs(failedRevisionIDs, c.failedRevisionLimit) + + excludedIDs := make([]int, 0, len(protectedSucceededRevisionIDs)+len(protectedFailedRevisionIDs)) + excludedIDs = append(excludedIDs, protectedSucceededRevisionIDs...) + excludedIDs = append(excludedIDs, protectedFailedRevisionIDs...) + sort.Ints(excludedIDs) + + // Run pruning pod on each node and pin it to that node + for _, nodeStatus := range operatorStatus.NodeStatuses { + if err := c.ensurePrunePod(nodeStatus.NodeName, excludedIDs[len(excludedIDs)-1], excludedIDs, nodeStatus.TargetRevision); err != nil { + return err + } + } + return nil +} + +func protectedIDs(revisionIDs []int, revisionLimit int) []int { + sort.Ints(revisionIDs) + if len(revisionIDs) == 0 { + return revisionIDs + } + return revisionIDs[protectedRevisionKeyToStart(len(revisionIDs), revisionLimit):] +} + +func protectedRevisionKeyToStart(length, limit int) int { + // 0 = default = unlimited revisions (ie, protect everything) + if limit == 0 || length < limit { + return 0 + } + return length - limit +} + +func (c *PruneController) ensurePrunePod(nodeName string, maxEligibleRevision int, protectedRevisions []int, revision int32) error { + pod := resourceread.ReadPodV1OrDie(bindata.MustAsset(filepath.Join("pkg/operator/staticpod/controller/prune", "manifests/pruner-pod.yaml"))) + + pod.Name = getPrunerPodName(nodeName, revision) + pod.Namespace = c.targetNamespace + pod.Spec.NodeName = nodeName + pod.Spec.Containers[0].Image = c.prunerPodImageFn() + pod.Spec.Containers[0].Command = c.command + pod.Spec.Containers[0].Args = append(pod.Spec.Containers[0].Args, + fmt.Sprintf("-v=%d", 4), + fmt.Sprintf("--max-eligible-id=%d", maxEligibleRevision), + fmt.Sprintf("--protected-ids=%s", revisionsToString(protectedRevisions)), + fmt.Sprintf("--resource-dir=%s", "/etc/kubernetes/static-pod-resources"), + fmt.Sprintf("--static-pod-name=%s", c.podResourcePrefix), + ) + + _, _, err := resourceapply.ApplyPod(c.kubeClient.CoreV1(), c.eventRecorder, pod) + return err +} + +func getPrunerPodName(nodeName string, revision int32) string { + return fmt.Sprintf("revision-pruner-%d-%s", revision, nodeName) +} + +func revisionsToString(revisions []int) string { + values := []string{} + for _, id := range revisions { + value := strconv.Itoa(id) + values = append(values, value) + } + return strings.Join(values, ",") +} + +func getPrunerPodImageFromEnv() string { + return os.Getenv("OPERATOR_IMAGE") +} + +func (c *PruneController) Run(workers int, stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + defer c.queue.ShutDown() + + glog.Infof("Starting PruneController") + defer glog.Infof("Shutting down PruneController") + + // doesn't matter what workers say, only start one. + go wait.Until(c.runWorker, time.Second, stopCh) + + <-stopCh +} + +func (c *PruneController) runWorker() { + for c.processNextWorkItem() { + } +} + +func (c *PruneController) processNextWorkItem() bool { + dsKey, quit := c.queue.Get() + if quit { + return false + } + defer c.queue.Done(dsKey) + + err := c.sync() + if err == nil { + c.queue.Forget(dsKey) + return true + } + + utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err)) + c.queue.AddRateLimited(dsKey) + + return true +} + +func (c *PruneController) sync() error { + _, operatorStatus, _, err := c.operatorConfigClient.Get() + if err != nil { + return err + } + + return c.pruneRevisionHistory(operatorStatus) +} + +// eventHandler queues the operator to check spec and status +func (c *PruneController) eventHandler() cache.ResourceEventHandler { + return cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { c.queue.Add(pruneControllerWorkQueueKey) }, + UpdateFunc: func(old, new interface{}) { c.queue.Add(pruneControllerWorkQueueKey) }, + DeleteFunc: func(obj interface{}) { c.queue.Add(pruneControllerWorkQueueKey) }, + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/prune_controller_test.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/prune_controller_test.go new file mode 100644 index 000000000..16e74386a --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/prune/prune_controller_test.go @@ -0,0 +1,249 @@ +package prune + +import ( + "fmt" + "testing" + + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/kubernetes/fake" + ktesting "k8s.io/client-go/testing" + + operatorv1 "github.com/openshift/api/operator/v1" + "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" +) + +type configMapInfo struct { + name string + namespace string + revision string + phase string +} + +func TestPruneRevisionHistory(t *testing.T) { + tests := []struct { + name string + failedLimit int + succeededLimit int + maxEligibleID int + protectedIDs string + configMaps []configMapInfo + expectedErr string + }{ + { + name: "creates prune pod appropriately", + configMaps: []configMapInfo{ + { + name: "revision-status-1", + namespace: "test", + revision: "1", + phase: string(v1.PodSucceeded), + }, + { + name: "revision-status-2", + namespace: "test", + revision: "2", + phase: string(v1.PodFailed), + }, + { + name: "revision-status-3", + namespace: "test", + revision: "3", + phase: string(v1.PodSucceeded), + }, + }, + maxEligibleID: 3, + protectedIDs: "2,3", + failedLimit: 1, + succeededLimit: 1, + }, + + { + name: "defaults to unlimited revision history", + configMaps: []configMapInfo{ + { + name: "revision-status-1", + namespace: "test", + revision: "1", + phase: string(v1.PodSucceeded), + }, + { + name: "revision-status-2", + namespace: "test", + revision: "2", + phase: string(v1.PodFailed), + }, + { + name: "revision-status-3", + namespace: "test", + revision: "3", + phase: string(v1.PodSucceeded), + }, + }, + maxEligibleID: 3, + protectedIDs: "1,2,3", + }, + + { + name: "returns an error for unknown revision status", + configMaps: []configMapInfo{ + { + name: "revision-status-1", + namespace: "test", + revision: "1", + phase: string(v1.PodSucceeded), + }, + { + name: "revision-status-2", + namespace: "test", + revision: "2", + phase: "garbage", + }, + }, + maxEligibleID: 2, + protectedIDs: "1,2", + expectedErr: "unknown pod status phase for revision 2: garbage", + }, + + { + name: "handles revisions of only one type of phase", + configMaps: []configMapInfo{ + { + name: "revision-status-1", + namespace: "test", + revision: "1", + phase: string(v1.PodSucceeded), + }, + { + name: "revision-status-2", + namespace: "test", + revision: "2", + phase: string(v1.PodSucceeded), + }, + }, + maxEligibleID: 2, + protectedIDs: "2", + failedLimit: 1, + succeededLimit: 1, + }, + } + + for _, test := range tests { + kubeClient := fake.NewSimpleClientset() + + var prunerPod *v1.Pod + kubeClient.PrependReactor("create", "pods", func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { + prunerPod = action.(ktesting.CreateAction).GetObject().(*v1.Pod) + return false, nil, nil + }) + kubeClient.PrependReactor("list", "configmaps", func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { + return true, configMapList(test.configMaps), nil + }) + + fakeStaticPodOperatorClient := common.NewFakeStaticPodOperatorClient( + &operatorv1.OperatorSpec{ + ManagementState: operatorv1.Managed, + }, + &operatorv1.OperatorStatus{}, + &operatorv1.StaticPodOperatorStatus{ + LatestAvailableRevision: 1, + NodeStatuses: []operatorv1.NodeStatus{ + { + NodeName: "test-node-1", + CurrentRevision: 0, + TargetRevision: 0, + }, + }, + }, + nil, + ) + eventRecorder := events.NewRecorder(kubeClient.CoreV1().Events("test"), "test-operator", &v1.ObjectReference{}) + + operatorStatus := &operatorv1.StaticPodOperatorStatus{ + LatestAvailableRevision: 1, + NodeStatuses: []operatorv1.NodeStatus{ + { + NodeName: "test-node-1", + CurrentRevision: 0, + TargetRevision: 0, + }, + }, + } + + c := &PruneController{ + targetNamespace: "test", + podResourcePrefix: "test-pod", + command: []string{"/bin/true"}, + kubeClient: kubeClient, + eventRecorder: eventRecorder, + operatorConfigClient: fakeStaticPodOperatorClient, + failedRevisionLimit: test.failedLimit, + succeededRevisionLimit: test.succeededLimit, + } + c.prunerPodImageFn = func() string { return "docker.io/foo/bar" } + + err := c.pruneRevisionHistory(operatorStatus) + if err != nil { + if err.Error() != test.expectedErr { + t.Errorf("expected error %v, got %v", test.expectedErr, err) + } + + if prunerPod != nil { + t.Fatalf("expected not to create installer pod") + } + continue + } + + if prunerPod == nil { + t.Fatalf("expected to create installer pod") + } + + if prunerPod.Spec.Containers[0].Image != "docker.io/foo/bar" { + t.Fatalf("expected docker.io/foo/bar image, got %q", prunerPod.Spec.Containers[0].Image) + } + + if prunerPod.Spec.Containers[0].Command[0] != "/bin/true" { + t.Fatalf("expected /bin/true as a command, got %q", prunerPod.Spec.Containers[0].Command[0]) + } + + expectedArgs := []string{ + "-v=4", + fmt.Sprintf("--max-eligible-id=%d", test.maxEligibleID), + fmt.Sprintf("--protected-ids=%s", test.protectedIDs), + fmt.Sprintf("--resource-dir=%s", "/etc/kubernetes/static-pod-resources"), + fmt.Sprintf("--static-pod-name=%s", "test-pod"), + } + + if len(expectedArgs) != len(prunerPod.Spec.Containers[0].Args) { + t.Fatalf("expected arguments does not match container arguments: %#v != %#v", expectedArgs, prunerPod.Spec.Containers[0].Args) + } + + for i, v := range prunerPod.Spec.Containers[0].Args { + if expectedArgs[i] != v { + t.Errorf("arg[%d] expected %q, got %q", i, expectedArgs[i], v) + } + } + + } +} + +func configMapList(configMaps []configMapInfo) *v1.ConfigMapList { + items := make([]v1.ConfigMap, 0, len(configMaps)) + for _, cm := range configMaps { + configMap := v1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: cm.name, + Namespace: cm.namespace, + }, + Data: map[string]string{ + "revision": cm.revision, + "phase": cm.phase, + }, + } + items = append(items, configMap) + } + + return &v1.ConfigMapList{Items: items} +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/revision/deployment_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/revision/deployment_controller.go index 774058c90..ea5532a19 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/revision/deployment_controller.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controller/revision/deployment_controller.go @@ -2,7 +2,6 @@ package revision import ( "fmt" - "reflect" "time" "github.com/golang/glog" @@ -23,11 +22,14 @@ import ( "github.com/openshift/library-go/pkg/operator/events" "github.com/openshift/library-go/pkg/operator/resource/resourceapply" "github.com/openshift/library-go/pkg/operator/staticpod/controller/common" - "github.com/openshift/library-go/pkg/operator/v1helpers" ) +const operatorStatusRevisionControllerFailing = "RevisionControllerFailing" const revisionControllerWorkQueueKey = "key" +// RevisionController is a controller that watches a set of configmaps and secrets and them against a revision snapshot +// of them. If the original resources changes, the revision counter is increased, stored in LatestAvailableRevision +// field of the operator config and new snapshots suffixed by the revision are created. type RevisionController struct { targetNamespace string // configMaps is the list of configmaps that are directly copied.A different actor/controller modifies these. @@ -46,6 +48,7 @@ type RevisionController struct { eventRecorder events.Recorder } +// NewRevisionController create a new revision controller. func NewRevisionController( targetNamespace string, configMaps []string, @@ -90,32 +93,29 @@ func (c RevisionController) createRevisionIfNeeded(operatorSpec *operatorv1.Oper nextRevision := latestRevision + 1 glog.Infof("new revision %d triggered by %q", nextRevision, reason) if err := c.createNewRevision(nextRevision); err != nil { - v1helpers.SetOperatorCondition(&operatorStatus.Conditions, operatorv1.OperatorCondition{ + cond := operatorv1.OperatorCondition{ Type: "RevisionControllerFailing", Status: operatorv1.ConditionTrue, Reason: "ContentCreationError", Message: err.Error(), - }) - if !reflect.DeepEqual(operatorStatusOriginal, operatorStatus) { - _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus) - if updateError != nil { - c.eventRecorder.Warningf("RevisionCreateFailed", "Failed to create revision %d: %v", nextRevision, err.Error()) - } + } + if _, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond)); updateError != nil { + c.eventRecorder.Warningf("RevisionCreateFailed", "Failed to create revision %d: %v", nextRevision, err.Error()) return true, updateError } return true, nil } - v1helpers.SetOperatorCondition(&operatorStatus.Conditions, operatorv1.OperatorCondition{ + cond := operatorv1.OperatorCondition{ Type: "RevisionControllerFailing", Status: operatorv1.ConditionFalse, - }) - operatorStatus.LatestAvailableRevision = nextRevision - if !reflect.DeepEqual(operatorStatusOriginal, operatorStatus) { - _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus) - if updateError != nil { - return true, updateError - } + } + if updated, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond), func(operatorStatus *operatorv1.StaticPodOperatorStatus) error { + operatorStatus.LatestAvailableRevision = nextRevision + return nil + }); updateError != nil { + return true, updateError + } else if updated { c.eventRecorder.Eventf("RevisionCreate", "Revision %d created because %s", operatorStatus.LatestAvailableRevision, reason) } @@ -202,22 +202,23 @@ func (c RevisionController) sync() error { } err = syncErr + // update failing condition + cond := operatorv1.OperatorCondition{ + Type: operatorStatusRevisionControllerFailing, + Status: operatorv1.ConditionFalse, + } if err != nil { - v1helpers.SetOperatorCondition(&operatorStatus.Conditions, operatorv1.OperatorCondition{ - Type: operatorv1.OperatorStatusTypeFailing, - Status: operatorv1.ConditionTrue, - Reason: "StatusUpdateError", - Message: err.Error(), - }) - if !reflect.DeepEqual(originalOperatorStatus, operatorStatus) { - if _, updateError := c.operatorConfigClient.UpdateStatus(resourceVersion, operatorStatus); updateError != nil { - glog.Error(updateError) - } + cond.Status = operatorv1.ConditionTrue + cond.Reason = "Error" + cond.Message = err.Error() + } + if _, updateError := common.UpdateStatus(c.operatorConfigClient, common.UpdateConditionFn(cond)); updateError != nil { + if err == nil { + return updateError } - return err } - return nil + return err } // Run starts the kube-apiserver and blocks until stopCh is closed. diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controllers.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controllers.go index 7d91765b4..5f61ab315 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controllers.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/controllers.go @@ -2,6 +2,8 @@ package staticpod import ( "github.com/openshift/library-go/pkg/operator/events" + "github.com/openshift/library-go/pkg/operator/staticpod/controller/monitoring" + "k8s.io/client-go/dynamic" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" @@ -13,10 +15,11 @@ import ( ) type staticPodOperatorControllers struct { - revisionController *revision.RevisionController - installerController *installer.InstallerController - nodeController *node.NodeController - serviceAccountController *backingresource.BackingResourceController + revisionController *revision.RevisionController + installerController *installer.InstallerController + nodeController *node.NodeController + backingResourceController *backingresource.BackingResourceController + monitoringResourceController *monitoring.MonitoringResourceController } // NewControllers provides all control loops needed to run a static pod based operator. That includes: @@ -27,8 +30,11 @@ type staticPodOperatorControllers struct { // appears that doesn't match the current latest for first kubeletStatus and the first kubeletStatus isn't already transitioning, // it kicks off an installer pod. If the next kubeletStatus doesn't match the immediate prior one, it kicks off that transition. // 3. NodeController - watches nodes for master nodes and keeps the operator status up to date +// 4. BackingResourceController - this creates the backing resources needed for the operand, such as cluster rolebindings and installer service +// account. +// 5. MonitoringResourceController - this creates the service monitor used by prometheus to scrape metrics. func NewControllers(targetNamespaceName, staticPodName string, command, revisionConfigMaps, revisionSecrets []string, - staticPodOperatorClient common.OperatorClient, kubeClient kubernetes.Interface, kubeInformersNamespaceScoped, + staticPodOperatorClient common.OperatorClient, kubeClient kubernetes.Interface, dynamicClient dynamic.Interface, kubeInformersNamespaceScoped, kubeInformersClusterScoped informers.SharedInformerFactory, eventRecorder events.Recorder) *staticPodOperatorControllers { controller := &staticPodOperatorControllers{} @@ -60,7 +66,7 @@ func NewControllers(targetNamespaceName, staticPodName string, command, revision eventRecorder, ) - controller.serviceAccountController = backingresource.NewBackingResourceController( + controller.backingResourceController = backingresource.NewBackingResourceController( targetNamespaceName, staticPodOperatorClient, kubeInformersNamespaceScoped, @@ -68,14 +74,25 @@ func NewControllers(targetNamespaceName, staticPodName string, command, revision eventRecorder, ) + controller.monitoringResourceController = monitoring.NewMonitoringResourceController( + targetNamespaceName, + targetNamespaceName, + staticPodOperatorClient, + kubeInformersNamespaceScoped, + kubeClient, + dynamicClient, + eventRecorder, + ) + return controller } func (o *staticPodOperatorControllers) Run(stopCh <-chan struct{}) { - go o.serviceAccountController.Run(1, stopCh) go o.revisionController.Run(1, stopCh) go o.installerController.Run(1, stopCh) go o.nodeController.Run(1, stopCh) + go o.backingResourceController.Run(1, stopCh) + go o.monitoringResourceController.Run(1, stopCh) <-stopCh } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/prune/cmd.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/prune/cmd.go new file mode 100644 index 000000000..fcd683028 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/prune/cmd.go @@ -0,0 +1,116 @@ +package prune + +import ( + "fmt" + "io/ioutil" + "os" + "path" + "strconv" + "strings" + + "github.com/davecgh/go-spew/spew" + "github.com/golang/glog" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + + "k8s.io/apimachinery/pkg/util/sets" +) + +type PruneOptions struct { + MaxEligibleRevisionID int + ProtectedRevisionIDs []int + + ResourceDir string + StaticPodName string +} + +func NewPruneOptions() *PruneOptions { + return &PruneOptions{} +} + +func NewPrune() *cobra.Command { + o := NewPruneOptions() + + cmd := &cobra.Command{ + Use: "prune", + Short: "Prune static pod installer revisions", + Run: func(cmd *cobra.Command, args []string) { + glog.V(1).Info(cmd.Flags()) + glog.V(1).Info(spew.Sdump(o)) + + if err := o.Validate(); err != nil { + glog.Fatal(err) + } + if err := o.Run(); err != nil { + glog.Fatal(err) + } + }, + } + + o.AddFlags(cmd.Flags()) + + return cmd +} + +func (o *PruneOptions) AddFlags(fs *pflag.FlagSet) { + fs.IntVar(&o.MaxEligibleRevisionID, "max-eligible-id", o.MaxEligibleRevisionID, "highest revision ID to be eligible for pruning") + fs.IntSliceVar(&o.ProtectedRevisionIDs, "protected-ids", o.ProtectedRevisionIDs, "list of revision IDs to preserve (not delete)") + fs.StringVar(&o.ResourceDir, "resource-dir", o.ResourceDir, "directory for all files supporting the static pod manifest") + fs.StringVar(&o.StaticPodName, "static-pod-name", o.StaticPodName, "name of the static pod") +} + +func (o *PruneOptions) Validate() error { + if len(o.ResourceDir) == 0 { + return fmt.Errorf("--resource-dir is required") + } + if o.MaxEligibleRevisionID == 0 { + return fmt.Errorf("--max-eligible-id is required") + } + if len(o.StaticPodName) == 0 { + return fmt.Errorf("--static-pod-name is required") + } + + return nil +} + +func (o *PruneOptions) Run() error { + protectedIDs := sets.NewInt(o.ProtectedRevisionIDs...) + + files, err := ioutil.ReadDir(o.ResourceDir) + if err != nil { + return err + } + + for _, file := range files { + // If the file is not a resource directory... + if !file.IsDir() { + continue + } + // And doesn't match our static pod prefix... + if !strings.HasPrefix(file.Name(), o.StaticPodName) { + continue + } + + // Split file name to get just the integer revision ID + fileSplit := strings.Split(file.Name(), o.StaticPodName+"-") + revisionID, err := strconv.Atoi(fileSplit[len(fileSplit)-1]) + if err != nil { + return err + } + + // And is not protected... + if protected := protectedIDs.Has(revisionID); protected { + continue + } + // And is less than or equal to the maxEligibleRevisionID + if revisionID > o.MaxEligibleRevisionID { + continue + } + + err = os.RemoveAll(path.Join(o.ResourceDir, file.Name())) + if err != nil { + return err + } + } + return nil +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/staticpod/prune/cmd_test.go b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/prune/cmd_test.go new file mode 100644 index 000000000..9615a148c --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/staticpod/prune/cmd_test.go @@ -0,0 +1,103 @@ +package prune + +import ( + "io/ioutil" + "os" + "path" + "reflect" + "sort" + "testing" + + "vbom.ml/util/sortorder" +) + +func TestRun(t *testing.T) { + tests := []struct { + name string + o PruneOptions + files []string + expected []string + }{ + { + name: "only deletes non-protected revisions of the specified pod", + o: PruneOptions{ + MaxEligibleRevisionID: 3, + ProtectedRevisionIDs: []int{3, 2}, + StaticPodName: "test", + }, + files: []string{"test-1", "test-2", "test-3", "othertest-4"}, + expected: []string{"test-2", "test-3", "othertest-4"}, + }, + { + name: "doesn't delete anything higher than highest eligible revision", + o: PruneOptions{ + MaxEligibleRevisionID: 2, + ProtectedRevisionIDs: []int{2}, + StaticPodName: "test", + }, + files: []string{"test-1", "test-2", "test-3"}, + expected: []string{"test-2", "test-3"}, + }, + { + name: "revision numbers do not conflict between pods when detecting protected IDs", + o: PruneOptions{ + MaxEligibleRevisionID: 2, + ProtectedRevisionIDs: []int{2}, + StaticPodName: "test", + }, + files: []string{"test-1", "test-2", "othertest-1", "othertest-2"}, + expected: []string{"test-2", "othertest-1", "othertest-2"}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + testDir, err := ioutil.TempDir("", "prune-revisions-test") + if err != nil { + t.Fatal(err) + } + defer func() { + os.Remove(testDir) + }() + + resourceDir := path.Join(testDir, "resources") + err = os.Mkdir(resourceDir, os.ModePerm) + if err != nil { + t.Error(err) + } + for _, file := range test.files { + err = os.Mkdir(path.Join(resourceDir, file), os.ModePerm) + if err != nil { + t.Error(err) + } + } + + o := test.o + o.ResourceDir = resourceDir + + err = o.Run() + if err != nil { + t.Error(err) + } + checkPruned(t, o.ResourceDir, test.expected) + }) + } +} + +func checkPruned(t *testing.T, resourceDir string, expected []string) { + files, err := ioutil.ReadDir(resourceDir) + if err != nil { + t.Error(err) + } + actual := make([]string, 0, len(files)) + for _, file := range files { + actual = append(actual, file.Name()) + } + + sort.Sort(sortorder.Natural(expected)) + sort.Sort(sortorder.Natural(actual)) + + if !reflect.DeepEqual(expected, actual) { + t.Errorf("expected %+v, got %+v", expected, actual) + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/status/controller.go b/vendor/github.com/openshift/library-go/pkg/operator/status/controller.go deleted file mode 100644 index eeec21d5c..000000000 --- a/vendor/github.com/openshift/library-go/pkg/operator/status/controller.go +++ /dev/null @@ -1,239 +0,0 @@ -package status - -import ( - "bytes" - "encoding/json" - "fmt" - "strings" - "time" - - "github.com/golang/glog" - - "k8s.io/apimachinery/pkg/api/equality" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - operatorv1 "github.com/openshift/api/operator/v1" - v1helpers "github.com/openshift/library-go/pkg/operator/v1helpers" -) - -var workQueueKey = "instance" - -type OperatorStatusProvider interface { - Informer() cache.SharedIndexInformer - CurrentStatus() (operatorv1.OperatorStatus, error) -} - -type StatusSyncer struct { - clusterOperatorNamespace string - clusterOperatorName string - - // TODO use a generated client when it moves to openshift/api - clusterOperatorClient dynamic.ResourceInterface - - operatorStatusProvider OperatorStatusProvider - - // queue only ever has one item, but it has nice error handling backoff/retry semantics - queue workqueue.RateLimitingInterface -} - -func NewClusterOperatorStatusController( - namespace, name string, - clusterOperatorClient dynamic.Interface, - operatorStatusProvider OperatorStatusProvider, -) *StatusSyncer { - c := &StatusSyncer{ - clusterOperatorNamespace: namespace, - clusterOperatorName: name, - clusterOperatorClient: clusterOperatorClient.Resource(schema.GroupVersionResource{Group: "config.openshift.io", Version: "v1", Resource: "clusteroperators"}).Namespace(namespace), - operatorStatusProvider: operatorStatusProvider, - - queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "StatusSyncer-"+name), - } - - operatorStatusProvider.Informer().AddEventHandler(c.eventHandler()) - // TODO watch clusterOperator.status changes when it moves to openshift/api - - return c -} - -// sync reacts to a change in prereqs by finding information that is required to match another value in the cluster. This -// must be information that is logically "owned" by another component. -func (c StatusSyncer) sync() error { - currentDetailedStatus, err := c.operatorStatusProvider.CurrentStatus() - if apierrors.IsNotFound(err) { - glog.Infof("operator.status not found") - return c.clusterOperatorClient.Delete(c.clusterOperatorName, nil) - } - if err != nil { - return err - } - - originalConfig, err := c.clusterOperatorClient.Get(c.clusterOperatorName, metav1.GetOptions{}) - if err != nil && !apierrors.IsNotFound(err) { - return err - } - operatorConfig := originalConfig.DeepCopy() - - if operatorConfig == nil { - glog.Infof("clusterOperator %s/%s not found", c.clusterOperatorNamespace, c.clusterOperatorName) - operatorConfig = &unstructured.Unstructured{Object: map[string]interface{}{}} - } - unstructured.RemoveNestedField(operatorConfig.Object, "status") - unstructured.SetNestedField(operatorConfig.Object, "ClusterOperator", "kind") - unstructured.SetNestedField(operatorConfig.Object, "config.openshift.io/v1", "apiVersion") - unstructured.SetNestedField(operatorConfig.Object, c.clusterOperatorNamespace, "metadata", "namespace") - unstructured.SetNestedField(operatorConfig.Object, c.clusterOperatorName, "metadata", "name") - - conditions := []interface{}{} - availableCondition, err := OperatorConditionToClusterOperatorCondition(v1helpers.FindOperatorCondition(currentDetailedStatus.Conditions, operatorv1.OperatorStatusTypeAvailable)) - if err != nil { - return err - } - if availableCondition != nil { - conditions = append(conditions, availableCondition) - } - - var failingConditions []operatorv1.OperatorCondition - for _, condition := range currentDetailedStatus.Conditions { - if strings.HasSuffix(condition.Type, "Failing") && condition.Status == operatorv1.ConditionTrue { - failingConditions = append(failingConditions, condition) - } - } - failingCondition := map[string]interface{}{} - unstructured.SetNestedField(failingCondition, operatorv1.OperatorStatusTypeFailing, "Type") - unstructured.SetNestedField(failingCondition, string(operatorv1.ConditionUnknown), "Status") - if len(failingConditions) > 0 { - unstructured.SetNestedField(failingCondition, string(operatorv1.ConditionTrue), "Status") - var messages []string - for _, condition := range failingConditions { - if len(condition.Message) == 0 { - continue - } - for _, message := range strings.Split(condition.Message, "\n") { - messages = append(messages, fmt.Sprintf("%s: %s", condition.Type, message)) - } - } - if len(messages) > 0 { - unstructured.SetNestedField(failingCondition, strings.Join(messages, "\n"), "Message") - } - if len(failingConditions) == 1 { - unstructured.SetNestedField(failingCondition, failingConditions[0].Type, "Reason") - } else { - unstructured.SetNestedField(failingCondition, "MultipleConditionsFailing", "Reason") - } - } else { - unstructured.SetNestedField(failingCondition, string(operatorv1.ConditionFalse), "Status") - } - - if failingCondition != nil { - conditions = append(conditions, failingCondition) - } - - progressingCondition, err := OperatorConditionToClusterOperatorCondition(v1helpers.FindOperatorCondition(currentDetailedStatus.Conditions, operatorv1.OperatorStatusTypeProgressing)) - if err != nil { - return err - } - if progressingCondition != nil { - conditions = append(conditions, progressingCondition) - } - unstructured.SetNestedSlice(operatorConfig.Object, conditions, "status", "conditions") - - if equality.Semantic.DeepEqual(operatorConfig, originalConfig) { - return nil - } - - glog.V(4).Infof("clusterOperator %s/%s set to %v", c.clusterOperatorNamespace, c.clusterOperatorName, runtime.EncodeOrDie(unstructured.UnstructuredJSONScheme, operatorConfig)) - _, updateErr := c.clusterOperatorClient.UpdateStatus(operatorConfig) - if apierrors.IsNotFound(updateErr) { - freshOperatorConfig, createErr := c.clusterOperatorClient.Create(operatorConfig) - if apierrors.IsNotFound(createErr) { - // this means that the API isn't present. We did not fail. Try again later - glog.Infof("ClusterOperator API not created") - c.queue.AddRateLimited(workQueueKey) - return nil - } - if createErr != nil { - return createErr - } - if err := unstructured.SetNestedMap(freshOperatorConfig.Object, operatorConfig.Object["status"].(map[string]interface{}), "status"); err != nil { - return err - } - _, updateErr = c.clusterOperatorClient.UpdateStatus(operatorConfig) - } - if updateErr != nil { - return updateErr - } - - return nil -} - -func OperatorConditionToClusterOperatorCondition(condition *operatorv1.OperatorCondition) (map[string]interface{}, error) { - if condition == nil { - return nil, nil - } - buf := &bytes.Buffer{} - if err := json.NewEncoder(buf).Encode(condition); err != nil { - return nil, err - } - ret := map[string]interface{}{} - if err := json.NewDecoder(buf).Decode(&ret); err != nil { - return nil, err - } - - return ret, nil -} - -func (c *StatusSyncer) Run(workers int, stopCh <-chan struct{}) { - defer utilruntime.HandleCrash() - defer c.queue.ShutDown() - - glog.Infof("Starting StatusSyncer-" + c.clusterOperatorName) - defer glog.Infof("Shutting down StatusSyncer-" + c.clusterOperatorName) - - // doesn't matter what workers say, only start one. - go wait.Until(c.runWorker, time.Second, stopCh) - - <-stopCh -} - -func (c *StatusSyncer) runWorker() { - for c.processNextWorkItem() { - } -} - -func (c *StatusSyncer) processNextWorkItem() bool { - dsKey, quit := c.queue.Get() - if quit { - return false - } - defer c.queue.Done(dsKey) - - err := c.sync() - if err == nil { - c.queue.Forget(dsKey) - return true - } - - utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err)) - c.queue.AddRateLimited(dsKey) - - return true -} - -// eventHandler queues the operator to check spec and status -func (c *StatusSyncer) eventHandler() cache.ResourceEventHandler { - return cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { c.queue.Add(workQueueKey) }, - UpdateFunc: func(old, new interface{}) { c.queue.Add(workQueueKey) }, - DeleteFunc: func(obj interface{}) { c.queue.Add(workQueueKey) }, - } -} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go new file mode 100644 index 000000000..e0b383219 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go @@ -0,0 +1,250 @@ +package status + +import ( + "fmt" + "strings" + "time" + + "github.com/golang/glog" + + "k8s.io/apimachinery/pkg/api/equality" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" + + configv1 "github.com/openshift/api/config/v1" + operatorv1 "github.com/openshift/api/operator/v1" + configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" + configv1helpers "github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers" + "github.com/openshift/library-go/pkg/operator/events" + operatorv1helpers "github.com/openshift/library-go/pkg/operator/v1helpers" +) + +var workQueueKey = "instance" + +type OperatorStatusProvider interface { + Informer() cache.SharedIndexInformer + CurrentStatus() (operatorv1.OperatorStatus, error) +} + +type StatusSyncer struct { + clusterOperatorName string + + // TODO use a generated client when it moves to openshift/api + clusterOperatorClient configv1client.ClusterOperatorsGetter + eventRecorder events.Recorder + + operatorStatusProvider OperatorStatusProvider + + // queue only ever has one item, but it has nice error handling backoff/retry semantics + queue workqueue.RateLimitingInterface +} + +func NewClusterOperatorStatusController( + name string, + clusterOperatorClient configv1client.ClusterOperatorsGetter, + operatorStatusProvider OperatorStatusProvider, + recorder events.Recorder, +) *StatusSyncer { + c := &StatusSyncer{ + clusterOperatorName: name, + clusterOperatorClient: clusterOperatorClient, + operatorStatusProvider: operatorStatusProvider, + eventRecorder: recorder, + + queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "StatusSyncer-"+name), + } + + operatorStatusProvider.Informer().AddEventHandler(c.eventHandler()) + // TODO watch clusterOperator.status changes when it moves to openshift/api + + return c +} + +// sync reacts to a change in prereqs by finding information that is required to match another value in the cluster. This +// must be information that is logically "owned" by another component. +func (c StatusSyncer) sync() error { + currentDetailedStatus, err := c.operatorStatusProvider.CurrentStatus() + if apierrors.IsNotFound(err) { + glog.Infof("operator.status not found") + c.eventRecorder.Warningf("StatusNotFound", "Unable to determine current operator status for %s", c.clusterOperatorName) + return c.clusterOperatorClient.ClusterOperators().Delete(c.clusterOperatorName, nil) + } + if err != nil { + return err + } + + originalClusterOperatorObj, err := c.clusterOperatorClient.ClusterOperators().Get(c.clusterOperatorName, metav1.GetOptions{}) + if err != nil && !apierrors.IsNotFound(err) { + c.eventRecorder.Warningf("StatusFailed", "Unable to get current operator status for %s: %v", c.clusterOperatorName, err) + return err + } + clusterOperatorObj := originalClusterOperatorObj.DeepCopy() + + if clusterOperatorObj == nil || apierrors.IsNotFound(err) { + glog.Infof("clusteroperator/%s not found", c.clusterOperatorName) + clusterOperatorObj = &configv1.ClusterOperator{ + ObjectMeta: metav1.ObjectMeta{Name: c.clusterOperatorName}, + } + } + clusterOperatorObj.Status.Conditions = nil + + var failingConditions []operatorv1.OperatorCondition + for _, condition := range currentDetailedStatus.Conditions { + if strings.HasSuffix(condition.Type, "Failing") && condition.Status == operatorv1.ConditionTrue { + failingConditions = append(failingConditions, condition) + } + } + failingCondition := operatorv1.OperatorCondition{Type: operatorv1.OperatorStatusTypeFailing, Status: operatorv1.ConditionUnknown} + if len(failingConditions) > 0 { + failingCondition.Status = operatorv1.ConditionTrue + var messages []string + latestTransitionTime := metav1.Time{} + for _, condition := range failingConditions { + if latestTransitionTime.Before(&condition.LastTransitionTime) { + latestTransitionTime = condition.LastTransitionTime + } + + if len(condition.Message) == 0 { + continue + } + for _, message := range strings.Split(condition.Message, "\n") { + messages = append(messages, fmt.Sprintf("%s: %s", condition.Type, message)) + } + } + if len(messages) > 0 { + failingCondition.Message = strings.Join(messages, "\n") + } + if len(failingConditions) == 1 { + failingCondition.Reason = failingConditions[0].Type + } else { + failingCondition.Reason = "MultipleConditionsFailing" + } + failingCondition.LastTransitionTime = latestTransitionTime + + } else { + failingCondition.Status = operatorv1.ConditionFalse + } + configv1helpers.SetStatusCondition(&clusterOperatorObj.Status.Conditions, OperatorConditionToClusterOperatorCondition(failingCondition)) + + if condition := operatorv1helpers.FindOperatorCondition(currentDetailedStatus.Conditions, operatorv1.OperatorStatusTypeAvailable); condition != nil { + configv1helpers.SetStatusCondition(&clusterOperatorObj.Status.Conditions, OperatorConditionToClusterOperatorCondition(*condition)) + } else { + configv1helpers.RemoveStatusCondition(&clusterOperatorObj.Status.Conditions, configv1.ClusterStatusConditionType(operatorv1.OperatorStatusTypeAvailable)) + } + if condition := operatorv1helpers.FindOperatorCondition(currentDetailedStatus.Conditions, operatorv1.OperatorStatusTypeProgressing); condition != nil { + configv1helpers.SetStatusCondition(&clusterOperatorObj.Status.Conditions, OperatorConditionToClusterOperatorCondition(*condition)) + } else { + configv1helpers.RemoveStatusCondition(&clusterOperatorObj.Status.Conditions, configv1.ClusterStatusConditionType(operatorv1.OperatorStatusTypeProgressing)) + } + + if equality.Semantic.DeepEqual(clusterOperatorObj, originalClusterOperatorObj) { + return nil + } + + glog.V(4).Infof("clusteroperator/%s set to %v", c.clusterOperatorName, runtime.EncodeOrDie(unstructured.UnstructuredJSONScheme, clusterOperatorObj)) + + if len(clusterOperatorObj.ResourceVersion) != 0 { + if _, updateErr := c.clusterOperatorClient.ClusterOperators().UpdateStatus(clusterOperatorObj); err != nil { + return updateErr + } + c.eventRecorder.Eventf("OperatorStatusChanged", "Status for operator %s changed: %s", c.clusterOperatorName, configv1helpers.GetStatusConditionDiff(originalClusterOperatorObj.Status.Conditions, clusterOperatorObj.Status.Conditions)) + return nil + } + + freshOperatorConfig, createErr := c.clusterOperatorClient.ClusterOperators().Create(clusterOperatorObj) + if apierrors.IsNotFound(createErr) { + // this means that the API isn't present. We did not fail. Try again later + glog.Infof("ClusterOperator API not created") + c.queue.AddRateLimited(workQueueKey) + return nil + } + if createErr != nil { + c.eventRecorder.Warningf("StatusCreateFailed", "Failed to create operator status: %v", err) + return createErr + } + + if condition := configv1helpers.FindStatusCondition(clusterOperatorObj.Status.Conditions, configv1.OperatorAvailable); condition != nil { + configv1helpers.SetStatusCondition(&freshOperatorConfig.Status.Conditions, *condition) + } else { + configv1helpers.RemoveStatusCondition(&freshOperatorConfig.Status.Conditions, configv1.OperatorAvailable) + } + if condition := configv1helpers.FindStatusCondition(clusterOperatorObj.Status.Conditions, configv1.OperatorProgressing); condition != nil { + configv1helpers.SetStatusCondition(&freshOperatorConfig.Status.Conditions, *condition) + } else { + configv1helpers.RemoveStatusCondition(&freshOperatorConfig.Status.Conditions, configv1.OperatorProgressing) + } + if condition := configv1helpers.FindStatusCondition(clusterOperatorObj.Status.Conditions, configv1.OperatorFailing); condition != nil { + configv1helpers.SetStatusCondition(&freshOperatorConfig.Status.Conditions, *condition) + } else { + configv1helpers.RemoveStatusCondition(&freshOperatorConfig.Status.Conditions, configv1.OperatorFailing) + } + + if _, updateErr := c.clusterOperatorClient.ClusterOperators().UpdateStatus(freshOperatorConfig); updateErr != nil { + return updateErr + } + c.eventRecorder.Eventf("OperatorStatusChanged", "Status for operator %s changed: %s", c.clusterOperatorName, configv1helpers.GetStatusConditionDiff(originalClusterOperatorObj.Status.Conditions, clusterOperatorObj.Status.Conditions)) + + return nil +} + +func OperatorConditionToClusterOperatorCondition(condition operatorv1.OperatorCondition) configv1.ClusterOperatorStatusCondition { + return configv1.ClusterOperatorStatusCondition{ + Type: configv1.ClusterStatusConditionType(condition.Type), + Status: configv1.ConditionStatus(condition.Status), + LastTransitionTime: condition.LastTransitionTime, + Reason: condition.Reason, + Message: condition.Message, + } +} + +func (c *StatusSyncer) Run(workers int, stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + defer c.queue.ShutDown() + + glog.Infof("Starting StatusSyncer-" + c.clusterOperatorName) + defer glog.Infof("Shutting down StatusSyncer-" + c.clusterOperatorName) + + // doesn't matter what workers say, only start one. + go wait.Until(c.runWorker, time.Second, stopCh) + + <-stopCh +} + +func (c *StatusSyncer) runWorker() { + for c.processNextWorkItem() { + } +} + +func (c *StatusSyncer) processNextWorkItem() bool { + dsKey, quit := c.queue.Get() + if quit { + return false + } + defer c.queue.Done(dsKey) + + err := c.sync() + if err == nil { + c.queue.Forget(dsKey) + return true + } + + utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err)) + c.queue.AddRateLimited(dsKey) + + return true +} + +// eventHandler queues the operator to check spec and status +func (c *StatusSyncer) eventHandler() cache.ResourceEventHandler { + return cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { c.queue.Add(workQueueKey) }, + UpdateFunc: func(old, new interface{}) { c.queue.Add(workQueueKey) }, + DeleteFunc: func(obj interface{}) { c.queue.Add(workQueueKey) }, + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/status/controller_test.go b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller_test.go similarity index 51% rename from vendor/github.com/openshift/library-go/pkg/operator/status/controller_test.go rename to vendor/github.com/openshift/library-go/pkg/operator/status/status_controller_test.go index 8e54b98aa..48e123e06 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/status/controller_test.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller_test.go @@ -6,24 +6,21 @@ import ( "strings" "testing" - "github.com/ghodss/yaml" - - "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/openshift/library-go/pkg/operator/events" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/diff" - "k8s.io/client-go/dynamic/fake" "k8s.io/client-go/tools/cache" + configv1 "github.com/openshift/api/config/v1" operatorv1 "github.com/openshift/api/operator/v1" + fake "github.com/openshift/client-go/config/clientset/versioned/fake" ) func TestSync(t *testing.T) { testCases := []struct { conditions []operatorv1.OperatorCondition - expectedFailingStatus operatorv1.ConditionStatus + expectedFailingStatus configv1.ConditionStatus expectedMessages []string expectedReason string }{ @@ -31,13 +28,13 @@ func TestSync(t *testing.T) { conditions: []operatorv1.OperatorCondition{ {Type: "TypeAFailing", Status: operatorv1.ConditionFalse}, }, - expectedFailingStatus: operatorv1.ConditionFalse, + expectedFailingStatus: configv1.ConditionFalse, }, { conditions: []operatorv1.OperatorCondition{ {Type: "TypeAFailing", Status: operatorv1.ConditionTrue}, }, - expectedFailingStatus: operatorv1.ConditionTrue, + expectedFailingStatus: configv1.ConditionTrue, expectedReason: "TypeAFailing", }, { @@ -45,7 +42,7 @@ func TestSync(t *testing.T) { {Type: "TypeAFailing", Status: operatorv1.ConditionTrue, Message: "a message from type a"}, {Type: "TypeBFailing", Status: operatorv1.ConditionFalse}, }, - expectedFailingStatus: operatorv1.ConditionTrue, + expectedFailingStatus: configv1.ConditionTrue, expectedReason: "TypeAFailing", expectedMessages: []string{ "TypeAFailing: a message from type a", @@ -56,7 +53,7 @@ func TestSync(t *testing.T) { {Type: "TypeAFailing", Status: operatorv1.ConditionFalse}, {Type: "TypeBFailing", Status: operatorv1.ConditionTrue, Message: "a message from type b"}, }, - expectedFailingStatus: operatorv1.ConditionTrue, + expectedFailingStatus: configv1.ConditionTrue, expectedReason: "TypeBFailing", expectedMessages: []string{ "TypeBFailing: a message from type b", @@ -69,7 +66,7 @@ func TestSync(t *testing.T) { {Type: "TypeCFailing", Status: operatorv1.ConditionFalse, Message: "a message from type c"}, {Type: "TypeDFailing", Status: operatorv1.ConditionTrue, Message: "a message from type d"}, }, - expectedFailingStatus: operatorv1.ConditionTrue, + expectedFailingStatus: configv1.ConditionTrue, expectedReason: "MultipleConditionsFailing", expectedMessages: []string{ "TypeBFailing: a message from type b", @@ -80,19 +77,9 @@ func TestSync(t *testing.T) { } for name, tc := range testCases { t.Run(fmt.Sprintf("%05d", name), func(t *testing.T) { - clusterOperators := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "config.openshift.io/v1", - "kind": "ClusterOperator", - "metadata": map[string]interface{}{ - "name": "OPERATOR_NAME", - "namespace": "OPERATOR_NAMESPACE", - }, - }, - } - clusterOperatorClient := fake.NewSimpleDynamicClient(runtime.NewScheme(), clusterOperators). - Resource(schema.GroupVersionResource{Group: "config.openshift.io", Version: "v1", Resource: "clusteroperators"}). - Namespace("OPERATOR_NAMESPACE") + clusterOperatorClient := fake.NewSimpleClientset(&configv1.ClusterOperator{ + ObjectMeta: metav1.ObjectMeta{Name: "OPERATOR_NAME", ResourceVersion: "12"}, + }) statusClient := &statusClient{ t: t, @@ -101,40 +88,39 @@ func TestSync(t *testing.T) { }, } controller := &StatusSyncer{ - clusterOperatorNamespace: "OPERATOR_NAMESPACE", - clusterOperatorName: "OPERATOR_NAME", - clusterOperatorClient: clusterOperatorClient, - operatorStatusProvider: statusClient, + clusterOperatorName: "OPERATOR_NAME", + clusterOperatorClient: clusterOperatorClient.ConfigV1(), + operatorStatusProvider: statusClient, + eventRecorder: events.NewInMemoryRecorder("status"), } - controller.sync() - result, _ := clusterOperatorClient.Get("OPERATOR_NAME", v1.GetOptions{}) - expected := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "config.openshift.io/v1", - "kind": "ClusterOperator", - "metadata": map[string]interface{}{ - "name": "OPERATOR_NAME", - "namespace": "OPERATOR_NAMESPACE", - }, - }, + if err := controller.sync(); err != nil { + t.Errorf("unexpected sync error: %v", err) + return + } + result, _ := clusterOperatorClient.ConfigV1().ClusterOperators().Get("OPERATOR_NAME", metav1.GetOptions{}) + expected := &configv1.ClusterOperator{ + ObjectMeta: metav1.ObjectMeta{Name: "OPERATOR_NAME", ResourceVersion: "12"}, } - expectedConditions := []interface{}{} + if tc.expectedFailingStatus != "" { - expectedCondition := map[string]interface{}{} - unstructured.SetNestedField(expectedCondition, operatorv1.OperatorStatusTypeFailing, "Type") - unstructured.SetNestedField(expectedCondition, string(tc.expectedFailingStatus), "Status") + condition := configv1.ClusterOperatorStatusCondition{ + Type: configv1.OperatorFailing, + Status: configv1.ConditionStatus(string(tc.expectedFailingStatus)), + } if len(tc.expectedMessages) > 0 { - unstructured.SetNestedField(expectedCondition, strings.Join(tc.expectedMessages, "\n"), "Message") + condition.Message = strings.Join(tc.expectedMessages, "\n") } if len(tc.expectedReason) > 0 { - unstructured.SetNestedField(expectedCondition, tc.expectedReason, "Reason") + condition.Reason = tc.expectedReason } - expectedConditions = append(expectedConditions, expectedCondition) + expected.Status.Conditions = append(expected.Status.Conditions, condition) + } + for i := range result.Status.Conditions { + result.Status.Conditions[i].LastTransitionTime = metav1.Time{} } - unstructured.SetNestedSlice(expected.Object, expectedConditions, "status", "conditions") + if !reflect.DeepEqual(expected, result) { - t.Errorf("\n===== observed config expected:\n%v\n===== observed config actual:\n%v", toYAML(expected), toYAML(result)) - t.Error(diff.ObjectGoPrintSideBySide(expected, result)) + t.Error(diff.ObjectDiff(expected, result)) } }) } @@ -154,11 +140,3 @@ func (c *statusClient) Informer() cache.SharedIndexInformer { func (c *statusClient) CurrentStatus() (operatorv1.OperatorStatus, error) { return c.status, nil } - -func toYAML(o interface{}) string { - b, e := yaml.Marshal(o) - if e != nil { - return e.Error() - } - return string(b) -} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/helpers.go b/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/helpers.go index 5f5fc32f6..da11cbf1b 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/helpers.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/helpers.go @@ -6,19 +6,21 @@ import ( "github.com/ghodss/yaml" + "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" + "k8s.io/client-go/util/retry" - operatorsv1 "github.com/openshift/api/operator/v1" + operatorv1 "github.com/openshift/api/operator/v1" ) -func SetOperatorCondition(conditions *[]operatorsv1.OperatorCondition, newCondition operatorsv1.OperatorCondition) { +func SetOperatorCondition(conditions *[]operatorv1.OperatorCondition, newCondition operatorv1.OperatorCondition) { if conditions == nil { - conditions = &[]operatorsv1.OperatorCondition{} + conditions = &[]operatorv1.OperatorCondition{} } existingCondition := FindOperatorCondition(*conditions, newCondition.Type) if existingCondition == nil { @@ -36,11 +38,11 @@ func SetOperatorCondition(conditions *[]operatorsv1.OperatorCondition, newCondit existingCondition.Message = newCondition.Message } -func RemoveOperatorCondition(conditions *[]operatorsv1.OperatorCondition, conditionType string) { +func RemoveOperatorCondition(conditions *[]operatorv1.OperatorCondition, conditionType string) { if conditions == nil { - conditions = &[]operatorsv1.OperatorCondition{} + conditions = &[]operatorv1.OperatorCondition{} } - newConditions := []operatorsv1.OperatorCondition{} + newConditions := []operatorv1.OperatorCondition{} for _, condition := range *conditions { if condition.Type != conditionType { newConditions = append(newConditions, condition) @@ -50,7 +52,7 @@ func RemoveOperatorCondition(conditions *[]operatorsv1.OperatorCondition, condit *conditions = newConditions } -func FindOperatorCondition(conditions []operatorsv1.OperatorCondition, conditionType string) *operatorsv1.OperatorCondition { +func FindOperatorCondition(conditions []operatorv1.OperatorCondition, conditionType string) *operatorv1.OperatorCondition { for i := range conditions { if conditions[i].Type == conditionType { return &conditions[i] @@ -60,15 +62,15 @@ func FindOperatorCondition(conditions []operatorsv1.OperatorCondition, condition return nil } -func IsOperatorConditionTrue(conditions []operatorsv1.OperatorCondition, conditionType string) bool { - return IsOperatorConditionPresentAndEqual(conditions, conditionType, operatorsv1.ConditionTrue) +func IsOperatorConditionTrue(conditions []operatorv1.OperatorCondition, conditionType string) bool { + return IsOperatorConditionPresentAndEqual(conditions, conditionType, operatorv1.ConditionTrue) } -func IsOperatorConditionFalse(conditions []operatorsv1.OperatorCondition, conditionType string) bool { - return IsOperatorConditionPresentAndEqual(conditions, conditionType, operatorsv1.ConditionFalse) +func IsOperatorConditionFalse(conditions []operatorv1.OperatorCondition, conditionType string) bool { + return IsOperatorConditionPresentAndEqual(conditions, conditionType, operatorv1.ConditionFalse) } -func IsOperatorConditionPresentAndEqual(conditions []operatorsv1.OperatorCondition, conditionType string, status operatorsv1.ConditionStatus) bool { +func IsOperatorConditionPresentAndEqual(conditions []operatorv1.OperatorCondition, conditionType string, status operatorv1.ConditionStatus) bool { for _, condition := range conditions { if condition.Type == conditionType { return condition.Status == status @@ -103,3 +105,42 @@ func EnsureOperatorConfigExists(client dynamic.Interface, operatorConfigBytes [] panic(err) } } + +// UpdateStatusFunc is a func that mutates an operator status. +type UpdateStatusFunc func(status *operatorv1.OperatorStatus) error + +// UpdateStatus applies the update funcs to the oldStatus and tries to update via the client. +func UpdateStatus(client OperatorClient, updateFuncs ...UpdateStatusFunc) (bool, error) { + updated := false + err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { + _, oldStatus, resourceVersion, err := client.GetOperatorState() + if err != nil { + return err + } + + newStatus := oldStatus.DeepCopy() + for _, update := range updateFuncs { + if err := update(newStatus); err != nil { + return err + } + } + + if equality.Semantic.DeepEqual(oldStatus, newStatus) { + return nil + } + + _, _, err = client.UpdateOperatorStatus(resourceVersion, newStatus) + updated = err == nil + return err + }) + + return updated, err +} + +// UpdateConditionFunc returns a func to update a condition. +func UpdateConditionFn(cond operatorv1.OperatorCondition) UpdateStatusFunc { + return func(oldStatus *operatorv1.OperatorStatus) error { + SetOperatorCondition(&oldStatus.Conditions, cond) + return nil + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/interfaces.go b/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/interfaces.go new file mode 100644 index 000000000..79f4fb1c4 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/interfaces.go @@ -0,0 +1,11 @@ +package v1helpers + +import ( + operatorv1 "github.com/openshift/api/operator/v1" +) + +type OperatorClient interface { + GetOperatorState() (spec *operatorv1.OperatorSpec, status *operatorv1.OperatorStatus, resourceVersion string, err error) + UpdateOperatorSpec(string, *operatorv1.OperatorSpec) (spec *operatorv1.OperatorSpec, resourceVersion string, err error) + UpdateOperatorStatus(string, *operatorv1.OperatorStatus) (status *operatorv1.OperatorStatus, resourceVersion string, err error) +} diff --git a/vendor/github.com/openshift/library-go/pkg/proc/reaper.go b/vendor/github.com/openshift/library-go/pkg/proc/reaper.go new file mode 100644 index 000000000..6bd8572f6 --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/proc/reaper.go @@ -0,0 +1,37 @@ +// +build linux + +package proc + +import ( + "os" + "os/signal" + "syscall" + + "github.com/golang/glog" +) + +// StartReaper starts a goroutine to reap processes if called from a process +// that has pid 1. +func StartReaper() { + if os.Getpid() == 1 { + glog.V(4).Infof("Launching reaper") + go func() { + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGCHLD) + for { + // Wait for a child to terminate + sig := <-sigs + glog.V(4).Infof("Signal received: %v", sig) + for { + // Reap processes + cpid, _ := syscall.Wait4(-1, nil, syscall.WNOHANG, nil) + if cpid < 1 { + break + } + + glog.V(4).Infof("Reaped process with pid %d", cpid) + } + } + }() + } +} diff --git a/vendor/github.com/openshift/library-go/pkg/proc/reaper_unsupported.go b/vendor/github.com/openshift/library-go/pkg/proc/reaper_unsupported.go new file mode 100644 index 000000000..75644fa5a --- /dev/null +++ b/vendor/github.com/openshift/library-go/pkg/proc/reaper_unsupported.go @@ -0,0 +1,8 @@ +// +build !linux + +package proc + +// StartReaper has no effect on non-linux platforms. +// Support for other unices will be added. +func StartReaper() { +} diff --git a/vendor/k8s.io/apiextensions-apiserver/.github/PULL_REQUEST_TEMPLATE.md b/vendor/k8s.io/apiextensions-apiserver/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e559c074b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,2 +0,0 @@ -Sorry, we do not accept changes directly against this repository. Please see -CONTRIBUTING.md for information on where and how to contribute instead. diff --git a/vendor/k8s.io/apiextensions-apiserver/CONTRIBUTING.md b/vendor/k8s.io/apiextensions-apiserver/CONTRIBUTING.md deleted file mode 100644 index d8ad4d2d3..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/CONTRIBUTING.md +++ /dev/null @@ -1,7 +0,0 @@ -# Contributing guidelines - -Do not open pull requests directly against this repository, they will be ignored. Instead, please open pull requests against [kubernetes/kubernetes](https://git.k8s.io/kubernetes/). Please follow the same [contributing guide](https://git.k8s.io/kubernetes/CONTRIBUTING.md) you would follow for any other pull request made to kubernetes/kubernetes. - -This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/apiextensions-apiserver](https://git.k8s.io/kubernetes/staging/src/k8s.io/apiextensions-apiserver) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot). - -Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/staging.md) for more information diff --git a/vendor/k8s.io/apiextensions-apiserver/Godeps/Godeps.json b/vendor/k8s.io/apiextensions-apiserver/Godeps/Godeps.json deleted file mode 100644 index 8a3625b1b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/Godeps/Godeps.json +++ /dev/null @@ -1,2102 +0,0 @@ -{ - "ImportPath": "k8s.io/apiextensions-apiserver", - "GoVersion": "go1.9", - "GodepVersion": "v80", - "Packages": [ - "./..." - ], - "Deps": [ - { - "ImportPath": "bitbucket.org/ww/goautoneg", - "Rev": "75cd24fc2f2c2a2088577d12123ddee5f54e0675" - }, - { - "ImportPath": "github.com/NYTimes/gziphandler", - "Rev": "56545f4a5d46df9a6648819d1664c3a03a13ffdb" - }, - { - "ImportPath": "github.com/PuerkitoBio/purell", - "Rev": "8a290539e2e8629dbc4e6bad948158f790ec31f4" - }, - { - "ImportPath": "github.com/PuerkitoBio/urlesc", - "Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e" - }, - { - "ImportPath": "github.com/asaskevich/govalidator", - "Rev": "593d64559f7600f29581a3ee42177f5dbded27a9" - }, - { - "ImportPath": "github.com/beorn7/perks/quantile", - "Rev": "3ac7bf7a47d159a033b107610db8a1b6575507a4" - }, - { - "ImportPath": "github.com/cockroachdb/cmux", - "Rev": "112f0506e7743d64a6eb8fedbcff13d9979bbf92" - }, - { - "ImportPath": "github.com/coreos/bbolt", - "Rev": "48ea1b39c25fc1bab3506fbc712ecbaa842c4d2d" - }, - { - "ImportPath": "github.com/coreos/etcd/alarm", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/auth", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/auth/authpb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/client", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/clientv3", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/clientv3/concurrency", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/clientv3/namespace", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/clientv3/naming", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/compactor", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/discovery", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/embed", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/error", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/etcdhttp", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v2http", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v2http/httptypes", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3client", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3election", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/gw", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3lock", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/gw", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3rpc", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/auth", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/etcdserverpb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/etcdserverpb/gw", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/membership", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/etcdserver/stats", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/integration", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/lease", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/lease/leasehttp", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/lease/leasepb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/mvcc", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/mvcc/backend", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/mvcc/mvccpb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/adt", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/contention", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/cors", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/cpuutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/crc", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/debugutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/fileutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/httputil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/idutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/ioutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/logutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/monotime", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/netutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/pathutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/pbutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/runtime", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/schedule", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/srv", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/testutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/tlsutil", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/transport", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/types", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/pkg/wait", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/proxy/grpcproxy", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/proxy/grpcproxy/adapter", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/proxy/grpcproxy/cache", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/raft", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/raft/raftpb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/rafthttp", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/snap", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/snap/snappb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/store", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/version", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/wal", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/etcd/wal/walpb", - "Rev": "95a726a27e09030f9ccbd9982a1508f5a6d25ada" - }, - { - "ImportPath": "github.com/coreos/go-semver/semver", - "Rev": "568e959cd89871e61434c1143528d9162da89ef2" - }, - { - "ImportPath": "github.com/coreos/go-systemd/daemon", - "Rev": "48702e0da86bd25e76cfef347e2adeb434a0d0a6" - }, - { - "ImportPath": "github.com/coreos/go-systemd/journal", - "Rev": "48702e0da86bd25e76cfef347e2adeb434a0d0a6" - }, - { - "ImportPath": "github.com/coreos/pkg/capnslog", - "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" - }, - { - "ImportPath": "github.com/davecgh/go-spew/spew", - "Rev": "782f4967f2dc4564575ca782fe2d04090b5faca8" - }, - { - "ImportPath": "github.com/dgrijalva/jwt-go", - "Rev": "01aeca54ebda6e0fbfafd0a524d234159c05ec20" - }, - { - "ImportPath": "github.com/elazarl/go-bindata-assetfs", - "Rev": "3dcc96556217539f50599357fb481ac0dc7439b9" - }, - { - "ImportPath": "github.com/emicklei/go-restful", - "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" - }, - { - "ImportPath": "github.com/emicklei/go-restful-swagger12", - "Rev": "dcef7f55730566d41eae5db10e7d6981829720f6" - }, - { - "ImportPath": "github.com/emicklei/go-restful/log", - "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" - }, - { - "ImportPath": "github.com/evanphx/json-patch", - "Rev": "94e38aa1586e8a6c8a75770bddf5ff84c48a106b" - }, - { - "ImportPath": "github.com/ghodss/yaml", - "Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee" - }, - { - "ImportPath": "github.com/go-openapi/analysis", - "Rev": "b44dc874b601d9e4e2f6e19140e794ba24bead3b" - }, - { - "ImportPath": "github.com/go-openapi/errors", - "Rev": "d24ebc2075bad502fac3a8ae27aa6dd58e1952dc" - }, - { - "ImportPath": "github.com/go-openapi/jsonpointer", - "Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98" - }, - { - "ImportPath": "github.com/go-openapi/jsonreference", - "Rev": "13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272" - }, - { - "ImportPath": "github.com/go-openapi/loads", - "Rev": "a80dea3052f00e5f032e860dd7355cd0cc67e24d" - }, - { - "ImportPath": "github.com/go-openapi/runtime", - "Rev": "11e322eeecc1032d5a0a96c566ed53f2b5c26e22" - }, - { - "ImportPath": "github.com/go-openapi/spec", - "Rev": "1de3e0542de65ad8d75452a595886fdd0befb363" - }, - { - "ImportPath": "github.com/go-openapi/strfmt", - "Rev": "d65c7fdb29eca313476e529628176fe17e58c488" - }, - { - "ImportPath": "github.com/go-openapi/swag", - "Rev": "f3f9494671f93fcff853e3c6e9e948b3eb71e590" - }, - { - "ImportPath": "github.com/go-openapi/validate", - "Rev": "d509235108fcf6ab4913d2dcb3a2260c0db2108e" - }, - { - "ImportPath": "github.com/gogo/protobuf/proto", - "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" - }, - { - "ImportPath": "github.com/gogo/protobuf/sortkeys", - "Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7" - }, - { - "ImportPath": "github.com/golang/glog", - "Rev": "44145f04b68cf362d9c4df2182967c2275eaefed" - }, - { - "ImportPath": "github.com/golang/groupcache/lru", - "Rev": "02826c3e79038b59d737d3b1c0a1d937f71a4433" - }, - { - "ImportPath": "github.com/golang/protobuf/jsonpb", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/golang/protobuf/proto", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/golang/protobuf/protoc-gen-go/descriptor", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes/any", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes/duration", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes/struct", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/golang/protobuf/ptypes/timestamp", - "Rev": "b4deda0973fb4c70b50d226b1af49f3da59f5265" - }, - { - "ImportPath": "github.com/google/btree", - "Rev": "7d79101e329e5a3adf994758c578dab82b90c017" - }, - { - "ImportPath": "github.com/google/gofuzz", - "Rev": "44d81051d367757e1c7c6a5a86423ece9afcf63c" - }, - { - "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" - }, - { - "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" - }, - { - "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" - }, - { - "ImportPath": "github.com/gregjones/httpcache", - "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" - }, - { - "ImportPath": "github.com/gregjones/httpcache/diskcache", - "Rev": "787624de3eb7bd915c329cba748687a3b22666a6" - }, - { - "ImportPath": "github.com/grpc-ecosystem/go-grpc-prometheus", - "Rev": "2500245aa6110c562d17020fb31a2c133d737799" - }, - { - "ImportPath": "github.com/grpc-ecosystem/grpc-gateway/runtime", - "Rev": "8cc3a55af3bcf171a1c23a90c4df9cf591706104" - }, - { - "ImportPath": "github.com/grpc-ecosystem/grpc-gateway/runtime/internal", - "Rev": "8cc3a55af3bcf171a1c23a90c4df9cf591706104" - }, - { - "ImportPath": "github.com/grpc-ecosystem/grpc-gateway/utilities", - "Rev": "8cc3a55af3bcf171a1c23a90c4df9cf591706104" - }, - { - "ImportPath": "github.com/hashicorp/golang-lru", - "Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4" - }, - { - "ImportPath": "github.com/hashicorp/golang-lru/simplelru", - "Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4" - }, - { - "ImportPath": "github.com/imdario/mergo", - "Rev": "6633656539c1639d9d78127b7d47c622b5d7b6dc" - }, - { - "ImportPath": "github.com/inconshreveable/mousetrap", - "Rev": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" - }, - { - "ImportPath": "github.com/jonboulle/clockwork", - "Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982" - }, - { - "ImportPath": "github.com/json-iterator/go", - "Rev": "f2b4162afba35581b6d4a50d3b8f34e33c144682" - }, - { - "ImportPath": "github.com/mailru/easyjson/buffer", - "Rev": "2f5df55504ebc322e4d52d34df6a1f5b503bf26d" - }, - { - "ImportPath": "github.com/mailru/easyjson/jlexer", - "Rev": "2f5df55504ebc322e4d52d34df6a1f5b503bf26d" - }, - { - "ImportPath": "github.com/mailru/easyjson/jwriter", - "Rev": "2f5df55504ebc322e4d52d34df6a1f5b503bf26d" - }, - { - "ImportPath": "github.com/matttproud/golang_protobuf_extensions/pbutil", - "Rev": "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a" - }, - { - "ImportPath": "github.com/modern-go/concurrent", - "Rev": "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" - }, - { - "ImportPath": "github.com/modern-go/reflect2", - "Rev": "05fbef0ca5da472bbf96c9322b84a53edc03c9fd" - }, - { - "ImportPath": "github.com/pborman/uuid", - "Rev": "ca53cad383cad2479bbba7f7a1a05797ec1386e4" - }, - { - "ImportPath": "github.com/peterbourgon/diskv", - "Rev": "5f041e8faa004a95c88a202771f4cc3e991971e6" - }, - { - "ImportPath": "github.com/pmezard/go-difflib/difflib", - "Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d" - }, - { - "ImportPath": "github.com/prometheus/client_golang/prometheus", - "Rev": "e7e903064f5e9eb5da98208bae10b475d4db0f8c" - }, - { - "ImportPath": "github.com/prometheus/client_model/go", - "Rev": "fa8ad6fec33561be4280a8f0514318c79d7f6cb6" - }, - { - "ImportPath": "github.com/prometheus/common/expfmt", - "Rev": "13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207" - }, - { - "ImportPath": "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg", - "Rev": "13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207" - }, - { - "ImportPath": "github.com/prometheus/common/model", - "Rev": "13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207" - }, - { - "ImportPath": "github.com/prometheus/procfs", - "Rev": "65c1f6f8f0fc1e2185eb9863a3bc751496404259" - }, - { - "ImportPath": "github.com/prometheus/procfs/xfs", - "Rev": "65c1f6f8f0fc1e2185eb9863a3bc751496404259" - }, - { - "ImportPath": "github.com/spf13/cobra", - "Rev": "c439c4fa093711d42e1b01acb1235b52004753c1" - }, - { - "ImportPath": "github.com/spf13/pflag", - "Rev": "583c0c0531f06d5278b7d917446061adc344b5cd" - }, - { - "ImportPath": "github.com/stretchr/testify/assert", - "Rev": "c679ae2cc0cb27ec3293fea7e254e47386f05d69" - }, - { - "ImportPath": "github.com/stretchr/testify/require", - "Rev": "c679ae2cc0cb27ec3293fea7e254e47386f05d69" - }, - { - "ImportPath": "github.com/ugorji/go/codec", - "Rev": "ded73eae5db7e7a0ef6f55aace87a2873c5d2b74" - }, - { - "ImportPath": "github.com/xiang90/probing", - "Rev": "07dd2e8dfe18522e9c447ba95f2fe95262f63bb2" - }, - { - "ImportPath": "golang.org/x/crypto/bcrypt", - "Rev": "49796115aa4b964c318aad4f3084fdb41e9aa067" - }, - { - "ImportPath": "golang.org/x/crypto/blowfish", - "Rev": "49796115aa4b964c318aad4f3084fdb41e9aa067" - }, - { - "ImportPath": "golang.org/x/crypto/ssh/terminal", - "Rev": "49796115aa4b964c318aad4f3084fdb41e9aa067" - }, - { - "ImportPath": "golang.org/x/net/context", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/net/http2", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/net/http2/hpack", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/net/idna", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/net/internal/timeseries", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/net/lex/httplex", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/net/trace", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/net/websocket", - "Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f" - }, - { - "ImportPath": "golang.org/x/sys/unix", - "Rev": "95c6576299259db960f6c5b9b69ea52422860fce" - }, - { - "ImportPath": "golang.org/x/sys/windows", - "Rev": "95c6576299259db960f6c5b9b69ea52422860fce" - }, - { - "ImportPath": "golang.org/x/text/cases", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/internal", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/internal/tag", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/language", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/runes", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/secure/bidirule", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/secure/precis", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/transform", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/unicode/bidi", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/unicode/norm", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/text/width", - "Rev": "b19bf474d317b857955b12035d2c5acb57ce8b01" - }, - { - "ImportPath": "golang.org/x/time/rate", - "Rev": "f51c12702a4d776e4c1fa9b0fabab841babae631" - }, - { - "ImportPath": "google.golang.org/genproto/googleapis/api/annotations", - "Rev": "09f6ed296fc66555a25fe4ce95173148778dfa85" - }, - { - "ImportPath": "google.golang.org/genproto/googleapis/rpc/status", - "Rev": "09f6ed296fc66555a25fe4ce95173148778dfa85" - }, - { - "ImportPath": "google.golang.org/grpc", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/balancer", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/codes", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/connectivity", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/credentials", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/grpclb/grpc_lb_v1/messages", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/grpclog", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/health/grpc_health_v1", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/internal", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/keepalive", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/metadata", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/naming", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/peer", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/resolver", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/stats", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/status", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/tap", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "google.golang.org/grpc/transport", - "Rev": "5b3c4e850e90a4cf6a20ebd46c8b32a0a3afcb9e" - }, - { - "ImportPath": "gopkg.in/inf.v0", - "Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" - }, - { - "ImportPath": "gopkg.in/natefinch/lumberjack.v2", - "Rev": "20b71e5b60d756d3d2f80def009790325acc2b23" - }, - { - "ImportPath": "gopkg.in/yaml.v2", - "Rev": "670d4cfef0544295bc27a114dbac37980d83185a" - }, - { - "ImportPath": "k8s.io/api/admission/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/admissionregistration/v1alpha1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/admissionregistration/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/apps/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/apps/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/apps/v1beta2", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/authentication/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/authentication/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/authorization/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/authorization/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/autoscaling/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/autoscaling/v2beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/batch/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/batch/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/batch/v2alpha1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/certificates/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/core/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/events/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/extensions/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/networking/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/policy/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/rbac/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/rbac/v1alpha1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/rbac/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/scheduling/v1alpha1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/scheduling/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/settings/v1alpha1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/storage/v1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/storage/v1alpha1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/api/storage/v1beta1", - "Rev": "072894a440bdee3a891dea811fe42902311cd2a3" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/equality", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/errors", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/meta", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/meta/table", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/resource", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/testing", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/validation", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/api/validation/path", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/validation", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/fields", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/labels", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/selection", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/types", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/cache", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/clock", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/diff", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/duration", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/errors", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/framer", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/intstr", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/json", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/net", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/rand", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/runtime", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/sets", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/uuid", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/validation", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/wait", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/waitgroup", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/util/yaml", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/version", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/pkg/watch", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", - "Rev": "103fd098999dc9c0c88536f5c9ad2e5da39373ae" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/configuration", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/initializer", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/metrics", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/initialization", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/config", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/v1alpha1", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/errors", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/generic", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/namespace", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/request", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/rules", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/validating", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/apiserver", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/apiserver/install", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/audit", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/audit/install", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/audit/v1alpha1", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/audit/v1beta1", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/apis/audit/validation", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/audit", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/audit/policy", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/authenticator", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/authenticatorfactory", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/group", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/request/anonymous", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/request/bearertoken", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/request/headerrequest", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/request/union", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/request/websocket", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/request/x509", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/serviceaccount", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/token/tokenfile", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authentication/user", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authorization/authorizer", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authorization/authorizerfactory", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/authorization/union", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/discovery", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/filters", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/handlers", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/handlers/negotiation", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/metrics", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/openapi", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/endpoints/request", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/features", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/registry/generic", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/registry/generic/registry", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/registry/generic/testing", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/registry/rest", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/registry/rest/resttest", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/filters", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/healthz", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/httplog", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/mux", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/options", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/resourceconfig", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/routes", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/routes/data/swagger", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/server/storage", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/errors", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/etcdtest", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/metrics", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/testing", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/testing/testingcert", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/util", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd3", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/etcd3/preflight", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/names", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/storagebackend", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/storagebackend/factory", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/testing", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/storage/value", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/feature", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/flag", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/flushwriter", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/logs", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/openapi", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/trace", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/webhook", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/pkg/util/wsstream", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/buffered", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/log", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/truncate", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/webhook", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/plugin/pkg/authenticator/token/webhook", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/apiserver/plugin/pkg/authorizer/webhook", - "Rev": "01459b68eb5fee2dcf5ca0e29df8bcac89ead47b" - }, - { - "ImportPath": "k8s.io/client-go/discovery", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/discovery/fake", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/dynamic", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/admissionregistration", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/admissionregistration/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/admissionregistration/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/apps", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/apps/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/apps/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/apps/v1beta2", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/autoscaling", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/autoscaling/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/autoscaling/v2beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/batch", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/batch/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/batch/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/batch/v2alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/certificates", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/certificates/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/core", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/core/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/events", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/events/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/extensions", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/extensions/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/internalinterfaces", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/networking", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/networking/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/policy", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/policy/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/rbac", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/rbac/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/rbac/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/rbac/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/scheduling", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/scheduling/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/scheduling/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/settings", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/settings/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/storage", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/storage/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/storage/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/informers/storage/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/scheme", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/apps/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/apps/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/apps/v1beta2", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/authentication/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/authentication/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/authorization/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/authorization/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v2alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/certificates/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/core/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/events/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/extensions/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/networking/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/policy/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/rbac/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/rbac/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/settings/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/storage/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/storage/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/kubernetes/typed/storage/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/admissionregistration/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/admissionregistration/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/apps/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/apps/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/apps/v1beta2", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/autoscaling/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/autoscaling/v2beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/batch/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/batch/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/batch/v2alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/certificates/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/core/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/events/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/extensions/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/networking/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/policy/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/rbac/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/rbac/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/rbac/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/scheduling/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/scheduling/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/settings/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/storage/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/storage/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/listers/storage/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/pkg/apis/clientauthentication", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/pkg/version", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/plugin/pkg/client/auth/exec", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/rest", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/rest/watch", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/restmapper", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale/scheme", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale/scheme/appsint", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale/scheme/appsv1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale/scheme/appsv1beta2", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale/scheme/autoscalingv1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale/scheme/extensionsint", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/scale/scheme/extensionsv1beta1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/testing", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/third_party/forked/golang/template", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/auth", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/cache", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/clientcmd", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/clientcmd/api", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/clientcmd/api/latest", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/clientcmd/api/v1", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/metrics", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/pager", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/tools/reference", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/transport", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/buffer", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/cert", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/connrotation", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/flowcontrol", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/homedir", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/integer", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/jsonpath", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/retry", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/client-go/util/workqueue", - "Rev": "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - }, - { - "ImportPath": "k8s.io/kube-openapi/pkg/builder", - "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" - }, - { - "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" - }, - { - "ImportPath": "k8s.io/kube-openapi/pkg/handler", - "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" - }, - { - "ImportPath": "k8s.io/kube-openapi/pkg/util", - "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" - }, - { - "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" - } - ] -} diff --git a/vendor/k8s.io/apiextensions-apiserver/Godeps/OWNERS b/vendor/k8s.io/apiextensions-apiserver/Godeps/OWNERS deleted file mode 100644 index 3d49f3060..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/Godeps/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -approvers: -- dep-approvers diff --git a/vendor/k8s.io/apiextensions-apiserver/OWNERS b/vendor/k8s.io/apiextensions-apiserver/OWNERS deleted file mode 100644 index d9cb557fc..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/OWNERS +++ /dev/null @@ -1,9 +0,0 @@ -reviewers: -- deads2k -- sttts -- enisoc -- mbohlool -approvers: -- deads2k -- lavalamp -- sttts diff --git a/vendor/k8s.io/apiextensions-apiserver/README.md b/vendor/k8s.io/apiextensions-apiserver/README.md deleted file mode 100644 index be75b9ba4..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# apiextensions-apiserver - -Implements: https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/thirdpartyresources.md - -It provides an API for registering `CustomResourceDefinitions`. - -## Purpose - -This API server provides the implementation for `CustomResourceDefinitions` which is included as -delegate server inside of `kube-apiserver`. - - -## Compatibility - -HEAD of this repo will match HEAD of k8s.io/apiserver, k8s.io/apimachinery, and k8s.io/client-go. - -## Where does it come from? - -`apiextensions-apiserver` is synced from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver. -Code changes are made in that location, merged into `k8s.io/kubernetes` and later synced here. diff --git a/vendor/k8s.io/apiextensions-apiserver/SECURITY_CONTACTS b/vendor/k8s.io/apiextensions-apiserver/SECURITY_CONTACTS deleted file mode 100644 index 0648a8ebf..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/SECURITY_CONTACTS +++ /dev/null @@ -1,17 +0,0 @@ -# Defined below are the security contacts for this repo. -# -# They are the contact point for the Product Security Team to reach out -# to for triaging and handling of incoming issues. -# -# The below names agree to abide by the -# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy) -# and will be removed and replaced if they violate that agreement. -# -# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE -# INSTRUCTIONS AT https://kubernetes.io/security/ - -cjcullen -jessfraz -liggitt -philips -tallclair diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-apiservice.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-apiservice.yaml deleted file mode 100644 index 44d07f641..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-apiservice.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: apiregistration.k8s.io/v1beta1 -kind: APIService -metadata: - name: v1alpha1.mygroup.example.com -spec: - insecureSkipTLSVerify: true - group: mygroup.example.com - priority: 500 - service: - name: api - namespace: apiextensions - version: v1alpha1 diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-resource-definition.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-resource-definition.yaml deleted file mode 100644 index 86205f9db..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-resource-definition.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: noxus.mygroup.example.com -spec: - group: mygroup.example.com - version: v1alpha1 - scope: Namespaced - names: - plural: noxus - singular: noxu - kind: Noxu - listKind: NoxuList \ No newline at end of file diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu.yaml deleted file mode 100644 index 3cdda5efe..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: mygroup.example.com/v1alpha1 -kind: Noxu -metadata: - name: alfa-noxu -spec: - key: value \ No newline at end of file diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/apiservice.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/apiservice.yaml deleted file mode 100644 index 332bb120a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/apiservice.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: apiregistration.k8s.io/v1beta1 -kind: APIService -metadata: - name: v1alpha1.apiextensions.k8s.io -spec: - insecureSkipTLSVerify: true - group: apiextensions.k8s.io - priority: 100 - service: - name: api - namespace: apiextensions - version: v1alpha1 diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-delegator.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-delegator.yaml deleted file mode 100644 index ef608eced..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-delegator.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: apiextensions:system:auth-delegator -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:auth-delegator -subjects: -- kind: ServiceAccount - name: apiserver - namespace: apiextensions diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-reader.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-reader.yaml deleted file mode 100644 index 4f0f0e2b6..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-reader.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: apiextensions-auth-reader - namespace: kube-system -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: extension-apiserver-authentication-reader -subjects: -- kind: ServiceAccount - name: apiserver - namespace: apiextensions diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/rc.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/rc.yaml deleted file mode 100644 index 86b5d3070..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/rc.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: v1 -kind: ReplicationController -metadata: - name: apiextensions-server - namespace: apiextensions - labels: - apiserver: "true" -spec: - replicas: 1 - selector: - apiserver: "true" - template: - metadata: - labels: - apiserver: "true" - spec: - serviceAccountName: apiserver - containers: - - name: apiextensions-server - image: apiextensions-apiserver:latest - imagePullPolicy: Never - args: - - "--etcd-servers=http://localhost:2379" - - "--audit-log-path=-" - - name: etcd - image: quay.io/coreos/etcd:v3.2.18 diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/sa.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/sa.yaml deleted file mode 100644 index 0f2e17f6a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/sa.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: ServiceAccount -apiVersion: v1 -metadata: - name: apiserver - namespace: apiextensions diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/service.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/service.yaml deleted file mode 100644 index 2b66f1d8a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: api - namespace: apiextensions -spec: - ports: - - port: 443 - protocol: TCP - targetPort: 443 - selector: - apiserver: "true" diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile b/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile deleted file mode 100644 index c41affec9..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2017 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. - -FROM fedora -ADD apiextensions-apiserver / -ENTRYPOINT ["/apiextensions-apiserver"] diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/README.md b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/README.md deleted file mode 100644 index 1949e5d47..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Custom Resource Example - -**Note:** CustomResourceDefinition is the successor of the deprecated ThirdPartyResource. - -This particular example demonstrates how to generate a client for CustomResources using [`k8s.io/code-generator`](https://github.com/kubernetes/code-generator). The clientset can -be generated using the `./hack/update-codegen.sh` script. - -The `update-codegen` script will automatically generate the following files and -directories: - -* `pkg/apis/cr/v1/zz_generated.deepcopy.go` -* `pkg/client/` - -The following code-generators are used: - -* `deepcopy-gen` - creates a method `func (t* T) DeepCopy() *T` for each type T -* `client-gen` - creates typed clientsets for CustomResource APIGroups -* `informer-gen` - creates informers for CustomResources which offer an event based -interface to react on changes of CustomResources on the server -* `lister-gen` - creates listers for CustomResources which offer a read-only caching layer for GET and LIST requests. - -Changes should not be made to these files manually, and when creating your own -controller based off of this implementation you should not copy these files and -instead run the `update-codegen` script to generate your own. - -Please see [`k8s.io/sample-controller`](https://github.com/kubernetes/sample-controller) for an example -controller for CustomResources using the generated client. - -## Use Cases - -CustomResourceDefinitions can be used to implement custom resource types for your Kubernetes cluster. -These act like most other Resources in Kubernetes, and may be `kubectl apply`'d, etc. - -Some example use cases: - -* Provisioning/Management of external datastores/databases (eg. CloudSQL/RDS instances) -* Higher level abstractions around Kubernetes primitives (eg. a single Resource to define an etcd cluster, backed by a Service and a ReplicationController) - -## Defining types - -Each instance of your custom resource has an attached Spec, which should be defined via a `struct{}` to provide data format validation. -In practice, this Spec is arbitrary key-value data that specifies the configuration/behavior of your Resource. - -For example, if you were implementing a custom resource for a Database, you might provide a DatabaseSpec like the following: - -``` go -type DatabaseSpec struct { - Databases []string `json:"databases"` - Users []User `json:"users"` - Version string `json:"version"` -} - -type User struct { - Name string `json:"name"` - Password string `json:"password"` -} -``` diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh deleted file mode 100755 index ea26ad63c..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2017 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. - -set -o errexit -set -o nounset -set -o pipefail - -SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/.. -CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} - -# generate the code with: -# --output-base because this script should also be able to run inside the vendor dir of -# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir -# instead of the $GOPATH directly. For normal projects this can be dropped. -${CODEGEN_PKG}/generate-groups.sh all \ - k8s.io/apiextensions-apiserver/examples/client-go/pkg/client k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis \ - cr:v1 \ - --output-base "$(dirname ${BASH_SOURCE})/../../../../.." - -# To use your own boilerplate text append: -# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/verify-codegen.sh b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/verify-codegen.sh deleted file mode 100755 index d02a6fa39..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/verify-codegen.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2017 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. - -set -o errexit -set -o nounset -set -o pipefail - -SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. - -DIFFROOT="${SCRIPT_ROOT}/pkg" -TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg" -_tmp="${SCRIPT_ROOT}/_tmp" - -cleanup() { - rm -rf "${_tmp}" -} -trap "cleanup" EXIT SIGINT - -cleanup - -mkdir -p "${TMP_DIFFROOT}" -cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" - -"${SCRIPT_ROOT}/hack/update-codegen.sh" -echo "diffing ${DIFFROOT} against freshly generated codegen" -ret=0 -diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? -cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" -if [[ $ret -eq 0 ]] -then - echo "${DIFFROOT} up to date." -else - echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" - exit 1 -fi diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/register.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/register.go deleted file mode 100644 index bd3b2ba64..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/register.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2017 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 v1 - -import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - - cr "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr" -) - -// SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: cr.GroupName, Version: "v1"} - -// Kind takes an unqualified kind and returns back a Group qualified GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - AddToScheme = SchemeBuilder.AddToScheme -) - -// Adds the list of known types to Scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &Example{}, - &ExampleList{}, - ) - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/types.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/types.go deleted file mode 100644 index 274b30f61..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/types.go +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright 2017 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 v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +genclient -// +genclient:noStatus -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Example is a specification for an Example resource -type Example struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - - Spec ExampleSpec `json:"spec"` - Status ExampleStatus `json:"status,omitempty"` -} - -// ExampleSpec is the spec for an Example resource -type ExampleSpec struct { - Foo string `json:"foo"` - Bar bool `json:"bar"` -} - -// ExampleStatus is the status for an Example resource -type ExampleStatus struct { - State ExampleState `json:"state,omitempty"` - Message string `json:"message,omitempty"` -} - -type ExampleState string - -const ( - ExampleStateCreated ExampleState = "Created" - ExampleStateProcessed ExampleState = "Processed" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ExampleList is a list of Example resources -type ExampleList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []Example `json:"items"` -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/zz_generated.deepcopy.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/zz_generated.deepcopy.go deleted file mode 100644 index 50828809d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,118 +0,0 @@ -// +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 deepcopy-gen. DO NOT EDIT. - -package v1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Example) DeepCopyInto(out *Example) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Example. -func (in *Example) DeepCopy() *Example { - if in == nil { - return nil - } - out := new(Example) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Example) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExampleList) DeepCopyInto(out *ExampleList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Example, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExampleList. -func (in *ExampleList) DeepCopy() *ExampleList { - if in == nil { - return nil - } - out := new(ExampleList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ExampleList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExampleSpec) DeepCopyInto(out *ExampleSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExampleSpec. -func (in *ExampleSpec) DeepCopy() *ExampleSpec { - if in == nil { - return nil - } - out := new(ExampleSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExampleStatus) DeepCopyInto(out *ExampleStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExampleStatus. -func (in *ExampleStatus) DeepCopy() *ExampleStatus { - if in == nil { - return nil - } - out := new(ExampleStatus) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/clientset.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/clientset.go deleted file mode 100644 index 92ff15819..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/clientset.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package versioned - -import ( - crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1" - discovery "k8s.io/client-go/discovery" - rest "k8s.io/client-go/rest" - flowcontrol "k8s.io/client-go/util/flowcontrol" -) - -type Interface interface { - Discovery() discovery.DiscoveryInterface - CrV1() crv1.CrV1Interface - // Deprecated: please explicitly pick a version if possible. - Cr() crv1.CrV1Interface -} - -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. -type Clientset struct { - *discovery.DiscoveryClient - crV1 *crv1.CrV1Client -} - -// CrV1 retrieves the CrV1Client -func (c *Clientset) CrV1() crv1.CrV1Interface { - return c.crV1 -} - -// Deprecated: Cr retrieves the default version of CrClient. -// Please explicitly pick a version. -func (c *Clientset) Cr() crv1.CrV1Interface { - return c.crV1 -} - -// Discovery retrieves the DiscoveryClient -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - if c == nil { - return nil - } - return c.DiscoveryClient -} - -// NewForConfig creates a new Clientset for the given config. -func NewForConfig(c *rest.Config) (*Clientset, error) { - configShallowCopy := *c - if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { - configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) - } - var cs Clientset - var err error - cs.crV1, err = crv1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - return &cs, nil -} - -// NewForConfigOrDie creates a new Clientset for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.crV1 = crv1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs -} - -// New creates a new Clientset for the given RESTClient. -func New(c rest.Interface) *Clientset { - var cs Clientset - cs.crV1 = crv1.New(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClient(c) - return &cs -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/clientset_generated.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/clientset_generated.go deleted file mode 100644 index 28089890d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/clientset_generated.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - clientset "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned" - crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1" - fakecrv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/discovery" - fakediscovery "k8s.io/client-go/discovery/fake" - "k8s.io/client-go/testing" -) - -// NewSimpleClientset returns a clientset that will respond with the provided objects. -// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement -// for a real clientset and is mostly useful in simple unit tests. -func NewSimpleClientset(objects ...runtime.Object) *Clientset { - o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - cs := &Clientset{} - cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} - cs.AddReactor("*", "*", testing.ObjectReaction(o)) - cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { - gvr := action.GetResource() - ns := action.GetNamespace() - watch, err := o.Watch(gvr, ns) - if err != nil { - return false, nil, err - } - return true, watch, nil - }) - - return cs -} - -// Clientset implements clientset.Interface. Meant to be embedded into a -// struct to get a default implementation. This makes faking out just the method -// you want to test easier. -type Clientset struct { - testing.Fake - discovery *fakediscovery.FakeDiscovery -} - -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - return c.discovery -} - -var _ clientset.Interface = &Clientset{} - -// CrV1 retrieves the CrV1Client -func (c *Clientset) CrV1() crv1.CrV1Interface { - return &fakecrv1.FakeCrV1{Fake: &c.Fake} -} - -// Cr retrieves the CrV1Client -func (c *Clientset) Cr() crv1.CrV1Interface { - return &fakecrv1.FakeCrV1{Fake: &c.Fake} -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/doc.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/doc.go deleted file mode 100644 index 9b99e7167..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated fake clientset. -package fake diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/register.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/register.go deleted file mode 100644 index fdcedd4c5..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/register.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var scheme = runtime.NewScheme() -var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) - -func init() { - v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) - AddToScheme(scheme) -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -func AddToScheme(scheme *runtime.Scheme) { - crv1.AddToScheme(scheme) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/doc.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/doc.go deleted file mode 100644 index 7dc375616..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/register.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/register.go deleted file mode 100644 index 74d8fa4d0..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/register.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package scheme - -import ( - crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - AddToScheme(Scheme) -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -func AddToScheme(scheme *runtime.Scheme) { - crv1.AddToScheme(scheme) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/cr_client.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/cr_client.go deleted file mode 100644 index 04e3930e1..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/cr_client.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package v1 - -import ( - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - rest "k8s.io/client-go/rest" -) - -type CrV1Interface interface { - RESTClient() rest.Interface - ExamplesGetter -} - -// CrV1Client is used to interact with features provided by the cr.example.apiextensions.k8s.io group. -type CrV1Client struct { - restClient rest.Interface -} - -func (c *CrV1Client) Examples(namespace string) ExampleInterface { - return newExamples(c, namespace) -} - -// NewForConfig creates a new CrV1Client for the given config. -func NewForConfig(c *rest.Config) (*CrV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &CrV1Client{client}, nil -} - -// NewForConfigOrDie creates a new CrV1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *CrV1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new CrV1Client for the given RESTClient. -func New(c rest.Interface) *CrV1Client { - return &CrV1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *CrV1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/doc.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/doc.go deleted file mode 100644 index 3af5d054f..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1 diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go deleted file mode 100644 index a0cc33852..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go +++ /dev/null @@ -1,157 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package v1 - -import ( - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - scheme "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ExamplesGetter has a method to return a ExampleInterface. -// A group's client should implement this interface. -type ExamplesGetter interface { - Examples(namespace string) ExampleInterface -} - -// ExampleInterface has methods to work with Example resources. -type ExampleInterface interface { - Create(*v1.Example) (*v1.Example, error) - Update(*v1.Example) (*v1.Example, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.Example, error) - List(opts meta_v1.ListOptions) (*v1.ExampleList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Example, err error) - ExampleExpansion -} - -// examples implements ExampleInterface -type examples struct { - client rest.Interface - ns string -} - -// newExamples returns a Examples -func newExamples(c *CrV1Client, namespace string) *examples { - return &examples{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the example, and returns the corresponding example object, and an error if there is any. -func (c *examples) Get(name string, options meta_v1.GetOptions) (result *v1.Example, err error) { - result = &v1.Example{} - err = c.client.Get(). - Namespace(c.ns). - Resource("examples"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Examples that match those selectors. -func (c *examples) List(opts meta_v1.ListOptions) (result *v1.ExampleList, err error) { - result = &v1.ExampleList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("examples"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested examples. -func (c *examples) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("examples"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a example and creates it. Returns the server's representation of the example, and an error, if there is any. -func (c *examples) Create(example *v1.Example) (result *v1.Example, err error) { - result = &v1.Example{} - err = c.client.Post(). - Namespace(c.ns). - Resource("examples"). - Body(example). - Do(). - Into(result) - return -} - -// Update takes the representation of a example and updates it. Returns the server's representation of the example, and an error, if there is any. -func (c *examples) Update(example *v1.Example) (result *v1.Example, err error) { - result = &v1.Example{} - err = c.client.Put(). - Namespace(c.ns). - Resource("examples"). - Name(example.Name). - Body(example). - Do(). - Into(result) - return -} - -// Delete takes name of the example and deletes it. Returns an error if one occurs. -func (c *examples) Delete(name string, options *meta_v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("examples"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *examples) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("examples"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched example. -func (c *examples) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Example, err error) { - result = &v1.Example{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("examples"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go deleted file mode 100644 index 5ce902313..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeCrV1 struct { - *testing.Fake -} - -func (c *FakeCrV1) Examples(namespace string) v1.ExampleInterface { - return &FakeExamples{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeCrV1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go deleted file mode 100644 index 2db7f5c1e..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go +++ /dev/null @@ -1,128 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - cr_v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeExamples implements ExampleInterface -type FakeExamples struct { - Fake *FakeCrV1 - ns string -} - -var examplesResource = schema.GroupVersionResource{Group: "cr.example.apiextensions.k8s.io", Version: "v1", Resource: "examples"} - -var examplesKind = schema.GroupVersionKind{Group: "cr.example.apiextensions.k8s.io", Version: "v1", Kind: "Example"} - -// Get takes name of the example, and returns the corresponding example object, and an error if there is any. -func (c *FakeExamples) Get(name string, options v1.GetOptions) (result *cr_v1.Example, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(examplesResource, c.ns, name), &cr_v1.Example{}) - - if obj == nil { - return nil, err - } - return obj.(*cr_v1.Example), err -} - -// List takes label and field selectors, and returns the list of Examples that match those selectors. -func (c *FakeExamples) List(opts v1.ListOptions) (result *cr_v1.ExampleList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(examplesResource, examplesKind, c.ns, opts), &cr_v1.ExampleList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &cr_v1.ExampleList{ListMeta: obj.(*cr_v1.ExampleList).ListMeta} - for _, item := range obj.(*cr_v1.ExampleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested examples. -func (c *FakeExamples) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(examplesResource, c.ns, opts)) - -} - -// Create takes the representation of a example and creates it. Returns the server's representation of the example, and an error, if there is any. -func (c *FakeExamples) Create(example *cr_v1.Example) (result *cr_v1.Example, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(examplesResource, c.ns, example), &cr_v1.Example{}) - - if obj == nil { - return nil, err - } - return obj.(*cr_v1.Example), err -} - -// Update takes the representation of a example and updates it. Returns the server's representation of the example, and an error, if there is any. -func (c *FakeExamples) Update(example *cr_v1.Example) (result *cr_v1.Example, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(examplesResource, c.ns, example), &cr_v1.Example{}) - - if obj == nil { - return nil, err - } - return obj.(*cr_v1.Example), err -} - -// Delete takes name of the example and deletes it. Returns an error if one occurs. -func (c *FakeExamples) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(examplesResource, c.ns, name), &cr_v1.Example{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeExamples) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(examplesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &cr_v1.ExampleList{}) - return err -} - -// Patch applies the patch and returns the patched example. -func (c *FakeExamples) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *cr_v1.Example, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(examplesResource, c.ns, name, data, subresources...), &cr_v1.Example{}) - - if obj == nil { - return nil, err - } - return obj.(*cr_v1.Example), err -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/interface.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/interface.go deleted file mode 100644 index 0c633e3ef..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/interface.go +++ /dev/null @@ -1,46 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package cr - -import ( - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1" - internalinterfaces "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to each of this group's versions. -type Interface interface { - // V1 provides access to shared informers for resources in V1. - V1() v1.Interface -} - -type group struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// V1 returns a new v1.Interface. -func (g *group) V1() v1.Interface { - return v1.New(g.factory, g.namespace, g.tweakListOptions) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/example.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/example.go deleted file mode 100644 index 50b563d39..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/example.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package v1 - -import ( - time "time" - - cr_v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - versioned "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned" - internalinterfaces "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces" - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// ExampleInformer provides access to a shared informer and lister for -// Examples. -type ExampleInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1.ExampleLister -} - -type exampleInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewExampleInformer constructs a new informer for Example type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewExampleInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredExampleInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredExampleInformer constructs a new informer for Example type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredExampleInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.CrV1().Examples(namespace).List(options) - }, - WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.CrV1().Examples(namespace).Watch(options) - }, - }, - &cr_v1.Example{}, - resyncPeriod, - indexers, - ) -} - -func (f *exampleInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredExampleInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *exampleInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&cr_v1.Example{}, f.defaultInformer) -} - -func (f *exampleInformer) Lister() v1.ExampleLister { - return v1.NewExampleLister(f.Informer().GetIndexer()) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/interface.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/interface.go deleted file mode 100644 index 96ee1514c..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/interface.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package v1 - -import ( - internalinterfaces "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // Examples returns a ExampleInformer. - Examples() ExampleInformer -} - -type version struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// Examples returns a ExampleInformer. -func (v *version) Examples() ExampleInformer { - return &exampleInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/factory.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/factory.go deleted file mode 100644 index 67c55af39..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/factory.go +++ /dev/null @@ -1,180 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package externalversions - -import ( - reflect "reflect" - sync "sync" - time "time" - - versioned "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned" - cr "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr" - internalinterfaces "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// SharedInformerOption defines the functional option type for SharedInformerFactory. -type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory - -type sharedInformerFactory struct { - client versioned.Interface - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc - lock sync.Mutex - defaultResync time.Duration - customResync map[reflect.Type]time.Duration - - informers map[reflect.Type]cache.SharedIndexInformer - // startedInformers is used for tracking which informers have been started. - // This allows Start() to be called multiple times safely. - startedInformers map[reflect.Type]bool -} - -// WithCustomResyncConfig sets a custom resync period for the specified informer types. -func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - for k, v := range resyncConfig { - factory.customResync[reflect.TypeOf(k)] = v - } - return factory - } -} - -// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.tweakListOptions = tweakListOptions - return factory - } -} - -// WithNamespace limits the SharedInformerFactory to the specified namespace. -func WithNamespace(namespace string) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.namespace = namespace - return factory - } -} - -// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. -func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync) -} - -// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. -// Listers obtained via this SharedInformerFactory will be subject to the same filters -// as specified here. -// Deprecated: Please use NewSharedInformerFactoryWithOptions instead -func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) -} - -// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { - factory := &sharedInformerFactory{ - client: client, - namespace: v1.NamespaceAll, - defaultResync: defaultResync, - informers: make(map[reflect.Type]cache.SharedIndexInformer), - startedInformers: make(map[reflect.Type]bool), - customResync: make(map[reflect.Type]time.Duration), - } - - // Apply all options - for _, opt := range options { - factory = opt(factory) - } - - return factory -} - -// Start initializes all requested informers. -func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { - f.lock.Lock() - defer f.lock.Unlock() - - for informerType, informer := range f.informers { - if !f.startedInformers[informerType] { - go informer.Run(stopCh) - f.startedInformers[informerType] = true - } - } -} - -// WaitForCacheSync waits for all started informers' cache were synced. -func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { - informers := func() map[reflect.Type]cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informers := map[reflect.Type]cache.SharedIndexInformer{} - for informerType, informer := range f.informers { - if f.startedInformers[informerType] { - informers[informerType] = informer - } - } - return informers - }() - - res := map[reflect.Type]bool{} - for informType, informer := range informers { - res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) - } - return res -} - -// InternalInformerFor returns the SharedIndexInformer for obj using an internal -// client. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informerType := reflect.TypeOf(obj) - informer, exists := f.informers[informerType] - if exists { - return informer - } - - resyncPeriod, exists := f.customResync[informerType] - if !exists { - resyncPeriod = f.defaultResync - } - - informer = newFunc(f.client, resyncPeriod) - f.informers[informerType] = informer - - return informer -} - -// SharedInformerFactory provides shared informers for resources in all known -// API group versions. -type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory - ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - Cr() cr.Interface -} - -func (f *sharedInformerFactory) Cr() cr.Interface { - return cr.New(f, f.namespace, f.tweakListOptions) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/generic.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/generic.go deleted file mode 100644 index 2bf6c5a47..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/generic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package externalversions - -import ( - "fmt" - - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// GenericInformer is type of SharedIndexInformer which will locate and delegate to other -// sharedInformers based on type -type GenericInformer interface { - Informer() cache.SharedIndexInformer - Lister() cache.GenericLister -} - -type genericInformer struct { - informer cache.SharedIndexInformer - resource schema.GroupResource -} - -// Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer -} - -// Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) -} - -// ForResource gives generic access to a shared informer of the matching type -// TODO extend this to unknown resources with a client pool -func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { - switch resource { - // Group=cr.example.apiextensions.k8s.io, Version=v1 - case v1.SchemeGroupVersion.WithResource("examples"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Cr().V1().Examples().Informer()}, nil - - } - - return nil, fmt.Errorf("no informer found for %v", resource) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go deleted file mode 100644 index 5b81f037b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package internalinterfaces - -import ( - time "time" - - versioned "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - cache "k8s.io/client-go/tools/cache" -) - -type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer - -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle -type SharedInformerFactory interface { - Start(stopCh <-chan struct{}) - InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer -} - -type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/example.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/example.go deleted file mode 100644 index 8a64d09cc..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/example.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -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 lister-gen. DO NOT EDIT. - -package v1 - -import ( - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ExampleLister helps list Examples. -type ExampleLister interface { - // List lists all Examples in the indexer. - List(selector labels.Selector) (ret []*v1.Example, err error) - // Examples returns an object that can list and get Examples. - Examples(namespace string) ExampleNamespaceLister - ExampleListerExpansion -} - -// exampleLister implements the ExampleLister interface. -type exampleLister struct { - indexer cache.Indexer -} - -// NewExampleLister returns a new ExampleLister. -func NewExampleLister(indexer cache.Indexer) ExampleLister { - return &exampleLister{indexer: indexer} -} - -// List lists all Examples in the indexer. -func (s *exampleLister) List(selector labels.Selector) (ret []*v1.Example, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.Example)) - }) - return ret, err -} - -// Examples returns an object that can list and get Examples. -func (s *exampleLister) Examples(namespace string) ExampleNamespaceLister { - return exampleNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ExampleNamespaceLister helps list and get Examples. -type ExampleNamespaceLister interface { - // List lists all Examples in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.Example, err error) - // Get retrieves the Example from the indexer for a given namespace and name. - Get(name string) (*v1.Example, error) - ExampleNamespaceListerExpansion -} - -// exampleNamespaceLister implements the ExampleNamespaceLister -// interface. -type exampleNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Examples in the indexer for a given namespace. -func (s exampleNamespaceLister) List(selector labels.Selector) (ret []*v1.Example, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.Example)) - }) - return ret, err -} - -// Get retrieves the Example from the indexer for a given namespace and name. -func (s exampleNamespaceLister) Get(name string) (*v1.Example, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("example"), name) - } - return obj.(*v1.Example), nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/expansion_generated.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/expansion_generated.go deleted file mode 100644 index 5291ebaec..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/expansion_generated.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -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 lister-gen. DO NOT EDIT. - -package v1 - -// ExampleListerExpansion allows custom methods to be added to -// ExampleLister. -type ExampleListerExpansion interface{} - -// ExampleNamespaceListerExpansion allows custom methods to be added to -// ExampleNamespaceLister. -type ExampleNamespaceListerExpansion interface{} diff --git a/vendor/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt b/vendor/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt deleted file mode 100644 index b7c650da4..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt +++ /dev/null @@ -1,16 +0,0 @@ -/* -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. -*/ - diff --git a/vendor/k8s.io/apiextensions-apiserver/hack/build-image.sh b/vendor/k8s.io/apiextensions-apiserver/hack/build-image.sh deleted file mode 100755 index d0d129078..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/hack/build-image.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2017 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. - - -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../../../.. -source "${KUBE_ROOT}/hack/lib/util.sh" - -# Register function to be called on EXIT to remove generated binary. -function cleanup { - rm "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/apiextensions-apiserver" -} -trap cleanup EXIT - -pushd "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver" -cp -v ../../../../_output/local/bin/linux/amd64/apiextensions-apiserver ./artifacts/simple-image/apiextensions-apiserver -docker build -t apiextensions-apiserver:latest ./artifacts/simple-image -popd diff --git a/vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh b/vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh deleted file mode 100755 index a586b48e0..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2017 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. - -set -o errexit -set -o nounset -set -o pipefail - -SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. -SCRIPT_BASE=${SCRIPT_ROOT}/../.. -CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo k8s.io/code-generator)} - -if LANG=C sed --help 2>&1 | grep -q GNU; then - SED="sed" -elif which gsed &>/dev/null; then - SED="gsed" -else - echo "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2 - exit 1 -fi - -# Register function to be called on EXIT to remove generated binary. -function cleanup { - rm -f "${CLIENTGEN:-}" - rm -f "${listergen:-}" - rm -f "${informergen:-}" -} -trap cleanup EXIT - -echo "Building client-gen" -CLIENTGEN="${PWD}/client-gen" -go build -o "${CLIENTGEN}" ${CODEGEN_PKG}/cmd/client-gen - -PREFIX=k8s.io/apiextensions-apiserver/pkg/apis -INPUT_BASE="--input-base ${PREFIX}" -INPUT_APIS=( -apiextensions/ -apiextensions/v1beta1 -) -INPUT="--input ${INPUT_APIS[@]}" -CLIENTSET_PATH="--output-package k8s.io/apiextensions-apiserver/pkg/client/clientset" - -${CLIENTGEN} ${INPUT_BASE} ${INPUT} ${CLIENTSET_PATH} --output-base ${SCRIPT_BASE} -${CLIENTGEN} --clientset-name="clientset" ${INPUT_BASE} --input apiextensions/v1beta1 ${CLIENTSET_PATH} --output-base ${SCRIPT_BASE} --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt - - -echo "Building lister-gen" -listergen="${PWD}/lister-gen" -go build -o "${listergen}" ${CODEGEN_PKG}/cmd/lister-gen - -LISTER_INPUT="--input-dirs k8s.io/apiextensions-apiserver/pkg/apis/apiextensions --input-dirs k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" -LISTER_PATH="--output-package k8s.io/apiextensions-apiserver/pkg/client/listers" -${listergen} ${LISTER_INPUT} ${LISTER_PATH} --output-base ${SCRIPT_BASE} --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt - - -echo "Building informer-gen" -informergen="${PWD}/informer-gen" -go build -o "${informergen}" ${CODEGEN_PKG}/cmd/informer-gen - -${informergen} \ - --output-base ${SCRIPT_BASE} \ - --input-dirs k8s.io/apiextensions-apiserver/pkg/apis/apiextensions --input-dirs k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1 \ - --versioned-clientset-package k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset \ - --internal-clientset-package k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset \ - --listers-package k8s.io/apiextensions-apiserver/pkg/client/listers \ - --output-package k8s.io/apiextensions-apiserver/pkg/client/informers \ - --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt - "$@" diff --git a/vendor/k8s.io/apiextensions-apiserver/hack/verify-codegen.sh b/vendor/k8s.io/apiextensions-apiserver/hack/verify-codegen.sh deleted file mode 100755 index ab43ba23d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/hack/verify-codegen.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2017 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. - -set -o errexit -set -o nounset -set -o pipefail - -SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. -SCRIPT_BASE=${SCRIPT_ROOT}/../.. - -DIFFROOT="${SCRIPT_ROOT}/pkg" -TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg" -_tmp="${SCRIPT_ROOT}/_tmp" - -cleanup() { - rm -rf "${_tmp}" -} -trap "cleanup" EXIT SIGINT - -cleanup - -mkdir -p "${TMP_DIFFROOT}" -cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" - -"${SCRIPT_ROOT}/hack/update-codegen.sh" -echo "diffing ${DIFFROOT} against freshly generated codegen" -ret=0 -diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? -cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" -if [[ $ret -eq 0 ]] -then - echo "${DIFFROOT} up to date." -else - echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" - exit 1 -fi diff --git a/vendor/k8s.io/apiextensions-apiserver/main.go b/vendor/k8s.io/apiextensions-apiserver/main.go deleted file mode 100644 index 09143ab6e..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/main.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2017 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 ( - "flag" - "os" - - "github.com/golang/glog" - - "k8s.io/apiextensions-apiserver/pkg/cmd/server" - genericapiserver "k8s.io/apiserver/pkg/server" - "k8s.io/apiserver/pkg/util/logs" -) - -func main() { - logs.InitLogs() - defer logs.FlushLogs() - - stopCh := genericapiserver.SetupSignalHandler() - cmd := server.NewCommandStartCustomResourceDefinitionsServer(os.Stdout, os.Stderr, stopCh) - cmd.Flags().AddGoFlagSet(flag.CommandLine) - if err := cmd.Execute(); err != nil { - glog.Fatal(err) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/deepcopy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/deepcopy.go deleted file mode 100644 index 37b4d1df9..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/deepcopy.go +++ /dev/null @@ -1,262 +0,0 @@ -/* -Copyright 2017 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 apiextensions - -import "k8s.io/apimachinery/pkg/runtime" - -// TODO: Update this after a tag is created for interface fields in DeepCopy -func (in *JSONSchemaProps) DeepCopy() *JSONSchemaProps { - if in == nil { - return nil - } - out := new(JSONSchemaProps) - - *out = *in - - if in.Default != nil { - defaultJSON := JSON(runtime.DeepCopyJSONValue(*(in.Default))) - out.Default = &(defaultJSON) - } else { - out.Default = nil - } - - if in.Example != nil { - exampleJSON := JSON(runtime.DeepCopyJSONValue(*(in.Example))) - out.Example = &(exampleJSON) - } else { - out.Example = nil - } - - if in.Ref != nil { - in, out := &in.Ref, &out.Ref - if *in == nil { - *out = nil - } else { - *out = new(string) - **out = **in - } - } - - if in.Maximum != nil { - in, out := &in.Maximum, &out.Maximum - if *in == nil { - *out = nil - } else { - *out = new(float64) - **out = **in - } - } - - if in.Minimum != nil { - in, out := &in.Minimum, &out.Minimum - if *in == nil { - *out = nil - } else { - *out = new(float64) - **out = **in - } - } - - if in.MaxLength != nil { - in, out := &in.MaxLength, &out.MaxLength - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MinLength != nil { - in, out := &in.MinLength, &out.MinLength - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - if in.MaxItems != nil { - in, out := &in.MaxItems, &out.MaxItems - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MinItems != nil { - in, out := &in.MinItems, &out.MinItems - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MultipleOf != nil { - in, out := &in.MultipleOf, &out.MultipleOf - if *in == nil { - *out = nil - } else { - *out = new(float64) - **out = **in - } - } - - if in.Enum != nil { - out.Enum = make([]JSON, len(in.Enum)) - for i := range in.Enum { - out.Enum[i] = runtime.DeepCopyJSONValue(in.Enum[i]) - } - } - - if in.MaxProperties != nil { - in, out := &in.MaxProperties, &out.MaxProperties - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MinProperties != nil { - in, out := &in.MinProperties, &out.MinProperties - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.Required != nil { - in, out := &in.Required, &out.Required - *out = make([]string, len(*in)) - copy(*out, *in) - } - - if in.Items != nil { - in, out := &in.Items, &out.Items - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaPropsOrArray) - (*in).DeepCopyInto(*out) - } - } - - if in.AllOf != nil { - in, out := &in.AllOf, &out.AllOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - - if in.OneOf != nil { - in, out := &in.OneOf, &out.OneOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.AnyOf != nil { - in, out := &in.AnyOf, &out.AnyOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - - if in.Not != nil { - in, out := &in.Not, &out.Not - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaProps) - (*in).DeepCopyInto(*out) - } - } - - if in.Properties != nil { - in, out := &in.Properties, &out.Properties - *out = make(map[string]JSONSchemaProps, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.AdditionalProperties != nil { - in, out := &in.AdditionalProperties, &out.AdditionalProperties - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaPropsOrBool) - (*in).DeepCopyInto(*out) - } - } - - if in.PatternProperties != nil { - in, out := &in.PatternProperties, &out.PatternProperties - *out = make(map[string]JSONSchemaProps, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.Dependencies != nil { - in, out := &in.Dependencies, &out.Dependencies - *out = make(JSONSchemaDependencies, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.AdditionalItems != nil { - in, out := &in.AdditionalItems, &out.AdditionalItems - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaPropsOrBool) - (*in).DeepCopyInto(*out) - } - } - - if in.Definitions != nil { - in, out := &in.Definitions, &out.Definitions - *out = make(JSONSchemaDefinitions, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.ExternalDocs != nil { - in, out := &in.ExternalDocs, &out.ExternalDocs - if *in == nil { - *out = nil - } else { - *out = new(ExternalDocumentation) - (*in).DeepCopyInto(*out) - } - } - - return out -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/doc.go deleted file mode 100644 index 0517ec6a8..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2017 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. -*/ - -// +k8s:deepcopy-gen=package - -// Package apiextensions is the internal version of the API. -// +groupName=apiextensions.k8s.io -package apiextensions // import "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go deleted file mode 100644 index ff8cc0334..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright 2017 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 fuzzer - -import ( - "reflect" - "strings" - - "github.com/google/gofuzz" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc() - -// Funcs returns the fuzzer functions for the apiextensions apis. -func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { - return []interface{}{ - func(obj *apiextensions.CustomResourceDefinitionSpec, c fuzz.Continue) { - c.FuzzNoCustom(obj) - - // match our defaulter - if len(obj.Scope) == 0 { - obj.Scope = apiextensions.NamespaceScoped - } - if len(obj.Names.Singular) == 0 { - obj.Names.Singular = strings.ToLower(obj.Names.Kind) - } - if len(obj.Names.ListKind) == 0 && len(obj.Names.Kind) > 0 { - obj.Names.ListKind = obj.Names.Kind + "List" - } - if len(obj.Versions) == 0 && len(obj.Version) != 0 { - obj.Versions = []apiextensions.CustomResourceDefinitionVersion{ - { - Name: obj.Version, - Served: true, - Storage: true, - }, - } - } else if len(obj.Versions) != 0 { - obj.Version = obj.Versions[0].Name - } - if len(obj.AdditionalPrinterColumns) == 0 { - obj.AdditionalPrinterColumns = []apiextensions.CustomResourceColumnDefinition{ - {Name: "Age", Type: "date", Description: swaggerMetadataDescriptions["creationTimestamp"], JSONPath: ".metadata.creationTimestamp"}, - } - } - }, - func(obj *apiextensions.CustomResourceDefinition, c fuzz.Continue) { - c.FuzzNoCustom(obj) - - if len(obj.Status.StoredVersions) == 0 { - for _, v := range obj.Spec.Versions { - if v.Storage && !apiextensions.IsStoredVersion(obj, v.Name) { - obj.Status.StoredVersions = append(obj.Status.StoredVersions, v.Name) - } - } - } - }, - func(obj *apiextensions.JSONSchemaProps, c fuzz.Continue) { - // we cannot use c.FuzzNoCustom because of the interface{} fields. So let's loop with reflection. - vobj := reflect.ValueOf(obj).Elem() - tobj := reflect.TypeOf(obj).Elem() - for i := 0; i < tobj.NumField(); i++ { - field := tobj.Field(i) - switch field.Name { - case "Default", "Enum", "Example", "Ref": - continue - default: - isValue := true - switch field.Type.Kind() { - case reflect.Interface, reflect.Map, reflect.Slice, reflect.Ptr: - isValue = false - } - if isValue || c.Intn(10) == 0 { - c.Fuzz(vobj.Field(i).Addr().Interface()) - } - } - } - if c.RandBool() { - validJSON := apiextensions.JSON(`{"some": {"json": "test"}, "string": 42}`) - obj.Default = &validJSON - } - if c.RandBool() { - obj.Enum = []apiextensions.JSON{c.Float64(), c.RandString(), c.RandBool()} - } - if c.RandBool() { - validJSON := apiextensions.JSON(`"foobarbaz"`) - obj.Example = &validJSON - } - if c.RandBool() { - validRef := "validRef" - obj.Ref = &validRef - } - }, - func(obj *apiextensions.JSONSchemaPropsOrBool, c fuzz.Continue) { - if c.RandBool() { - obj.Allows = true - obj.Schema = &apiextensions.JSONSchemaProps{} - c.Fuzz(obj.Schema) - } else { - obj.Allows = c.RandBool() - } - }, - func(obj *apiextensions.JSONSchemaPropsOrArray, c fuzz.Continue) { - // disallow both Schema and JSONSchemas to be nil. - if c.RandBool() { - obj.Schema = &apiextensions.JSONSchemaProps{} - c.Fuzz(obj.Schema) - } else { - obj.JSONSchemas = make([]apiextensions.JSONSchemaProps, c.Intn(3)+1) - for i := range obj.JSONSchemas { - c.Fuzz(&obj.JSONSchemas[i]) - } - } - }, - func(obj *apiextensions.JSONSchemaPropsOrStringArray, c fuzz.Continue) { - if c.RandBool() { - obj.Schema = &apiextensions.JSONSchemaProps{} - c.Fuzz(obj.Schema) - } else { - c.Fuzz(&obj.Property) - } - }, - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers.go deleted file mode 100644 index 92cad7d9b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers.go +++ /dev/null @@ -1,149 +0,0 @@ -/* -Copyright 2017 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 apiextensions - -import ( - "fmt" - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// SetCRDCondition sets the status condition. It either overwrites the existing one or -// creates a new one -func SetCRDCondition(crd *CustomResourceDefinition, newCondition CustomResourceDefinitionCondition) { - existingCondition := FindCRDCondition(crd, newCondition.Type) - if existingCondition == nil { - newCondition.LastTransitionTime = metav1.NewTime(time.Now()) - crd.Status.Conditions = append(crd.Status.Conditions, newCondition) - return - } - - if existingCondition.Status != newCondition.Status { - existingCondition.Status = newCondition.Status - existingCondition.LastTransitionTime = newCondition.LastTransitionTime - } - - existingCondition.Reason = newCondition.Reason - existingCondition.Message = newCondition.Message -} - -// RemoveCRDCondition removes the status condition. -func RemoveCRDCondition(crd *CustomResourceDefinition, conditionType CustomResourceDefinitionConditionType) { - newConditions := []CustomResourceDefinitionCondition{} - for _, condition := range crd.Status.Conditions { - if condition.Type != conditionType { - newConditions = append(newConditions, condition) - } - } - crd.Status.Conditions = newConditions -} - -// FindCRDCondition returns the condition you're looking for or nil -func FindCRDCondition(crd *CustomResourceDefinition, conditionType CustomResourceDefinitionConditionType) *CustomResourceDefinitionCondition { - for i := range crd.Status.Conditions { - if crd.Status.Conditions[i].Type == conditionType { - return &crd.Status.Conditions[i] - } - } - - return nil -} - -// IsCRDConditionTrue indicates if the condition is present and strictly true -func IsCRDConditionTrue(crd *CustomResourceDefinition, conditionType CustomResourceDefinitionConditionType) bool { - return IsCRDConditionPresentAndEqual(crd, conditionType, ConditionTrue) -} - -// IsCRDConditionFalse indicates if the condition is present and false true -func IsCRDConditionFalse(crd *CustomResourceDefinition, conditionType CustomResourceDefinitionConditionType) bool { - return IsCRDConditionPresentAndEqual(crd, conditionType, ConditionFalse) -} - -// IsCRDConditionPresentAndEqual indicates if the condition is present and equal to the arg -func IsCRDConditionPresentAndEqual(crd *CustomResourceDefinition, conditionType CustomResourceDefinitionConditionType, status ConditionStatus) bool { - for _, condition := range crd.Status.Conditions { - if condition.Type == conditionType { - return condition.Status == status - } - } - return false -} - -// IsCRDConditionEquivalent returns true if the lhs and rhs are equivalent except for times -func IsCRDConditionEquivalent(lhs, rhs *CustomResourceDefinitionCondition) bool { - if lhs == nil && rhs == nil { - return true - } - if lhs == nil || rhs == nil { - return false - } - - return lhs.Message == rhs.Message && lhs.Reason == rhs.Reason && lhs.Status == rhs.Status && lhs.Type == rhs.Type -} - -// CRDHasFinalizer returns true if the finalizer is in the list -func CRDHasFinalizer(crd *CustomResourceDefinition, needle string) bool { - for _, finalizer := range crd.Finalizers { - if finalizer == needle { - return true - } - } - - return false -} - -// CRDRemoveFinalizer removes the finalizer if present -func CRDRemoveFinalizer(crd *CustomResourceDefinition, needle string) { - newFinalizers := []string{} - for _, finalizer := range crd.Finalizers { - if finalizer != needle { - newFinalizers = append(newFinalizers, finalizer) - } - } - crd.Finalizers = newFinalizers -} - -// HasServedCRDVersion returns true if `version` is in the list of CRD's versions and the Served flag is set. -func HasServedCRDVersion(crd *CustomResourceDefinition, version string) bool { - for _, v := range crd.Spec.Versions { - if v.Name == version { - return v.Served - } - } - return false -} - -// GetCRDStorageVersion returns the storage version for given CRD. -func GetCRDStorageVersion(crd *CustomResourceDefinition) (string, error) { - for _, v := range crd.Spec.Versions { - if v.Storage { - return v.Name, nil - } - } - // This should not happened if crd is valid - return "", fmt.Errorf("invalid CustomResourceDefinition, no storage version") -} - -func IsStoredVersion(crd *CustomResourceDefinition, version string) bool { - for _, v := range crd.Status.StoredVersions { - if version == v { - return true - } - } - return false -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers_test.go deleted file mode 100644 index df58a7cbf..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers_test.go +++ /dev/null @@ -1,421 +0,0 @@ -/* -Copyright 2017 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 apiextensions - -import ( - "reflect" - "testing" - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func TestCRDHasFinalizer(t *testing.T) { - tests := []struct { - name string - crd *CustomResourceDefinition - finalizerToCheck string - - expected bool - }{ - { - name: "missing", - crd: &CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Finalizers: []string{"not-it"}}, - }, - finalizerToCheck: "it", - expected: false, - }, - { - name: "present", - crd: &CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Finalizers: []string{"not-it", "it"}}, - }, - finalizerToCheck: "it", - expected: true, - }, - } - for _, tc := range tests { - actual := CRDHasFinalizer(tc.crd, tc.finalizerToCheck) - if tc.expected != actual { - t.Errorf("%v expected %v, got %v", tc.name, tc.expected, actual) - } - } -} - -func TestCRDRemoveFinalizer(t *testing.T) { - tests := []struct { - name string - crd *CustomResourceDefinition - finalizerToCheck string - - expected []string - }{ - { - name: "missing", - crd: &CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Finalizers: []string{"not-it"}}, - }, - finalizerToCheck: "it", - expected: []string{"not-it"}, - }, - { - name: "present", - crd: &CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Finalizers: []string{"not-it", "it"}}, - }, - finalizerToCheck: "it", - expected: []string{"not-it"}, - }, - } - for _, tc := range tests { - CRDRemoveFinalizer(tc.crd, tc.finalizerToCheck) - if !reflect.DeepEqual(tc.expected, tc.crd.Finalizers) { - t.Errorf("%v expected %v, got %v", tc.name, tc.expected, tc.crd.Finalizers) - } - } -} - -func TestSetCRDCondition(t *testing.T) { - tests := []struct { - name string - crdCondition []CustomResourceDefinitionCondition - newCondition CustomResourceDefinitionCondition - expectedcrdCondition []CustomResourceDefinitionCondition - }{ - { - name: "test setCRDcondition when one condition", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - newCondition: CustomResourceDefinitionCondition{ - Type: Established, - Status: ConditionFalse, - Reason: "NotAccepted", - Message: "Not accepted", - LastTransitionTime: metav1.Date(2018, 1, 2, 0, 0, 0, 0, time.UTC), - }, - expectedcrdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionFalse, - Reason: "NotAccepted", - Message: "Not accepted", - LastTransitionTime: metav1.Date(2018, 1, 2, 0, 0, 0, 0, time.UTC), - }, - }, - }, - { - name: "test setCRDcondition when two condition", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - newCondition: CustomResourceDefinitionCondition{ - Type: NamesAccepted, - Status: ConditionFalse, - Reason: "Conflicts", - Message: "conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 2, 0, 0, 0, 0, time.UTC), - }, - expectedcrdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionFalse, - Reason: "Conflicts", - Message: "conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 2, 0, 0, 0, 0, time.UTC), - }, - }, - }, - { - name: "test setCRDcondition when condition needs to be appended", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - newCondition: CustomResourceDefinitionCondition{ - Type: Terminating, - Status: ConditionFalse, - Reason: "NeverEstablished", - Message: "resource was never established", - LastTransitionTime: metav1.Date(2018, 2, 1, 0, 0, 0, 0, time.UTC), - }, - expectedcrdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: Terminating, - Status: ConditionFalse, - Reason: "NeverEstablished", - Message: "resource was never established", - LastTransitionTime: metav1.Date(2018, 2, 1, 0, 0, 0, 0, time.UTC), - }, - }, - }, - } - for _, tc := range tests { - crd := generateCRDwithCondition(tc.crdCondition) - SetCRDCondition(crd, tc.newCondition) - if len(tc.expectedcrdCondition) != len(crd.Status.Conditions) { - t.Errorf("%v expected %v, got %v", tc.name, tc.expectedcrdCondition, crd.Status.Conditions) - } - for i := range tc.expectedcrdCondition { - if !IsCRDConditionEquivalent(&tc.expectedcrdCondition[i], &crd.Status.Conditions[i]) { - t.Errorf("%v expected %v, got %v", tc.name, tc.expectedcrdCondition, crd.Status.Conditions) - } - } - } -} - -func TestRemoveCRDCondition(t *testing.T) { - tests := []struct { - name string - crdCondition []CustomResourceDefinitionCondition - conditionType CustomResourceDefinitionConditionType - expectedcrdCondition []CustomResourceDefinitionCondition - }{ - { - name: "test remove CRDCondition when the conditionType meets", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - conditionType: NamesAccepted, - expectedcrdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2011, 1, 2, 0, 0, 0, 0, time.UTC), - }, - }, - }, - { - name: "test remove CRDCondition when the conditionType not meets", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - conditionType: Terminating, - expectedcrdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - }, - } - for _, tc := range tests { - crd := generateCRDwithCondition(tc.crdCondition) - RemoveCRDCondition(crd, tc.conditionType) - if len(tc.expectedcrdCondition) != len(crd.Status.Conditions) { - t.Errorf("%v expected %v, got %v", tc.name, tc.expectedcrdCondition, crd.Status.Conditions) - } - for i := range tc.expectedcrdCondition { - if !IsCRDConditionEquivalent(&tc.expectedcrdCondition[i], &crd.Status.Conditions[i]) { - t.Errorf("%v expected %v, got %v", tc.name, tc.expectedcrdCondition, crd.Status.Conditions) - } - } - } -} - -func TestIsCRDConditionPresentAndEqual(t *testing.T) { - tests := []struct { - name string - crdCondition []CustomResourceDefinitionCondition - conditionType CustomResourceDefinitionConditionType - status ConditionStatus - expectresult bool - }{ - { - name: "test CRDCondition is not Present", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - conditionType: Terminating, - status: ConditionTrue, - expectresult: false, - }, - { - name: "test CRDCondition is Present but not Equal", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - conditionType: Established, - status: ConditionFalse, - expectresult: false, - }, - { - name: "test CRDCondition is Present and Equal", - crdCondition: []CustomResourceDefinitionCondition{ - { - Type: Established, - Status: ConditionTrue, - Reason: "Accepted", - Message: "the initial names have been accepted", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - { - Type: NamesAccepted, - Status: ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", - LastTransitionTime: metav1.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC), - }, - }, - conditionType: NamesAccepted, - status: ConditionTrue, - expectresult: true, - }, - } - for _, tc := range tests { - crd := generateCRDwithCondition(tc.crdCondition) - res := IsCRDConditionPresentAndEqual(crd, tc.conditionType, tc.status) - if res != tc.expectresult { - t.Errorf("%v expected %t, got %t", tc.name, tc.expectresult, res) - } - } -} - -func generateCRDwithCondition(conditions []CustomResourceDefinitionCondition) *CustomResourceDefinition { - testCRDObjectMeta := metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "12", - } - testCRDSpec := CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Scope: ResourceScope("Cluster"), - Names: CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - } - testCRDAcceptedNames := CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - } - return &CustomResourceDefinition{ - ObjectMeta: testCRDObjectMeta, - Spec: testCRDSpec, - Status: CustomResourceDefinitionStatus{ - AcceptedNames: testCRDAcceptedNames, - Conditions: conditions, - }, - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go deleted file mode 100644 index 2fd04b77d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2017 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 install - -import ( - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -// Install registers the API group and adds types to a scheme -func Install(scheme *runtime.Scheme) { - utilruntime.Must(apiextensions.AddToScheme(scheme)) - utilruntime.Must(v1beta1.AddToScheme(scheme)) - utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion)) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/register.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/register.go deleted file mode 100644 index 273f7f123..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/register.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2017 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 apiextensions - -import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -const GroupName = "apiextensions.k8s.io" - -// SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} - -// Kind takes an unqualified kind and returns back a Group qualified GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Resource takes an unqualified resource and returns back a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - AddToScheme = SchemeBuilder.AddToScheme -) - -// Adds the list of known types to the given scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &CustomResourceDefinition{}, - &CustomResourceDefinitionList{}, - ) - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types.go deleted file mode 100644 index 6fc75154f..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types.go +++ /dev/null @@ -1,250 +0,0 @@ -/* -Copyright 2017 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 apiextensions - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// CustomResourceDefinitionSpec describes how a user wants their resource to appear -type CustomResourceDefinitionSpec struct { - // Group is the group this resource belongs in - Group string - // Version is the version this resource belongs in - // Should be always first item in Versions field if provided. - // Optional, but at least one of Version or Versions must be set. - // Deprecated: Please use `Versions`. - Version string - // Names are the names used to describe this custom resource - Names CustomResourceDefinitionNames - // Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced - Scope ResourceScope - // Validation describes the validation methods for CustomResources - Validation *CustomResourceValidation - // Subresources describes the subresources for CustomResources - Subresources *CustomResourceSubresources - // Versions is the list of all supported versions for this resource. - // If Version field is provided, this field is optional. - // Validation: All versions must use the same validation schema for now. i.e., top - // level Validation field is applied to all of these versions. - // Order: The version name will be used to compute the order. - // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered - // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version), - // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first - // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing - // major version, then minor version. An example sorted list of versions: - // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10. - Versions []CustomResourceDefinitionVersion - // AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column. - AdditionalPrinterColumns []CustomResourceColumnDefinition -} - -type CustomResourceDefinitionVersion struct { - // Name is the version name, e.g. “v1”, “v2beta1”, etc. - Name string - // Served is a flag enabling/disabling this version from being served via REST APIs - Served bool - // Storage flags the version as storage version. There must be exactly one flagged - // as storage version. - Storage bool -} - -// CustomResourceColumnDefinition specifies a column for server side printing. -type CustomResourceColumnDefinition struct { - // name is a human readable name for the column. - Name string - // type is an OpenAPI type definition for this column. - // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. - Type string - // format is an optional OpenAPI type definition for this column. The 'name' format is applied - // to the primary identifier column to assist in clients identifying column is the resource name. - // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. - Format string - // description is a human readable description of this column. - Description string - // priority is an integer defining the relative importance of this column compared to others. Lower - // numbers are considered higher priority. Columns that may be omitted in limited space scenarios - // should be given a higher priority. - Priority int32 - - // JSONPath is a simple JSON path, i.e. without array notation. - JSONPath string -} - -// CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition -type CustomResourceDefinitionNames struct { - // Plural is the plural name of the resource to serve. It must match the name of the CustomResourceDefinition-registration - // too: plural.group and it must be all lowercase. - Plural string - // Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased - Singular string - // ShortNames are short names for the resource. It must be all lowercase. - ShortNames []string - // Kind is the serialized kind of the resource. It is normally CamelCase and singular. - Kind string - // ListKind is the serialized kind of the list for this resource. Defaults to List. - ListKind string - // Categories is a list of grouped resources custom resources belong to (e.g. 'all') - // +optional - Categories []string -} - -// ResourceScope is an enum defining the different scopes available to a custom resource -type ResourceScope string - -const ( - ClusterScoped ResourceScope = "Cluster" - NamespaceScoped ResourceScope = "Namespaced" -) - -type ConditionStatus string - -// These are valid condition statuses. "ConditionTrue" means a resource is in the condition. -// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes -// can't decide if a resource is in the condition or not. In the future, we could add other -// intermediate conditions, e.g. ConditionDegraded. -const ( - ConditionTrue ConditionStatus = "True" - ConditionFalse ConditionStatus = "False" - ConditionUnknown ConditionStatus = "Unknown" -) - -// CustomResourceDefinitionConditionType is a valid value for CustomResourceDefinitionCondition.Type -type CustomResourceDefinitionConditionType string - -const ( - // Established means that the resource has become active. A resource is established when all names are - // accepted without a conflict for the first time. A resource stays established until deleted, even during - // a later NamesAccepted due to changed names. Note that not all names can be changed. - Established CustomResourceDefinitionConditionType = "Established" - // NamesAccepted means the names chosen for this CustomResourceDefinition do not conflict with others in - // the group and are therefore accepted. - NamesAccepted CustomResourceDefinitionConditionType = "NamesAccepted" - // Terminating means that the CustomResourceDefinition has been deleted and is cleaning up. - Terminating CustomResourceDefinitionConditionType = "Terminating" -) - -// CustomResourceDefinitionCondition contains details for the current condition of this pod. -type CustomResourceDefinitionCondition struct { - // Type is the type of the condition. - Type CustomResourceDefinitionConditionType - // Status is the status of the condition. - // Can be True, False, Unknown. - Status ConditionStatus - // Last time the condition transitioned from one status to another. - // +optional - LastTransitionTime metav1.Time - // Unique, one-word, CamelCase reason for the condition's last transition. - // +optional - Reason string - // Human-readable message indicating details about last transition. - // +optional - Message string -} - -// CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition -type CustomResourceDefinitionStatus struct { - // Conditions indicate state for particular aspects of a CustomResourceDefinition - Conditions []CustomResourceDefinitionCondition - - // AcceptedNames are the names that are actually being used to serve discovery - // They may be different than the names in spec. - AcceptedNames CustomResourceDefinitionNames - - // StoredVersions are all versions of CustomResources that were ever persisted. Tracking these - // versions allows a migration path for stored versions in etcd. The field is mutable - // so the migration controller can first finish a migration to another version (i.e. - // that no old objects are left in the storage), and then remove the rest of the - // versions from this list. - // None of the versions in this list can be removed from the spec.Versions field. - StoredVersions []string -} - -// CustomResourceCleanupFinalizer is the name of the finalizer which will delete instances of -// a CustomResourceDefinition -const CustomResourceCleanupFinalizer = "customresourcecleanup.apiextensions.k8s.io" - -// +genclient -// +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format -// <.spec.name>.<.spec.group>. -type CustomResourceDefinition struct { - metav1.TypeMeta - metav1.ObjectMeta - - // Spec describes how the user wants the resources to appear - Spec CustomResourceDefinitionSpec - // Status indicates the actual state of the CustomResourceDefinition - Status CustomResourceDefinitionStatus -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// CustomResourceDefinitionList is a list of CustomResourceDefinition objects. -type CustomResourceDefinitionList struct { - metav1.TypeMeta - metav1.ListMeta - - // Items individual CustomResourceDefinitions - Items []CustomResourceDefinition -} - -// CustomResourceValidation is a list of validation methods for CustomResources. -type CustomResourceValidation struct { - // OpenAPIV3Schema is the OpenAPI v3 schema to be validated against. - OpenAPIV3Schema *JSONSchemaProps -} - -// CustomResourceSubresources defines the status and scale subresources for CustomResources. -type CustomResourceSubresources struct { - // Status denotes the status subresource for CustomResources - Status *CustomResourceSubresourceStatus - // Scale denotes the scale subresource for CustomResources - Scale *CustomResourceSubresourceScale -} - -// CustomResourceSubresourceStatus defines how to serve the status subresource for CustomResources. -// Status is represented by the `.status` JSON path inside of a CustomResource. When set, -// * exposes a /status subresource for the custom resource -// * PUT requests to the /status subresource take a custom resource object, and ignore changes to anything except the status stanza -// * PUT/POST/PATCH requests to the custom resource ignore changes to the status stanza -type CustomResourceSubresourceStatus struct{} - -// CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources. -type CustomResourceSubresourceScale struct { - // SpecReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Spec.Replicas. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .spec. - // If there is no value under the given path in the CustomResource, the /scale subresource will return an error on GET. - SpecReplicasPath string - // StatusReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Replicas. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .status. - // If there is no value under the given path in the CustomResource, the status replica value in the /scale subresource - // will default to 0. - StatusReplicasPath string - // LabelSelectorPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Selector. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .status. - // Must be set to work with HPA. - // If there is no value under the given path in the CustomResource, the status label selector value in the /scale - // subresource will default to the empty string. - // +optional - LabelSelectorPath *string -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types_jsonschema.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types_jsonschema.go deleted file mode 100644 index 79f34e8bf..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types_jsonschema.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2017 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 apiextensions - -// JSONSchemaProps is a JSON-Schema following Specification Draft 4 (http://json-schema.org/). -type JSONSchemaProps struct { - ID string - Schema JSONSchemaURL - Ref *string - Description string - Type string - Format string - Title string - Default *JSON - Maximum *float64 - ExclusiveMaximum bool - Minimum *float64 - ExclusiveMinimum bool - MaxLength *int64 - MinLength *int64 - Pattern string - MaxItems *int64 - MinItems *int64 - UniqueItems bool - MultipleOf *float64 - Enum []JSON - MaxProperties *int64 - MinProperties *int64 - Required []string - Items *JSONSchemaPropsOrArray - AllOf []JSONSchemaProps - OneOf []JSONSchemaProps - AnyOf []JSONSchemaProps - Not *JSONSchemaProps - Properties map[string]JSONSchemaProps - AdditionalProperties *JSONSchemaPropsOrBool - PatternProperties map[string]JSONSchemaProps - Dependencies JSONSchemaDependencies - AdditionalItems *JSONSchemaPropsOrBool - Definitions JSONSchemaDefinitions - ExternalDocs *ExternalDocumentation - Example *JSON -} - -// JSON represents any valid JSON value. -// These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil. -type JSON interface{} - -// JSONSchemaURL represents a schema url. -type JSONSchemaURL string - -// JSONSchemaPropsOrArray represents a value that can either be a JSONSchemaProps -// or an array of JSONSchemaProps. Mainly here for serialization purposes. -type JSONSchemaPropsOrArray struct { - Schema *JSONSchemaProps - JSONSchemas []JSONSchemaProps -} - -// JSONSchemaPropsOrBool represents JSONSchemaProps or a boolean value. -// Defaults to true for the boolean property. -type JSONSchemaPropsOrBool struct { - Allows bool - Schema *JSONSchemaProps -} - -// JSONSchemaDependencies represent a dependencies property. -type JSONSchemaDependencies map[string]JSONSchemaPropsOrStringArray - -// JSONSchemaPropsOrStringArray represents a JSONSchemaProps or a string array. -type JSONSchemaPropsOrStringArray struct { - Schema *JSONSchemaProps - Property []string -} - -// JSONSchemaDefinitions contains the models explicitly defined in this spec. -type JSONSchemaDefinitions map[string]JSONSchemaProps - -// ExternalDocumentation allows referencing an external resource for extended documentation. -type ExternalDocumentation struct { - Description string - URL string -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion.go deleted file mode 100644 index f9951009d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -import ( - "k8s.io/apimachinery/pkg/conversion" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/json" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" -) - -func addConversionFuncs(scheme *runtime.Scheme) error { - // Add non-generated conversion functions - err := scheme.AddConversionFuncs( - Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps, - Convert_apiextensions_JSON_To_v1beta1_JSON, - Convert_v1beta1_JSON_To_apiextensions_JSON, - ) - if err != nil { - return err - } - return nil -} - -func Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in *apiextensions.JSONSchemaProps, out *JSONSchemaProps, s conversion.Scope) error { - if err := autoConvert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in, out, s); err != nil { - return err - } - if in.Default != nil && *(in.Default) == nil { - out.Default = nil - } - if in.Example != nil && *(in.Example) == nil { - out.Example = nil - } - return nil -} - -func Convert_apiextensions_JSON_To_v1beta1_JSON(in *apiextensions.JSON, out *JSON, s conversion.Scope) error { - raw, err := json.Marshal(*in) - if err != nil { - return err - } - out.Raw = raw - return nil -} - -func Convert_v1beta1_JSON_To_apiextensions_JSON(in *JSON, out *apiextensions.JSON, s conversion.Scope) error { - if in != nil { - var i interface{} - if err := json.Unmarshal(in.Raw, &i); err != nil { - return err - } - *out = i - } else { - out = nil - } - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion_test.go deleted file mode 100644 index a697dd9e3..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion_test.go +++ /dev/null @@ -1,113 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -import ( - "reflect" - "testing" - - "k8s.io/apimachinery/pkg/runtime" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" -) - -func TestJSONConversion(t *testing.T) { - nilJSON := apiextensions.JSON(nil) - nullJSON := apiextensions.JSON("null") - stringJSON := apiextensions.JSON("foo") - boolJSON := apiextensions.JSON(true) - sliceJSON := apiextensions.JSON([]string{"foo", "bar", "baz"}) - - testCases := map[string]struct { - input *apiextensions.JSONSchemaProps - expected *JSONSchemaProps - }{ - "nil": { - input: &apiextensions.JSONSchemaProps{ - Default: nil, - }, - expected: &JSONSchemaProps{}, - }, - "aliased nil": { - input: &apiextensions.JSONSchemaProps{ - Default: &nilJSON, - }, - expected: &JSONSchemaProps{}, - }, - "null": { - input: &apiextensions.JSONSchemaProps{ - Default: &nullJSON, - }, - expected: &JSONSchemaProps{ - Default: &JSON{ - Raw: []byte(`"null"`), - }, - }, - }, - "string": { - input: &apiextensions.JSONSchemaProps{ - Default: &stringJSON, - }, - expected: &JSONSchemaProps{ - Default: &JSON{ - Raw: []byte(`"foo"`), - }, - }, - }, - "bool": { - input: &apiextensions.JSONSchemaProps{ - Default: &boolJSON, - }, - expected: &JSONSchemaProps{ - Default: &JSON{ - Raw: []byte(`true`), - }, - }, - }, - "slice": { - input: &apiextensions.JSONSchemaProps{ - Default: &sliceJSON, - }, - expected: &JSONSchemaProps{ - Default: &JSON{ - Raw: []byte(`["foo","bar","baz"]`), - }, - }, - }, - } - - scheme := runtime.NewScheme() - - // add internal and external types - if err := apiextensions.AddToScheme(scheme); err != nil { - t.Fatal(err) - } - if err := AddToScheme(scheme); err != nil { - t.Fatal(err) - } - - for k, tc := range testCases { - external := &JSONSchemaProps{} - if err := scheme.Convert(tc.input, external, nil); err != nil { - t.Errorf("%s: unexpected error: %v", k, err) - } - - if !reflect.DeepEqual(external, tc.expected) { - t.Errorf("%s: expected\n\t%#v, got \n\t%#v", k, tc.expected, external) - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/deepcopy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/deepcopy.go deleted file mode 100644 index f6a114e2b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/deepcopy.go +++ /dev/null @@ -1,238 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -// TODO: Update this after a tag is created for interface fields in DeepCopy -func (in *JSONSchemaProps) DeepCopy() *JSONSchemaProps { - if in == nil { - return nil - } - out := new(JSONSchemaProps) - *out = *in - - if in.Ref != nil { - in, out := &in.Ref, &out.Ref - if *in == nil { - *out = nil - } else { - *out = new(string) - **out = **in - } - } - - if in.Maximum != nil { - in, out := &in.Maximum, &out.Maximum - if *in == nil { - *out = nil - } else { - *out = new(float64) - **out = **in - } - } - - if in.Minimum != nil { - in, out := &in.Minimum, &out.Minimum - if *in == nil { - *out = nil - } else { - *out = new(float64) - **out = **in - } - } - - if in.MaxLength != nil { - in, out := &in.MaxLength, &out.MaxLength - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MinLength != nil { - in, out := &in.MinLength, &out.MinLength - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - if in.MaxItems != nil { - in, out := &in.MaxItems, &out.MaxItems - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MinItems != nil { - in, out := &in.MinItems, &out.MinItems - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MultipleOf != nil { - in, out := &in.MultipleOf, &out.MultipleOf - if *in == nil { - *out = nil - } else { - *out = new(float64) - **out = **in - } - } - - if in.MaxProperties != nil { - in, out := &in.MaxProperties, &out.MaxProperties - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.MinProperties != nil { - in, out := &in.MinProperties, &out.MinProperties - if *in == nil { - *out = nil - } else { - *out = new(int64) - **out = **in - } - } - - if in.Required != nil { - in, out := &in.Required, &out.Required - *out = make([]string, len(*in)) - copy(*out, *in) - } - - if in.Items != nil { - in, out := &in.Items, &out.Items - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaPropsOrArray) - (*in).DeepCopyInto(*out) - } - } - - if in.AllOf != nil { - in, out := &in.AllOf, &out.AllOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - - if in.OneOf != nil { - in, out := &in.OneOf, &out.OneOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.AnyOf != nil { - in, out := &in.AnyOf, &out.AnyOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - - if in.Not != nil { - in, out := &in.Not, &out.Not - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaProps) - (*in).DeepCopyInto(*out) - } - } - - if in.Properties != nil { - in, out := &in.Properties, &out.Properties - *out = make(map[string]JSONSchemaProps, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.AdditionalProperties != nil { - in, out := &in.AdditionalProperties, &out.AdditionalProperties - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaPropsOrBool) - (*in).DeepCopyInto(*out) - } - } - - if in.PatternProperties != nil { - in, out := &in.PatternProperties, &out.PatternProperties - *out = make(map[string]JSONSchemaProps, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.Dependencies != nil { - in, out := &in.Dependencies, &out.Dependencies - *out = make(JSONSchemaDependencies, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.AdditionalItems != nil { - in, out := &in.AdditionalItems, &out.AdditionalItems - if *in == nil { - *out = nil - } else { - *out = new(JSONSchemaPropsOrBool) - (*in).DeepCopyInto(*out) - } - } - - if in.Definitions != nil { - in, out := &in.Definitions, &out.Definitions - *out = make(JSONSchemaDefinitions, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - - if in.ExternalDocs != nil { - in, out := &in.ExternalDocs, &out.ExternalDocs - if *in == nil { - *out = nil - } else { - *out = new(ExternalDocumentation) - (*in).DeepCopyInto(*out) - } - } - - return out -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/defaults.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/defaults.go deleted file mode 100644 index e3235e870..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/defaults.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -import ( - "strings" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" -) - -var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc() - -func addDefaultingFuncs(scheme *runtime.Scheme) error { - scheme.AddTypeDefaultingFunc(&CustomResourceDefinition{}, func(obj interface{}) { SetDefaults_CustomResourceDefinition(obj.(*CustomResourceDefinition)) }) - // TODO figure out why I can't seem to get my defaulter generated - // return RegisterDefaults(scheme) - return nil -} - -func SetDefaults_CustomResourceDefinition(obj *CustomResourceDefinition) { - SetDefaults_CustomResourceDefinitionSpec(&obj.Spec) - if len(obj.Status.StoredVersions) == 0 { - for _, v := range obj.Spec.Versions { - if v.Storage { - obj.Status.StoredVersions = append(obj.Status.StoredVersions, v.Name) - break - } - } - } -} - -func SetDefaults_CustomResourceDefinitionSpec(obj *CustomResourceDefinitionSpec) { - if len(obj.Scope) == 0 { - obj.Scope = NamespaceScoped - } - if len(obj.Names.Singular) == 0 { - obj.Names.Singular = strings.ToLower(obj.Names.Kind) - } - if len(obj.Names.ListKind) == 0 && len(obj.Names.Kind) > 0 { - obj.Names.ListKind = obj.Names.Kind + "List" - } - // If there is no list of versions, create on using deprecated Version field. - if len(obj.Versions) == 0 && len(obj.Version) != 0 { - obj.Versions = []CustomResourceDefinitionVersion{{ - Name: obj.Version, - Storage: true, - Served: true, - }} - } - // For backward compatibility set the version field to the first item in versions list. - if len(obj.Version) == 0 && len(obj.Versions) != 0 { - obj.Version = obj.Versions[0].Name - } - if len(obj.AdditionalPrinterColumns) == 0 { - obj.AdditionalPrinterColumns = []CustomResourceColumnDefinition{ - {Name: "Age", Type: "date", Description: swaggerMetadataDescriptions["creationTimestamp"], JSONPath: ".metadata.creationTimestamp"}, - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/doc.go deleted file mode 100644 index 50ab2b54c..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/doc.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright 2017 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. -*/ - -// +k8s:deepcopy-gen=package -// +k8s:conversion-gen=k8s.io/apiextensions-apiserver/pkg/apis/apiextensions -// +k8s:defaulter-gen=TypeMeta - -// Package v1beta1 is the v1beta1 version of the API. -// +groupName=apiextensions.k8s.io -// +k8s:openapi-gen=true -package v1beta1 // import "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.pb.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.pb.go deleted file mode 100644 index 8e30403c8..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.pb.go +++ /dev/null @@ -1,6023 +0,0 @@ -/* -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 protoc-gen-gogo. -// source: k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto -// DO NOT EDIT! - -/* - Package v1beta1 is a generated protocol buffer package. - - It is generated from these files: - k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto - - It has these top-level messages: - CustomResourceColumnDefinition - CustomResourceDefinition - CustomResourceDefinitionCondition - CustomResourceDefinitionList - CustomResourceDefinitionNames - CustomResourceDefinitionSpec - CustomResourceDefinitionStatus - CustomResourceDefinitionVersion - CustomResourceSubresourceScale - CustomResourceSubresourceStatus - CustomResourceSubresources - CustomResourceValidation - ExternalDocumentation - JSON - JSONSchemaProps - JSONSchemaPropsOrArray - JSONSchemaPropsOrBool - JSONSchemaPropsOrStringArray -*/ -package v1beta1 - -import proto "github.com/gogo/protobuf/proto" -import fmt "fmt" -import math "math" - -import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" - -import strings "strings" -import reflect "reflect" - -import io "io" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package - -func (m *CustomResourceColumnDefinition) Reset() { *m = CustomResourceColumnDefinition{} } -func (*CustomResourceColumnDefinition) ProtoMessage() {} -func (*CustomResourceColumnDefinition) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{0} -} - -func (m *CustomResourceDefinition) Reset() { *m = CustomResourceDefinition{} } -func (*CustomResourceDefinition) ProtoMessage() {} -func (*CustomResourceDefinition) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{1} -} - -func (m *CustomResourceDefinitionCondition) Reset() { *m = CustomResourceDefinitionCondition{} } -func (*CustomResourceDefinitionCondition) ProtoMessage() {} -func (*CustomResourceDefinitionCondition) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{2} -} - -func (m *CustomResourceDefinitionList) Reset() { *m = CustomResourceDefinitionList{} } -func (*CustomResourceDefinitionList) ProtoMessage() {} -func (*CustomResourceDefinitionList) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{3} -} - -func (m *CustomResourceDefinitionNames) Reset() { *m = CustomResourceDefinitionNames{} } -func (*CustomResourceDefinitionNames) ProtoMessage() {} -func (*CustomResourceDefinitionNames) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{4} -} - -func (m *CustomResourceDefinitionSpec) Reset() { *m = CustomResourceDefinitionSpec{} } -func (*CustomResourceDefinitionSpec) ProtoMessage() {} -func (*CustomResourceDefinitionSpec) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{5} -} - -func (m *CustomResourceDefinitionStatus) Reset() { *m = CustomResourceDefinitionStatus{} } -func (*CustomResourceDefinitionStatus) ProtoMessage() {} -func (*CustomResourceDefinitionStatus) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{6} -} - -func (m *CustomResourceDefinitionVersion) Reset() { *m = CustomResourceDefinitionVersion{} } -func (*CustomResourceDefinitionVersion) ProtoMessage() {} -func (*CustomResourceDefinitionVersion) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{7} -} - -func (m *CustomResourceSubresourceScale) Reset() { *m = CustomResourceSubresourceScale{} } -func (*CustomResourceSubresourceScale) ProtoMessage() {} -func (*CustomResourceSubresourceScale) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{8} -} - -func (m *CustomResourceSubresourceStatus) Reset() { *m = CustomResourceSubresourceStatus{} } -func (*CustomResourceSubresourceStatus) ProtoMessage() {} -func (*CustomResourceSubresourceStatus) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{9} -} - -func (m *CustomResourceSubresources) Reset() { *m = CustomResourceSubresources{} } -func (*CustomResourceSubresources) ProtoMessage() {} -func (*CustomResourceSubresources) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{10} -} - -func (m *CustomResourceValidation) Reset() { *m = CustomResourceValidation{} } -func (*CustomResourceValidation) ProtoMessage() {} -func (*CustomResourceValidation) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{11} -} - -func (m *ExternalDocumentation) Reset() { *m = ExternalDocumentation{} } -func (*ExternalDocumentation) ProtoMessage() {} -func (*ExternalDocumentation) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{12} } - -func (m *JSON) Reset() { *m = JSON{} } -func (*JSON) ProtoMessage() {} -func (*JSON) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{13} } - -func (m *JSONSchemaProps) Reset() { *m = JSONSchemaProps{} } -func (*JSONSchemaProps) ProtoMessage() {} -func (*JSONSchemaProps) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{14} } - -func (m *JSONSchemaPropsOrArray) Reset() { *m = JSONSchemaPropsOrArray{} } -func (*JSONSchemaPropsOrArray) ProtoMessage() {} -func (*JSONSchemaPropsOrArray) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{15} } - -func (m *JSONSchemaPropsOrBool) Reset() { *m = JSONSchemaPropsOrBool{} } -func (*JSONSchemaPropsOrBool) ProtoMessage() {} -func (*JSONSchemaPropsOrBool) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{16} } - -func (m *JSONSchemaPropsOrStringArray) Reset() { *m = JSONSchemaPropsOrStringArray{} } -func (*JSONSchemaPropsOrStringArray) ProtoMessage() {} -func (*JSONSchemaPropsOrStringArray) Descriptor() ([]byte, []int) { - return fileDescriptorGenerated, []int{17} -} - -func init() { - proto.RegisterType((*CustomResourceColumnDefinition)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceColumnDefinition") - proto.RegisterType((*CustomResourceDefinition)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceDefinition") - proto.RegisterType((*CustomResourceDefinitionCondition)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceDefinitionCondition") - proto.RegisterType((*CustomResourceDefinitionList)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceDefinitionList") - proto.RegisterType((*CustomResourceDefinitionNames)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceDefinitionNames") - proto.RegisterType((*CustomResourceDefinitionSpec)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceDefinitionSpec") - proto.RegisterType((*CustomResourceDefinitionStatus)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceDefinitionStatus") - proto.RegisterType((*CustomResourceDefinitionVersion)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceDefinitionVersion") - proto.RegisterType((*CustomResourceSubresourceScale)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceSubresourceScale") - proto.RegisterType((*CustomResourceSubresourceStatus)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceSubresourceStatus") - proto.RegisterType((*CustomResourceSubresources)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceSubresources") - proto.RegisterType((*CustomResourceValidation)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.CustomResourceValidation") - proto.RegisterType((*ExternalDocumentation)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.ExternalDocumentation") - proto.RegisterType((*JSON)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.JSON") - proto.RegisterType((*JSONSchemaProps)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.JSONSchemaProps") - proto.RegisterType((*JSONSchemaPropsOrArray)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.JSONSchemaPropsOrArray") - proto.RegisterType((*JSONSchemaPropsOrBool)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.JSONSchemaPropsOrBool") - proto.RegisterType((*JSONSchemaPropsOrStringArray)(nil), "k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1.JSONSchemaPropsOrStringArray") -} -func (m *CustomResourceColumnDefinition) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceColumnDefinition) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Type))) - i += copy(dAtA[i:], m.Type) - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Format))) - i += copy(dAtA[i:], m.Format) - dAtA[i] = 0x22 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Description))) - i += copy(dAtA[i:], m.Description) - dAtA[i] = 0x28 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Priority)) - dAtA[i] = 0x32 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.JSONPath))) - i += copy(dAtA[i:], m.JSONPath) - return i, nil -} - -func (m *CustomResourceDefinition) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceDefinition) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.ObjectMeta.Size())) - n1, err := m.ObjectMeta.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n1 - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Spec.Size())) - n2, err := m.Spec.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n2 - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Status.Size())) - n3, err := m.Status.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n3 - return i, nil -} - -func (m *CustomResourceDefinitionCondition) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceDefinitionCondition) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Type))) - i += copy(dAtA[i:], m.Type) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Status))) - i += copy(dAtA[i:], m.Status) - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.LastTransitionTime.Size())) - n4, err := m.LastTransitionTime.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n4 - dAtA[i] = 0x22 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Reason))) - i += copy(dAtA[i:], m.Reason) - dAtA[i] = 0x2a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Message))) - i += copy(dAtA[i:], m.Message) - return i, nil -} - -func (m *CustomResourceDefinitionList) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceDefinitionList) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n5, err := m.ListMeta.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n5 - if len(m.Items) > 0 { - for _, msg := range m.Items { - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - return i, nil -} - -func (m *CustomResourceDefinitionNames) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceDefinitionNames) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Plural))) - i += copy(dAtA[i:], m.Plural) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Singular))) - i += copy(dAtA[i:], m.Singular) - if len(m.ShortNames) > 0 { - for _, s := range m.ShortNames { - dAtA[i] = 0x1a - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } - } - dAtA[i] = 0x22 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Kind))) - i += copy(dAtA[i:], m.Kind) - dAtA[i] = 0x2a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.ListKind))) - i += copy(dAtA[i:], m.ListKind) - if len(m.Categories) > 0 { - for _, s := range m.Categories { - dAtA[i] = 0x32 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } - } - return i, nil -} - -func (m *CustomResourceDefinitionSpec) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceDefinitionSpec) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Group))) - i += copy(dAtA[i:], m.Group) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Version))) - i += copy(dAtA[i:], m.Version) - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Names.Size())) - n6, err := m.Names.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n6 - dAtA[i] = 0x22 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Scope))) - i += copy(dAtA[i:], m.Scope) - if m.Validation != nil { - dAtA[i] = 0x2a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Validation.Size())) - n7, err := m.Validation.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n7 - } - if m.Subresources != nil { - dAtA[i] = 0x32 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Subresources.Size())) - n8, err := m.Subresources.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n8 - } - if len(m.Versions) > 0 { - for _, msg := range m.Versions { - dAtA[i] = 0x3a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if len(m.AdditionalPrinterColumns) > 0 { - for _, msg := range m.AdditionalPrinterColumns { - dAtA[i] = 0x42 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - return i, nil -} - -func (m *CustomResourceDefinitionStatus) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceDefinitionStatus) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Conditions) > 0 { - for _, msg := range m.Conditions { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.AcceptedNames.Size())) - n9, err := m.AcceptedNames.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n9 - if len(m.StoredVersions) > 0 { - for _, s := range m.StoredVersions { - dAtA[i] = 0x1a - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } - } - return i, nil -} - -func (m *CustomResourceDefinitionVersion) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceDefinitionVersion) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) - dAtA[i] = 0x10 - i++ - if m.Served { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - dAtA[i] = 0x18 - i++ - if m.Storage { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - return i, nil -} - -func (m *CustomResourceSubresourceScale) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceSubresourceScale) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.SpecReplicasPath))) - i += copy(dAtA[i:], m.SpecReplicasPath) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.StatusReplicasPath))) - i += copy(dAtA[i:], m.StatusReplicasPath) - if m.LabelSelectorPath != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.LabelSelectorPath))) - i += copy(dAtA[i:], *m.LabelSelectorPath) - } - return i, nil -} - -func (m *CustomResourceSubresourceStatus) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceSubresourceStatus) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - return i, nil -} - -func (m *CustomResourceSubresources) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceSubresources) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Status != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Status.Size())) - n10, err := m.Status.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n10 - } - if m.Scale != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Scale.Size())) - n11, err := m.Scale.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n11 - } - return i, nil -} - -func (m *CustomResourceValidation) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomResourceValidation) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.OpenAPIV3Schema != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.OpenAPIV3Schema.Size())) - n12, err := m.OpenAPIV3Schema.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n12 - } - return i, nil -} - -func (m *ExternalDocumentation) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExternalDocumentation) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Description))) - i += copy(dAtA[i:], m.Description) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.URL))) - i += copy(dAtA[i:], m.URL) - return i, nil -} - -func (m *JSON) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *JSON) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Raw != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Raw))) - i += copy(dAtA[i:], m.Raw) - } - return i, nil -} - -func (m *JSONSchemaProps) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *JSONSchemaProps) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.ID))) - i += copy(dAtA[i:], m.ID) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Schema))) - i += copy(dAtA[i:], m.Schema) - if m.Ref != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.Ref))) - i += copy(dAtA[i:], *m.Ref) - } - dAtA[i] = 0x22 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Description))) - i += copy(dAtA[i:], m.Description) - dAtA[i] = 0x2a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Type))) - i += copy(dAtA[i:], m.Type) - dAtA[i] = 0x32 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Format))) - i += copy(dAtA[i:], m.Format) - dAtA[i] = 0x3a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Title))) - i += copy(dAtA[i:], m.Title) - if m.Default != nil { - dAtA[i] = 0x42 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Default.Size())) - n13, err := m.Default.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n13 - } - if m.Maximum != nil { - dAtA[i] = 0x49 - i++ - i = encodeFixed64Generated(dAtA, i, uint64(math.Float64bits(float64(*m.Maximum)))) - } - dAtA[i] = 0x50 - i++ - if m.ExclusiveMaximum { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - if m.Minimum != nil { - dAtA[i] = 0x59 - i++ - i = encodeFixed64Generated(dAtA, i, uint64(math.Float64bits(float64(*m.Minimum)))) - } - dAtA[i] = 0x60 - i++ - if m.ExclusiveMinimum { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - if m.MaxLength != nil { - dAtA[i] = 0x68 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(*m.MaxLength)) - } - if m.MinLength != nil { - dAtA[i] = 0x70 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(*m.MinLength)) - } - dAtA[i] = 0x7a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Pattern))) - i += copy(dAtA[i:], m.Pattern) - if m.MaxItems != nil { - dAtA[i] = 0x80 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(*m.MaxItems)) - } - if m.MinItems != nil { - dAtA[i] = 0x88 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(*m.MinItems)) - } - dAtA[i] = 0x90 - i++ - dAtA[i] = 0x1 - i++ - if m.UniqueItems { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - if m.MultipleOf != nil { - dAtA[i] = 0x99 - i++ - dAtA[i] = 0x1 - i++ - i = encodeFixed64Generated(dAtA, i, uint64(math.Float64bits(float64(*m.MultipleOf)))) - } - if len(m.Enum) > 0 { - for _, msg := range m.Enum { - dAtA[i] = 0xa2 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if m.MaxProperties != nil { - dAtA[i] = 0xa8 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(*m.MaxProperties)) - } - if m.MinProperties != nil { - dAtA[i] = 0xb0 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(*m.MinProperties)) - } - if len(m.Required) > 0 { - for _, s := range m.Required { - dAtA[i] = 0xba - i++ - dAtA[i] = 0x1 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } - } - if m.Items != nil { - dAtA[i] = 0xc2 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Items.Size())) - n14, err := m.Items.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n14 - } - if len(m.AllOf) > 0 { - for _, msg := range m.AllOf { - dAtA[i] = 0xca - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if len(m.OneOf) > 0 { - for _, msg := range m.OneOf { - dAtA[i] = 0xd2 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if len(m.AnyOf) > 0 { - for _, msg := range m.AnyOf { - dAtA[i] = 0xda - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if m.Not != nil { - dAtA[i] = 0xe2 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Not.Size())) - n15, err := m.Not.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n15 - } - if len(m.Properties) > 0 { - keysForProperties := make([]string, 0, len(m.Properties)) - for k := range m.Properties { - keysForProperties = append(keysForProperties, string(k)) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForProperties) - for _, k := range keysForProperties { - dAtA[i] = 0xea - i++ - dAtA[i] = 0x1 - i++ - v := m.Properties[string(k)] - msgSize := 0 - if (&v) != nil { - msgSize = (&v).Size() - msgSize += 1 + sovGenerated(uint64(msgSize)) - } - mapSize := 1 + len(k) + sovGenerated(uint64(len(k))) + msgSize - i = encodeVarintGenerated(dAtA, i, uint64(mapSize)) - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(k))) - i += copy(dAtA[i:], k) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64((&v).Size())) - n16, err := (&v).MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n16 - } - } - if m.AdditionalProperties != nil { - dAtA[i] = 0xf2 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.AdditionalProperties.Size())) - n17, err := m.AdditionalProperties.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n17 - } - if len(m.PatternProperties) > 0 { - keysForPatternProperties := make([]string, 0, len(m.PatternProperties)) - for k := range m.PatternProperties { - keysForPatternProperties = append(keysForPatternProperties, string(k)) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForPatternProperties) - for _, k := range keysForPatternProperties { - dAtA[i] = 0xfa - i++ - dAtA[i] = 0x1 - i++ - v := m.PatternProperties[string(k)] - msgSize := 0 - if (&v) != nil { - msgSize = (&v).Size() - msgSize += 1 + sovGenerated(uint64(msgSize)) - } - mapSize := 1 + len(k) + sovGenerated(uint64(len(k))) + msgSize - i = encodeVarintGenerated(dAtA, i, uint64(mapSize)) - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(k))) - i += copy(dAtA[i:], k) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64((&v).Size())) - n18, err := (&v).MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n18 - } - } - if len(m.Dependencies) > 0 { - keysForDependencies := make([]string, 0, len(m.Dependencies)) - for k := range m.Dependencies { - keysForDependencies = append(keysForDependencies, string(k)) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForDependencies) - for _, k := range keysForDependencies { - dAtA[i] = 0x82 - i++ - dAtA[i] = 0x2 - i++ - v := m.Dependencies[string(k)] - msgSize := 0 - if (&v) != nil { - msgSize = (&v).Size() - msgSize += 1 + sovGenerated(uint64(msgSize)) - } - mapSize := 1 + len(k) + sovGenerated(uint64(len(k))) + msgSize - i = encodeVarintGenerated(dAtA, i, uint64(mapSize)) - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(k))) - i += copy(dAtA[i:], k) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64((&v).Size())) - n19, err := (&v).MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n19 - } - } - if m.AdditionalItems != nil { - dAtA[i] = 0x8a - i++ - dAtA[i] = 0x2 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.AdditionalItems.Size())) - n20, err := m.AdditionalItems.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n20 - } - if len(m.Definitions) > 0 { - keysForDefinitions := make([]string, 0, len(m.Definitions)) - for k := range m.Definitions { - keysForDefinitions = append(keysForDefinitions, string(k)) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForDefinitions) - for _, k := range keysForDefinitions { - dAtA[i] = 0x92 - i++ - dAtA[i] = 0x2 - i++ - v := m.Definitions[string(k)] - msgSize := 0 - if (&v) != nil { - msgSize = (&v).Size() - msgSize += 1 + sovGenerated(uint64(msgSize)) - } - mapSize := 1 + len(k) + sovGenerated(uint64(len(k))) + msgSize - i = encodeVarintGenerated(dAtA, i, uint64(mapSize)) - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(k))) - i += copy(dAtA[i:], k) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64((&v).Size())) - n21, err := (&v).MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n21 - } - } - if m.ExternalDocs != nil { - dAtA[i] = 0x9a - i++ - dAtA[i] = 0x2 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.ExternalDocs.Size())) - n22, err := m.ExternalDocs.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n22 - } - if m.Example != nil { - dAtA[i] = 0xa2 - i++ - dAtA[i] = 0x2 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Example.Size())) - n23, err := m.Example.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n23 - } - return i, nil -} - -func (m *JSONSchemaPropsOrArray) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *JSONSchemaPropsOrArray) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Schema != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Schema.Size())) - n24, err := m.Schema.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n24 - } - if len(m.JSONSchemas) > 0 { - for _, msg := range m.JSONSchemas { - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - return i, nil -} - -func (m *JSONSchemaPropsOrBool) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *JSONSchemaPropsOrBool) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0x8 - i++ - if m.Allows { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - if m.Schema != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Schema.Size())) - n25, err := m.Schema.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n25 - } - return i, nil -} - -func (m *JSONSchemaPropsOrStringArray) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *JSONSchemaPropsOrStringArray) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Schema != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Schema.Size())) - n26, err := m.Schema.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n26 - } - if len(m.Property) > 0 { - for _, s := range m.Property { - dAtA[i] = 0x12 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } - } - return i, nil -} - -func encodeFixed64Generated(dAtA []byte, offset int, v uint64) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - dAtA[offset+4] = uint8(v >> 32) - dAtA[offset+5] = uint8(v >> 40) - dAtA[offset+6] = uint8(v >> 48) - dAtA[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Generated(dAtA []byte, offset int, v uint32) int { - dAtA[offset] = uint8(v) - dAtA[offset+1] = uint8(v >> 8) - dAtA[offset+2] = uint8(v >> 16) - dAtA[offset+3] = uint8(v >> 24) - return offset + 4 -} -func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return offset + 1 -} -func (m *CustomResourceColumnDefinition) Size() (n int) { - var l int - _ = l - l = len(m.Name) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Type) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Format) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Description) - n += 1 + l + sovGenerated(uint64(l)) - n += 1 + sovGenerated(uint64(m.Priority)) - l = len(m.JSONPath) - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func (m *CustomResourceDefinition) Size() (n int) { - var l int - _ = l - l = m.ObjectMeta.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.Spec.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.Status.Size() - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func (m *CustomResourceDefinitionCondition) Size() (n int) { - var l int - _ = l - l = len(m.Type) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Status) - n += 1 + l + sovGenerated(uint64(l)) - l = m.LastTransitionTime.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Reason) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Message) - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func (m *CustomResourceDefinitionList) Size() (n int) { - var l int - _ = l - l = m.ListMeta.Size() - n += 1 + l + sovGenerated(uint64(l)) - if len(m.Items) > 0 { - for _, e := range m.Items { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - } - return n -} - -func (m *CustomResourceDefinitionNames) Size() (n int) { - var l int - _ = l - l = len(m.Plural) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Singular) - n += 1 + l + sovGenerated(uint64(l)) - if len(m.ShortNames) > 0 { - for _, s := range m.ShortNames { - l = len(s) - n += 1 + l + sovGenerated(uint64(l)) - } - } - l = len(m.Kind) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.ListKind) - n += 1 + l + sovGenerated(uint64(l)) - if len(m.Categories) > 0 { - for _, s := range m.Categories { - l = len(s) - n += 1 + l + sovGenerated(uint64(l)) - } - } - return n -} - -func (m *CustomResourceDefinitionSpec) Size() (n int) { - var l int - _ = l - l = len(m.Group) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Version) - n += 1 + l + sovGenerated(uint64(l)) - l = m.Names.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Scope) - n += 1 + l + sovGenerated(uint64(l)) - if m.Validation != nil { - l = m.Validation.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.Subresources != nil { - l = m.Subresources.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if len(m.Versions) > 0 { - for _, e := range m.Versions { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - } - if len(m.AdditionalPrinterColumns) > 0 { - for _, e := range m.AdditionalPrinterColumns { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - } - return n -} - -func (m *CustomResourceDefinitionStatus) Size() (n int) { - var l int - _ = l - if len(m.Conditions) > 0 { - for _, e := range m.Conditions { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - } - l = m.AcceptedNames.Size() - n += 1 + l + sovGenerated(uint64(l)) - if len(m.StoredVersions) > 0 { - for _, s := range m.StoredVersions { - l = len(s) - n += 1 + l + sovGenerated(uint64(l)) - } - } - return n -} - -func (m *CustomResourceDefinitionVersion) Size() (n int) { - var l int - _ = l - l = len(m.Name) - n += 1 + l + sovGenerated(uint64(l)) - n += 2 - n += 2 - return n -} - -func (m *CustomResourceSubresourceScale) Size() (n int) { - var l int - _ = l - l = len(m.SpecReplicasPath) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.StatusReplicasPath) - n += 1 + l + sovGenerated(uint64(l)) - if m.LabelSelectorPath != nil { - l = len(*m.LabelSelectorPath) - n += 1 + l + sovGenerated(uint64(l)) - } - return n -} - -func (m *CustomResourceSubresourceStatus) Size() (n int) { - var l int - _ = l - return n -} - -func (m *CustomResourceSubresources) Size() (n int) { - var l int - _ = l - if m.Status != nil { - l = m.Status.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.Scale != nil { - l = m.Scale.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - return n -} - -func (m *CustomResourceValidation) Size() (n int) { - var l int - _ = l - if m.OpenAPIV3Schema != nil { - l = m.OpenAPIV3Schema.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - return n -} - -func (m *ExternalDocumentation) Size() (n int) { - var l int - _ = l - l = len(m.Description) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.URL) - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func (m *JSON) Size() (n int) { - var l int - _ = l - if m.Raw != nil { - l = len(m.Raw) - n += 1 + l + sovGenerated(uint64(l)) - } - return n -} - -func (m *JSONSchemaProps) Size() (n int) { - var l int - _ = l - l = len(m.ID) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Schema) - n += 1 + l + sovGenerated(uint64(l)) - if m.Ref != nil { - l = len(*m.Ref) - n += 1 + l + sovGenerated(uint64(l)) - } - l = len(m.Description) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Type) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Format) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Title) - n += 1 + l + sovGenerated(uint64(l)) - if m.Default != nil { - l = m.Default.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.Maximum != nil { - n += 9 - } - n += 2 - if m.Minimum != nil { - n += 9 - } - n += 2 - if m.MaxLength != nil { - n += 1 + sovGenerated(uint64(*m.MaxLength)) - } - if m.MinLength != nil { - n += 1 + sovGenerated(uint64(*m.MinLength)) - } - l = len(m.Pattern) - n += 1 + l + sovGenerated(uint64(l)) - if m.MaxItems != nil { - n += 2 + sovGenerated(uint64(*m.MaxItems)) - } - if m.MinItems != nil { - n += 2 + sovGenerated(uint64(*m.MinItems)) - } - n += 3 - if m.MultipleOf != nil { - n += 10 - } - if len(m.Enum) > 0 { - for _, e := range m.Enum { - l = e.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - } - if m.MaxProperties != nil { - n += 2 + sovGenerated(uint64(*m.MaxProperties)) - } - if m.MinProperties != nil { - n += 2 + sovGenerated(uint64(*m.MinProperties)) - } - if len(m.Required) > 0 { - for _, s := range m.Required { - l = len(s) - n += 2 + l + sovGenerated(uint64(l)) - } - } - if m.Items != nil { - l = m.Items.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - if len(m.AllOf) > 0 { - for _, e := range m.AllOf { - l = e.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - } - if len(m.OneOf) > 0 { - for _, e := range m.OneOf { - l = e.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - } - if len(m.AnyOf) > 0 { - for _, e := range m.AnyOf { - l = e.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - } - if m.Not != nil { - l = m.Not.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - if len(m.Properties) > 0 { - for k, v := range m.Properties { - _ = k - _ = v - l = v.Size() - mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + l + sovGenerated(uint64(l)) - n += mapEntrySize + 2 + sovGenerated(uint64(mapEntrySize)) - } - } - if m.AdditionalProperties != nil { - l = m.AdditionalProperties.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - if len(m.PatternProperties) > 0 { - for k, v := range m.PatternProperties { - _ = k - _ = v - l = v.Size() - mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + l + sovGenerated(uint64(l)) - n += mapEntrySize + 2 + sovGenerated(uint64(mapEntrySize)) - } - } - if len(m.Dependencies) > 0 { - for k, v := range m.Dependencies { - _ = k - _ = v - l = v.Size() - mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + l + sovGenerated(uint64(l)) - n += mapEntrySize + 2 + sovGenerated(uint64(mapEntrySize)) - } - } - if m.AdditionalItems != nil { - l = m.AdditionalItems.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - if len(m.Definitions) > 0 { - for k, v := range m.Definitions { - _ = k - _ = v - l = v.Size() - mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + l + sovGenerated(uint64(l)) - n += mapEntrySize + 2 + sovGenerated(uint64(mapEntrySize)) - } - } - if m.ExternalDocs != nil { - l = m.ExternalDocs.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - if m.Example != nil { - l = m.Example.Size() - n += 2 + l + sovGenerated(uint64(l)) - } - return n -} - -func (m *JSONSchemaPropsOrArray) Size() (n int) { - var l int - _ = l - if m.Schema != nil { - l = m.Schema.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if len(m.JSONSchemas) > 0 { - for _, e := range m.JSONSchemas { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - } - return n -} - -func (m *JSONSchemaPropsOrBool) Size() (n int) { - var l int - _ = l - n += 2 - if m.Schema != nil { - l = m.Schema.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - return n -} - -func (m *JSONSchemaPropsOrStringArray) Size() (n int) { - var l int - _ = l - if m.Schema != nil { - l = m.Schema.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if len(m.Property) > 0 { - for _, s := range m.Property { - l = len(s) - n += 1 + l + sovGenerated(uint64(l)) - } - } - return n -} - -func sovGenerated(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n -} -func sozGenerated(x uint64) (n int) { - return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *CustomResourceColumnDefinition) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceColumnDefinition{`, - `Name:` + fmt.Sprintf("%v", this.Name) + `,`, - `Type:` + fmt.Sprintf("%v", this.Type) + `,`, - `Format:` + fmt.Sprintf("%v", this.Format) + `,`, - `Description:` + fmt.Sprintf("%v", this.Description) + `,`, - `Priority:` + fmt.Sprintf("%v", this.Priority) + `,`, - `JSONPath:` + fmt.Sprintf("%v", this.JSONPath) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceDefinition) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceDefinition{`, - `ObjectMeta:` + strings.Replace(strings.Replace(this.ObjectMeta.String(), "ObjectMeta", "k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta", 1), `&`, ``, 1) + `,`, - `Spec:` + strings.Replace(strings.Replace(this.Spec.String(), "CustomResourceDefinitionSpec", "CustomResourceDefinitionSpec", 1), `&`, ``, 1) + `,`, - `Status:` + strings.Replace(strings.Replace(this.Status.String(), "CustomResourceDefinitionStatus", "CustomResourceDefinitionStatus", 1), `&`, ``, 1) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceDefinitionCondition) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceDefinitionCondition{`, - `Type:` + fmt.Sprintf("%v", this.Type) + `,`, - `Status:` + fmt.Sprintf("%v", this.Status) + `,`, - `LastTransitionTime:` + strings.Replace(strings.Replace(this.LastTransitionTime.String(), "Time", "k8s_io_apimachinery_pkg_apis_meta_v1.Time", 1), `&`, ``, 1) + `,`, - `Reason:` + fmt.Sprintf("%v", this.Reason) + `,`, - `Message:` + fmt.Sprintf("%v", this.Message) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceDefinitionList) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceDefinitionList{`, - `ListMeta:` + strings.Replace(strings.Replace(this.ListMeta.String(), "ListMeta", "k8s_io_apimachinery_pkg_apis_meta_v1.ListMeta", 1), `&`, ``, 1) + `,`, - `Items:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Items), "CustomResourceDefinition", "CustomResourceDefinition", 1), `&`, ``, 1) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceDefinitionNames) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceDefinitionNames{`, - `Plural:` + fmt.Sprintf("%v", this.Plural) + `,`, - `Singular:` + fmt.Sprintf("%v", this.Singular) + `,`, - `ShortNames:` + fmt.Sprintf("%v", this.ShortNames) + `,`, - `Kind:` + fmt.Sprintf("%v", this.Kind) + `,`, - `ListKind:` + fmt.Sprintf("%v", this.ListKind) + `,`, - `Categories:` + fmt.Sprintf("%v", this.Categories) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceDefinitionSpec) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceDefinitionSpec{`, - `Group:` + fmt.Sprintf("%v", this.Group) + `,`, - `Version:` + fmt.Sprintf("%v", this.Version) + `,`, - `Names:` + strings.Replace(strings.Replace(this.Names.String(), "CustomResourceDefinitionNames", "CustomResourceDefinitionNames", 1), `&`, ``, 1) + `,`, - `Scope:` + fmt.Sprintf("%v", this.Scope) + `,`, - `Validation:` + strings.Replace(fmt.Sprintf("%v", this.Validation), "CustomResourceValidation", "CustomResourceValidation", 1) + `,`, - `Subresources:` + strings.Replace(fmt.Sprintf("%v", this.Subresources), "CustomResourceSubresources", "CustomResourceSubresources", 1) + `,`, - `Versions:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Versions), "CustomResourceDefinitionVersion", "CustomResourceDefinitionVersion", 1), `&`, ``, 1) + `,`, - `AdditionalPrinterColumns:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.AdditionalPrinterColumns), "CustomResourceColumnDefinition", "CustomResourceColumnDefinition", 1), `&`, ``, 1) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceDefinitionStatus) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceDefinitionStatus{`, - `Conditions:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Conditions), "CustomResourceDefinitionCondition", "CustomResourceDefinitionCondition", 1), `&`, ``, 1) + `,`, - `AcceptedNames:` + strings.Replace(strings.Replace(this.AcceptedNames.String(), "CustomResourceDefinitionNames", "CustomResourceDefinitionNames", 1), `&`, ``, 1) + `,`, - `StoredVersions:` + fmt.Sprintf("%v", this.StoredVersions) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceDefinitionVersion) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceDefinitionVersion{`, - `Name:` + fmt.Sprintf("%v", this.Name) + `,`, - `Served:` + fmt.Sprintf("%v", this.Served) + `,`, - `Storage:` + fmt.Sprintf("%v", this.Storage) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceSubresourceScale) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceSubresourceScale{`, - `SpecReplicasPath:` + fmt.Sprintf("%v", this.SpecReplicasPath) + `,`, - `StatusReplicasPath:` + fmt.Sprintf("%v", this.StatusReplicasPath) + `,`, - `LabelSelectorPath:` + valueToStringGenerated(this.LabelSelectorPath) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceSubresourceStatus) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceSubresourceStatus{`, - `}`, - }, "") - return s -} -func (this *CustomResourceSubresources) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceSubresources{`, - `Status:` + strings.Replace(fmt.Sprintf("%v", this.Status), "CustomResourceSubresourceStatus", "CustomResourceSubresourceStatus", 1) + `,`, - `Scale:` + strings.Replace(fmt.Sprintf("%v", this.Scale), "CustomResourceSubresourceScale", "CustomResourceSubresourceScale", 1) + `,`, - `}`, - }, "") - return s -} -func (this *CustomResourceValidation) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&CustomResourceValidation{`, - `OpenAPIV3Schema:` + strings.Replace(fmt.Sprintf("%v", this.OpenAPIV3Schema), "JSONSchemaProps", "JSONSchemaProps", 1) + `,`, - `}`, - }, "") - return s -} -func (this *ExternalDocumentation) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&ExternalDocumentation{`, - `Description:` + fmt.Sprintf("%v", this.Description) + `,`, - `URL:` + fmt.Sprintf("%v", this.URL) + `,`, - `}`, - }, "") - return s -} -func (this *JSON) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&JSON{`, - `Raw:` + valueToStringGenerated(this.Raw) + `,`, - `}`, - }, "") - return s -} -func (this *JSONSchemaProps) String() string { - if this == nil { - return "nil" - } - keysForProperties := make([]string, 0, len(this.Properties)) - for k := range this.Properties { - keysForProperties = append(keysForProperties, k) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForProperties) - mapStringForProperties := "map[string]JSONSchemaProps{" - for _, k := range keysForProperties { - mapStringForProperties += fmt.Sprintf("%v: %v,", k, this.Properties[k]) - } - mapStringForProperties += "}" - keysForPatternProperties := make([]string, 0, len(this.PatternProperties)) - for k := range this.PatternProperties { - keysForPatternProperties = append(keysForPatternProperties, k) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForPatternProperties) - mapStringForPatternProperties := "map[string]JSONSchemaProps{" - for _, k := range keysForPatternProperties { - mapStringForPatternProperties += fmt.Sprintf("%v: %v,", k, this.PatternProperties[k]) - } - mapStringForPatternProperties += "}" - keysForDependencies := make([]string, 0, len(this.Dependencies)) - for k := range this.Dependencies { - keysForDependencies = append(keysForDependencies, k) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForDependencies) - mapStringForDependencies := "JSONSchemaDependencies{" - for _, k := range keysForDependencies { - mapStringForDependencies += fmt.Sprintf("%v: %v,", k, this.Dependencies[k]) - } - mapStringForDependencies += "}" - keysForDefinitions := make([]string, 0, len(this.Definitions)) - for k := range this.Definitions { - keysForDefinitions = append(keysForDefinitions, k) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForDefinitions) - mapStringForDefinitions := "JSONSchemaDefinitions{" - for _, k := range keysForDefinitions { - mapStringForDefinitions += fmt.Sprintf("%v: %v,", k, this.Definitions[k]) - } - mapStringForDefinitions += "}" - s := strings.Join([]string{`&JSONSchemaProps{`, - `ID:` + fmt.Sprintf("%v", this.ID) + `,`, - `Schema:` + fmt.Sprintf("%v", this.Schema) + `,`, - `Ref:` + valueToStringGenerated(this.Ref) + `,`, - `Description:` + fmt.Sprintf("%v", this.Description) + `,`, - `Type:` + fmt.Sprintf("%v", this.Type) + `,`, - `Format:` + fmt.Sprintf("%v", this.Format) + `,`, - `Title:` + fmt.Sprintf("%v", this.Title) + `,`, - `Default:` + strings.Replace(fmt.Sprintf("%v", this.Default), "JSON", "JSON", 1) + `,`, - `Maximum:` + valueToStringGenerated(this.Maximum) + `,`, - `ExclusiveMaximum:` + fmt.Sprintf("%v", this.ExclusiveMaximum) + `,`, - `Minimum:` + valueToStringGenerated(this.Minimum) + `,`, - `ExclusiveMinimum:` + fmt.Sprintf("%v", this.ExclusiveMinimum) + `,`, - `MaxLength:` + valueToStringGenerated(this.MaxLength) + `,`, - `MinLength:` + valueToStringGenerated(this.MinLength) + `,`, - `Pattern:` + fmt.Sprintf("%v", this.Pattern) + `,`, - `MaxItems:` + valueToStringGenerated(this.MaxItems) + `,`, - `MinItems:` + valueToStringGenerated(this.MinItems) + `,`, - `UniqueItems:` + fmt.Sprintf("%v", this.UniqueItems) + `,`, - `MultipleOf:` + valueToStringGenerated(this.MultipleOf) + `,`, - `Enum:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Enum), "JSON", "JSON", 1), `&`, ``, 1) + `,`, - `MaxProperties:` + valueToStringGenerated(this.MaxProperties) + `,`, - `MinProperties:` + valueToStringGenerated(this.MinProperties) + `,`, - `Required:` + fmt.Sprintf("%v", this.Required) + `,`, - `Items:` + strings.Replace(fmt.Sprintf("%v", this.Items), "JSONSchemaPropsOrArray", "JSONSchemaPropsOrArray", 1) + `,`, - `AllOf:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.AllOf), "JSONSchemaProps", "JSONSchemaProps", 1), `&`, ``, 1) + `,`, - `OneOf:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.OneOf), "JSONSchemaProps", "JSONSchemaProps", 1), `&`, ``, 1) + `,`, - `AnyOf:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.AnyOf), "JSONSchemaProps", "JSONSchemaProps", 1), `&`, ``, 1) + `,`, - `Not:` + strings.Replace(fmt.Sprintf("%v", this.Not), "JSONSchemaProps", "JSONSchemaProps", 1) + `,`, - `Properties:` + mapStringForProperties + `,`, - `AdditionalProperties:` + strings.Replace(fmt.Sprintf("%v", this.AdditionalProperties), "JSONSchemaPropsOrBool", "JSONSchemaPropsOrBool", 1) + `,`, - `PatternProperties:` + mapStringForPatternProperties + `,`, - `Dependencies:` + mapStringForDependencies + `,`, - `AdditionalItems:` + strings.Replace(fmt.Sprintf("%v", this.AdditionalItems), "JSONSchemaPropsOrBool", "JSONSchemaPropsOrBool", 1) + `,`, - `Definitions:` + mapStringForDefinitions + `,`, - `ExternalDocs:` + strings.Replace(fmt.Sprintf("%v", this.ExternalDocs), "ExternalDocumentation", "ExternalDocumentation", 1) + `,`, - `Example:` + strings.Replace(fmt.Sprintf("%v", this.Example), "JSON", "JSON", 1) + `,`, - `}`, - }, "") - return s -} -func (this *JSONSchemaPropsOrArray) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&JSONSchemaPropsOrArray{`, - `Schema:` + strings.Replace(fmt.Sprintf("%v", this.Schema), "JSONSchemaProps", "JSONSchemaProps", 1) + `,`, - `JSONSchemas:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.JSONSchemas), "JSONSchemaProps", "JSONSchemaProps", 1), `&`, ``, 1) + `,`, - `}`, - }, "") - return s -} -func (this *JSONSchemaPropsOrBool) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&JSONSchemaPropsOrBool{`, - `Allows:` + fmt.Sprintf("%v", this.Allows) + `,`, - `Schema:` + strings.Replace(fmt.Sprintf("%v", this.Schema), "JSONSchemaProps", "JSONSchemaProps", 1) + `,`, - `}`, - }, "") - return s -} -func (this *JSONSchemaPropsOrStringArray) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&JSONSchemaPropsOrStringArray{`, - `Schema:` + strings.Replace(fmt.Sprintf("%v", this.Schema), "JSONSchemaProps", "JSONSchemaProps", 1) + `,`, - `Property:` + fmt.Sprintf("%v", this.Property) + `,`, - `}`, - }, "") - return s -} -func valueToStringGenerated(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *CustomResourceColumnDefinition) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceColumnDefinition: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceColumnDefinition: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Format = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Priority", wireType) - } - m.Priority = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Priority |= (int32(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field JSONPath", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.JSONPath = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceDefinition) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceDefinition: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceDefinition: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceDefinitionCondition) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceDefinitionCondition: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceDefinitionCondition: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = CustomResourceDefinitionConditionType(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Status = ConditionStatus(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastTransitionTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LastTransitionTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Reason = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Message = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceDefinitionList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceDefinitionList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceDefinitionList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Items = append(m.Items, CustomResourceDefinition{}) - if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceDefinitionNames) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceDefinitionNames: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceDefinitionNames: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Plural", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Plural = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Singular", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Singular = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ShortNames", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ShortNames = append(m.ShortNames, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Kind = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ListKind", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ListKind = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Categories", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Categories = append(m.Categories, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceDefinitionSpec) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceDefinitionSpec: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceDefinitionSpec: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Group = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Names", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Names.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Scope = ResourceScope(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validation", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Validation == nil { - m.Validation = &CustomResourceValidation{} - } - if err := m.Validation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Subresources", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Subresources == nil { - m.Subresources = &CustomResourceSubresources{} - } - if err := m.Subresources.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Versions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Versions = append(m.Versions, CustomResourceDefinitionVersion{}) - if err := m.Versions[len(m.Versions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AdditionalPrinterColumns", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AdditionalPrinterColumns = append(m.AdditionalPrinterColumns, CustomResourceColumnDefinition{}) - if err := m.AdditionalPrinterColumns[len(m.AdditionalPrinterColumns)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceDefinitionStatus) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceDefinitionStatus: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceDefinitionStatus: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Conditions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Conditions = append(m.Conditions, CustomResourceDefinitionCondition{}) - if err := m.Conditions[len(m.Conditions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcceptedNames", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.AcceptedNames.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StoredVersions", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StoredVersions = append(m.StoredVersions, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceDefinitionVersion) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceDefinitionVersion: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceDefinitionVersion: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Served", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Served = bool(v != 0) - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Storage", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Storage = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceSubresourceScale) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceSubresourceScale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceSubresourceScale: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpecReplicasPath", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SpecReplicasPath = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StatusReplicasPath", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StatusReplicasPath = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LabelSelectorPath", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - s := string(dAtA[iNdEx:postIndex]) - m.LabelSelectorPath = &s - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceSubresourceStatus) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceSubresourceStatus: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceSubresourceStatus: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceSubresources) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceSubresources: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceSubresources: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &CustomResourceSubresourceStatus{} - } - if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Scale", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Scale == nil { - m.Scale = &CustomResourceSubresourceScale{} - } - if err := m.Scale.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CustomResourceValidation) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomResourceValidation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomResourceValidation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OpenAPIV3Schema", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.OpenAPIV3Schema == nil { - m.OpenAPIV3Schema = &JSONSchemaProps{} - } - if err := m.OpenAPIV3Schema.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExternalDocumentation) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExternalDocumentation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExternalDocumentation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field URL", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.URL = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *JSON) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: JSON: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: JSON: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Raw", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Raw = append(m.Raw[:0], dAtA[iNdEx:postIndex]...) - if m.Raw == nil { - m.Raw = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *JSONSchemaProps) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: JSONSchemaProps: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: JSONSchemaProps: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Schema = JSONSchemaURL(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ref", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - s := string(dAtA[iNdEx:postIndex]) - m.Ref = &s - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Format = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Default", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Default == nil { - m.Default = &JSON{} - } - if err := m.Default.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Maximum", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - iNdEx += 8 - v = uint64(dAtA[iNdEx-8]) - v |= uint64(dAtA[iNdEx-7]) << 8 - v |= uint64(dAtA[iNdEx-6]) << 16 - v |= uint64(dAtA[iNdEx-5]) << 24 - v |= uint64(dAtA[iNdEx-4]) << 32 - v |= uint64(dAtA[iNdEx-3]) << 40 - v |= uint64(dAtA[iNdEx-2]) << 48 - v |= uint64(dAtA[iNdEx-1]) << 56 - v2 := float64(math.Float64frombits(v)) - m.Maximum = &v2 - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExclusiveMaximum", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.ExclusiveMaximum = bool(v != 0) - case 11: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Minimum", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - iNdEx += 8 - v = uint64(dAtA[iNdEx-8]) - v |= uint64(dAtA[iNdEx-7]) << 8 - v |= uint64(dAtA[iNdEx-6]) << 16 - v |= uint64(dAtA[iNdEx-5]) << 24 - v |= uint64(dAtA[iNdEx-4]) << 32 - v |= uint64(dAtA[iNdEx-3]) << 40 - v |= uint64(dAtA[iNdEx-2]) << 48 - v |= uint64(dAtA[iNdEx-1]) << 56 - v2 := float64(math.Float64frombits(v)) - m.Minimum = &v2 - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExclusiveMinimum", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.ExclusiveMinimum = bool(v != 0) - case 13: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxLength", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.MaxLength = &v - case 14: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinLength", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.MinLength = &v - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pattern", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pattern = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 16: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxItems", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.MaxItems = &v - case 17: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinItems", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.MinItems = &v - case 18: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UniqueItems", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.UniqueItems = bool(v != 0) - case 19: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field MultipleOf", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - iNdEx += 8 - v = uint64(dAtA[iNdEx-8]) - v |= uint64(dAtA[iNdEx-7]) << 8 - v |= uint64(dAtA[iNdEx-6]) << 16 - v |= uint64(dAtA[iNdEx-5]) << 24 - v |= uint64(dAtA[iNdEx-4]) << 32 - v |= uint64(dAtA[iNdEx-3]) << 40 - v |= uint64(dAtA[iNdEx-2]) << 48 - v |= uint64(dAtA[iNdEx-1]) << 56 - v2 := float64(math.Float64frombits(v)) - m.MultipleOf = &v2 - case 20: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Enum", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Enum = append(m.Enum, JSON{}) - if err := m.Enum[len(m.Enum)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 21: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxProperties", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.MaxProperties = &v - case 22: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinProperties", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.MinProperties = &v - case 23: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Required", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Required = append(m.Required, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 24: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Items == nil { - m.Items = &JSONSchemaPropsOrArray{} - } - if err := m.Items.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 25: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AllOf", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AllOf = append(m.AllOf, JSONSchemaProps{}) - if err := m.AllOf[len(m.AllOf)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 26: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OneOf", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OneOf = append(m.OneOf, JSONSchemaProps{}) - if err := m.OneOf[len(m.OneOf)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 27: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AnyOf", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AnyOf = append(m.AnyOf, JSONSchemaProps{}) - if err := m.AnyOf[len(m.AnyOf)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 28: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Not", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Not == nil { - m.Not = &JSONSchemaProps{} - } - if err := m.Not.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 29: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Properties", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - var keykey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - keykey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthGenerated - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey := string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - if m.Properties == nil { - m.Properties = make(map[string]JSONSchemaProps) - } - if iNdEx < postIndex { - var valuekey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - valuekey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - postmsgIndex := iNdEx + mapmsglen - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue := &JSONSchemaProps{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - m.Properties[mapkey] = *mapvalue - } else { - var mapvalue JSONSchemaProps - m.Properties[mapkey] = mapvalue - } - iNdEx = postIndex - case 30: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AdditionalProperties", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AdditionalProperties == nil { - m.AdditionalProperties = &JSONSchemaPropsOrBool{} - } - if err := m.AdditionalProperties.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 31: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PatternProperties", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - var keykey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - keykey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthGenerated - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey := string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - if m.PatternProperties == nil { - m.PatternProperties = make(map[string]JSONSchemaProps) - } - if iNdEx < postIndex { - var valuekey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - valuekey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - postmsgIndex := iNdEx + mapmsglen - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue := &JSONSchemaProps{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - m.PatternProperties[mapkey] = *mapvalue - } else { - var mapvalue JSONSchemaProps - m.PatternProperties[mapkey] = mapvalue - } - iNdEx = postIndex - case 32: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Dependencies", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - var keykey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - keykey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthGenerated - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey := string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - if m.Dependencies == nil { - m.Dependencies = make(JSONSchemaDependencies) - } - if iNdEx < postIndex { - var valuekey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - valuekey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - postmsgIndex := iNdEx + mapmsglen - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue := &JSONSchemaPropsOrStringArray{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - m.Dependencies[mapkey] = *mapvalue - } else { - var mapvalue JSONSchemaPropsOrStringArray - m.Dependencies[mapkey] = mapvalue - } - iNdEx = postIndex - case 33: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AdditionalItems", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AdditionalItems == nil { - m.AdditionalItems = &JSONSchemaPropsOrBool{} - } - if err := m.AdditionalItems.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 34: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Definitions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - var keykey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - keykey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthGenerated - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey := string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - if m.Definitions == nil { - m.Definitions = make(JSONSchemaDefinitions) - } - if iNdEx < postIndex { - var valuekey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - valuekey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - postmsgIndex := iNdEx + mapmsglen - if mapmsglen < 0 { - return ErrInvalidLengthGenerated - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue := &JSONSchemaProps{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - m.Definitions[mapkey] = *mapvalue - } else { - var mapvalue JSONSchemaProps - m.Definitions[mapkey] = mapvalue - } - iNdEx = postIndex - case 35: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExternalDocs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ExternalDocs == nil { - m.ExternalDocs = &ExternalDocumentation{} - } - if err := m.ExternalDocs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 36: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Example", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Example == nil { - m.Example = &JSON{} - } - if err := m.Example.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *JSONSchemaPropsOrArray) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: JSONSchemaPropsOrArray: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: JSONSchemaPropsOrArray: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Schema == nil { - m.Schema = &JSONSchemaProps{} - } - if err := m.Schema.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field JSONSchemas", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.JSONSchemas = append(m.JSONSchemas, JSONSchemaProps{}) - if err := m.JSONSchemas[len(m.JSONSchemas)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *JSONSchemaPropsOrBool) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: JSONSchemaPropsOrBool: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: JSONSchemaPropsOrBool: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Allows", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Allows = bool(v != 0) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Schema == nil { - m.Schema = &JSONSchemaProps{} - } - if err := m.Schema.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *JSONSchemaPropsOrStringArray) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: JSONSchemaPropsOrStringArray: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: JSONSchemaPropsOrStringArray: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Schema == nil { - m.Schema = &JSONSchemaProps{} - } - if err := m.Schema.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Property", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Property = append(m.Property, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenerated(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - return iNdEx, nil - case 1: - iNdEx += 8 - return iNdEx, nil - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - iNdEx += length - if length < 0 { - return 0, ErrInvalidLengthGenerated - } - return iNdEx, nil - case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipGenerated(dAtA[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil - case 4: - return iNdEx, nil - case 5: - iNdEx += 4 - return iNdEx, nil - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - } - panic("unreachable") -} - -var ( - ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") -) - -func init() { - proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto", fileDescriptorGenerated) -} - -var fileDescriptorGenerated = []byte{ - // 2306 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0xdd, 0x6f, 0x5b, 0x49, - 0x15, 0xef, 0xb5, 0xe3, 0xc4, 0x19, 0x27, 0x4d, 0x32, 0x6d, 0xca, 0x6d, 0x68, 0xed, 0xd4, 0x65, - 0x57, 0x01, 0xb6, 0x36, 0xed, 0xee, 0xb2, 0xcb, 0x4a, 0x3c, 0xc4, 0x49, 0x41, 0x5d, 0x9a, 0x26, - 0x1a, 0xb7, 0x45, 0xb0, 0x9f, 0x13, 0x7b, 0xe2, 0xdc, 0xe6, 0x7e, 0x75, 0x66, 0xae, 0x9b, 0x48, - 0x80, 0xf8, 0xd0, 0x0a, 0x09, 0x01, 0x0b, 0x6c, 0x85, 0x84, 0xc4, 0x0b, 0x48, 0xbc, 0x20, 0x04, - 0x0f, 0xf0, 0x06, 0x7f, 0x40, 0x1f, 0xf7, 0x71, 0x9f, 0x2c, 0x6a, 0xfe, 0x05, 0x24, 0xa4, 0x3c, - 0xa1, 0xf9, 0xb8, 0x73, 0xef, 0xb5, 0xe3, 0x6d, 0xb5, 0x6b, 0x6f, 0xdf, 0x7c, 0xcf, 0x39, 0x73, - 0x7e, 0xbf, 0x39, 0x73, 0xe6, 0xcc, 0x39, 0x09, 0xd8, 0x3b, 0x78, 0x95, 0xd5, 0x9c, 0xa0, 0x7e, - 0x10, 0xed, 0x12, 0xea, 0x13, 0x4e, 0x58, 0xbd, 0x4b, 0xfc, 0x76, 0x40, 0xeb, 0x5a, 0x81, 0x43, - 0x87, 0x1c, 0x72, 0xe2, 0x33, 0x27, 0xf0, 0xd9, 0x15, 0x1c, 0x3a, 0x8c, 0xd0, 0x2e, 0xa1, 0xf5, - 0xf0, 0xa0, 0x23, 0x74, 0x2c, 0x6b, 0x50, 0xef, 0x5e, 0xdd, 0x25, 0x1c, 0x5f, 0xad, 0x77, 0x88, - 0x4f, 0x28, 0xe6, 0xa4, 0x5d, 0x0b, 0x69, 0xc0, 0x03, 0xf8, 0x75, 0xe5, 0xae, 0x96, 0xb1, 0x7e, - 0xc7, 0xb8, 0xab, 0x85, 0x07, 0x1d, 0xa1, 0x63, 0x59, 0x83, 0x9a, 0x76, 0xb7, 0x72, 0xa5, 0xe3, - 0xf0, 0xfd, 0x68, 0xb7, 0xd6, 0x0a, 0xbc, 0x7a, 0x27, 0xe8, 0x04, 0x75, 0xe9, 0x75, 0x37, 0xda, - 0x93, 0x5f, 0xf2, 0x43, 0xfe, 0x52, 0x68, 0x2b, 0x2f, 0x25, 0xe4, 0x3d, 0xdc, 0xda, 0x77, 0x7c, - 0x42, 0x8f, 0x12, 0xc6, 0x1e, 0xe1, 0xb8, 0xde, 0x1d, 0xe2, 0xb8, 0x52, 0x1f, 0xb5, 0x8a, 0x46, - 0x3e, 0x77, 0x3c, 0x32, 0xb4, 0xe0, 0xab, 0x4f, 0x5a, 0xc0, 0x5a, 0xfb, 0xc4, 0xc3, 0x43, 0xeb, - 0x5e, 0x1c, 0xb5, 0x2e, 0xe2, 0x8e, 0x5b, 0x77, 0x7c, 0xce, 0x38, 0x1d, 0x5c, 0x54, 0xfd, 0x20, - 0x07, 0xca, 0x1b, 0x11, 0xe3, 0x81, 0x87, 0x08, 0x0b, 0x22, 0xda, 0x22, 0x1b, 0x81, 0x1b, 0x79, - 0xfe, 0x26, 0xd9, 0x73, 0x7c, 0x87, 0x3b, 0x81, 0x0f, 0x57, 0xc1, 0x94, 0x8f, 0x3d, 0x62, 0x5b, - 0xab, 0xd6, 0xda, 0x6c, 0x63, 0xee, 0x51, 0xaf, 0x72, 0xaa, 0xdf, 0xab, 0x4c, 0xdd, 0xc2, 0x1e, - 0x41, 0x52, 0x23, 0x2c, 0xf8, 0x51, 0x48, 0xec, 0x5c, 0xd6, 0xe2, 0xf6, 0x51, 0x48, 0x90, 0xd4, - 0xc0, 0xe7, 0xc1, 0xf4, 0x5e, 0x40, 0x3d, 0xcc, 0xed, 0xbc, 0xb4, 0x39, 0xad, 0x6d, 0xa6, 0xbf, - 0x21, 0xa5, 0x48, 0x6b, 0xe1, 0xcb, 0xa0, 0xd4, 0x26, 0xac, 0x45, 0x9d, 0x50, 0x40, 0xdb, 0x53, - 0xd2, 0xf8, 0x8c, 0x36, 0x2e, 0x6d, 0x26, 0x2a, 0x94, 0xb6, 0x83, 0x2f, 0x80, 0x62, 0x48, 0x9d, - 0x80, 0x3a, 0xfc, 0xc8, 0x2e, 0xac, 0x5a, 0x6b, 0x85, 0xc6, 0xa2, 0x5e, 0x53, 0xdc, 0xd1, 0x72, - 0x64, 0x2c, 0xe0, 0x2a, 0x28, 0xbe, 0xde, 0xdc, 0xbe, 0xb5, 0x83, 0xf9, 0xbe, 0x3d, 0x2d, 0x11, - 0xa6, 0x84, 0x35, 0x2a, 0xde, 0xd3, 0xd2, 0xea, 0x4f, 0xf2, 0xc0, 0xce, 0x46, 0x25, 0x15, 0x8f, - 0x77, 0x41, 0x51, 0x9c, 0x75, 0x1b, 0x73, 0x2c, 0x63, 0x52, 0xba, 0xf6, 0x95, 0x5a, 0x92, 0x87, - 0x26, 0xf4, 0x49, 0xf2, 0x09, 0xeb, 0x5a, 0xf7, 0x6a, 0x6d, 0x7b, 0xf7, 0x1e, 0x69, 0xf1, 0x2d, - 0xc2, 0x71, 0x03, 0x6a, 0x7a, 0x20, 0x91, 0x21, 0xe3, 0x15, 0x7e, 0x1f, 0x4c, 0xb1, 0x90, 0xb4, - 0x64, 0x3c, 0x4b, 0xd7, 0xde, 0xa8, 0x7d, 0xaa, 0x2c, 0xaf, 0x8d, 0xda, 0x48, 0x33, 0x24, 0xad, - 0xe4, 0xb0, 0xc4, 0x17, 0x92, 0xb0, 0xf0, 0x3d, 0x0b, 0x4c, 0x33, 0x8e, 0x79, 0xc4, 0xe4, 0x69, - 0x95, 0xae, 0xbd, 0x35, 0x29, 0x06, 0x12, 0x24, 0x49, 0x06, 0xf5, 0x8d, 0x34, 0x78, 0xf5, 0xbf, - 0x39, 0x70, 0x69, 0xd4, 0xd2, 0x8d, 0xc0, 0x6f, 0xab, 0xe3, 0xb8, 0xa1, 0x93, 0x4f, 0xa5, 0xe7, - 0xcb, 0xe9, 0xe4, 0x3b, 0xee, 0x55, 0x9e, 0x7b, 0xa2, 0x83, 0x54, 0x96, 0x7e, 0xcd, 0xec, 0x5b, - 0x65, 0xf2, 0xa5, 0x2c, 0xb1, 0xe3, 0x5e, 0x65, 0xc1, 0x2c, 0xcb, 0x72, 0x85, 0x5d, 0x00, 0x5d, - 0xcc, 0xf8, 0x6d, 0x8a, 0x7d, 0xa6, 0xdc, 0x3a, 0x1e, 0xd1, 0xe1, 0xfb, 0xd2, 0xd3, 0xa5, 0x87, - 0x58, 0xd1, 0x58, 0xd1, 0x90, 0xf0, 0xe6, 0x90, 0x37, 0x74, 0x02, 0x82, 0xb8, 0x58, 0x94, 0x60, - 0x66, 0xee, 0x8a, 0x89, 0x25, 0x92, 0x52, 0xa4, 0xb5, 0xf0, 0x8b, 0x60, 0xc6, 0x23, 0x8c, 0xe1, - 0x0e, 0x91, 0x17, 0x64, 0xb6, 0xb1, 0xa0, 0x0d, 0x67, 0xb6, 0x94, 0x18, 0xc5, 0xfa, 0xea, 0xb1, - 0x05, 0x2e, 0x8c, 0x8a, 0xda, 0x4d, 0x87, 0x71, 0xf8, 0xe6, 0xd0, 0x05, 0xa8, 0x3d, 0xdd, 0x0e, - 0xc5, 0x6a, 0x99, 0xfe, 0xe6, 0x76, 0xc6, 0x92, 0x54, 0xf2, 0x7f, 0x0f, 0x14, 0x1c, 0x4e, 0x3c, - 0x71, 0x06, 0xf9, 0xb5, 0xd2, 0xb5, 0x6f, 0x4f, 0x28, 0xf7, 0x1a, 0xf3, 0x9a, 0x43, 0xe1, 0x86, - 0x40, 0x43, 0x0a, 0xb4, 0xfa, 0xa7, 0x1c, 0xb8, 0x38, 0x6a, 0x89, 0xa8, 0x78, 0x4c, 0x44, 0x3c, - 0x74, 0x23, 0x8a, 0x5d, 0x9d, 0x71, 0x26, 0xe2, 0x3b, 0x52, 0x8a, 0xb4, 0x56, 0xd4, 0x24, 0xe6, - 0xf8, 0x9d, 0xc8, 0xc5, 0x54, 0xa7, 0x93, 0xd9, 0x75, 0x53, 0xcb, 0x91, 0xb1, 0x80, 0x35, 0x00, - 0xd8, 0x7e, 0x40, 0xb9, 0xc4, 0xb0, 0xf3, 0xab, 0x79, 0xe1, 0x59, 0x14, 0x88, 0xa6, 0x91, 0xa2, - 0x94, 0x85, 0x28, 0xb9, 0x07, 0x8e, 0xdf, 0xd6, 0xa7, 0x6e, 0x6e, 0xf1, 0xb7, 0x1c, 0xbf, 0x8d, - 0xa4, 0x46, 0xe0, 0xbb, 0x0e, 0xe3, 0x42, 0xa2, 0x8f, 0x3c, 0x13, 0x75, 0x69, 0x69, 0x2c, 0x04, - 0x7e, 0x0b, 0x73, 0xd2, 0x09, 0xa8, 0x43, 0x98, 0x3d, 0x9d, 0xe0, 0x6f, 0x18, 0x29, 0x4a, 0x59, - 0x54, 0x7f, 0x3d, 0x33, 0x3a, 0x49, 0x44, 0x29, 0x81, 0x97, 0x41, 0xa1, 0x43, 0x83, 0x28, 0xd4, - 0x51, 0x32, 0xd1, 0xfe, 0xa6, 0x10, 0x22, 0xa5, 0x13, 0x59, 0xd9, 0x25, 0x54, 0x1c, 0x98, 0x0e, - 0x91, 0xc9, 0xca, 0xbb, 0x4a, 0x8c, 0x62, 0x3d, 0xfc, 0x91, 0x05, 0x0a, 0xbe, 0x0e, 0x8e, 0x48, - 0xb9, 0x37, 0x27, 0x94, 0x17, 0x32, 0xbc, 0x09, 0x5d, 0x15, 0x79, 0x85, 0x0c, 0x5f, 0x02, 0x05, - 0xd6, 0x0a, 0x42, 0xa2, 0xa3, 0x5e, 0x8e, 0x8d, 0x9a, 0x42, 0x78, 0xdc, 0xab, 0xcc, 0xc7, 0xee, - 0xa4, 0x00, 0x29, 0x63, 0xf8, 0x53, 0x0b, 0x80, 0x2e, 0x76, 0x9d, 0x36, 0x96, 0x6f, 0x5a, 0x41, - 0xd2, 0x1f, 0x6f, 0x5a, 0xdf, 0x35, 0xee, 0xd5, 0xa1, 0x25, 0xdf, 0x28, 0x05, 0x0d, 0xdf, 0xb7, - 0xc0, 0x1c, 0x8b, 0x76, 0xa9, 0x5e, 0xc5, 0xe4, 0xeb, 0x57, 0xba, 0xf6, 0x9d, 0xb1, 0x72, 0x69, - 0xa6, 0x00, 0x1a, 0x8b, 0xfd, 0x5e, 0x65, 0x2e, 0x2d, 0x41, 0x19, 0x02, 0xf0, 0xe7, 0x16, 0x28, - 0xea, 0x13, 0x66, 0xf6, 0x8c, 0xbc, 0xf0, 0x6f, 0x4f, 0xe8, 0x60, 0x75, 0x46, 0x25, 0xb7, 0x40, - 0x0b, 0x18, 0x32, 0x0c, 0xe0, 0x3f, 0x2d, 0x60, 0xe3, 0xb6, 0x2a, 0xf0, 0xd8, 0xdd, 0xa1, 0x8e, - 0xcf, 0x09, 0x55, 0x0d, 0x11, 0xb3, 0x8b, 0x92, 0xde, 0x78, 0xdf, 0xc2, 0xc1, 0x66, 0xab, 0xb1, - 0xaa, 0xd9, 0xd9, 0xeb, 0x23, 0x68, 0xa0, 0x91, 0x04, 0xab, 0xef, 0xe7, 0x07, 0x7b, 0xb9, 0xc1, - 0xa7, 0x16, 0x3e, 0xb4, 0x00, 0x68, 0xc5, 0x4f, 0x18, 0xb3, 0x2d, 0xb9, 0xa5, 0x77, 0x27, 0x14, - 0x71, 0xf3, 0x56, 0x26, 0xed, 0x8e, 0x11, 0x89, 0x6a, 0x62, 0x7e, 0xc3, 0xdf, 0x59, 0x60, 0x1e, - 0xb7, 0x5a, 0x24, 0xe4, 0xa4, 0xad, 0x2a, 0x60, 0xee, 0x33, 0xb8, 0xe4, 0xcb, 0x9a, 0xd5, 0xfc, - 0x7a, 0x1a, 0x1a, 0x65, 0x99, 0xc0, 0xd7, 0xc0, 0x69, 0xc6, 0x03, 0x4a, 0xda, 0x71, 0xbe, 0xe8, - 0xea, 0x0c, 0xfb, 0xbd, 0xca, 0xe9, 0x66, 0x46, 0x83, 0x06, 0x2c, 0xab, 0xbf, 0xb5, 0x40, 0xe5, - 0x09, 0xf9, 0xf8, 0x14, 0xed, 0xf5, 0xf3, 0x60, 0x5a, 0x6e, 0xb7, 0x2d, 0xa3, 0x52, 0x4c, 0xf5, - 0x4b, 0x52, 0x8a, 0xb4, 0x56, 0x54, 0x53, 0x81, 0x2f, 0xde, 0xf8, 0xbc, 0x34, 0x34, 0xd5, 0xb4, - 0xa9, 0xc4, 0x28, 0xd6, 0x57, 0xff, 0x67, 0x0d, 0xa6, 0x4a, 0xea, 0x92, 0x36, 0x5b, 0xd8, 0x25, - 0x70, 0x13, 0x2c, 0x8a, 0x6e, 0x10, 0x91, 0xd0, 0x75, 0x5a, 0x98, 0xc9, 0x6e, 0x59, 0x71, 0xb4, - 0xb5, 0xdb, 0xc5, 0xe6, 0x80, 0x1e, 0x0d, 0xad, 0x80, 0xaf, 0x03, 0xa8, 0x3a, 0xa4, 0x8c, 0x1f, - 0x55, 0xec, 0x4d, 0xaf, 0xd3, 0x1c, 0xb2, 0x40, 0x27, 0xac, 0x82, 0x1b, 0x60, 0xc9, 0xc5, 0xbb, - 0xc4, 0x6d, 0x12, 0x97, 0xb4, 0x78, 0x40, 0xa5, 0x2b, 0x35, 0x4f, 0x2c, 0xf7, 0x7b, 0x95, 0xa5, - 0x9b, 0x83, 0x4a, 0x34, 0x6c, 0x5f, 0xbd, 0x34, 0x78, 0x22, 0xe9, 0x8d, 0xab, 0xbe, 0xf3, 0x0f, - 0x39, 0xb0, 0x32, 0xba, 0xa6, 0xc1, 0x1f, 0x27, 0xed, 0xb1, 0xea, 0x7e, 0xde, 0x9e, 0x54, 0xfd, - 0xd4, 0xfd, 0x31, 0x18, 0xee, 0x8d, 0xe1, 0x0f, 0xc4, 0x53, 0x84, 0x5d, 0xa2, 0x2f, 0xca, 0x5b, - 0x13, 0xa3, 0x20, 0x40, 0x1a, 0xb3, 0xea, 0x95, 0xc3, 0xae, 0x7c, 0xd4, 0xb0, 0x4b, 0xaa, 0x7f, - 0xb6, 0x06, 0x27, 0xa4, 0xe4, 0xcd, 0x81, 0xbf, 0xb0, 0xc0, 0x42, 0x10, 0x12, 0x7f, 0x7d, 0xe7, - 0xc6, 0xdd, 0x17, 0x9b, 0x72, 0x5a, 0xd5, 0xa1, 0xba, 0xf5, 0x29, 0x79, 0x8a, 0xb9, 0x4d, 0x39, - 0xdc, 0xa1, 0x41, 0xc8, 0x1a, 0x67, 0xfa, 0xbd, 0xca, 0xc2, 0x76, 0x16, 0x0a, 0x0d, 0x62, 0x57, - 0x3d, 0xb0, 0x7c, 0xfd, 0x90, 0x13, 0xea, 0x63, 0x77, 0x33, 0x68, 0x45, 0x1e, 0xf1, 0xb9, 0x22, - 0x3a, 0x30, 0x6e, 0x5a, 0x4f, 0x39, 0x6e, 0x5e, 0x04, 0xf9, 0x88, 0xba, 0x3a, 0x8b, 0x4b, 0xda, - 0x3c, 0x7f, 0x07, 0xdd, 0x44, 0x42, 0x5e, 0xbd, 0x04, 0xa6, 0x04, 0x4f, 0x78, 0x1e, 0xe4, 0x29, - 0x7e, 0x20, 0xbd, 0xce, 0x35, 0x66, 0x84, 0x09, 0xc2, 0x0f, 0x90, 0x90, 0x55, 0xff, 0x72, 0x01, - 0x2c, 0x0c, 0xec, 0x05, 0xae, 0x80, 0x9c, 0xd3, 0xd6, 0x1c, 0x80, 0x76, 0x9a, 0xbb, 0xb1, 0x89, - 0x72, 0x4e, 0x1b, 0xbe, 0x02, 0xa6, 0xd5, 0xd4, 0xaf, 0x41, 0x2b, 0xa6, 0x04, 0x48, 0xa9, 0xe8, - 0x3d, 0x12, 0x77, 0x82, 0x88, 0x36, 0x97, 0x1c, 0xc8, 0x9e, 0xbe, 0x25, 0x8a, 0x03, 0xd9, 0x43, - 0x42, 0xf6, 0x49, 0x67, 0xed, 0x78, 0xd8, 0x2f, 0x3c, 0xc5, 0xb0, 0x3f, 0xfd, 0xb1, 0xc3, 0xfe, - 0x65, 0x50, 0xe0, 0x0e, 0x77, 0x89, 0x3d, 0x93, 0x6d, 0x11, 0x6f, 0x0b, 0x21, 0x52, 0x3a, 0x78, - 0x0f, 0xcc, 0xb4, 0xc9, 0x1e, 0x8e, 0x5c, 0x6e, 0x17, 0x65, 0x0a, 0x6d, 0x8c, 0x21, 0x85, 0x1a, - 0x25, 0x51, 0x15, 0x37, 0x95, 0x5f, 0x14, 0x03, 0xc0, 0xe7, 0xc0, 0x8c, 0x87, 0x0f, 0x1d, 0x2f, - 0xf2, 0xec, 0xd9, 0x55, 0x6b, 0xcd, 0x52, 0x66, 0x5b, 0x4a, 0x84, 0x62, 0x9d, 0xa8, 0x8c, 0xe4, - 0xb0, 0xe5, 0x46, 0xcc, 0xe9, 0x12, 0xad, 0xb4, 0x81, 0x2c, 0xb8, 0xa6, 0x32, 0x5e, 0x1f, 0xd0, - 0xa3, 0xa1, 0x15, 0x12, 0xcc, 0xf1, 0xe5, 0xe2, 0x52, 0x0a, 0x4c, 0x89, 0x50, 0xac, 0xcb, 0x82, - 0x69, 0xfb, 0xb9, 0x51, 0x60, 0x7a, 0xf1, 0xd0, 0x0a, 0xf8, 0x65, 0x30, 0xeb, 0xe1, 0xc3, 0x9b, - 0xc4, 0xef, 0xf0, 0x7d, 0x7b, 0x7e, 0xd5, 0x5a, 0xcb, 0x37, 0xe6, 0xfb, 0xbd, 0xca, 0xec, 0x56, - 0x2c, 0x44, 0x89, 0x5e, 0x1a, 0x3b, 0xbe, 0x36, 0x3e, 0x9d, 0x32, 0x8e, 0x85, 0x28, 0xd1, 0x8b, - 0x47, 0x27, 0xc4, 0x5c, 0x5c, 0x2e, 0x7b, 0x21, 0xdb, 0xc2, 0xef, 0x28, 0x31, 0x8a, 0xf5, 0x70, - 0x0d, 0x14, 0x3d, 0x7c, 0x28, 0xc7, 0x2d, 0x7b, 0x51, 0xba, 0x9d, 0x13, 0x7d, 0xd8, 0x96, 0x96, - 0x21, 0xa3, 0x95, 0x96, 0x8e, 0xaf, 0x2c, 0x97, 0x52, 0x96, 0x5a, 0x86, 0x8c, 0x56, 0x24, 0x71, - 0xe4, 0x3b, 0xf7, 0x23, 0xa2, 0x8c, 0xa1, 0x8c, 0x8c, 0x49, 0xe2, 0x3b, 0x89, 0x0a, 0xa5, 0xed, - 0xc4, 0xb8, 0xe3, 0x45, 0x2e, 0x77, 0x42, 0x97, 0x6c, 0xef, 0xd9, 0x67, 0x64, 0xfc, 0x65, 0xe7, - 0xbc, 0x65, 0xa4, 0x28, 0x65, 0x01, 0x09, 0x98, 0x22, 0x7e, 0xe4, 0xd9, 0x67, 0x65, 0xc3, 0x34, - 0x96, 0x14, 0x34, 0x37, 0xe7, 0xba, 0x1f, 0x79, 0x48, 0xba, 0x87, 0xaf, 0x80, 0x79, 0x0f, 0x1f, - 0x8a, 0x72, 0x40, 0x28, 0x17, 0x83, 0xd8, 0xb2, 0xdc, 0xfc, 0x92, 0x68, 0x52, 0xb6, 0xd2, 0x0a, - 0x94, 0xb5, 0x93, 0x0b, 0x1d, 0x3f, 0xb5, 0xf0, 0x5c, 0x6a, 0x61, 0x5a, 0x81, 0xb2, 0x76, 0x22, - 0xd2, 0x94, 0xdc, 0x8f, 0x1c, 0x4a, 0xda, 0xf6, 0xe7, 0x64, 0x5f, 0x23, 0x23, 0x8d, 0xb4, 0x0c, - 0x19, 0x2d, 0xec, 0xc6, 0x73, 0xb9, 0x2d, 0xaf, 0xe1, 0x9d, 0xf1, 0x56, 0xf2, 0x6d, 0xba, 0x4e, - 0x29, 0x3e, 0x52, 0x2f, 0x4d, 0x7a, 0x22, 0x87, 0x0c, 0x14, 0xb0, 0xeb, 0x6e, 0xef, 0xd9, 0xe7, - 0x65, 0xec, 0xc7, 0xfd, 0x82, 0x98, 0xaa, 0xb3, 0x2e, 0x40, 0x90, 0xc2, 0x12, 0xa0, 0x81, 0x2f, - 0x52, 0x63, 0x65, 0xb2, 0xa0, 0xdb, 0x02, 0x04, 0x29, 0x2c, 0xb9, 0x53, 0xff, 0x68, 0x7b, 0xcf, - 0xfe, 0xfc, 0x84, 0x77, 0x2a, 0x40, 0x90, 0xc2, 0x82, 0x0e, 0xc8, 0xfb, 0x01, 0xb7, 0x2f, 0x4c, - 0xe4, 0x79, 0x96, 0x0f, 0xce, 0xad, 0x80, 0x23, 0x81, 0x01, 0x7f, 0x63, 0x01, 0x10, 0x26, 0x29, - 0x7a, 0x71, 0x2c, 0xe3, 0xde, 0x00, 0x64, 0x2d, 0xc9, 0xed, 0xeb, 0x3e, 0xa7, 0x47, 0xc9, 0xe8, - 0x91, 0xba, 0x03, 0x29, 0x16, 0xf0, 0x8f, 0x16, 0x38, 0x9b, 0x9e, 0xa8, 0x0c, 0xbd, 0xb2, 0x8c, - 0xc8, 0xed, 0x71, 0xa7, 0x79, 0x23, 0x08, 0xdc, 0x86, 0xdd, 0xef, 0x55, 0xce, 0xae, 0x9f, 0x80, - 0x8a, 0x4e, 0xe4, 0x02, 0xff, 0x6a, 0x81, 0x25, 0x5d, 0x45, 0x53, 0x0c, 0x2b, 0x32, 0x80, 0x64, - 0xdc, 0x01, 0x1c, 0xc4, 0x51, 0x71, 0x3c, 0xaf, 0xe3, 0xb8, 0x34, 0xa4, 0x47, 0xc3, 0xd4, 0xe0, - 0x3f, 0x2c, 0x30, 0xd7, 0x26, 0x21, 0xf1, 0xdb, 0xc4, 0x6f, 0x09, 0xae, 0xab, 0x63, 0x99, 0x34, - 0x07, 0xb9, 0x6e, 0xa6, 0x20, 0x14, 0xcd, 0x9a, 0xa6, 0x39, 0x97, 0x56, 0x1d, 0xf7, 0x2a, 0xe7, - 0x92, 0xa5, 0x69, 0x0d, 0xca, 0xb0, 0x84, 0x1f, 0x58, 0x60, 0x21, 0x39, 0x00, 0xf5, 0xa4, 0x5c, - 0x9a, 0x60, 0x1e, 0xc8, 0xf6, 0x75, 0x3d, 0x0b, 0x88, 0x06, 0x19, 0xc0, 0xbf, 0x59, 0xa2, 0x53, - 0x8b, 0xe7, 0x46, 0x66, 0x57, 0x65, 0x2c, 0xdf, 0x19, 0x7b, 0x2c, 0x0d, 0x82, 0x0a, 0xe5, 0x0b, - 0x49, 0x2b, 0x68, 0x34, 0xc7, 0xbd, 0xca, 0x72, 0x3a, 0x92, 0x46, 0x81, 0xd2, 0x0c, 0xe1, 0xcf, - 0x2c, 0x30, 0x47, 0x92, 0x8e, 0x9b, 0xd9, 0x97, 0xc7, 0x12, 0xc4, 0x13, 0x9b, 0x78, 0xf5, 0x37, - 0xa6, 0x94, 0x8a, 0xa1, 0x0c, 0xb6, 0xe8, 0x20, 0xc9, 0x21, 0xf6, 0x42, 0x97, 0xd8, 0x5f, 0x18, - 0x73, 0x07, 0x79, 0x5d, 0xf9, 0x45, 0x31, 0xc0, 0x8a, 0x98, 0x7c, 0x06, 0x6e, 0x0e, 0x5c, 0x04, - 0xf9, 0x03, 0x72, 0xa4, 0x1a, 0x7b, 0x24, 0x7e, 0xc2, 0x36, 0x28, 0x74, 0xb1, 0x1b, 0xc5, 0xc3, - 0xdb, 0x98, 0xab, 0x2e, 0x52, 0xce, 0x5f, 0xcb, 0xbd, 0x6a, 0xad, 0x3c, 0xb4, 0xc0, 0xb9, 0x93, - 0x2f, 0xf4, 0x33, 0xa5, 0xf5, 0x7b, 0x0b, 0x2c, 0x0d, 0xdd, 0xdd, 0x13, 0x18, 0xdd, 0xcf, 0x32, - 0x7a, 0x63, 0xdc, 0x97, 0xb0, 0xc9, 0xa9, 0xe3, 0x77, 0x64, 0xe7, 0x91, 0xa6, 0xf7, 0x4b, 0x0b, - 0x2c, 0x0e, 0x5e, 0x87, 0x67, 0x19, 0xaf, 0xea, 0xc3, 0x1c, 0x38, 0x77, 0x72, 0xc3, 0x04, 0xa9, - 0x99, 0x0c, 0x27, 0x33, 0x61, 0x83, 0x64, 0xca, 0x34, 0x43, 0xe5, 0x7b, 0x16, 0x28, 0xdd, 0x33, - 0x76, 0xf1, 0x7f, 0x6a, 0xc6, 0x3e, 0xdb, 0xc7, 0xf5, 0x27, 0x51, 0x30, 0x94, 0xc6, 0xad, 0xfe, - 0xdd, 0x02, 0xcb, 0x27, 0x16, 0x56, 0x31, 0x82, 0x62, 0xd7, 0x0d, 0x1e, 0xa8, 0x3f, 0xd1, 0xa4, - 0xfe, 0x64, 0xb6, 0x2e, 0xa5, 0x48, 0x6b, 0x53, 0xd1, 0xcb, 0x7d, 0x56, 0xd1, 0xab, 0xfe, 0xcb, - 0x02, 0x17, 0x3e, 0x2e, 0x13, 0x9f, 0xc9, 0x91, 0xae, 0x81, 0xa2, 0x6e, 0x8a, 0x8e, 0xe4, 0x71, - 0xea, 0x39, 0x40, 0x17, 0x0d, 0xf9, 0xdf, 0x73, 0xf5, 0xab, 0x71, 0xe5, 0xd1, 0xe3, 0xf2, 0xa9, - 0x0f, 0x1f, 0x97, 0x4f, 0x7d, 0xf4, 0xb8, 0x7c, 0xea, 0x87, 0xfd, 0xb2, 0xf5, 0xa8, 0x5f, 0xb6, - 0x3e, 0xec, 0x97, 0xad, 0x8f, 0xfa, 0x65, 0xeb, 0xdf, 0xfd, 0xb2, 0xf5, 0xab, 0xff, 0x94, 0x4f, - 0x7d, 0x77, 0x46, 0x83, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x11, 0xe8, 0x41, 0x0b, 0x22, - 0x00, 0x00, -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto deleted file mode 100644 index 2a75484ff..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto +++ /dev/null @@ -1,354 +0,0 @@ -/* -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. -*/ - - -// This file was autogenerated by go-to-protobuf. Do not edit it manually! - -syntax = 'proto2'; - -package k8s.io.apiextensions_apiserver.pkg.apis.apiextensions.v1beta1; - -import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; -import "k8s.io/apimachinery/pkg/runtime/generated.proto"; -import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; -import "k8s.io/apimachinery/pkg/util/intstr/generated.proto"; - -// Package-wide variables from generator "generated". -option go_package = "v1beta1"; - -// CustomResourceColumnDefinition specifies a column for server side printing. -message CustomResourceColumnDefinition { - // name is a human readable name for the column. - optional string name = 1; - - // type is an OpenAPI type definition for this column. - // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. - optional string type = 2; - - // format is an optional OpenAPI type definition for this column. The 'name' format is applied - // to the primary identifier column to assist in clients identifying column is the resource name. - // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. - optional string format = 3; - - // description is a human readable description of this column. - optional string description = 4; - - // priority is an integer defining the relative importance of this column compared to others. Lower - // numbers are considered higher priority. Columns that may be omitted in limited space scenarios - // should be given a higher priority. - optional int32 priority = 5; - - // JSONPath is a simple JSON path, i.e. with array notation. - optional string JSONPath = 6; -} - -// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format -// <.spec.name>.<.spec.group>. -message CustomResourceDefinition { - optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; - - // Spec describes how the user wants the resources to appear - optional CustomResourceDefinitionSpec spec = 2; - - // Status indicates the actual state of the CustomResourceDefinition - optional CustomResourceDefinitionStatus status = 3; -} - -// CustomResourceDefinitionCondition contains details for the current condition of this pod. -message CustomResourceDefinitionCondition { - // Type is the type of the condition. - optional string type = 1; - - // Status is the status of the condition. - // Can be True, False, Unknown. - optional string status = 2; - - // Last time the condition transitioned from one status to another. - // +optional - optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 3; - - // Unique, one-word, CamelCase reason for the condition's last transition. - // +optional - optional string reason = 4; - - // Human-readable message indicating details about last transition. - // +optional - optional string message = 5; -} - -// CustomResourceDefinitionList is a list of CustomResourceDefinition objects. -message CustomResourceDefinitionList { - optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1; - - // Items individual CustomResourceDefinitions - repeated CustomResourceDefinition items = 2; -} - -// CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition -message CustomResourceDefinitionNames { - // Plural is the plural name of the resource to serve. It must match the name of the CustomResourceDefinition-registration - // too: plural.group and it must be all lowercase. - optional string plural = 1; - - // Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased - optional string singular = 2; - - // ShortNames are short names for the resource. It must be all lowercase. - repeated string shortNames = 3; - - // Kind is the serialized kind of the resource. It is normally CamelCase and singular. - optional string kind = 4; - - // ListKind is the serialized kind of the list for this resource. Defaults to List. - optional string listKind = 5; - - // Categories is a list of grouped resources custom resources belong to (e.g. 'all') - // +optional - repeated string categories = 6; -} - -// CustomResourceDefinitionSpec describes how a user wants their resource to appear -message CustomResourceDefinitionSpec { - // Group is the group this resource belongs in - optional string group = 1; - - // Version is the version this resource belongs in - // Should be always first item in Versions field if provided. - // Optional, but at least one of Version or Versions must be set. - // Deprecated: Please use `Versions`. - // +optional - optional string version = 2; - - // Names are the names used to describe this custom resource - optional CustomResourceDefinitionNames names = 3; - - // Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced - optional string scope = 4; - - // Validation describes the validation methods for CustomResources - // +optional - optional CustomResourceValidation validation = 5; - - // Subresources describes the subresources for CustomResources - // +optional - optional CustomResourceSubresources subresources = 6; - - // Versions is the list of all supported versions for this resource. - // If Version field is provided, this field is optional. - // Validation: All versions must use the same validation schema for now. i.e., top - // level Validation field is applied to all of these versions. - // Order: The version name will be used to compute the order. - // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered - // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version), - // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first - // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing - // major version, then minor version. An example sorted list of versions: - // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10. - repeated CustomResourceDefinitionVersion versions = 7; - - // AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column. - repeated CustomResourceColumnDefinition additionalPrinterColumns = 8; -} - -// CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition -message CustomResourceDefinitionStatus { - // Conditions indicate state for particular aspects of a CustomResourceDefinition - repeated CustomResourceDefinitionCondition conditions = 1; - - // AcceptedNames are the names that are actually being used to serve discovery - // They may be different than the names in spec. - optional CustomResourceDefinitionNames acceptedNames = 2; - - // StoredVersions are all versions of CustomResources that were ever persisted. Tracking these - // versions allows a migration path for stored versions in etcd. The field is mutable - // so the migration controller can first finish a migration to another version (i.e. - // that no old objects are left in the storage), and then remove the rest of the - // versions from this list. - // None of the versions in this list can be removed from the spec.Versions field. - repeated string storedVersions = 3; -} - -message CustomResourceDefinitionVersion { - // Name is the version name, e.g. “v1”, “v2beta1”, etc. - optional string name = 1; - - // Served is a flag enabling/disabling this version from being served via REST APIs - optional bool served = 2; - - // Storage flags the version as storage version. There must be exactly one - // flagged as storage version. - optional bool storage = 3; -} - -// CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources. -message CustomResourceSubresourceScale { - // SpecReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Spec.Replicas. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .spec. - // If there is no value under the given path in the CustomResource, the /scale subresource will return an error on GET. - optional string specReplicasPath = 1; - - // StatusReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Replicas. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .status. - // If there is no value under the given path in the CustomResource, the status replica value in the /scale subresource - // will default to 0. - optional string statusReplicasPath = 2; - - // LabelSelectorPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Selector. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .status. - // Must be set to work with HPA. - // If there is no value under the given path in the CustomResource, the status label selector value in the /scale - // subresource will default to the empty string. - // +optional - optional string labelSelectorPath = 3; -} - -// CustomResourceSubresourceStatus defines how to serve the status subresource for CustomResources. -// Status is represented by the `.status` JSON path inside of a CustomResource. When set, -// * exposes a /status subresource for the custom resource -// * PUT requests to the /status subresource take a custom resource object, and ignore changes to anything except the status stanza -// * PUT/POST/PATCH requests to the custom resource ignore changes to the status stanza -message CustomResourceSubresourceStatus { -} - -// CustomResourceSubresources defines the status and scale subresources for CustomResources. -message CustomResourceSubresources { - // Status denotes the status subresource for CustomResources - optional CustomResourceSubresourceStatus status = 1; - - // Scale denotes the scale subresource for CustomResources - optional CustomResourceSubresourceScale scale = 2; -} - -// CustomResourceValidation is a list of validation methods for CustomResources. -message CustomResourceValidation { - // OpenAPIV3Schema is the OpenAPI v3 schema to be validated against. - optional JSONSchemaProps openAPIV3Schema = 1; -} - -// ExternalDocumentation allows referencing an external resource for extended documentation. -message ExternalDocumentation { - optional string description = 1; - - optional string url = 2; -} - -// JSON represents any valid JSON value. -// These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil. -message JSON { - optional bytes raw = 1; -} - -// JSONSchemaProps is a JSON-Schema following Specification Draft 4 (http://json-schema.org/). -message JSONSchemaProps { - optional string id = 1; - - optional string schema = 2; - - optional string ref = 3; - - optional string description = 4; - - optional string type = 5; - - optional string format = 6; - - optional string title = 7; - - optional JSON default = 8; - - optional double maximum = 9; - - optional bool exclusiveMaximum = 10; - - optional double minimum = 11; - - optional bool exclusiveMinimum = 12; - - optional int64 maxLength = 13; - - optional int64 minLength = 14; - - optional string pattern = 15; - - optional int64 maxItems = 16; - - optional int64 minItems = 17; - - optional bool uniqueItems = 18; - - optional double multipleOf = 19; - - repeated JSON enum = 20; - - optional int64 maxProperties = 21; - - optional int64 minProperties = 22; - - repeated string required = 23; - - optional JSONSchemaPropsOrArray items = 24; - - repeated JSONSchemaProps allOf = 25; - - repeated JSONSchemaProps oneOf = 26; - - repeated JSONSchemaProps anyOf = 27; - - optional JSONSchemaProps not = 28; - - map properties = 29; - - optional JSONSchemaPropsOrBool additionalProperties = 30; - - map patternProperties = 31; - - map dependencies = 32; - - optional JSONSchemaPropsOrBool additionalItems = 33; - - map definitions = 34; - - optional ExternalDocumentation externalDocs = 35; - - optional JSON example = 36; -} - -// JSONSchemaPropsOrArray represents a value that can either be a JSONSchemaProps -// or an array of JSONSchemaProps. Mainly here for serialization purposes. -message JSONSchemaPropsOrArray { - optional JSONSchemaProps schema = 1; - - repeated JSONSchemaProps jSONSchemas = 2; -} - -// JSONSchemaPropsOrBool represents JSONSchemaProps or a boolean value. -// Defaults to true for the boolean property. -message JSONSchemaPropsOrBool { - optional bool allows = 1; - - optional JSONSchemaProps schema = 2; -} - -// JSONSchemaPropsOrStringArray represents a JSONSchemaProps or a string array. -message JSONSchemaPropsOrStringArray { - optional JSONSchemaProps schema = 1; - - repeated string property = 2; -} - diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal.go deleted file mode 100644 index 9a8fad3b7..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -import ( - "errors" - - "k8s.io/apimachinery/pkg/util/json" -) - -var jsTrue = []byte("true") -var jsFalse = []byte("false") - -func (s JSONSchemaPropsOrBool) MarshalJSON() ([]byte, error) { - if s.Schema != nil { - return json.Marshal(s.Schema) - } - - if s.Schema == nil && !s.Allows { - return jsFalse, nil - } - return jsTrue, nil -} - -func (s *JSONSchemaPropsOrBool) UnmarshalJSON(data []byte) error { - var nw JSONSchemaPropsOrBool - switch { - case len(data) == 0: - case data[0] == '{': - var sch JSONSchemaProps - if err := json.Unmarshal(data, &sch); err != nil { - return err - } - nw.Allows = true - nw.Schema = &sch - case len(data) == 4 && string(data) == "true": - nw.Allows = true - case len(data) == 5 && string(data) == "false": - nw.Allows = false - default: - return errors.New("boolean or JSON schema expected") - } - *s = nw - return nil -} - -func (s JSONSchemaPropsOrStringArray) MarshalJSON() ([]byte, error) { - if len(s.Property) > 0 { - return json.Marshal(s.Property) - } - if s.Schema != nil { - return json.Marshal(s.Schema) - } - return []byte("null"), nil -} - -func (s *JSONSchemaPropsOrStringArray) UnmarshalJSON(data []byte) error { - var first byte - if len(data) > 1 { - first = data[0] - } - var nw JSONSchemaPropsOrStringArray - if first == '{' { - var sch JSONSchemaProps - if err := json.Unmarshal(data, &sch); err != nil { - return err - } - nw.Schema = &sch - } - if first == '[' { - if err := json.Unmarshal(data, &nw.Property); err != nil { - return err - } - } - *s = nw - return nil -} - -func (s JSONSchemaPropsOrArray) MarshalJSON() ([]byte, error) { - if len(s.JSONSchemas) > 0 { - return json.Marshal(s.JSONSchemas) - } - return json.Marshal(s.Schema) -} - -func (s *JSONSchemaPropsOrArray) UnmarshalJSON(data []byte) error { - var nw JSONSchemaPropsOrArray - var first byte - if len(data) > 1 { - first = data[0] - } - if first == '{' { - var sch JSONSchemaProps - if err := json.Unmarshal(data, &sch); err != nil { - return err - } - nw.Schema = &sch - } - if first == '[' { - if err := json.Unmarshal(data, &nw.JSONSchemas); err != nil { - return err - } - } - *s = nw - return nil -} - -func (s JSON) MarshalJSON() ([]byte, error) { - if len(s.Raw) > 0 { - return s.Raw, nil - } - return []byte("null"), nil - -} - -func (s *JSON) UnmarshalJSON(data []byte) error { - if len(data) > 0 && string(data) != "null" { - s.Raw = data - } - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal_test.go deleted file mode 100644 index 99065ff95..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal_test.go +++ /dev/null @@ -1,150 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -import ( - "encoding/json" - "reflect" - "testing" -) - -type JSONSchemaPropsOrBoolHolder struct { - JSPoB JSONSchemaPropsOrBool `json:"val1"` - JSPoBOmitEmpty *JSONSchemaPropsOrBool `json:"val2,omitempty"` -} - -func TestJSONSchemaPropsOrBoolUnmarshalJSON(t *testing.T) { - cases := []struct { - input string - result JSONSchemaPropsOrBoolHolder - }{ - {`{}`, JSONSchemaPropsOrBoolHolder{}}, - - {`{"val1": {}}`, JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{Allows: true, Schema: &JSONSchemaProps{}}}}, - {`{"val1": {"type":"string"}}`, JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{Allows: true, Schema: &JSONSchemaProps{Type: "string"}}}}, - {`{"val1": false}`, JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{}}}, - {`{"val1": true}`, JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{Allows: true}}}, - - {`{"val2": {}}`, JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{Allows: true, Schema: &JSONSchemaProps{}}}}, - {`{"val2": {"type":"string"}}`, JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{Allows: true, Schema: &JSONSchemaProps{Type: "string"}}}}, - {`{"val2": false}`, JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{}}}, - {`{"val2": true}`, JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{Allows: true}}}, - } - - for _, c := range cases { - var result JSONSchemaPropsOrBoolHolder - if err := json.Unmarshal([]byte(c.input), &result); err != nil { - t.Errorf("Failed to unmarshal input '%v': %v", c.input, err) - } - if !reflect.DeepEqual(result, c.result) { - t.Errorf("Failed to unmarshal input '%v': expected %+v, got %+v", c.input, c.result, result) - } - } -} - -func TestStringArrayOrStringMarshalJSON(t *testing.T) { - cases := []struct { - input JSONSchemaPropsOrBoolHolder - result string - }{ - {JSONSchemaPropsOrBoolHolder{}, `{"val1":false}`}, - - {JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{Schema: &JSONSchemaProps{}}}, `{"val1":{}}`}, - {JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{Schema: &JSONSchemaProps{Type: "string"}}}, `{"val1":{"type":"string"}}`}, - {JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{}}, `{"val1":false}`}, - {JSONSchemaPropsOrBoolHolder{JSPoB: JSONSchemaPropsOrBool{Allows: true}}, `{"val1":true}`}, - - {JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{Schema: &JSONSchemaProps{}}}, `{"val1":false,"val2":{}}`}, - {JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{Schema: &JSONSchemaProps{Type: "string"}}}, `{"val1":false,"val2":{"type":"string"}}`}, - {JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{}}, `{"val1":false,"val2":false}`}, - {JSONSchemaPropsOrBoolHolder{JSPoBOmitEmpty: &JSONSchemaPropsOrBool{Allows: true}}, `{"val1":false,"val2":true}`}, - } - - for _, c := range cases { - result, err := json.Marshal(&c.input) - if err != nil { - t.Errorf("Unexpected error marshaling input '%v': %v", c.input, err) - } - if string(result) != c.result { - t.Errorf("Failed to marshal input '%v': expected: %q, got %q", c.input, c.result, string(result)) - } - } -} - -type JSONSchemaPropsOrArrayHolder struct { - JSPoA JSONSchemaPropsOrArray `json:"val1"` - JSPoAOmitEmpty *JSONSchemaPropsOrArray `json:"val2,omitempty"` -} - -func TestJSONSchemaPropsOrArrayUnmarshalJSON(t *testing.T) { - cases := []struct { - input string - result JSONSchemaPropsOrArrayHolder - }{ - {`{}`, JSONSchemaPropsOrArrayHolder{}}, - - {`{"val1": {}}`, JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{}}}}, - {`{"val1": {"type":"string"}}`, JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{Type: "string"}}}}, - {`{"val1": [{}]}`, JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}}}}}, - {`{"val1": [{},{"type":"string"}]}`, JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}, {Type: "string"}}}}}, - - {`{"val2": {}}`, JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{}}}}, - {`{"val2": {"type":"string"}}`, JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{Type: "string"}}}}, - {`{"val2": [{}]}`, JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}}}}}, - {`{"val2": [{},{"type":"string"}]}`, JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}, {Type: "string"}}}}}, - } - - for _, c := range cases { - var result JSONSchemaPropsOrArrayHolder - if err := json.Unmarshal([]byte(c.input), &result); err != nil { - t.Errorf("Failed to unmarshal input '%v': %v", c.input, err) - } - if !reflect.DeepEqual(result, c.result) { - t.Errorf("Failed to unmarshal input '%v': expected %+v, got %+v", c.input, c.result, result) - } - } -} - -func TestJSONSchemaPropsOrArrayMarshalJSON(t *testing.T) { - cases := []struct { - input JSONSchemaPropsOrArrayHolder - result string - }{ - {JSONSchemaPropsOrArrayHolder{}, `{"val1":null}`}, - - {JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{}}}, `{"val1":{}}`}, - {JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{Type: "string"}}}, `{"val1":{"type":"string"}}`}, - {JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}}}}, `{"val1":[{}]}`}, - {JSONSchemaPropsOrArrayHolder{JSPoA: JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}, {Type: "string"}}}}, `{"val1":[{},{"type":"string"}]}`}, - - {JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{}}, `{"val1":null,"val2":null}`}, - {JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{}}}, `{"val1":null,"val2":{}}`}, - {JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{Schema: &JSONSchemaProps{Type: "string"}}}, `{"val1":null,"val2":{"type":"string"}}`}, - {JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}}}}, `{"val1":null,"val2":[{}]}`}, - {JSONSchemaPropsOrArrayHolder{JSPoAOmitEmpty: &JSONSchemaPropsOrArray{JSONSchemas: []JSONSchemaProps{{}, {Type: "string"}}}}, `{"val1":null,"val2":[{},{"type":"string"}]}`}, - } - - for i, c := range cases { - result, err := json.Marshal(&c.input) - if err != nil { - t.Errorf("%d: Unexpected error marshaling input '%v': %v", i, c.input, err) - } - if string(result) != c.result { - t.Errorf("%d: Failed to marshal input '%v': expected: %q, got %q", i, c.input, c.result, string(result)) - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/register.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/register.go deleted file mode 100644 index 77f849975..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/register.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -const GroupName = "apiextensions.k8s.io" - -// SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} - -// Kind takes an unqualified kind and returns back a Group qualified GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Resource takes an unqualified resource and returns back a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs, addConversionFuncs) - localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme -) - -// Adds the list of known types to the given scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &CustomResourceDefinition{}, - &CustomResourceDefinitionList{}, - ) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} - -func init() { - // We only register manually written functions here. The registration of the - // generated functions takes place in the generated files. The separation - // makes the code compile even when the generated files are missing. - localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go deleted file mode 100644 index 2080cc821..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go +++ /dev/null @@ -1,253 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// CustomResourceDefinitionSpec describes how a user wants their resource to appear -type CustomResourceDefinitionSpec struct { - // Group is the group this resource belongs in - Group string `json:"group" protobuf:"bytes,1,opt,name=group"` - // Version is the version this resource belongs in - // Should be always first item in Versions field if provided. - // Optional, but at least one of Version or Versions must be set. - // Deprecated: Please use `Versions`. - // +optional - Version string `json:"version,omitempty" protobuf:"bytes,2,opt,name=version"` - // Names are the names used to describe this custom resource - Names CustomResourceDefinitionNames `json:"names" protobuf:"bytes,3,opt,name=names"` - // Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced - Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"` - // Validation describes the validation methods for CustomResources - // +optional - Validation *CustomResourceValidation `json:"validation,omitempty" protobuf:"bytes,5,opt,name=validation"` - // Subresources describes the subresources for CustomResources - // +optional - Subresources *CustomResourceSubresources `json:"subresources,omitempty" protobuf:"bytes,6,opt,name=subresources"` - // Versions is the list of all supported versions for this resource. - // If Version field is provided, this field is optional. - // Validation: All versions must use the same validation schema for now. i.e., top - // level Validation field is applied to all of these versions. - // Order: The version name will be used to compute the order. - // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered - // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version), - // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first - // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing - // major version, then minor version. An example sorted list of versions: - // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10. - Versions []CustomResourceDefinitionVersion `json:"versions,omitempty" protobuf:"bytes,7,rep,name=versions"` - // AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column. - AdditionalPrinterColumns []CustomResourceColumnDefinition `json:"additionalPrinterColumns,omitempty" protobuf:"bytes,8,rep,name=additionalPrinterColumns"` -} - -type CustomResourceDefinitionVersion struct { - // Name is the version name, e.g. “v1”, “v2beta1”, etc. - Name string `json:"name" protobuf:"bytes,1,opt,name=name"` - // Served is a flag enabling/disabling this version from being served via REST APIs - Served bool `json:"served" protobuf:"varint,2,opt,name=served"` - // Storage flags the version as storage version. There must be exactly one - // flagged as storage version. - Storage bool `json:"storage" protobuf:"varint,3,opt,name=storage"` -} - -// CustomResourceColumnDefinition specifies a column for server side printing. -type CustomResourceColumnDefinition struct { - // name is a human readable name for the column. - Name string `json:"name" protobuf:"bytes,1,opt,name=name"` - // type is an OpenAPI type definition for this column. - // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. - Type string `json:"type" protobuf:"bytes,2,opt,name=type"` - // format is an optional OpenAPI type definition for this column. The 'name' format is applied - // to the primary identifier column to assist in clients identifying column is the resource name. - // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. - Format string `json:"format,omitempty" protobuf:"bytes,3,opt,name=format"` - // description is a human readable description of this column. - Description string `json:"description,omitempty" protobuf:"bytes,4,opt,name=description"` - // priority is an integer defining the relative importance of this column compared to others. Lower - // numbers are considered higher priority. Columns that may be omitted in limited space scenarios - // should be given a higher priority. - Priority int32 `json:"priority,omitempty" protobuf:"bytes,5,opt,name=priority"` - - // JSONPath is a simple JSON path, i.e. with array notation. - JSONPath string `json:"JSONPath" protobuf:"bytes,6,opt,name=JSONPath"` -} - -// CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition -type CustomResourceDefinitionNames struct { - // Plural is the plural name of the resource to serve. It must match the name of the CustomResourceDefinition-registration - // too: plural.group and it must be all lowercase. - Plural string `json:"plural" protobuf:"bytes,1,opt,name=plural"` - // Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased - Singular string `json:"singular,omitempty" protobuf:"bytes,2,opt,name=singular"` - // ShortNames are short names for the resource. It must be all lowercase. - ShortNames []string `json:"shortNames,omitempty" protobuf:"bytes,3,opt,name=shortNames"` - // Kind is the serialized kind of the resource. It is normally CamelCase and singular. - Kind string `json:"kind" protobuf:"bytes,4,opt,name=kind"` - // ListKind is the serialized kind of the list for this resource. Defaults to List. - ListKind string `json:"listKind,omitempty" protobuf:"bytes,5,opt,name=listKind"` - // Categories is a list of grouped resources custom resources belong to (e.g. 'all') - // +optional - Categories []string `json:"categories,omitempty" protobuf:"bytes,6,rep,name=categories"` -} - -// ResourceScope is an enum defining the different scopes available to a custom resource -type ResourceScope string - -const ( - ClusterScoped ResourceScope = "Cluster" - NamespaceScoped ResourceScope = "Namespaced" -) - -type ConditionStatus string - -// These are valid condition statuses. "ConditionTrue" means a resource is in the condition. -// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes -// can't decide if a resource is in the condition or not. In the future, we could add other -// intermediate conditions, e.g. ConditionDegraded. -const ( - ConditionTrue ConditionStatus = "True" - ConditionFalse ConditionStatus = "False" - ConditionUnknown ConditionStatus = "Unknown" -) - -// CustomResourceDefinitionConditionType is a valid value for CustomResourceDefinitionCondition.Type -type CustomResourceDefinitionConditionType string - -const ( - // Established means that the resource has become active. A resource is established when all names are - // accepted without a conflict for the first time. A resource stays established until deleted, even during - // a later NamesAccepted due to changed names. Note that not all names can be changed. - Established CustomResourceDefinitionConditionType = "Established" - // NamesAccepted means the names chosen for this CustomResourceDefinition do not conflict with others in - // the group and are therefore accepted. - NamesAccepted CustomResourceDefinitionConditionType = "NamesAccepted" - // Terminating means that the CustomResourceDefinition has been deleted and is cleaning up. - Terminating CustomResourceDefinitionConditionType = "Terminating" -) - -// CustomResourceDefinitionCondition contains details for the current condition of this pod. -type CustomResourceDefinitionCondition struct { - // Type is the type of the condition. - Type CustomResourceDefinitionConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CustomResourceDefinitionConditionType"` - // Status is the status of the condition. - // Can be True, False, Unknown. - Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"` - // Last time the condition transitioned from one status to another. - // +optional - LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` - // Unique, one-word, CamelCase reason for the condition's last transition. - // +optional - Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` - // Human-readable message indicating details about last transition. - // +optional - Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` -} - -// CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition -type CustomResourceDefinitionStatus struct { - // Conditions indicate state for particular aspects of a CustomResourceDefinition - Conditions []CustomResourceDefinitionCondition `json:"conditions" protobuf:"bytes,1,opt,name=conditions"` - - // AcceptedNames are the names that are actually being used to serve discovery - // They may be different than the names in spec. - AcceptedNames CustomResourceDefinitionNames `json:"acceptedNames" protobuf:"bytes,2,opt,name=acceptedNames"` - - // StoredVersions are all versions of CustomResources that were ever persisted. Tracking these - // versions allows a migration path for stored versions in etcd. The field is mutable - // so the migration controller can first finish a migration to another version (i.e. - // that no old objects are left in the storage), and then remove the rest of the - // versions from this list. - // None of the versions in this list can be removed from the spec.Versions field. - StoredVersions []string `json:"storedVersions" protobuf:"bytes,3,rep,name=storedVersions"` -} - -// CustomResourceCleanupFinalizer is the name of the finalizer which will delete instances of -// a CustomResourceDefinition -const CustomResourceCleanupFinalizer = "customresourcecleanup.apiextensions.k8s.io" - -// +genclient -// +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format -// <.spec.name>.<.spec.group>. -type CustomResourceDefinition struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - - // Spec describes how the user wants the resources to appear - Spec CustomResourceDefinitionSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` - // Status indicates the actual state of the CustomResourceDefinition - Status CustomResourceDefinitionStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// CustomResourceDefinitionList is a list of CustomResourceDefinition objects. -type CustomResourceDefinitionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` - - // Items individual CustomResourceDefinitions - Items []CustomResourceDefinition `json:"items" protobuf:"bytes,2,rep,name=items"` -} - -// CustomResourceValidation is a list of validation methods for CustomResources. -type CustomResourceValidation struct { - // OpenAPIV3Schema is the OpenAPI v3 schema to be validated against. - OpenAPIV3Schema *JSONSchemaProps `json:"openAPIV3Schema,omitempty" protobuf:"bytes,1,opt,name=openAPIV3Schema"` -} - -// CustomResourceSubresources defines the status and scale subresources for CustomResources. -type CustomResourceSubresources struct { - // Status denotes the status subresource for CustomResources - Status *CustomResourceSubresourceStatus `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"` - // Scale denotes the scale subresource for CustomResources - Scale *CustomResourceSubresourceScale `json:"scale,omitempty" protobuf:"bytes,2,opt,name=scale"` -} - -// CustomResourceSubresourceStatus defines how to serve the status subresource for CustomResources. -// Status is represented by the `.status` JSON path inside of a CustomResource. When set, -// * exposes a /status subresource for the custom resource -// * PUT requests to the /status subresource take a custom resource object, and ignore changes to anything except the status stanza -// * PUT/POST/PATCH requests to the custom resource ignore changes to the status stanza -type CustomResourceSubresourceStatus struct{} - -// CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources. -type CustomResourceSubresourceScale struct { - // SpecReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Spec.Replicas. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .spec. - // If there is no value under the given path in the CustomResource, the /scale subresource will return an error on GET. - SpecReplicasPath string `json:"specReplicasPath" protobuf:"bytes,1,name=specReplicasPath"` - // StatusReplicasPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Replicas. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .status. - // If there is no value under the given path in the CustomResource, the status replica value in the /scale subresource - // will default to 0. - StatusReplicasPath string `json:"statusReplicasPath" protobuf:"bytes,2,opt,name=statusReplicasPath"` - // LabelSelectorPath defines the JSON path inside of a CustomResource that corresponds to Scale.Status.Selector. - // Only JSON paths without the array notation are allowed. - // Must be a JSON Path under .status. - // Must be set to work with HPA. - // If there is no value under the given path in the CustomResource, the status label selector value in the /scale - // subresource will default to the empty string. - // +optional - LabelSelectorPath *string `json:"labelSelectorPath,omitempty" protobuf:"bytes,3,opt,name=labelSelectorPath"` -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types_jsonschema.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types_jsonschema.go deleted file mode 100644 index 9776731cf..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types_jsonschema.go +++ /dev/null @@ -1,150 +0,0 @@ -/* -Copyright 2017 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 v1beta1 - -// JSONSchemaProps is a JSON-Schema following Specification Draft 4 (http://json-schema.org/). -type JSONSchemaProps struct { - ID string `json:"id,omitempty" protobuf:"bytes,1,opt,name=id"` - Schema JSONSchemaURL `json:"$schema,omitempty" protobuf:"bytes,2,opt,name=schema"` - Ref *string `json:"$ref,omitempty" protobuf:"bytes,3,opt,name=ref"` - Description string `json:"description,omitempty" protobuf:"bytes,4,opt,name=description"` - Type string `json:"type,omitempty" protobuf:"bytes,5,opt,name=type"` - Format string `json:"format,omitempty" protobuf:"bytes,6,opt,name=format"` - Title string `json:"title,omitempty" protobuf:"bytes,7,opt,name=title"` - Default *JSON `json:"default,omitempty" protobuf:"bytes,8,opt,name=default"` - Maximum *float64 `json:"maximum,omitempty" protobuf:"bytes,9,opt,name=maximum"` - ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty" protobuf:"bytes,10,opt,name=exclusiveMaximum"` - Minimum *float64 `json:"minimum,omitempty" protobuf:"bytes,11,opt,name=minimum"` - ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty" protobuf:"bytes,12,opt,name=exclusiveMinimum"` - MaxLength *int64 `json:"maxLength,omitempty" protobuf:"bytes,13,opt,name=maxLength"` - MinLength *int64 `json:"minLength,omitempty" protobuf:"bytes,14,opt,name=minLength"` - Pattern string `json:"pattern,omitempty" protobuf:"bytes,15,opt,name=pattern"` - MaxItems *int64 `json:"maxItems,omitempty" protobuf:"bytes,16,opt,name=maxItems"` - MinItems *int64 `json:"minItems,omitempty" protobuf:"bytes,17,opt,name=minItems"` - UniqueItems bool `json:"uniqueItems,omitempty" protobuf:"bytes,18,opt,name=uniqueItems"` - MultipleOf *float64 `json:"multipleOf,omitempty" protobuf:"bytes,19,opt,name=multipleOf"` - Enum []JSON `json:"enum,omitempty" protobuf:"bytes,20,rep,name=enum"` - MaxProperties *int64 `json:"maxProperties,omitempty" protobuf:"bytes,21,opt,name=maxProperties"` - MinProperties *int64 `json:"minProperties,omitempty" protobuf:"bytes,22,opt,name=minProperties"` - Required []string `json:"required,omitempty" protobuf:"bytes,23,rep,name=required"` - Items *JSONSchemaPropsOrArray `json:"items,omitempty" protobuf:"bytes,24,opt,name=items"` - AllOf []JSONSchemaProps `json:"allOf,omitempty" protobuf:"bytes,25,rep,name=allOf"` - OneOf []JSONSchemaProps `json:"oneOf,omitempty" protobuf:"bytes,26,rep,name=oneOf"` - AnyOf []JSONSchemaProps `json:"anyOf,omitempty" protobuf:"bytes,27,rep,name=anyOf"` - Not *JSONSchemaProps `json:"not,omitempty" protobuf:"bytes,28,opt,name=not"` - Properties map[string]JSONSchemaProps `json:"properties,omitempty" protobuf:"bytes,29,rep,name=properties"` - AdditionalProperties *JSONSchemaPropsOrBool `json:"additionalProperties,omitempty" protobuf:"bytes,30,opt,name=additionalProperties"` - PatternProperties map[string]JSONSchemaProps `json:"patternProperties,omitempty" protobuf:"bytes,31,rep,name=patternProperties"` - Dependencies JSONSchemaDependencies `json:"dependencies,omitempty" protobuf:"bytes,32,opt,name=dependencies"` - AdditionalItems *JSONSchemaPropsOrBool `json:"additionalItems,omitempty" protobuf:"bytes,33,opt,name=additionalItems"` - Definitions JSONSchemaDefinitions `json:"definitions,omitempty" protobuf:"bytes,34,opt,name=definitions"` - ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty" protobuf:"bytes,35,opt,name=externalDocs"` - Example *JSON `json:"example,omitempty" protobuf:"bytes,36,opt,name=example"` -} - -// JSON represents any valid JSON value. -// These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil. -type JSON struct { - Raw []byte `protobuf:"bytes,1,opt,name=raw"` -} - -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ JSON) OpenAPISchemaType() []string { - // TODO: return actual types when anyOf is supported - return []string{} -} - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ JSON) OpenAPISchemaFormat() string { return "" } - -// JSONSchemaURL represents a schema url. -type JSONSchemaURL string - -// JSONSchemaPropsOrArray represents a value that can either be a JSONSchemaProps -// or an array of JSONSchemaProps. Mainly here for serialization purposes. -type JSONSchemaPropsOrArray struct { - Schema *JSONSchemaProps `protobuf:"bytes,1,opt,name=schema"` - JSONSchemas []JSONSchemaProps `protobuf:"bytes,2,rep,name=jSONSchemas"` -} - -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ JSONSchemaPropsOrArray) OpenAPISchemaType() []string { - // TODO: return actual types when anyOf is supported - return []string{} -} - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ JSONSchemaPropsOrArray) OpenAPISchemaFormat() string { return "" } - -// JSONSchemaPropsOrBool represents JSONSchemaProps or a boolean value. -// Defaults to true for the boolean property. -type JSONSchemaPropsOrBool struct { - Allows bool `protobuf:"varint,1,opt,name=allows"` - Schema *JSONSchemaProps `protobuf:"bytes,2,opt,name=schema"` -} - -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ JSONSchemaPropsOrBool) OpenAPISchemaType() []string { - // TODO: return actual types when anyOf is supported - return []string{} -} - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ JSONSchemaPropsOrBool) OpenAPISchemaFormat() string { return "" } - -// JSONSchemaDependencies represent a dependencies property. -type JSONSchemaDependencies map[string]JSONSchemaPropsOrStringArray - -// JSONSchemaPropsOrStringArray represents a JSONSchemaProps or a string array. -type JSONSchemaPropsOrStringArray struct { - Schema *JSONSchemaProps `protobuf:"bytes,1,opt,name=schema"` - Property []string `protobuf:"bytes,2,rep,name=property"` -} - -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ JSONSchemaPropsOrStringArray) OpenAPISchemaType() []string { - // TODO: return actual types when anyOf is supported - return []string{} -} - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ JSONSchemaPropsOrStringArray) OpenAPISchemaFormat() string { return "" } - -// JSONSchemaDefinitions contains the models explicitly defined in this spec. -type JSONSchemaDefinitions map[string]JSONSchemaProps - -// ExternalDocumentation allows referencing an external resource for extended documentation. -type ExternalDocumentation struct { - Description string `json:"description,omitempty" protobuf:"bytes,1,opt,name=description"` - URL string `json:"url,omitempty" protobuf:"bytes,2,opt,name=url"` -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.conversion.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.conversion.go deleted file mode 100644 index bcb2527c8..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.conversion.go +++ /dev/null @@ -1,967 +0,0 @@ -// +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 conversion-gen. DO NOT EDIT. - -package v1beta1 - -import ( - unsafe "unsafe" - - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - conversion "k8s.io/apimachinery/pkg/conversion" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -func init() { - localSchemeBuilder.Register(RegisterConversions) -} - -// RegisterConversions adds conversion functions to the given scheme. -// Public to allow building arbitrary schemes. -func RegisterConversions(scheme *runtime.Scheme) error { - return scheme.AddGeneratedConversionFuncs( - Convert_v1beta1_CustomResourceColumnDefinition_To_apiextensions_CustomResourceColumnDefinition, - Convert_apiextensions_CustomResourceColumnDefinition_To_v1beta1_CustomResourceColumnDefinition, - Convert_v1beta1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition, - Convert_apiextensions_CustomResourceDefinition_To_v1beta1_CustomResourceDefinition, - Convert_v1beta1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition, - Convert_apiextensions_CustomResourceDefinitionCondition_To_v1beta1_CustomResourceDefinitionCondition, - Convert_v1beta1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList, - Convert_apiextensions_CustomResourceDefinitionList_To_v1beta1_CustomResourceDefinitionList, - Convert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames, - Convert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames, - Convert_v1beta1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec, - Convert_apiextensions_CustomResourceDefinitionSpec_To_v1beta1_CustomResourceDefinitionSpec, - Convert_v1beta1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus, - Convert_apiextensions_CustomResourceDefinitionStatus_To_v1beta1_CustomResourceDefinitionStatus, - Convert_v1beta1_CustomResourceDefinitionVersion_To_apiextensions_CustomResourceDefinitionVersion, - Convert_apiextensions_CustomResourceDefinitionVersion_To_v1beta1_CustomResourceDefinitionVersion, - Convert_v1beta1_CustomResourceSubresourceScale_To_apiextensions_CustomResourceSubresourceScale, - Convert_apiextensions_CustomResourceSubresourceScale_To_v1beta1_CustomResourceSubresourceScale, - Convert_v1beta1_CustomResourceSubresourceStatus_To_apiextensions_CustomResourceSubresourceStatus, - Convert_apiextensions_CustomResourceSubresourceStatus_To_v1beta1_CustomResourceSubresourceStatus, - Convert_v1beta1_CustomResourceSubresources_To_apiextensions_CustomResourceSubresources, - Convert_apiextensions_CustomResourceSubresources_To_v1beta1_CustomResourceSubresources, - Convert_v1beta1_CustomResourceValidation_To_apiextensions_CustomResourceValidation, - Convert_apiextensions_CustomResourceValidation_To_v1beta1_CustomResourceValidation, - Convert_v1beta1_ExternalDocumentation_To_apiextensions_ExternalDocumentation, - Convert_apiextensions_ExternalDocumentation_To_v1beta1_ExternalDocumentation, - Convert_v1beta1_JSON_To_apiextensions_JSON, - Convert_apiextensions_JSON_To_v1beta1_JSON, - Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps, - Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps, - Convert_v1beta1_JSONSchemaPropsOrArray_To_apiextensions_JSONSchemaPropsOrArray, - Convert_apiextensions_JSONSchemaPropsOrArray_To_v1beta1_JSONSchemaPropsOrArray, - Convert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool, - Convert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool, - Convert_v1beta1_JSONSchemaPropsOrStringArray_To_apiextensions_JSONSchemaPropsOrStringArray, - Convert_apiextensions_JSONSchemaPropsOrStringArray_To_v1beta1_JSONSchemaPropsOrStringArray, - ) -} - -func autoConvert_v1beta1_CustomResourceColumnDefinition_To_apiextensions_CustomResourceColumnDefinition(in *CustomResourceColumnDefinition, out *apiextensions.CustomResourceColumnDefinition, s conversion.Scope) error { - out.Name = in.Name - out.Type = in.Type - out.Format = in.Format - out.Description = in.Description - out.Priority = in.Priority - out.JSONPath = in.JSONPath - return nil -} - -// Convert_v1beta1_CustomResourceColumnDefinition_To_apiextensions_CustomResourceColumnDefinition is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceColumnDefinition_To_apiextensions_CustomResourceColumnDefinition(in *CustomResourceColumnDefinition, out *apiextensions.CustomResourceColumnDefinition, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceColumnDefinition_To_apiextensions_CustomResourceColumnDefinition(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceColumnDefinition_To_v1beta1_CustomResourceColumnDefinition(in *apiextensions.CustomResourceColumnDefinition, out *CustomResourceColumnDefinition, s conversion.Scope) error { - out.Name = in.Name - out.Type = in.Type - out.Format = in.Format - out.Description = in.Description - out.Priority = in.Priority - out.JSONPath = in.JSONPath - return nil -} - -// Convert_apiextensions_CustomResourceColumnDefinition_To_v1beta1_CustomResourceColumnDefinition is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceColumnDefinition_To_v1beta1_CustomResourceColumnDefinition(in *apiextensions.CustomResourceColumnDefinition, out *CustomResourceColumnDefinition, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceColumnDefinition_To_v1beta1_CustomResourceColumnDefinition(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(in *CustomResourceDefinition, out *apiextensions.CustomResourceDefinition, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1beta1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(in *CustomResourceDefinition, out *apiextensions.CustomResourceDefinition, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceDefinition_To_v1beta1_CustomResourceDefinition(in *apiextensions.CustomResourceDefinition, out *CustomResourceDefinition, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_apiextensions_CustomResourceDefinitionSpec_To_v1beta1_CustomResourceDefinitionSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_apiextensions_CustomResourceDefinitionStatus_To_v1beta1_CustomResourceDefinitionStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_apiextensions_CustomResourceDefinition_To_v1beta1_CustomResourceDefinition is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceDefinition_To_v1beta1_CustomResourceDefinition(in *apiextensions.CustomResourceDefinition, out *CustomResourceDefinition, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceDefinition_To_v1beta1_CustomResourceDefinition(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition(in *CustomResourceDefinitionCondition, out *apiextensions.CustomResourceDefinitionCondition, s conversion.Scope) error { - out.Type = apiextensions.CustomResourceDefinitionConditionType(in.Type) - out.Status = apiextensions.ConditionStatus(in.Status) - out.LastTransitionTime = in.LastTransitionTime - out.Reason = in.Reason - out.Message = in.Message - return nil -} - -// Convert_v1beta1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition(in *CustomResourceDefinitionCondition, out *apiextensions.CustomResourceDefinitionCondition, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceDefinitionCondition_To_v1beta1_CustomResourceDefinitionCondition(in *apiextensions.CustomResourceDefinitionCondition, out *CustomResourceDefinitionCondition, s conversion.Scope) error { - out.Type = CustomResourceDefinitionConditionType(in.Type) - out.Status = ConditionStatus(in.Status) - out.LastTransitionTime = in.LastTransitionTime - out.Reason = in.Reason - out.Message = in.Message - return nil -} - -// Convert_apiextensions_CustomResourceDefinitionCondition_To_v1beta1_CustomResourceDefinitionCondition is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceDefinitionCondition_To_v1beta1_CustomResourceDefinitionCondition(in *apiextensions.CustomResourceDefinitionCondition, out *CustomResourceDefinitionCondition, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceDefinitionCondition_To_v1beta1_CustomResourceDefinitionCondition(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList(in *CustomResourceDefinitionList, out *apiextensions.CustomResourceDefinitionList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]apiextensions.CustomResourceDefinition, len(*in)) - for i := range *in { - if err := Convert_v1beta1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList(in *CustomResourceDefinitionList, out *apiextensions.CustomResourceDefinitionList, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceDefinitionList_To_v1beta1_CustomResourceDefinitionList(in *apiextensions.CustomResourceDefinitionList, out *CustomResourceDefinitionList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]CustomResourceDefinition, len(*in)) - for i := range *in { - if err := Convert_apiextensions_CustomResourceDefinition_To_v1beta1_CustomResourceDefinition(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_apiextensions_CustomResourceDefinitionList_To_v1beta1_CustomResourceDefinitionList is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceDefinitionList_To_v1beta1_CustomResourceDefinitionList(in *apiextensions.CustomResourceDefinitionList, out *CustomResourceDefinitionList, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceDefinitionList_To_v1beta1_CustomResourceDefinitionList(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(in *CustomResourceDefinitionNames, out *apiextensions.CustomResourceDefinitionNames, s conversion.Scope) error { - out.Plural = in.Plural - out.Singular = in.Singular - out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames)) - out.Kind = in.Kind - out.ListKind = in.ListKind - out.Categories = *(*[]string)(unsafe.Pointer(&in.Categories)) - return nil -} - -// Convert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(in *CustomResourceDefinitionNames, out *apiextensions.CustomResourceDefinitionNames, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames(in *apiextensions.CustomResourceDefinitionNames, out *CustomResourceDefinitionNames, s conversion.Scope) error { - out.Plural = in.Plural - out.Singular = in.Singular - out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames)) - out.Kind = in.Kind - out.ListKind = in.ListKind - out.Categories = *(*[]string)(unsafe.Pointer(&in.Categories)) - return nil -} - -// Convert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames(in *apiextensions.CustomResourceDefinitionNames, out *CustomResourceDefinitionNames, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(in *CustomResourceDefinitionSpec, out *apiextensions.CustomResourceDefinitionSpec, s conversion.Scope) error { - out.Group = in.Group - out.Version = in.Version - if err := Convert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(&in.Names, &out.Names, s); err != nil { - return err - } - out.Scope = apiextensions.ResourceScope(in.Scope) - if in.Validation != nil { - in, out := &in.Validation, &out.Validation - *out = new(apiextensions.CustomResourceValidation) - if err := Convert_v1beta1_CustomResourceValidation_To_apiextensions_CustomResourceValidation(*in, *out, s); err != nil { - return err - } - } else { - out.Validation = nil - } - out.Subresources = (*apiextensions.CustomResourceSubresources)(unsafe.Pointer(in.Subresources)) - out.Versions = *(*[]apiextensions.CustomResourceDefinitionVersion)(unsafe.Pointer(&in.Versions)) - out.AdditionalPrinterColumns = *(*[]apiextensions.CustomResourceColumnDefinition)(unsafe.Pointer(&in.AdditionalPrinterColumns)) - return nil -} - -// Convert_v1beta1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(in *CustomResourceDefinitionSpec, out *apiextensions.CustomResourceDefinitionSpec, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceDefinitionSpec_To_v1beta1_CustomResourceDefinitionSpec(in *apiextensions.CustomResourceDefinitionSpec, out *CustomResourceDefinitionSpec, s conversion.Scope) error { - out.Group = in.Group - out.Version = in.Version - if err := Convert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames(&in.Names, &out.Names, s); err != nil { - return err - } - out.Scope = ResourceScope(in.Scope) - if in.Validation != nil { - in, out := &in.Validation, &out.Validation - *out = new(CustomResourceValidation) - if err := Convert_apiextensions_CustomResourceValidation_To_v1beta1_CustomResourceValidation(*in, *out, s); err != nil { - return err - } - } else { - out.Validation = nil - } - out.Subresources = (*CustomResourceSubresources)(unsafe.Pointer(in.Subresources)) - out.Versions = *(*[]CustomResourceDefinitionVersion)(unsafe.Pointer(&in.Versions)) - out.AdditionalPrinterColumns = *(*[]CustomResourceColumnDefinition)(unsafe.Pointer(&in.AdditionalPrinterColumns)) - return nil -} - -// Convert_apiextensions_CustomResourceDefinitionSpec_To_v1beta1_CustomResourceDefinitionSpec is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceDefinitionSpec_To_v1beta1_CustomResourceDefinitionSpec(in *apiextensions.CustomResourceDefinitionSpec, out *CustomResourceDefinitionSpec, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceDefinitionSpec_To_v1beta1_CustomResourceDefinitionSpec(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(in *CustomResourceDefinitionStatus, out *apiextensions.CustomResourceDefinitionStatus, s conversion.Scope) error { - out.Conditions = *(*[]apiextensions.CustomResourceDefinitionCondition)(unsafe.Pointer(&in.Conditions)) - if err := Convert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil { - return err - } - out.StoredVersions = *(*[]string)(unsafe.Pointer(&in.StoredVersions)) - return nil -} - -// Convert_v1beta1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(in *CustomResourceDefinitionStatus, out *apiextensions.CustomResourceDefinitionStatus, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceDefinitionStatus_To_v1beta1_CustomResourceDefinitionStatus(in *apiextensions.CustomResourceDefinitionStatus, out *CustomResourceDefinitionStatus, s conversion.Scope) error { - out.Conditions = *(*[]CustomResourceDefinitionCondition)(unsafe.Pointer(&in.Conditions)) - if err := Convert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil { - return err - } - out.StoredVersions = *(*[]string)(unsafe.Pointer(&in.StoredVersions)) - return nil -} - -// Convert_apiextensions_CustomResourceDefinitionStatus_To_v1beta1_CustomResourceDefinitionStatus is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceDefinitionStatus_To_v1beta1_CustomResourceDefinitionStatus(in *apiextensions.CustomResourceDefinitionStatus, out *CustomResourceDefinitionStatus, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceDefinitionStatus_To_v1beta1_CustomResourceDefinitionStatus(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceDefinitionVersion_To_apiextensions_CustomResourceDefinitionVersion(in *CustomResourceDefinitionVersion, out *apiextensions.CustomResourceDefinitionVersion, s conversion.Scope) error { - out.Name = in.Name - out.Served = in.Served - out.Storage = in.Storage - return nil -} - -// Convert_v1beta1_CustomResourceDefinitionVersion_To_apiextensions_CustomResourceDefinitionVersion is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceDefinitionVersion_To_apiextensions_CustomResourceDefinitionVersion(in *CustomResourceDefinitionVersion, out *apiextensions.CustomResourceDefinitionVersion, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceDefinitionVersion_To_apiextensions_CustomResourceDefinitionVersion(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceDefinitionVersion_To_v1beta1_CustomResourceDefinitionVersion(in *apiextensions.CustomResourceDefinitionVersion, out *CustomResourceDefinitionVersion, s conversion.Scope) error { - out.Name = in.Name - out.Served = in.Served - out.Storage = in.Storage - return nil -} - -// Convert_apiextensions_CustomResourceDefinitionVersion_To_v1beta1_CustomResourceDefinitionVersion is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceDefinitionVersion_To_v1beta1_CustomResourceDefinitionVersion(in *apiextensions.CustomResourceDefinitionVersion, out *CustomResourceDefinitionVersion, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceDefinitionVersion_To_v1beta1_CustomResourceDefinitionVersion(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceSubresourceScale_To_apiextensions_CustomResourceSubresourceScale(in *CustomResourceSubresourceScale, out *apiextensions.CustomResourceSubresourceScale, s conversion.Scope) error { - out.SpecReplicasPath = in.SpecReplicasPath - out.StatusReplicasPath = in.StatusReplicasPath - out.LabelSelectorPath = (*string)(unsafe.Pointer(in.LabelSelectorPath)) - return nil -} - -// Convert_v1beta1_CustomResourceSubresourceScale_To_apiextensions_CustomResourceSubresourceScale is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceSubresourceScale_To_apiextensions_CustomResourceSubresourceScale(in *CustomResourceSubresourceScale, out *apiextensions.CustomResourceSubresourceScale, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceSubresourceScale_To_apiextensions_CustomResourceSubresourceScale(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceSubresourceScale_To_v1beta1_CustomResourceSubresourceScale(in *apiextensions.CustomResourceSubresourceScale, out *CustomResourceSubresourceScale, s conversion.Scope) error { - out.SpecReplicasPath = in.SpecReplicasPath - out.StatusReplicasPath = in.StatusReplicasPath - out.LabelSelectorPath = (*string)(unsafe.Pointer(in.LabelSelectorPath)) - return nil -} - -// Convert_apiextensions_CustomResourceSubresourceScale_To_v1beta1_CustomResourceSubresourceScale is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceSubresourceScale_To_v1beta1_CustomResourceSubresourceScale(in *apiextensions.CustomResourceSubresourceScale, out *CustomResourceSubresourceScale, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceSubresourceScale_To_v1beta1_CustomResourceSubresourceScale(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceSubresourceStatus_To_apiextensions_CustomResourceSubresourceStatus(in *CustomResourceSubresourceStatus, out *apiextensions.CustomResourceSubresourceStatus, s conversion.Scope) error { - return nil -} - -// Convert_v1beta1_CustomResourceSubresourceStatus_To_apiextensions_CustomResourceSubresourceStatus is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceSubresourceStatus_To_apiextensions_CustomResourceSubresourceStatus(in *CustomResourceSubresourceStatus, out *apiextensions.CustomResourceSubresourceStatus, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceSubresourceStatus_To_apiextensions_CustomResourceSubresourceStatus(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceSubresourceStatus_To_v1beta1_CustomResourceSubresourceStatus(in *apiextensions.CustomResourceSubresourceStatus, out *CustomResourceSubresourceStatus, s conversion.Scope) error { - return nil -} - -// Convert_apiextensions_CustomResourceSubresourceStatus_To_v1beta1_CustomResourceSubresourceStatus is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceSubresourceStatus_To_v1beta1_CustomResourceSubresourceStatus(in *apiextensions.CustomResourceSubresourceStatus, out *CustomResourceSubresourceStatus, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceSubresourceStatus_To_v1beta1_CustomResourceSubresourceStatus(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceSubresources_To_apiextensions_CustomResourceSubresources(in *CustomResourceSubresources, out *apiextensions.CustomResourceSubresources, s conversion.Scope) error { - out.Status = (*apiextensions.CustomResourceSubresourceStatus)(unsafe.Pointer(in.Status)) - out.Scale = (*apiextensions.CustomResourceSubresourceScale)(unsafe.Pointer(in.Scale)) - return nil -} - -// Convert_v1beta1_CustomResourceSubresources_To_apiextensions_CustomResourceSubresources is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceSubresources_To_apiextensions_CustomResourceSubresources(in *CustomResourceSubresources, out *apiextensions.CustomResourceSubresources, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceSubresources_To_apiextensions_CustomResourceSubresources(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceSubresources_To_v1beta1_CustomResourceSubresources(in *apiextensions.CustomResourceSubresources, out *CustomResourceSubresources, s conversion.Scope) error { - out.Status = (*CustomResourceSubresourceStatus)(unsafe.Pointer(in.Status)) - out.Scale = (*CustomResourceSubresourceScale)(unsafe.Pointer(in.Scale)) - return nil -} - -// Convert_apiextensions_CustomResourceSubresources_To_v1beta1_CustomResourceSubresources is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceSubresources_To_v1beta1_CustomResourceSubresources(in *apiextensions.CustomResourceSubresources, out *CustomResourceSubresources, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceSubresources_To_v1beta1_CustomResourceSubresources(in, out, s) -} - -func autoConvert_v1beta1_CustomResourceValidation_To_apiextensions_CustomResourceValidation(in *CustomResourceValidation, out *apiextensions.CustomResourceValidation, s conversion.Scope) error { - if in.OpenAPIV3Schema != nil { - in, out := &in.OpenAPIV3Schema, &out.OpenAPIV3Schema - *out = new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.OpenAPIV3Schema = nil - } - return nil -} - -// Convert_v1beta1_CustomResourceValidation_To_apiextensions_CustomResourceValidation is an autogenerated conversion function. -func Convert_v1beta1_CustomResourceValidation_To_apiextensions_CustomResourceValidation(in *CustomResourceValidation, out *apiextensions.CustomResourceValidation, s conversion.Scope) error { - return autoConvert_v1beta1_CustomResourceValidation_To_apiextensions_CustomResourceValidation(in, out, s) -} - -func autoConvert_apiextensions_CustomResourceValidation_To_v1beta1_CustomResourceValidation(in *apiextensions.CustomResourceValidation, out *CustomResourceValidation, s conversion.Scope) error { - if in.OpenAPIV3Schema != nil { - in, out := &in.OpenAPIV3Schema, &out.OpenAPIV3Schema - *out = new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.OpenAPIV3Schema = nil - } - return nil -} - -// Convert_apiextensions_CustomResourceValidation_To_v1beta1_CustomResourceValidation is an autogenerated conversion function. -func Convert_apiextensions_CustomResourceValidation_To_v1beta1_CustomResourceValidation(in *apiextensions.CustomResourceValidation, out *CustomResourceValidation, s conversion.Scope) error { - return autoConvert_apiextensions_CustomResourceValidation_To_v1beta1_CustomResourceValidation(in, out, s) -} - -func autoConvert_v1beta1_ExternalDocumentation_To_apiextensions_ExternalDocumentation(in *ExternalDocumentation, out *apiextensions.ExternalDocumentation, s conversion.Scope) error { - out.Description = in.Description - out.URL = in.URL - return nil -} - -// Convert_v1beta1_ExternalDocumentation_To_apiextensions_ExternalDocumentation is an autogenerated conversion function. -func Convert_v1beta1_ExternalDocumentation_To_apiextensions_ExternalDocumentation(in *ExternalDocumentation, out *apiextensions.ExternalDocumentation, s conversion.Scope) error { - return autoConvert_v1beta1_ExternalDocumentation_To_apiextensions_ExternalDocumentation(in, out, s) -} - -func autoConvert_apiextensions_ExternalDocumentation_To_v1beta1_ExternalDocumentation(in *apiextensions.ExternalDocumentation, out *ExternalDocumentation, s conversion.Scope) error { - out.Description = in.Description - out.URL = in.URL - return nil -} - -// Convert_apiextensions_ExternalDocumentation_To_v1beta1_ExternalDocumentation is an autogenerated conversion function. -func Convert_apiextensions_ExternalDocumentation_To_v1beta1_ExternalDocumentation(in *apiextensions.ExternalDocumentation, out *ExternalDocumentation, s conversion.Scope) error { - return autoConvert_apiextensions_ExternalDocumentation_To_v1beta1_ExternalDocumentation(in, out, s) -} - -func autoConvert_v1beta1_JSON_To_apiextensions_JSON(in *JSON, out *apiextensions.JSON, s conversion.Scope) error { - // WARNING: in.Raw requires manual conversion: does not exist in peer-type - return nil -} - -func autoConvert_apiextensions_JSON_To_v1beta1_JSON(in *apiextensions.JSON, out *JSON, s conversion.Scope) error { - // FIXME: Type apiextensions.JSON is unsupported. - return nil -} - -func autoConvert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(in *JSONSchemaProps, out *apiextensions.JSONSchemaProps, s conversion.Scope) error { - out.ID = in.ID - out.Schema = apiextensions.JSONSchemaURL(in.Schema) - out.Ref = (*string)(unsafe.Pointer(in.Ref)) - out.Description = in.Description - out.Type = in.Type - out.Format = in.Format - out.Title = in.Title - if in.Default != nil { - in, out := &in.Default, &out.Default - *out = new(apiextensions.JSON) - if err := Convert_v1beta1_JSON_To_apiextensions_JSON(*in, *out, s); err != nil { - return err - } - } else { - out.Default = nil - } - out.Maximum = (*float64)(unsafe.Pointer(in.Maximum)) - out.ExclusiveMaximum = in.ExclusiveMaximum - out.Minimum = (*float64)(unsafe.Pointer(in.Minimum)) - out.ExclusiveMinimum = in.ExclusiveMinimum - out.MaxLength = (*int64)(unsafe.Pointer(in.MaxLength)) - out.MinLength = (*int64)(unsafe.Pointer(in.MinLength)) - out.Pattern = in.Pattern - out.MaxItems = (*int64)(unsafe.Pointer(in.MaxItems)) - out.MinItems = (*int64)(unsafe.Pointer(in.MinItems)) - out.UniqueItems = in.UniqueItems - out.MultipleOf = (*float64)(unsafe.Pointer(in.MultipleOf)) - if in.Enum != nil { - in, out := &in.Enum, &out.Enum - *out = make([]apiextensions.JSON, len(*in)) - for i := range *in { - if err := Convert_v1beta1_JSON_To_apiextensions_JSON(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Enum = nil - } - out.MaxProperties = (*int64)(unsafe.Pointer(in.MaxProperties)) - out.MinProperties = (*int64)(unsafe.Pointer(in.MinProperties)) - out.Required = *(*[]string)(unsafe.Pointer(&in.Required)) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = new(apiextensions.JSONSchemaPropsOrArray) - if err := Convert_v1beta1_JSONSchemaPropsOrArray_To_apiextensions_JSONSchemaPropsOrArray(*in, *out, s); err != nil { - return err - } - } else { - out.Items = nil - } - if in.AllOf != nil { - in, out := &in.AllOf, &out.AllOf - *out = make([]apiextensions.JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.AllOf = nil - } - if in.OneOf != nil { - in, out := &in.OneOf, &out.OneOf - *out = make([]apiextensions.JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.OneOf = nil - } - if in.AnyOf != nil { - in, out := &in.AnyOf, &out.AnyOf - *out = make([]apiextensions.JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.AnyOf = nil - } - if in.Not != nil { - in, out := &in.Not, &out.Not - *out = new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Not = nil - } - if in.Properties != nil { - in, out := &in.Properties, &out.Properties - *out = make(map[string]apiextensions.JSONSchemaProps, len(*in)) - for key, val := range *in { - newVal := new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.Properties = nil - } - if in.AdditionalProperties != nil { - in, out := &in.AdditionalProperties, &out.AdditionalProperties - *out = new(apiextensions.JSONSchemaPropsOrBool) - if err := Convert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool(*in, *out, s); err != nil { - return err - } - } else { - out.AdditionalProperties = nil - } - if in.PatternProperties != nil { - in, out := &in.PatternProperties, &out.PatternProperties - *out = make(map[string]apiextensions.JSONSchemaProps, len(*in)) - for key, val := range *in { - newVal := new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.PatternProperties = nil - } - if in.Dependencies != nil { - in, out := &in.Dependencies, &out.Dependencies - *out = make(apiextensions.JSONSchemaDependencies, len(*in)) - for key, val := range *in { - newVal := new(apiextensions.JSONSchemaPropsOrStringArray) - if err := Convert_v1beta1_JSONSchemaPropsOrStringArray_To_apiextensions_JSONSchemaPropsOrStringArray(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.Dependencies = nil - } - if in.AdditionalItems != nil { - in, out := &in.AdditionalItems, &out.AdditionalItems - *out = new(apiextensions.JSONSchemaPropsOrBool) - if err := Convert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool(*in, *out, s); err != nil { - return err - } - } else { - out.AdditionalItems = nil - } - if in.Definitions != nil { - in, out := &in.Definitions, &out.Definitions - *out = make(apiextensions.JSONSchemaDefinitions, len(*in)) - for key, val := range *in { - newVal := new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.Definitions = nil - } - out.ExternalDocs = (*apiextensions.ExternalDocumentation)(unsafe.Pointer(in.ExternalDocs)) - if in.Example != nil { - in, out := &in.Example, &out.Example - *out = new(apiextensions.JSON) - if err := Convert_v1beta1_JSON_To_apiextensions_JSON(*in, *out, s); err != nil { - return err - } - } else { - out.Example = nil - } - return nil -} - -// Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps is an autogenerated conversion function. -func Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(in *JSONSchemaProps, out *apiextensions.JSONSchemaProps, s conversion.Scope) error { - return autoConvert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(in, out, s) -} - -func autoConvert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in *apiextensions.JSONSchemaProps, out *JSONSchemaProps, s conversion.Scope) error { - out.ID = in.ID - out.Schema = JSONSchemaURL(in.Schema) - out.Ref = (*string)(unsafe.Pointer(in.Ref)) - out.Description = in.Description - out.Type = in.Type - out.Format = in.Format - out.Title = in.Title - if in.Default != nil { - in, out := &in.Default, &out.Default - *out = new(JSON) - if err := Convert_apiextensions_JSON_To_v1beta1_JSON(*in, *out, s); err != nil { - return err - } - } else { - out.Default = nil - } - out.Maximum = (*float64)(unsafe.Pointer(in.Maximum)) - out.ExclusiveMaximum = in.ExclusiveMaximum - out.Minimum = (*float64)(unsafe.Pointer(in.Minimum)) - out.ExclusiveMinimum = in.ExclusiveMinimum - out.MaxLength = (*int64)(unsafe.Pointer(in.MaxLength)) - out.MinLength = (*int64)(unsafe.Pointer(in.MinLength)) - out.Pattern = in.Pattern - out.MaxItems = (*int64)(unsafe.Pointer(in.MaxItems)) - out.MinItems = (*int64)(unsafe.Pointer(in.MinItems)) - out.UniqueItems = in.UniqueItems - out.MultipleOf = (*float64)(unsafe.Pointer(in.MultipleOf)) - if in.Enum != nil { - in, out := &in.Enum, &out.Enum - *out = make([]JSON, len(*in)) - for i := range *in { - if err := Convert_apiextensions_JSON_To_v1beta1_JSON(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Enum = nil - } - out.MaxProperties = (*int64)(unsafe.Pointer(in.MaxProperties)) - out.MinProperties = (*int64)(unsafe.Pointer(in.MinProperties)) - out.Required = *(*[]string)(unsafe.Pointer(&in.Required)) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = new(JSONSchemaPropsOrArray) - if err := Convert_apiextensions_JSONSchemaPropsOrArray_To_v1beta1_JSONSchemaPropsOrArray(*in, *out, s); err != nil { - return err - } - } else { - out.Items = nil - } - if in.AllOf != nil { - in, out := &in.AllOf, &out.AllOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.AllOf = nil - } - if in.OneOf != nil { - in, out := &in.OneOf, &out.OneOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.OneOf = nil - } - if in.AnyOf != nil { - in, out := &in.AnyOf, &out.AnyOf - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.AnyOf = nil - } - if in.Not != nil { - in, out := &in.Not, &out.Not - *out = new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Not = nil - } - if in.Properties != nil { - in, out := &in.Properties, &out.Properties - *out = make(map[string]JSONSchemaProps, len(*in)) - for key, val := range *in { - newVal := new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.Properties = nil - } - if in.AdditionalProperties != nil { - in, out := &in.AdditionalProperties, &out.AdditionalProperties - *out = new(JSONSchemaPropsOrBool) - if err := Convert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool(*in, *out, s); err != nil { - return err - } - } else { - out.AdditionalProperties = nil - } - if in.PatternProperties != nil { - in, out := &in.PatternProperties, &out.PatternProperties - *out = make(map[string]JSONSchemaProps, len(*in)) - for key, val := range *in { - newVal := new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.PatternProperties = nil - } - if in.Dependencies != nil { - in, out := &in.Dependencies, &out.Dependencies - *out = make(JSONSchemaDependencies, len(*in)) - for key, val := range *in { - newVal := new(JSONSchemaPropsOrStringArray) - if err := Convert_apiextensions_JSONSchemaPropsOrStringArray_To_v1beta1_JSONSchemaPropsOrStringArray(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.Dependencies = nil - } - if in.AdditionalItems != nil { - in, out := &in.AdditionalItems, &out.AdditionalItems - *out = new(JSONSchemaPropsOrBool) - if err := Convert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool(*in, *out, s); err != nil { - return err - } - } else { - out.AdditionalItems = nil - } - if in.Definitions != nil { - in, out := &in.Definitions, &out.Definitions - *out = make(JSONSchemaDefinitions, len(*in)) - for key, val := range *in { - newVal := new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(&val, newVal, s); err != nil { - return err - } - (*out)[key] = *newVal - } - } else { - out.Definitions = nil - } - out.ExternalDocs = (*ExternalDocumentation)(unsafe.Pointer(in.ExternalDocs)) - if in.Example != nil { - in, out := &in.Example, &out.Example - *out = new(JSON) - if err := Convert_apiextensions_JSON_To_v1beta1_JSON(*in, *out, s); err != nil { - return err - } - } else { - out.Example = nil - } - return nil -} - -func autoConvert_v1beta1_JSONSchemaPropsOrArray_To_apiextensions_JSONSchemaPropsOrArray(in *JSONSchemaPropsOrArray, out *apiextensions.JSONSchemaPropsOrArray, s conversion.Scope) error { - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Schema = nil - } - if in.JSONSchemas != nil { - in, out := &in.JSONSchemas, &out.JSONSchemas - *out = make([]apiextensions.JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.JSONSchemas = nil - } - return nil -} - -// Convert_v1beta1_JSONSchemaPropsOrArray_To_apiextensions_JSONSchemaPropsOrArray is an autogenerated conversion function. -func Convert_v1beta1_JSONSchemaPropsOrArray_To_apiextensions_JSONSchemaPropsOrArray(in *JSONSchemaPropsOrArray, out *apiextensions.JSONSchemaPropsOrArray, s conversion.Scope) error { - return autoConvert_v1beta1_JSONSchemaPropsOrArray_To_apiextensions_JSONSchemaPropsOrArray(in, out, s) -} - -func autoConvert_apiextensions_JSONSchemaPropsOrArray_To_v1beta1_JSONSchemaPropsOrArray(in *apiextensions.JSONSchemaPropsOrArray, out *JSONSchemaPropsOrArray, s conversion.Scope) error { - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Schema = nil - } - if in.JSONSchemas != nil { - in, out := &in.JSONSchemas, &out.JSONSchemas - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.JSONSchemas = nil - } - return nil -} - -// Convert_apiextensions_JSONSchemaPropsOrArray_To_v1beta1_JSONSchemaPropsOrArray is an autogenerated conversion function. -func Convert_apiextensions_JSONSchemaPropsOrArray_To_v1beta1_JSONSchemaPropsOrArray(in *apiextensions.JSONSchemaPropsOrArray, out *JSONSchemaPropsOrArray, s conversion.Scope) error { - return autoConvert_apiextensions_JSONSchemaPropsOrArray_To_v1beta1_JSONSchemaPropsOrArray(in, out, s) -} - -func autoConvert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool(in *JSONSchemaPropsOrBool, out *apiextensions.JSONSchemaPropsOrBool, s conversion.Scope) error { - out.Allows = in.Allows - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Schema = nil - } - return nil -} - -// Convert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool is an autogenerated conversion function. -func Convert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool(in *JSONSchemaPropsOrBool, out *apiextensions.JSONSchemaPropsOrBool, s conversion.Scope) error { - return autoConvert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool(in, out, s) -} - -func autoConvert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool(in *apiextensions.JSONSchemaPropsOrBool, out *JSONSchemaPropsOrBool, s conversion.Scope) error { - out.Allows = in.Allows - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Schema = nil - } - return nil -} - -// Convert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool is an autogenerated conversion function. -func Convert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool(in *apiextensions.JSONSchemaPropsOrBool, out *JSONSchemaPropsOrBool, s conversion.Scope) error { - return autoConvert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool(in, out, s) -} - -func autoConvert_v1beta1_JSONSchemaPropsOrStringArray_To_apiextensions_JSONSchemaPropsOrStringArray(in *JSONSchemaPropsOrStringArray, out *apiextensions.JSONSchemaPropsOrStringArray, s conversion.Scope) error { - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(apiextensions.JSONSchemaProps) - if err := Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Schema = nil - } - out.Property = *(*[]string)(unsafe.Pointer(&in.Property)) - return nil -} - -// Convert_v1beta1_JSONSchemaPropsOrStringArray_To_apiextensions_JSONSchemaPropsOrStringArray is an autogenerated conversion function. -func Convert_v1beta1_JSONSchemaPropsOrStringArray_To_apiextensions_JSONSchemaPropsOrStringArray(in *JSONSchemaPropsOrStringArray, out *apiextensions.JSONSchemaPropsOrStringArray, s conversion.Scope) error { - return autoConvert_v1beta1_JSONSchemaPropsOrStringArray_To_apiextensions_JSONSchemaPropsOrStringArray(in, out, s) -} - -func autoConvert_apiextensions_JSONSchemaPropsOrStringArray_To_v1beta1_JSONSchemaPropsOrStringArray(in *apiextensions.JSONSchemaPropsOrStringArray, out *JSONSchemaPropsOrStringArray, s conversion.Scope) error { - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(JSONSchemaProps) - if err := Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(*in, *out, s); err != nil { - return err - } - } else { - out.Schema = nil - } - out.Property = *(*[]string)(unsafe.Pointer(&in.Property)) - return nil -} - -// Convert_apiextensions_JSONSchemaPropsOrStringArray_To_v1beta1_JSONSchemaPropsOrStringArray is an autogenerated conversion function. -func Convert_apiextensions_JSONSchemaPropsOrStringArray_To_v1beta1_JSONSchemaPropsOrStringArray(in *apiextensions.JSONSchemaPropsOrStringArray, out *JSONSchemaPropsOrStringArray, s conversion.Scope) error { - return autoConvert_apiextensions_JSONSchemaPropsOrStringArray_To_v1beta1_JSONSchemaPropsOrStringArray(in, out, s) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.deepcopy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.deepcopy.go deleted file mode 100644 index d2c1cebf2..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.deepcopy.go +++ /dev/null @@ -1,506 +0,0 @@ -// +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 deepcopy-gen. DO NOT EDIT. - -package v1beta1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceColumnDefinition) DeepCopyInto(out *CustomResourceColumnDefinition) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceColumnDefinition. -func (in *CustomResourceColumnDefinition) DeepCopy() *CustomResourceColumnDefinition { - if in == nil { - return nil - } - out := new(CustomResourceColumnDefinition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinition) DeepCopyInto(out *CustomResourceDefinition) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinition. -func (in *CustomResourceDefinition) DeepCopy() *CustomResourceDefinition { - if in == nil { - return nil - } - out := new(CustomResourceDefinition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CustomResourceDefinition) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionCondition) DeepCopyInto(out *CustomResourceDefinitionCondition) { - *out = *in - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionCondition. -func (in *CustomResourceDefinitionCondition) DeepCopy() *CustomResourceDefinitionCondition { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionList) DeepCopyInto(out *CustomResourceDefinitionList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]CustomResourceDefinition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionList. -func (in *CustomResourceDefinitionList) DeepCopy() *CustomResourceDefinitionList { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CustomResourceDefinitionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionNames) DeepCopyInto(out *CustomResourceDefinitionNames) { - *out = *in - if in.ShortNames != nil { - in, out := &in.ShortNames, &out.ShortNames - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Categories != nil { - in, out := &in.Categories, &out.Categories - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionNames. -func (in *CustomResourceDefinitionNames) DeepCopy() *CustomResourceDefinitionNames { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionNames) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionSpec) DeepCopyInto(out *CustomResourceDefinitionSpec) { - *out = *in - in.Names.DeepCopyInto(&out.Names) - if in.Validation != nil { - in, out := &in.Validation, &out.Validation - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceValidation) - (*in).DeepCopyInto(*out) - } - } - if in.Subresources != nil { - in, out := &in.Subresources, &out.Subresources - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceSubresources) - (*in).DeepCopyInto(*out) - } - } - if in.Versions != nil { - in, out := &in.Versions, &out.Versions - *out = make([]CustomResourceDefinitionVersion, len(*in)) - copy(*out, *in) - } - if in.AdditionalPrinterColumns != nil { - in, out := &in.AdditionalPrinterColumns, &out.AdditionalPrinterColumns - *out = make([]CustomResourceColumnDefinition, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionSpec. -func (in *CustomResourceDefinitionSpec) DeepCopy() *CustomResourceDefinitionSpec { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionStatus) DeepCopyInto(out *CustomResourceDefinitionStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]CustomResourceDefinitionCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - in.AcceptedNames.DeepCopyInto(&out.AcceptedNames) - if in.StoredVersions != nil { - in, out := &in.StoredVersions, &out.StoredVersions - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionStatus. -func (in *CustomResourceDefinitionStatus) DeepCopy() *CustomResourceDefinitionStatus { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionVersion) DeepCopyInto(out *CustomResourceDefinitionVersion) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionVersion. -func (in *CustomResourceDefinitionVersion) DeepCopy() *CustomResourceDefinitionVersion { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionVersion) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceSubresourceScale) DeepCopyInto(out *CustomResourceSubresourceScale) { - *out = *in - if in.LabelSelectorPath != nil { - in, out := &in.LabelSelectorPath, &out.LabelSelectorPath - if *in == nil { - *out = nil - } else { - *out = new(string) - **out = **in - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceSubresourceScale. -func (in *CustomResourceSubresourceScale) DeepCopy() *CustomResourceSubresourceScale { - if in == nil { - return nil - } - out := new(CustomResourceSubresourceScale) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceSubresourceStatus) DeepCopyInto(out *CustomResourceSubresourceStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceSubresourceStatus. -func (in *CustomResourceSubresourceStatus) DeepCopy() *CustomResourceSubresourceStatus { - if in == nil { - return nil - } - out := new(CustomResourceSubresourceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceSubresources) DeepCopyInto(out *CustomResourceSubresources) { - *out = *in - if in.Status != nil { - in, out := &in.Status, &out.Status - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceSubresourceStatus) - **out = **in - } - } - if in.Scale != nil { - in, out := &in.Scale, &out.Scale - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceSubresourceScale) - (*in).DeepCopyInto(*out) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceSubresources. -func (in *CustomResourceSubresources) DeepCopy() *CustomResourceSubresources { - if in == nil { - return nil - } - out := new(CustomResourceSubresources) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceValidation) DeepCopyInto(out *CustomResourceValidation) { - *out = *in - if in.OpenAPIV3Schema != nil { - in, out := &in.OpenAPIV3Schema, &out.OpenAPIV3Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceValidation. -func (in *CustomResourceValidation) DeepCopy() *CustomResourceValidation { - if in == nil { - return nil - } - out := new(CustomResourceValidation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExternalDocumentation) DeepCopyInto(out *ExternalDocumentation) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalDocumentation. -func (in *ExternalDocumentation) DeepCopy() *ExternalDocumentation { - if in == nil { - return nil - } - out := new(ExternalDocumentation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSON) DeepCopyInto(out *JSON) { - *out = *in - if in.Raw != nil { - in, out := &in.Raw, &out.Raw - *out = make([]byte, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSON. -func (in *JSON) DeepCopy() *JSON { - if in == nil { - return nil - } - out := new(JSON) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in JSONSchemaDefinitions) DeepCopyInto(out *JSONSchemaDefinitions) { - { - in := &in - *out = make(JSONSchemaDefinitions, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - return - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaDefinitions. -func (in JSONSchemaDefinitions) DeepCopy() JSONSchemaDefinitions { - if in == nil { - return nil - } - out := new(JSONSchemaDefinitions) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in JSONSchemaDependencies) DeepCopyInto(out *JSONSchemaDependencies) { - { - in := &in - *out = make(JSONSchemaDependencies, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - return - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaDependencies. -func (in JSONSchemaDependencies) DeepCopy() JSONSchemaDependencies { - if in == nil { - return nil - } - out := new(JSONSchemaDependencies) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaProps) DeepCopyInto(out *JSONSchemaProps) { - clone := in.DeepCopy() - *out = *clone - return -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaPropsOrArray) DeepCopyInto(out *JSONSchemaPropsOrArray) { - *out = *in - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - if in.JSONSchemas != nil { - in, out := &in.JSONSchemas, &out.JSONSchemas - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaPropsOrArray. -func (in *JSONSchemaPropsOrArray) DeepCopy() *JSONSchemaPropsOrArray { - if in == nil { - return nil - } - out := new(JSONSchemaPropsOrArray) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaPropsOrBool) DeepCopyInto(out *JSONSchemaPropsOrBool) { - *out = *in - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaPropsOrBool. -func (in *JSONSchemaPropsOrBool) DeepCopy() *JSONSchemaPropsOrBool { - if in == nil { - return nil - } - out := new(JSONSchemaPropsOrBool) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaPropsOrStringArray) DeepCopyInto(out *JSONSchemaPropsOrStringArray) { - *out = *in - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - if in.Property != nil { - in, out := &in.Property, &out.Property - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaPropsOrStringArray. -func (in *JSONSchemaPropsOrStringArray) DeepCopy() *JSONSchemaPropsOrStringArray { - if in == nil { - return nil - } - out := new(JSONSchemaPropsOrStringArray) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.defaults.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.defaults.go deleted file mode 100644 index f65f47a03..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.defaults.go +++ /dev/null @@ -1,48 +0,0 @@ -// +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 defaulter-gen. DO NOT EDIT. - -package v1beta1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// RegisterDefaults adds defaulters functions to the given scheme. -// Public to allow building arbitrary schemes. -// All generated defaulters are covering - they call all nested defaulters. -func RegisterDefaults(scheme *runtime.Scheme) error { - scheme.AddTypeDefaultingFunc(&CustomResourceDefinition{}, func(obj interface{}) { SetObjectDefaults_CustomResourceDefinition(obj.(*CustomResourceDefinition)) }) - scheme.AddTypeDefaultingFunc(&CustomResourceDefinitionList{}, func(obj interface{}) { - SetObjectDefaults_CustomResourceDefinitionList(obj.(*CustomResourceDefinitionList)) - }) - return nil -} - -func SetObjectDefaults_CustomResourceDefinition(in *CustomResourceDefinition) { - SetDefaults_CustomResourceDefinition(in) - SetDefaults_CustomResourceDefinitionSpec(&in.Spec) -} - -func SetObjectDefaults_CustomResourceDefinitionList(in *CustomResourceDefinitionList) { - for i := range in.Items { - a := &in.Items[i] - SetObjectDefaults_CustomResourceDefinition(a) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go deleted file mode 100644 index 1179226dd..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go +++ /dev/null @@ -1,523 +0,0 @@ -/* -Copyright 2017 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 validation - -import ( - "fmt" - "reflect" - "strings" - - genericvalidation "k8s.io/apimachinery/pkg/api/validation" - "k8s.io/apimachinery/pkg/util/sets" - validationutil "k8s.io/apimachinery/pkg/util/validation" - "k8s.io/apimachinery/pkg/util/validation/field" - utilfeature "k8s.io/apiserver/pkg/util/feature" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - apiservervalidation "k8s.io/apiextensions-apiserver/pkg/apiserver/validation" - apiextensionsfeatures "k8s.io/apiextensions-apiserver/pkg/features" -) - -var ( - printerColumnDatatypes = sets.NewString("integer", "number", "string", "boolean", "date") - customResourceColumnDefinitionFormats = sets.NewString("int32", "int64", "float", "double", "byte", "date", "date-time", "password") -) - -// ValidateCustomResourceDefinition statically validates -func ValidateCustomResourceDefinition(obj *apiextensions.CustomResourceDefinition) field.ErrorList { - nameValidationFn := func(name string, prefix bool) []string { - ret := genericvalidation.NameIsDNSSubdomain(name, prefix) - requiredName := obj.Spec.Names.Plural + "." + obj.Spec.Group - if name != requiredName { - ret = append(ret, fmt.Sprintf(`must be spec.names.plural+"."+spec.group`)) - } - return ret - } - - allErrs := genericvalidation.ValidateObjectMeta(&obj.ObjectMeta, false, nameValidationFn, field.NewPath("metadata")) - allErrs = append(allErrs, ValidateCustomResourceDefinitionSpec(&obj.Spec, field.NewPath("spec"))...) - allErrs = append(allErrs, ValidateCustomResourceDefinitionStatus(&obj.Status, field.NewPath("status"))...) - allErrs = append(allErrs, ValidateCustomResourceDefinitionStoredVersions(obj.Status.StoredVersions, obj.Spec.Versions, field.NewPath("status").Child("storedVersions"))...) - return allErrs -} - -// ValidateCustomResourceDefinitionUpdate statically validates -func ValidateCustomResourceDefinitionUpdate(obj, oldObj *apiextensions.CustomResourceDefinition) field.ErrorList { - allErrs := genericvalidation.ValidateObjectMetaUpdate(&obj.ObjectMeta, &oldObj.ObjectMeta, field.NewPath("metadata")) - allErrs = append(allErrs, ValidateCustomResourceDefinitionSpecUpdate(&obj.Spec, &oldObj.Spec, apiextensions.IsCRDConditionTrue(oldObj, apiextensions.Established), field.NewPath("spec"))...) - allErrs = append(allErrs, ValidateCustomResourceDefinitionStatus(&obj.Status, field.NewPath("status"))...) - allErrs = append(allErrs, ValidateCustomResourceDefinitionStoredVersions(obj.Status.StoredVersions, obj.Spec.Versions, field.NewPath("status").Child("storedVersions"))...) - return allErrs -} - -// ValidateCustomResourceDefinitionStoredVersions statically validates -func ValidateCustomResourceDefinitionStoredVersions(storedVersions []string, versions []apiextensions.CustomResourceDefinitionVersion, fldPath *field.Path) field.ErrorList { - if len(storedVersions) == 0 { - return field.ErrorList{field.Invalid(fldPath, storedVersions, "must have at least one stored version")} - } - allErrs := field.ErrorList{} - storedVersionsMap := map[string]int{} - for i, v := range storedVersions { - storedVersionsMap[v] = i - } - for _, v := range versions { - _, ok := storedVersionsMap[v.Name] - if v.Storage && !ok { - allErrs = append(allErrs, field.Invalid(fldPath, v, "must have the storage version "+v.Name)) - } - if ok { - delete(storedVersionsMap, v.Name) - } - } - - for v, i := range storedVersionsMap { - allErrs = append(allErrs, field.Invalid(fldPath.Index(i), v, "must appear in spec.versions")) - } - - return allErrs -} - -// ValidateUpdateCustomResourceDefinitionStatus statically validates -func ValidateUpdateCustomResourceDefinitionStatus(obj, oldObj *apiextensions.CustomResourceDefinition) field.ErrorList { - allErrs := genericvalidation.ValidateObjectMetaUpdate(&obj.ObjectMeta, &oldObj.ObjectMeta, field.NewPath("metadata")) - allErrs = append(allErrs, ValidateCustomResourceDefinitionStatus(&obj.Status, field.NewPath("status"))...) - return allErrs -} - -// ValidateCustomResourceDefinitionSpec statically validates -func ValidateCustomResourceDefinitionSpec(spec *apiextensions.CustomResourceDefinitionSpec, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - - if len(spec.Group) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("group"), "")) - } else if errs := validationutil.IsDNS1123Subdomain(spec.Group); len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("group"), spec.Group, strings.Join(errs, ","))) - } else if len(strings.Split(spec.Group, ".")) < 2 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("group"), spec.Group, "should be a domain with at least one dot")) - } - - switch spec.Scope { - case "": - allErrs = append(allErrs, field.Required(fldPath.Child("scope"), "")) - case apiextensions.ClusterScoped, apiextensions.NamespaceScoped: - default: - allErrs = append(allErrs, field.NotSupported(fldPath.Child("scope"), spec.Scope, []string{string(apiextensions.ClusterScoped), string(apiextensions.NamespaceScoped)})) - } - - storageFlagCount := 0 - versionsMap := map[string]bool{} - uniqueNames := true - for i, version := range spec.Versions { - if version.Storage { - storageFlagCount++ - } - if versionsMap[version.Name] { - uniqueNames = false - } else { - versionsMap[version.Name] = true - } - if errs := validationutil.IsDNS1035Label(version.Name); len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("versions").Index(i).Child("name"), spec.Versions[i].Name, strings.Join(errs, ","))) - } - } - if !uniqueNames { - allErrs = append(allErrs, field.Invalid(fldPath.Child("versions"), spec.Versions, "must contain unique version names")) - } - if storageFlagCount != 1 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("versions"), spec.Versions, "must have exactly one version marked as storage version")) - } - if len(spec.Version) != 0 { - if errs := validationutil.IsDNS1035Label(spec.Version); len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("version"), spec.Version, strings.Join(errs, ","))) - } - if len(spec.Versions) >= 1 && spec.Versions[0].Name != spec.Version { - allErrs = append(allErrs, field.Invalid(fldPath.Child("version"), spec.Version, "must match the first version in spec.versions")) - } - } - - // in addition to the basic name restrictions, some names are required for spec, but not for status - if len(spec.Names.Plural) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("names", "plural"), "")) - } - if len(spec.Names.Singular) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("names", "singular"), "")) - } - if len(spec.Names.Kind) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("names", "kind"), "")) - } - if len(spec.Names.ListKind) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("names", "listKind"), "")) - } - - allErrs = append(allErrs, ValidateCustomResourceDefinitionNames(&spec.Names, fldPath.Child("names"))...) - - if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceValidation) { - statusEnabled := false - if spec.Subresources != nil && spec.Subresources.Status != nil { - statusEnabled = true - } - allErrs = append(allErrs, ValidateCustomResourceDefinitionValidation(spec.Validation, statusEnabled, fldPath.Child("validation"))...) - } else if spec.Validation != nil { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("validation"), "disabled by feature-gate CustomResourceValidation")) - } - - if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) { - allErrs = append(allErrs, ValidateCustomResourceDefinitionSubresources(spec.Subresources, fldPath.Child("subresources"))...) - } else if spec.Subresources != nil { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("subresources"), "disabled by feature-gate CustomResourceSubresources")) - } - - for i := range spec.AdditionalPrinterColumns { - if errs := ValidateCustomResourceColumnDefinition(&spec.AdditionalPrinterColumns[i], fldPath.Child("columns").Index(i)); len(errs) > 0 { - allErrs = append(allErrs, errs...) - } - } - - return allErrs -} - -// ValidateCustomResourceDefinitionSpecUpdate statically validates -func ValidateCustomResourceDefinitionSpecUpdate(spec, oldSpec *apiextensions.CustomResourceDefinitionSpec, established bool, fldPath *field.Path) field.ErrorList { - allErrs := ValidateCustomResourceDefinitionSpec(spec, fldPath) - - if established { - // these effect the storage and cannot be changed therefore - allErrs = append(allErrs, genericvalidation.ValidateImmutableField(spec.Scope, oldSpec.Scope, fldPath.Child("scope"))...) - allErrs = append(allErrs, genericvalidation.ValidateImmutableField(spec.Names.Kind, oldSpec.Names.Kind, fldPath.Child("names", "kind"))...) - } - - // these affects the resource name, which is always immutable, so this can't be updated. - allErrs = append(allErrs, genericvalidation.ValidateImmutableField(spec.Group, oldSpec.Group, fldPath.Child("group"))...) - allErrs = append(allErrs, genericvalidation.ValidateImmutableField(spec.Names.Plural, oldSpec.Names.Plural, fldPath.Child("names", "plural"))...) - - return allErrs -} - -// ValidateCustomResourceDefinitionStatus statically validates -func ValidateCustomResourceDefinitionStatus(status *apiextensions.CustomResourceDefinitionStatus, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - allErrs = append(allErrs, ValidateCustomResourceDefinitionNames(&status.AcceptedNames, fldPath.Child("acceptedNames"))...) - return allErrs -} - -// ValidateCustomResourceDefinitionNames statically validates -func ValidateCustomResourceDefinitionNames(names *apiextensions.CustomResourceDefinitionNames, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - if errs := validationutil.IsDNS1035Label(names.Plural); len(names.Plural) > 0 && len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("plural"), names.Plural, strings.Join(errs, ","))) - } - if errs := validationutil.IsDNS1035Label(names.Singular); len(names.Singular) > 0 && len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("singular"), names.Singular, strings.Join(errs, ","))) - } - if errs := validationutil.IsDNS1035Label(strings.ToLower(names.Kind)); len(names.Kind) > 0 && len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("kind"), names.Kind, "may have mixed case, but should otherwise match: "+strings.Join(errs, ","))) - } - if errs := validationutil.IsDNS1035Label(strings.ToLower(names.ListKind)); len(names.ListKind) > 0 && len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("listKind"), names.ListKind, "may have mixed case, but should otherwise match: "+strings.Join(errs, ","))) - } - - for i, shortName := range names.ShortNames { - if errs := validationutil.IsDNS1035Label(shortName); len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("shortNames").Index(i), shortName, strings.Join(errs, ","))) - } - } - - // kind and listKind may not be the same or parsing become ambiguous - if len(names.Kind) > 0 && names.Kind == names.ListKind { - allErrs = append(allErrs, field.Invalid(fldPath.Child("listKind"), names.ListKind, "kind and listKind may not be the same")) - } - - for i, category := range names.Categories { - if errs := validationutil.IsDNS1035Label(category); len(errs) > 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("categories").Index(i), category, strings.Join(errs, ","))) - } - } - - return allErrs -} - -// ValidateCustomResourceColumnDefinition statically validates a printer column. -func ValidateCustomResourceColumnDefinition(col *apiextensions.CustomResourceColumnDefinition, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - - if len(col.Name) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("header"), "")) - } - - if len(col.Type) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("type"), fmt.Sprintf("must be one of %s", strings.Join(printerColumnDatatypes.List(), ",")))) - } else if !printerColumnDatatypes.Has(col.Type) { - allErrs = append(allErrs, field.Invalid(fldPath.Child("type"), col.Type, fmt.Sprintf("must be one of %s", strings.Join(printerColumnDatatypes.List(), ",")))) - } - - if len(col.Format) > 0 && !customResourceColumnDefinitionFormats.Has(col.Format) { - allErrs = append(allErrs, field.Invalid(fldPath.Child("format"), col.Format, fmt.Sprintf("must be one of %s", strings.Join(customResourceColumnDefinitionFormats.List(), ",")))) - } - - if len(col.JSONPath) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("path"), "")) - } else if errs := validateSimpleJSONPath(col.JSONPath, fldPath.Child("path")); len(errs) > 0 { - allErrs = append(allErrs, errs...) - } - - return allErrs -} - -// specStandardValidator applies validations for different OpenAPI specification versions. -type specStandardValidator interface { - validate(spec *apiextensions.JSONSchemaProps, fldPath *field.Path) field.ErrorList -} - -// ValidateCustomResourceDefinitionValidation statically validates -func ValidateCustomResourceDefinitionValidation(customResourceValidation *apiextensions.CustomResourceValidation, statusSubresourceEnabled bool, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - - if customResourceValidation == nil { - return allErrs - } - - if schema := customResourceValidation.OpenAPIV3Schema; schema != nil { - // if subresources are enabled, only "properties", "required" and "description" are allowed inside the root schema - if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) && statusSubresourceEnabled { - v := reflect.ValueOf(schema).Elem() - for i := 0; i < v.NumField(); i++ { - // skip zero values - if value := v.Field(i).Interface(); reflect.DeepEqual(value, reflect.Zero(reflect.TypeOf(value)).Interface()) { - continue - } - - if name := v.Type().Field(i).Name; name != "Properties" && name != "Required" && name != "Description" { - allErrs = append(allErrs, field.Invalid(fldPath.Child("openAPIV3Schema"), *schema, fmt.Sprintf(`must only have "properties", "required" or "description" at the root if the status subresource is enabled`))) - break - } - } - } - - openAPIV3Schema := &specStandardValidatorV3{} - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(schema, fldPath.Child("openAPIV3Schema"), openAPIV3Schema)...) - } - - // if validation passed otherwise, make sure we can actually construct a schema validator from this custom resource validation. - if len(allErrs) == 0 { - if _, _, err := apiservervalidation.NewSchemaValidator(customResourceValidation); err != nil { - allErrs = append(allErrs, field.Invalid(fldPath, "", fmt.Sprintf("error building validator: %v", err))) - } - } - return allErrs -} - -// ValidateCustomResourceDefinitionOpenAPISchema statically validates -func ValidateCustomResourceDefinitionOpenAPISchema(schema *apiextensions.JSONSchemaProps, fldPath *field.Path, ssv specStandardValidator) field.ErrorList { - allErrs := field.ErrorList{} - - if schema == nil { - return allErrs - } - - allErrs = append(allErrs, ssv.validate(schema, fldPath)...) - - if schema.UniqueItems == true { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("uniqueItems"), "uniqueItems cannot be set to true since the runtime complexity becomes quadratic")) - } - - // additionalProperties and properties are mutual exclusive because otherwise they - // contradict Kubernetes' API convention to ignore unknown fields. - // - // In other words: - // - properties are for structs, - // - additionalProperties are for map[string]interface{} - // - // Note: when patternProperties is added to OpenAPI some day, this will have to be - // restricted like additionalProperties. - if schema.AdditionalProperties != nil { - if len(schema.Properties) != 0 { - if schema.AdditionalProperties.Allows == false || schema.AdditionalProperties.Schema != nil { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("additionalProperties"), "additionalProperties and properties are mutual exclusive")) - } - } - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(schema.AdditionalProperties.Schema, fldPath.Child("additionalProperties"), ssv)...) - } - - if len(schema.Properties) != 0 { - for property, jsonSchema := range schema.Properties { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(&jsonSchema, fldPath.Child("properties").Key(property), ssv)...) - } - } - - if len(schema.PatternProperties) != 0 { - for property, jsonSchema := range schema.PatternProperties { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(&jsonSchema, fldPath.Child("patternProperties").Key(property), ssv)...) - } - } - - if schema.AdditionalItems != nil { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(schema.AdditionalItems.Schema, fldPath.Child("additionalItems"), ssv)...) - } - - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(schema.Not, fldPath.Child("not"), ssv)...) - - if len(schema.AllOf) != 0 { - for i, jsonSchema := range schema.AllOf { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(&jsonSchema, fldPath.Child("allOf").Index(i), ssv)...) - } - } - - if len(schema.OneOf) != 0 { - for i, jsonSchema := range schema.OneOf { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(&jsonSchema, fldPath.Child("oneOf").Index(i), ssv)...) - } - } - - if len(schema.AnyOf) != 0 { - for i, jsonSchema := range schema.AnyOf { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(&jsonSchema, fldPath.Child("anyOf").Index(i), ssv)...) - } - } - - if len(schema.Definitions) != 0 { - for definition, jsonSchema := range schema.Definitions { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(&jsonSchema, fldPath.Child("definitions").Key(definition), ssv)...) - } - } - - if schema.Items != nil { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(schema.Items.Schema, fldPath.Child("items"), ssv)...) - if len(schema.Items.JSONSchemas) != 0 { - for i, jsonSchema := range schema.Items.JSONSchemas { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(&jsonSchema, fldPath.Child("items").Index(i), ssv)...) - } - } - } - - if schema.Dependencies != nil { - for dependency, jsonSchemaPropsOrStringArray := range schema.Dependencies { - allErrs = append(allErrs, ValidateCustomResourceDefinitionOpenAPISchema(jsonSchemaPropsOrStringArray.Schema, fldPath.Child("dependencies").Key(dependency), ssv)...) - } - } - - return allErrs -} - -type specStandardValidatorV3 struct{} - -// validate validates against OpenAPI Schema v3. -func (v *specStandardValidatorV3) validate(schema *apiextensions.JSONSchemaProps, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - - if schema == nil { - return allErrs - } - - if schema.Default != nil { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("default"), "default is not supported")) - } - - if schema.ID != "" { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("id"), "id is not supported")) - } - - if schema.AdditionalItems != nil { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("additionalItems"), "additionalItems is not supported")) - } - - if len(schema.PatternProperties) != 0 { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("patternProperties"), "patternProperties is not supported")) - } - - if len(schema.Definitions) != 0 { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("definitions"), "definitions is not supported")) - } - - if schema.Dependencies != nil { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("dependencies"), "dependencies is not supported")) - } - - if schema.Ref != nil { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("$ref"), "$ref is not supported")) - } - - if schema.Type == "null" { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("type"), "type cannot be set to null")) - } - - if schema.Items != nil && len(schema.Items.JSONSchemas) != 0 { - allErrs = append(allErrs, field.Forbidden(fldPath.Child("items"), "items must be a schema object and not an array")) - } - - return allErrs -} - -// ValidateCustomResourceDefinitionSubresources statically validates -func ValidateCustomResourceDefinitionSubresources(subresources *apiextensions.CustomResourceSubresources, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - - if subresources == nil { - return allErrs - } - - if subresources.Scale != nil { - if len(subresources.Scale.SpecReplicasPath) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("scale.specReplicasPath"), "")) - } else { - // should be constrained json path under .spec - if errs := validateSimpleJSONPath(subresources.Scale.SpecReplicasPath, fldPath.Child("scale.specReplicasPath")); len(errs) > 0 { - allErrs = append(allErrs, errs...) - } else if !strings.HasPrefix(subresources.Scale.SpecReplicasPath, ".spec.") { - allErrs = append(allErrs, field.Invalid(fldPath.Child("scale.specReplicasPath"), subresources.Scale.SpecReplicasPath, "should be a json path under .spec")) - } - } - - if len(subresources.Scale.StatusReplicasPath) == 0 { - allErrs = append(allErrs, field.Required(fldPath.Child("scale.statusReplicasPath"), "")) - } else { - // should be constrained json path under .status - if errs := validateSimpleJSONPath(subresources.Scale.StatusReplicasPath, fldPath.Child("scale.statusReplicasPath")); len(errs) > 0 { - allErrs = append(allErrs, errs...) - } else if !strings.HasPrefix(subresources.Scale.StatusReplicasPath, ".status.") { - allErrs = append(allErrs, field.Invalid(fldPath.Child("scale.statusReplicasPath"), subresources.Scale.StatusReplicasPath, "should be a json path under .status")) - } - } - - // if labelSelectorPath is present, it should be a constrained json path under .status - if subresources.Scale.LabelSelectorPath != nil && len(*subresources.Scale.LabelSelectorPath) > 0 { - if errs := validateSimpleJSONPath(*subresources.Scale.LabelSelectorPath, fldPath.Child("scale.labelSelectorPath")); len(errs) > 0 { - allErrs = append(allErrs, errs...) - } else if !strings.HasPrefix(*subresources.Scale.LabelSelectorPath, ".status.") { - allErrs = append(allErrs, field.Invalid(fldPath.Child("scale.labelSelectorPath"), subresources.Scale.LabelSelectorPath, "should be a json path under .status")) - } - } - } - - return allErrs -} - -func validateSimpleJSONPath(s string, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - - switch { - case len(s) == 0: - allErrs = append(allErrs, field.Invalid(fldPath, s, "must not be empty")) - case s[0] != '.': - allErrs = append(allErrs, field.Invalid(fldPath, s, "must be a simple json path starting with .")) - case s != ".": - if cs := strings.Split(s[1:], "."); len(cs) < 1 { - allErrs = append(allErrs, field.Invalid(fldPath, s, "must be a json path in the dot notation")) - } - } - - return allErrs -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go deleted file mode 100644 index 68dc8aaed..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go +++ /dev/null @@ -1,877 +0,0 @@ -/* -Copyright 2017 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 validation - -import ( - "testing" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/validation/field" -) - -type validationMatch struct { - path *field.Path - errorType field.ErrorType -} - -func required(path ...string) validationMatch { - return validationMatch{path: field.NewPath(path[0], path[1:]...), errorType: field.ErrorTypeRequired} -} -func invalid(path ...string) validationMatch { - return validationMatch{path: field.NewPath(path[0], path[1:]...), errorType: field.ErrorTypeInvalid} -} -func unsupported(path ...string) validationMatch { - return validationMatch{path: field.NewPath(path[0], path[1:]...), errorType: field.ErrorTypeNotSupported} -} -func immutable(path ...string) validationMatch { - return validationMatch{path: field.NewPath(path[0], path[1:]...), errorType: field.ErrorTypeInvalid} -} -func forbidden(path ...string) validationMatch { - return validationMatch{path: field.NewPath(path[0], path[1:]...), errorType: field.ErrorTypeForbidden} -} - -func (v validationMatch) matches(err *field.Error) bool { - return err.Type == v.errorType && err.Field == v.path.String() -} - -func TestValidateCustomResourceDefinition(t *testing.T) { - singleVersionList := []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - } - tests := []struct { - name string - resource *apiextensions.CustomResourceDefinition - errors []validationMatch - }{ - { - name: "no_storage_version", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "Plural", - ListKind: "PluralList", - }, - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: false, - }, - { - Name: "version2", - Served: true, - Storage: false, - }, - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{ - invalid("spec", "versions"), - }, - }, - { - name: "multiple_storage_version", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "Plural", - ListKind: "PluralList", - }, - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - { - Name: "version2", - Served: true, - Storage: true, - }, - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{ - invalid("spec", "versions"), - invalid("status", "storedVersions"), - }, - }, - { - name: "missing_storage_version_in_stored_versions", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "Plural", - ListKind: "PluralList", - }, - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: false, - }, - { - Name: "version2", - Served: true, - Storage: true, - }, - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{ - invalid("status", "storedVersions"), - }, - }, - { - name: "empty_stored_version", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "Plural", - ListKind: "PluralList", - }, - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - StoredVersions: []string{}, - }, - }, - errors: []validationMatch{ - invalid("status", "storedVersions"), - }, - }, - { - name: "mismatched name", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.not.group.com"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - }, - }, - }, - errors: []validationMatch{ - invalid("status", "storedVersions"), - invalid("metadata", "name"), - invalid("spec", "versions"), - required("spec", "scope"), - required("spec", "names", "singular"), - required("spec", "names", "kind"), - required("spec", "names", "listKind"), - }, - }, - { - name: "missing values", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"}, - }, - errors: []validationMatch{ - invalid("status", "storedVersions"), - invalid("metadata", "name"), - invalid("spec", "versions"), - required("spec", "group"), - required("spec", "scope"), - required("spec", "names", "plural"), - required("spec", "names", "singular"), - required("spec", "names", "kind"), - required("spec", "names", "listKind"), - }, - }, - { - name: "bad names 01", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group", - Version: "ve()*rsion", - Scope: apiextensions.ResourceScope("foo"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "pl()*ural", - Singular: "value()*a", - Kind: "value()*a", - ListKind: "value()*a", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "pl()*ural", - Singular: "value()*a", - Kind: "value()*a", - ListKind: "value()*a", - }, - }, - }, - errors: []validationMatch{ - invalid("status", "storedVersions"), - invalid("metadata", "name"), - invalid("spec", "group"), - unsupported("spec", "scope"), - invalid("spec", "names", "plural"), - invalid("spec", "names", "singular"), - invalid("spec", "names", "kind"), - invalid("spec", "names", "listKind"), // invalid format - invalid("spec", "names", "listKind"), // kind == listKind - invalid("status", "acceptedNames", "plural"), - invalid("status", "acceptedNames", "singular"), - invalid("status", "acceptedNames", "kind"), - invalid("status", "acceptedNames", "listKind"), // invalid format - invalid("status", "acceptedNames", "listKind"), // kind == listKind - invalid("spec", "versions"), - invalid("spec", "version"), - }, - }, - { - name: "bad names 02", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.c(*&om", - Version: "version", - Versions: singleVersionList, - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "matching", - ListKind: "matching", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "matching", - ListKind: "matching", - }, - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{ - invalid("metadata", "name"), - invalid("spec", "group"), - required("spec", "scope"), - invalid("spec", "names", "listKind"), - invalid("status", "acceptedNames", "listKind"), - }, - }, - { - name: "additionalProperties and properties forbidden", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: singleVersionList, - Scope: apiextensions.NamespaceScoped, - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "Plural", - ListKind: "PluralList", - }, - Validation: &apiextensions.CustomResourceValidation{ - OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ - Properties: map[string]apiextensions.JSONSchemaProps{ - "foo": {}, - }, - AdditionalProperties: &apiextensions.JSONSchemaPropsOrBool{Allows: false}, - }, - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{ - forbidden("spec", "validation", "openAPIV3Schema", "additionalProperties"), - }, - }, - { - name: "additionalProperties without properties allowed (map[string]string)", - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: singleVersionList, - Scope: apiextensions.NamespaceScoped, - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "Plural", - ListKind: "PluralList", - }, - Validation: &apiextensions.CustomResourceValidation{ - OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ - AdditionalProperties: &apiextensions.JSONSchemaPropsOrBool{ - Allows: true, - Schema: &apiextensions.JSONSchemaProps{ - Type: "string", - }, - }, - }, - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{}, - }, - } - - for _, tc := range tests { - errs := ValidateCustomResourceDefinition(tc.resource) - seenErrs := make([]bool, len(errs)) - - for _, expectedError := range tc.errors { - found := false - for i, err := range errs { - if expectedError.matches(err) && !seenErrs[i] { - found = true - seenErrs[i] = true - break - } - } - - if !found { - t.Errorf("%s: expected %v at %v, got %v", tc.name, expectedError.errorType, expectedError.path.String(), errs) - } - } - - for i, seen := range seenErrs { - if !seen { - t.Errorf("%s: unexpected error: %v", tc.name, errs[i]) - } - } - } -} - -func TestValidateCustomResourceDefinitionUpdate(t *testing.T) { - tests := []struct { - name string - old *apiextensions.CustomResourceDefinition - resource *apiextensions.CustomResourceDefinition - errors []validationMatch - }{ - { - name: "unchanged", - old: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - }, - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{}, - }, - { - name: "unchanged-established", - old: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - Conditions: []apiextensions.CustomResourceDefinitionCondition{ - {Type: apiextensions.Established, Status: apiextensions.ConditionTrue}, - }, - }, - }, - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - StoredVersions: []string{"version"}, - }, - }, - errors: []validationMatch{}, - }, - { - name: "version-deleted", - old: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - { - Name: "version2", - Served: true, - Storage: false, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - StoredVersions: []string{"version", "version2"}, - Conditions: []apiextensions.CustomResourceDefinitionCondition{ - {Type: apiextensions.Established, Status: apiextensions.ConditionTrue}, - }, - }, - }, - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - StoredVersions: []string{"version", "version2"}, - }, - }, - errors: []validationMatch{ - invalid("status", "storedVersions[1]"), - }, - }, - { - name: "changes", - old: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - Conditions: []apiextensions.CustomResourceDefinitionCondition{ - {Type: apiextensions.Established, Status: apiextensions.ConditionFalse}, - }, - }, - }, - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "abc.com", - Version: "version2", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version2", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Namespaced"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural2", - Singular: "singular2", - Kind: "kind2", - ListKind: "listkind2", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural2", - Singular: "singular2", - Kind: "kind2", - ListKind: "listkind2", - }, - StoredVersions: []string{"version2"}, - }, - }, - errors: []validationMatch{ - immutable("spec", "group"), - immutable("spec", "names", "plural"), - }, - }, - { - name: "changes-established", - old: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "group.com", - Version: "version", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Cluster"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural", - Singular: "singular", - Kind: "kind", - ListKind: "listkind", - }, - Conditions: []apiextensions.CustomResourceDefinitionCondition{ - {Type: apiextensions.Established, Status: apiextensions.ConditionTrue}, - }, - }, - }, - resource: &apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "plural.group.com", - ResourceVersion: "42", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "abc.com", - Version: "version2", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "version2", - Served: true, - Storage: true, - }, - }, - Scope: apiextensions.ResourceScope("Namespaced"), - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural2", - Singular: "singular2", - Kind: "kind2", - ListKind: "listkind2", - }, - }, - Status: apiextensions.CustomResourceDefinitionStatus{ - AcceptedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "plural2", - Singular: "singular2", - Kind: "kind2", - ListKind: "listkind2", - }, - StoredVersions: []string{"version2"}, - }, - }, - errors: []validationMatch{ - immutable("spec", "group"), - immutable("spec", "scope"), - immutable("spec", "names", "kind"), - immutable("spec", "names", "plural"), - }, - }, - } - - for _, tc := range tests { - errs := ValidateCustomResourceDefinitionUpdate(tc.resource, tc.old) - seenErrs := make([]bool, len(errs)) - - for _, expectedError := range tc.errors { - found := false - for i, err := range errs { - if expectedError.matches(err) && !seenErrs[i] { - found = true - seenErrs[i] = true - break - } - } - - if !found { - t.Errorf("%s: expected %v at %v, got %v", tc.name, expectedError.errorType, expectedError.path.String(), errs) - } - } - - for i, seen := range seenErrs { - if !seen { - t.Errorf("%s: unexpected error: %v", tc.name, errs[i]) - } - } - } -} - -func TestValidateCustomResourceDefinitionValidation(t *testing.T) { - tests := []struct { - name string - input apiextensions.CustomResourceValidation - statusEnabled bool - wantError bool - }{ - { - name: "empty", - input: apiextensions.CustomResourceValidation{}, - wantError: false, - }, - { - name: "empty with status", - input: apiextensions.CustomResourceValidation{}, - statusEnabled: true, - wantError: false, - }, - { - name: "root type without status", - input: apiextensions.CustomResourceValidation{ - OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ - Type: "object", - }, - }, - statusEnabled: false, - wantError: false, - }, - { - name: "root type with status", - input: apiextensions.CustomResourceValidation{ - OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ - Type: "object", - }, - }, - statusEnabled: true, - wantError: true, - }, - { - name: "properties, required and description with status", - input: apiextensions.CustomResourceValidation{ - OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ - Properties: map[string]apiextensions.JSONSchemaProps{ - "spec": {}, - "status": {}, - }, - Required: []string{"spec", "status"}, - Description: "This is a description", - }, - }, - statusEnabled: true, - wantError: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := ValidateCustomResourceDefinitionValidation(&tt.input, tt.statusEnabled, field.NewPath("spec", "validation")) - if !tt.wantError && len(got) > 0 { - t.Errorf("Expected no error, but got: %v", got) - } else if tt.wantError && len(got) == 0 { - t.Error("Expected error, but got none") - } - }) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/zz_generated.deepcopy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/zz_generated.deepcopy.go deleted file mode 100644 index 145b3c5d7..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/zz_generated.deepcopy.go +++ /dev/null @@ -1,485 +0,0 @@ -// +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 deepcopy-gen. DO NOT EDIT. - -package apiextensions - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceColumnDefinition) DeepCopyInto(out *CustomResourceColumnDefinition) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceColumnDefinition. -func (in *CustomResourceColumnDefinition) DeepCopy() *CustomResourceColumnDefinition { - if in == nil { - return nil - } - out := new(CustomResourceColumnDefinition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinition) DeepCopyInto(out *CustomResourceDefinition) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinition. -func (in *CustomResourceDefinition) DeepCopy() *CustomResourceDefinition { - if in == nil { - return nil - } - out := new(CustomResourceDefinition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CustomResourceDefinition) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionCondition) DeepCopyInto(out *CustomResourceDefinitionCondition) { - *out = *in - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionCondition. -func (in *CustomResourceDefinitionCondition) DeepCopy() *CustomResourceDefinitionCondition { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionList) DeepCopyInto(out *CustomResourceDefinitionList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]CustomResourceDefinition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionList. -func (in *CustomResourceDefinitionList) DeepCopy() *CustomResourceDefinitionList { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CustomResourceDefinitionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionNames) DeepCopyInto(out *CustomResourceDefinitionNames) { - *out = *in - if in.ShortNames != nil { - in, out := &in.ShortNames, &out.ShortNames - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Categories != nil { - in, out := &in.Categories, &out.Categories - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionNames. -func (in *CustomResourceDefinitionNames) DeepCopy() *CustomResourceDefinitionNames { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionNames) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionSpec) DeepCopyInto(out *CustomResourceDefinitionSpec) { - *out = *in - in.Names.DeepCopyInto(&out.Names) - if in.Validation != nil { - in, out := &in.Validation, &out.Validation - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceValidation) - (*in).DeepCopyInto(*out) - } - } - if in.Subresources != nil { - in, out := &in.Subresources, &out.Subresources - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceSubresources) - (*in).DeepCopyInto(*out) - } - } - if in.Versions != nil { - in, out := &in.Versions, &out.Versions - *out = make([]CustomResourceDefinitionVersion, len(*in)) - copy(*out, *in) - } - if in.AdditionalPrinterColumns != nil { - in, out := &in.AdditionalPrinterColumns, &out.AdditionalPrinterColumns - *out = make([]CustomResourceColumnDefinition, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionSpec. -func (in *CustomResourceDefinitionSpec) DeepCopy() *CustomResourceDefinitionSpec { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionStatus) DeepCopyInto(out *CustomResourceDefinitionStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]CustomResourceDefinitionCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - in.AcceptedNames.DeepCopyInto(&out.AcceptedNames) - if in.StoredVersions != nil { - in, out := &in.StoredVersions, &out.StoredVersions - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionStatus. -func (in *CustomResourceDefinitionStatus) DeepCopy() *CustomResourceDefinitionStatus { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceDefinitionVersion) DeepCopyInto(out *CustomResourceDefinitionVersion) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitionVersion. -func (in *CustomResourceDefinitionVersion) DeepCopy() *CustomResourceDefinitionVersion { - if in == nil { - return nil - } - out := new(CustomResourceDefinitionVersion) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceSubresourceScale) DeepCopyInto(out *CustomResourceSubresourceScale) { - *out = *in - if in.LabelSelectorPath != nil { - in, out := &in.LabelSelectorPath, &out.LabelSelectorPath - if *in == nil { - *out = nil - } else { - *out = new(string) - **out = **in - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceSubresourceScale. -func (in *CustomResourceSubresourceScale) DeepCopy() *CustomResourceSubresourceScale { - if in == nil { - return nil - } - out := new(CustomResourceSubresourceScale) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceSubresourceStatus) DeepCopyInto(out *CustomResourceSubresourceStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceSubresourceStatus. -func (in *CustomResourceSubresourceStatus) DeepCopy() *CustomResourceSubresourceStatus { - if in == nil { - return nil - } - out := new(CustomResourceSubresourceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceSubresources) DeepCopyInto(out *CustomResourceSubresources) { - *out = *in - if in.Status != nil { - in, out := &in.Status, &out.Status - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceSubresourceStatus) - **out = **in - } - } - if in.Scale != nil { - in, out := &in.Scale, &out.Scale - if *in == nil { - *out = nil - } else { - *out = new(CustomResourceSubresourceScale) - (*in).DeepCopyInto(*out) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceSubresources. -func (in *CustomResourceSubresources) DeepCopy() *CustomResourceSubresources { - if in == nil { - return nil - } - out := new(CustomResourceSubresources) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomResourceValidation) DeepCopyInto(out *CustomResourceValidation) { - *out = *in - if in.OpenAPIV3Schema != nil { - in, out := &in.OpenAPIV3Schema, &out.OpenAPIV3Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceValidation. -func (in *CustomResourceValidation) DeepCopy() *CustomResourceValidation { - if in == nil { - return nil - } - out := new(CustomResourceValidation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExternalDocumentation) DeepCopyInto(out *ExternalDocumentation) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalDocumentation. -func (in *ExternalDocumentation) DeepCopy() *ExternalDocumentation { - if in == nil { - return nil - } - out := new(ExternalDocumentation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in JSONSchemaDefinitions) DeepCopyInto(out *JSONSchemaDefinitions) { - { - in := &in - *out = make(JSONSchemaDefinitions, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - return - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaDefinitions. -func (in JSONSchemaDefinitions) DeepCopy() JSONSchemaDefinitions { - if in == nil { - return nil - } - out := new(JSONSchemaDefinitions) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in JSONSchemaDependencies) DeepCopyInto(out *JSONSchemaDependencies) { - { - in := &in - *out = make(JSONSchemaDependencies, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - return - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaDependencies. -func (in JSONSchemaDependencies) DeepCopy() JSONSchemaDependencies { - if in == nil { - return nil - } - out := new(JSONSchemaDependencies) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaProps) DeepCopyInto(out *JSONSchemaProps) { - clone := in.DeepCopy() - *out = *clone - return -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaPropsOrArray) DeepCopyInto(out *JSONSchemaPropsOrArray) { - *out = *in - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - if in.JSONSchemas != nil { - in, out := &in.JSONSchemas, &out.JSONSchemas - *out = make([]JSONSchemaProps, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaPropsOrArray. -func (in *JSONSchemaPropsOrArray) DeepCopy() *JSONSchemaPropsOrArray { - if in == nil { - return nil - } - out := new(JSONSchemaPropsOrArray) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaPropsOrBool) DeepCopyInto(out *JSONSchemaPropsOrBool) { - *out = *in - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaPropsOrBool. -func (in *JSONSchemaPropsOrBool) DeepCopy() *JSONSchemaPropsOrBool { - if in == nil { - return nil - } - out := new(JSONSchemaPropsOrBool) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JSONSchemaPropsOrStringArray) DeepCopyInto(out *JSONSchemaPropsOrStringArray) { - *out = *in - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - if in.Property != nil { - in, out := &in.Property, &out.Property - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaPropsOrStringArray. -func (in *JSONSchemaPropsOrStringArray) DeepCopy() *JSONSchemaPropsOrStringArray { - if in == nil { - return nil - } - out := new(JSONSchemaPropsOrStringArray) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go deleted file mode 100644 index f1fc89ba9..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go +++ /dev/null @@ -1,214 +0,0 @@ -/* -Copyright 2017 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 apiserver - -import ( - "fmt" - "net/http" - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/version" - "k8s.io/apiserver/pkg/endpoints/discovery" - genericregistry "k8s.io/apiserver/pkg/registry/generic" - "k8s.io/apiserver/pkg/registry/rest" - genericapiserver "k8s.io/apiserver/pkg/server" - serverstorage "k8s.io/apiserver/pkg/server/storage" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset" - internalinformers "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion" - "k8s.io/apiextensions-apiserver/pkg/controller/establish" - "k8s.io/apiextensions-apiserver/pkg/controller/finalizer" - "k8s.io/apiextensions-apiserver/pkg/controller/status" - "k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition" - - _ "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - _ "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions" - _ "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion" -) - -var ( - Scheme = runtime.NewScheme() - Codecs = serializer.NewCodecFactory(Scheme) - - // if you modify this, make sure you update the crEncoder - unversionedVersion = schema.GroupVersion{Group: "", Version: "v1"} - unversionedTypes = []runtime.Object{ - &metav1.Status{}, - &metav1.WatchEvent{}, - &metav1.APIVersions{}, - &metav1.APIGroupList{}, - &metav1.APIGroup{}, - &metav1.APIResourceList{}, - } -) - -func init() { - install.Install(Scheme) - - // we need to add the options to empty v1 - metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Group: "", Version: "v1"}) - - Scheme.AddUnversionedTypes(unversionedVersion, unversionedTypes...) -} - -type ExtraConfig struct { - CRDRESTOptionsGetter genericregistry.RESTOptionsGetter - - // MasterCount is used to detect whether cluster is HA, and if it is - // the CRD Establishing will be hold by 5 seconds. - MasterCount int -} - -type Config struct { - GenericConfig *genericapiserver.RecommendedConfig - ExtraConfig ExtraConfig -} - -type completedConfig struct { - GenericConfig genericapiserver.CompletedConfig - ExtraConfig *ExtraConfig -} - -type CompletedConfig struct { - // Embed a private pointer that cannot be instantiated outside of this package. - *completedConfig -} - -type CustomResourceDefinitions struct { - GenericAPIServer *genericapiserver.GenericAPIServer - - // provided for easier embedding - Informers internalinformers.SharedInformerFactory -} - -// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver. -func (cfg *Config) Complete() CompletedConfig { - c := completedConfig{ - cfg.GenericConfig.Complete(), - &cfg.ExtraConfig, - } - - c.GenericConfig.EnableDiscovery = false - c.GenericConfig.Version = &version.Info{ - Major: "0", - Minor: "1", - } - - return CompletedConfig{&c} -} - -// New returns a new instance of CustomResourceDefinitions from the given config. -func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget) (*CustomResourceDefinitions, error) { - genericServer, err := c.GenericConfig.New("apiextensions-apiserver", delegationTarget) - if err != nil { - return nil, err - } - - s := &CustomResourceDefinitions{ - GenericAPIServer: genericServer, - } - - apiResourceConfig := c.GenericConfig.MergedResourceConfig - apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(apiextensions.GroupName, Scheme, metav1.ParameterCodec, Codecs) - if apiResourceConfig.VersionEnabled(v1beta1.SchemeGroupVersion) { - storage := map[string]rest.Storage{} - // customresourcedefinitions - customResourceDefintionStorage := customresourcedefinition.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter) - storage["customresourcedefinitions"] = customResourceDefintionStorage - storage["customresourcedefinitions/status"] = customresourcedefinition.NewStatusREST(Scheme, customResourceDefintionStorage) - - apiGroupInfo.VersionedResourcesStorageMap["v1beta1"] = storage - } - - if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil { - return nil, err - } - - crdClient, err := internalclientset.NewForConfig(s.GenericAPIServer.LoopbackClientConfig) - if err != nil { - // it's really bad that this is leaking here, but until we can fix the test (which I'm pretty sure isn't even testing what it wants to test), - // we need to be able to move forward - return nil, fmt.Errorf("failed to create clientset: %v", err) - } - s.Informers = internalinformers.NewSharedInformerFactory(crdClient, 5*time.Minute) - - delegateHandler := delegationTarget.UnprotectedHandler() - if delegateHandler == nil { - delegateHandler = http.NotFoundHandler() - } - - versionDiscoveryHandler := &versionDiscoveryHandler{ - discovery: map[schema.GroupVersion]*discovery.APIVersionHandler{}, - delegate: delegateHandler, - } - groupDiscoveryHandler := &groupDiscoveryHandler{ - discovery: map[string]*discovery.APIGroupHandler{}, - delegate: delegateHandler, - } - establishingController := establish.NewEstablishingController(s.Informers.Apiextensions().InternalVersion().CustomResourceDefinitions(), crdClient.Apiextensions()) - crdHandler := NewCustomResourceDefinitionHandler( - versionDiscoveryHandler, - groupDiscoveryHandler, - s.Informers.Apiextensions().InternalVersion().CustomResourceDefinitions(), - delegateHandler, - c.ExtraConfig.CRDRESTOptionsGetter, - c.GenericConfig.AdmissionControl, - establishingController, - c.ExtraConfig.MasterCount, - ) - s.GenericAPIServer.Handler.NonGoRestfulMux.Handle("/apis", crdHandler) - s.GenericAPIServer.Handler.NonGoRestfulMux.HandlePrefix("/apis/", crdHandler) - - crdController := NewDiscoveryController(s.Informers.Apiextensions().InternalVersion().CustomResourceDefinitions(), versionDiscoveryHandler, groupDiscoveryHandler) - namingController := status.NewNamingConditionController(s.Informers.Apiextensions().InternalVersion().CustomResourceDefinitions(), crdClient.Apiextensions()) - finalizingController := finalizer.NewCRDFinalizer( - s.Informers.Apiextensions().InternalVersion().CustomResourceDefinitions(), - crdClient.Apiextensions(), - crdHandler, - ) - - s.GenericAPIServer.AddPostStartHook("start-apiextensions-informers", func(context genericapiserver.PostStartHookContext) error { - s.Informers.Start(context.StopCh) - return nil - }) - s.GenericAPIServer.AddPostStartHook("start-apiextensions-controllers", func(context genericapiserver.PostStartHookContext) error { - go crdController.Run(context.StopCh) - go namingController.Run(context.StopCh) - go establishingController.Run(context.StopCh) - go finalizingController.Run(5, context.StopCh) - return nil - }) - - return s, nil -} - -func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig { - ret := serverstorage.NewResourceConfig() - // NOTE: GroupVersions listed here will be enabled by default. Don't put alpha versions in the list. - ret.EnableVersions( - v1beta1.SchemeGroupVersion, - ) - - return ret -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/converter.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/converter.go deleted file mode 100644 index 69f5340a9..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/converter.go +++ /dev/null @@ -1,117 +0,0 @@ -/* -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 conversion - -import ( - "fmt" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// NewCRDConverter returns a new CRD converter based on the conversion settings in crd object. -func NewCRDConverter(crd *apiextensions.CustomResourceDefinition) (safe, unsafe runtime.ObjectConvertor) { - validVersions := map[schema.GroupVersion]bool{} - for _, version := range crd.Spec.Versions { - validVersions[schema.GroupVersion{Group: crd.Spec.Group, Version: version.Name}] = true - } - - // The only converter right now is nopConverter. More converters will be returned based on the - // CRD object when they introduced. - unsafe = &crdConverter{ - clusterScoped: crd.Spec.Scope == apiextensions.ClusterScoped, - delegate: &nopConverter{ - validVersions: validVersions, - }, - } - return &safeConverterWrapper{unsafe}, unsafe -} - -var _ runtime.ObjectConvertor = &crdConverter{} - -// crdConverter extends the delegate with generic CRD conversion behaviour. The delegate will implement the -// user defined conversion strategy given in the CustomResourceDefinition. -type crdConverter struct { - delegate runtime.ObjectConvertor - clusterScoped bool -} - -func (c *crdConverter) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { - // We currently only support metadata.namespace and metadata.name. - switch { - case label == "metadata.name": - return label, value, nil - case !c.clusterScoped && label == "metadata.namespace": - return label, value, nil - default: - return "", "", fmt.Errorf("field label not supported: %s", label) - } -} - -func (c *crdConverter) Convert(in, out, context interface{}) error { - return c.delegate.Convert(in, out, context) -} - -// ConvertToVersion converts in object to the given gvk in place and returns the same `in` object. -func (c *crdConverter) ConvertToVersion(in runtime.Object, target runtime.GroupVersioner) (runtime.Object, error) { - // Run the converter on the list items instead of list itself - if list, ok := in.(*unstructured.UnstructuredList); ok { - for i := range list.Items { - obj, err := c.delegate.ConvertToVersion(&list.Items[i], target) - if err != nil { - return nil, err - } - - u, ok := obj.(*unstructured.Unstructured) - if !ok { - return nil, fmt.Errorf("output type %T in not valid for unstructured conversion", obj) - } - list.Items[i] = *u - } - return list, nil - } - - return c.delegate.ConvertToVersion(in, target) -} - -// safeConverterWrapper is a wrapper over an unsafe object converter that makes copy of the input and then delegate to the unsafe converter. -type safeConverterWrapper struct { - unsafe runtime.ObjectConvertor -} - -var _ runtime.ObjectConvertor = &nopConverter{} - -// ConvertFieldLabel delegate the call to the unsafe converter. -func (c *safeConverterWrapper) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { - return c.unsafe.ConvertFieldLabel(version, kind, label, value) -} - -// Convert makes a copy of in object and then delegate the call to the unsafe converter. -func (c *safeConverterWrapper) Convert(in, out, context interface{}) error { - inObject, ok := in.(runtime.Object) - if !ok { - return fmt.Errorf("input type %T in not valid for object conversion", in) - } - return c.unsafe.Convert(inObject.DeepCopyObject(), out, context) -} - -// ConvertToVersion makes a copy of in object and then delegate the call to the unsafe converter. -func (c *safeConverterWrapper) ConvertToVersion(in runtime.Object, target runtime.GroupVersioner) (runtime.Object, error) { - return c.unsafe.ConvertToVersion(in.DeepCopyObject(), target) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/nop_converter.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/nop_converter.go deleted file mode 100644 index 716930bfb..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/nop_converter.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -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 conversion - -import ( - "errors" - "fmt" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// nopConverter is a converter that only sets the apiVersion fields, but does not real conversion. -type nopConverter struct { - validVersions map[schema.GroupVersion]bool -} - -var _ runtime.ObjectConvertor = &nopConverter{} - -func (nopConverter) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { - return "", "", errors.New("unstructured cannot convert field labels") -} - -func (c *nopConverter) Convert(in, out, context interface{}) error { - unstructIn, ok := in.(*unstructured.Unstructured) - if !ok { - return fmt.Errorf("input type %T in not valid for unstructured conversion", in) - } - - unstructOut, ok := out.(*unstructured.Unstructured) - if !ok { - return fmt.Errorf("output type %T in not valid for unstructured conversion", out) - } - - outGVK := unstructOut.GroupVersionKind() - if !c.validVersions[outGVK.GroupVersion()] { - return fmt.Errorf("request to convert CRD from an invalid group/version: %s", outGVK.String()) - } - inGVK := unstructIn.GroupVersionKind() - if !c.validVersions[inGVK.GroupVersion()] { - return fmt.Errorf("request to convert CRD to an invalid group/version: %s", inGVK.String()) - } - - unstructOut.SetUnstructuredContent(unstructIn.UnstructuredContent()) - _, err := c.ConvertToVersion(unstructOut, outGVK.GroupVersion()) - if err != nil { - return err - } - return nil -} - -func (c *nopConverter) ConvertToVersion(in runtime.Object, target runtime.GroupVersioner) (runtime.Object, error) { - kind := in.GetObjectKind().GroupVersionKind() - gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{kind}) - if !ok { - // TODO: should this be a typed error? - return nil, fmt.Errorf("%v is unstructured and is not suitable for converting to %q", kind, target) - } - if !c.validVersions[gvk.GroupVersion()] { - return nil, fmt.Errorf("request to convert CRD to an invalid group/version: %s", gvk.String()) - } - in.GetObjectKind().SetGroupVersionKind(gvk) - return in, nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery.go deleted file mode 100644 index f40c33791..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery.go +++ /dev/null @@ -1,127 +0,0 @@ -/* -Copyright 2017 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 apiserver - -import ( - "net/http" - "strings" - "sync" - - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apiserver/pkg/endpoints/discovery" -) - -type versionDiscoveryHandler struct { - // TODO, writing is infrequent, optimize this - discoveryLock sync.RWMutex - discovery map[schema.GroupVersion]*discovery.APIVersionHandler - - delegate http.Handler -} - -func (r *versionDiscoveryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - pathParts := splitPath(req.URL.Path) - // only match /apis// - if len(pathParts) != 3 || pathParts[0] != "apis" { - r.delegate.ServeHTTP(w, req) - return - } - discovery, ok := r.getDiscovery(schema.GroupVersion{Group: pathParts[1], Version: pathParts[2]}) - if !ok { - r.delegate.ServeHTTP(w, req) - return - } - - discovery.ServeHTTP(w, req) -} - -func (r *versionDiscoveryHandler) getDiscovery(gv schema.GroupVersion) (*discovery.APIVersionHandler, bool) { - r.discoveryLock.RLock() - defer r.discoveryLock.RUnlock() - - ret, ok := r.discovery[gv] - return ret, ok -} - -func (r *versionDiscoveryHandler) setDiscovery(gv schema.GroupVersion, discovery *discovery.APIVersionHandler) { - r.discoveryLock.Lock() - defer r.discoveryLock.Unlock() - - r.discovery[gv] = discovery -} - -func (r *versionDiscoveryHandler) unsetDiscovery(gv schema.GroupVersion) { - r.discoveryLock.Lock() - defer r.discoveryLock.Unlock() - - delete(r.discovery, gv) -} - -type groupDiscoveryHandler struct { - // TODO, writing is infrequent, optimize this - discoveryLock sync.RWMutex - discovery map[string]*discovery.APIGroupHandler - - delegate http.Handler -} - -func (r *groupDiscoveryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - pathParts := splitPath(req.URL.Path) - // only match /apis/ - if len(pathParts) != 2 || pathParts[0] != "apis" { - r.delegate.ServeHTTP(w, req) - return - } - discovery, ok := r.getDiscovery(pathParts[1]) - if !ok { - r.delegate.ServeHTTP(w, req) - return - } - - discovery.ServeHTTP(w, req) -} - -func (r *groupDiscoveryHandler) getDiscovery(group string) (*discovery.APIGroupHandler, bool) { - r.discoveryLock.RLock() - defer r.discoveryLock.RUnlock() - - ret, ok := r.discovery[group] - return ret, ok -} - -func (r *groupDiscoveryHandler) setDiscovery(group string, discovery *discovery.APIGroupHandler) { - r.discoveryLock.Lock() - defer r.discoveryLock.Unlock() - - r.discovery[group] = discovery -} - -func (r *groupDiscoveryHandler) unsetDiscovery(group string) { - r.discoveryLock.Lock() - defer r.discoveryLock.Unlock() - - delete(r.discovery, group) -} - -// splitPath returns the segments for a URL path. -func splitPath(path string) []string { - path = strings.Trim(path, "/") - if path == "" { - return []string{} - } - return strings.Split(path, "/") -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery_controller.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery_controller.go deleted file mode 100644 index e3b3d0a44..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery_controller.go +++ /dev/null @@ -1,275 +0,0 @@ -/* -Copyright 2017 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 apiserver - -import ( - "fmt" - "sort" - "time" - - "github.com/golang/glog" - - autoscaling "k8s.io/api/autoscaling/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/apimachinery/pkg/version" - "k8s.io/apiserver/pkg/endpoints/discovery" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - informers "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion" - listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion" -) - -type DiscoveryController struct { - versionHandler *versionDiscoveryHandler - groupHandler *groupDiscoveryHandler - - crdLister listers.CustomResourceDefinitionLister - crdsSynced cache.InformerSynced - - // To allow injection for testing. - syncFn func(version schema.GroupVersion) error - - queue workqueue.RateLimitingInterface -} - -func NewDiscoveryController(crdInformer informers.CustomResourceDefinitionInformer, versionHandler *versionDiscoveryHandler, groupHandler *groupDiscoveryHandler) *DiscoveryController { - c := &DiscoveryController{ - versionHandler: versionHandler, - groupHandler: groupHandler, - crdLister: crdInformer.Lister(), - crdsSynced: crdInformer.Informer().HasSynced, - - queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "DiscoveryController"), - } - - crdInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: c.addCustomResourceDefinition, - UpdateFunc: c.updateCustomResourceDefinition, - DeleteFunc: c.deleteCustomResourceDefinition, - }) - - c.syncFn = c.sync - - return c -} - -func (c *DiscoveryController) sync(version schema.GroupVersion) error { - - apiVersionsForDiscovery := []metav1.GroupVersionForDiscovery{} - apiResourcesForDiscovery := []metav1.APIResource{} - versionsForDiscoveryMap := map[metav1.GroupVersion]bool{} - - crds, err := c.crdLister.List(labels.Everything()) - if err != nil { - return err - } - foundVersion := false - foundGroup := false - for _, crd := range crds { - if !apiextensions.IsCRDConditionTrue(crd, apiextensions.Established) { - continue - } - - if crd.Spec.Group != version.Group { - continue - } - - foundThisVersion := false - for _, v := range crd.Spec.Versions { - if !v.Served { - continue - } - // If there is any Served version, that means the group should show up in discovery - foundGroup = true - - gv := metav1.GroupVersion{Group: crd.Spec.Group, Version: v.Name} - if !versionsForDiscoveryMap[gv] { - versionsForDiscoveryMap[gv] = true - apiVersionsForDiscovery = append(apiVersionsForDiscovery, metav1.GroupVersionForDiscovery{ - GroupVersion: crd.Spec.Group + "/" + v.Name, - Version: v.Name, - }) - } - if v.Name == version.Version { - foundThisVersion = true - } - } - - if !foundThisVersion { - continue - } - foundVersion = true - - verbs := metav1.Verbs([]string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}) - // if we're terminating we don't allow some verbs - if apiextensions.IsCRDConditionTrue(crd, apiextensions.Terminating) { - verbs = metav1.Verbs([]string{"delete", "deletecollection", "get", "list", "watch"}) - } - - apiResourcesForDiscovery = append(apiResourcesForDiscovery, metav1.APIResource{ - Name: crd.Status.AcceptedNames.Plural, - SingularName: crd.Status.AcceptedNames.Singular, - Namespaced: crd.Spec.Scope == apiextensions.NamespaceScoped, - Kind: crd.Status.AcceptedNames.Kind, - Verbs: verbs, - ShortNames: crd.Status.AcceptedNames.ShortNames, - Categories: crd.Status.AcceptedNames.Categories, - }) - - if crd.Spec.Subresources != nil && crd.Spec.Subresources.Status != nil { - apiResourcesForDiscovery = append(apiResourcesForDiscovery, metav1.APIResource{ - Name: crd.Status.AcceptedNames.Plural + "/status", - Namespaced: crd.Spec.Scope == apiextensions.NamespaceScoped, - Kind: crd.Status.AcceptedNames.Kind, - Verbs: metav1.Verbs([]string{"get", "patch", "update"}), - }) - } - - if crd.Spec.Subresources != nil && crd.Spec.Subresources.Scale != nil { - apiResourcesForDiscovery = append(apiResourcesForDiscovery, metav1.APIResource{ - Group: autoscaling.GroupName, - Version: "v1", - Kind: "Scale", - Name: crd.Status.AcceptedNames.Plural + "/scale", - Namespaced: crd.Spec.Scope == apiextensions.NamespaceScoped, - Verbs: metav1.Verbs([]string{"get", "patch", "update"}), - }) - } - } - - if !foundGroup { - c.groupHandler.unsetDiscovery(version.Group) - c.versionHandler.unsetDiscovery(version) - return nil - } - - sortGroupDiscoveryByKubeAwareVersion(apiVersionsForDiscovery) - - apiGroup := metav1.APIGroup{ - Name: version.Group, - Versions: apiVersionsForDiscovery, - // the preferred versions for a group is the first item in - // apiVersionsForDiscovery after it put in the right ordered - PreferredVersion: apiVersionsForDiscovery[0], - } - c.groupHandler.setDiscovery(version.Group, discovery.NewAPIGroupHandler(Codecs, apiGroup)) - - if !foundVersion { - c.versionHandler.unsetDiscovery(version) - return nil - } - c.versionHandler.setDiscovery(version, discovery.NewAPIVersionHandler(Codecs, version, discovery.APIResourceListerFunc(func() []metav1.APIResource { - return apiResourcesForDiscovery - }))) - - return nil -} - -func sortGroupDiscoveryByKubeAwareVersion(gd []metav1.GroupVersionForDiscovery) { - sort.Slice(gd, func(i, j int) bool { - return version.CompareKubeAwareVersionStrings(gd[i].Version, gd[j].Version) > 0 - }) -} - -func (c *DiscoveryController) Run(stopCh <-chan struct{}) { - defer utilruntime.HandleCrash() - defer c.queue.ShutDown() - defer glog.Infof("Shutting down DiscoveryController") - - glog.Infof("Starting DiscoveryController") - - if !cache.WaitForCacheSync(stopCh, c.crdsSynced) { - utilruntime.HandleError(fmt.Errorf("timed out waiting for caches to sync")) - return - } - - // only start one worker thread since its a slow moving API - go wait.Until(c.runWorker, time.Second, stopCh) - - <-stopCh -} - -func (c *DiscoveryController) runWorker() { - for c.processNextWorkItem() { - } -} - -// processNextWorkItem deals with one key off the queue. It returns false when it's time to quit. -func (c *DiscoveryController) processNextWorkItem() bool { - key, quit := c.queue.Get() - if quit { - return false - } - defer c.queue.Done(key) - - err := c.syncFn(key.(schema.GroupVersion)) - if err == nil { - c.queue.Forget(key) - return true - } - - utilruntime.HandleError(fmt.Errorf("%v failed with: %v", key, err)) - c.queue.AddRateLimited(key) - - return true -} - -func (c *DiscoveryController) enqueue(obj *apiextensions.CustomResourceDefinition) { - for _, v := range obj.Spec.Versions { - c.queue.Add(schema.GroupVersion{Group: obj.Spec.Group, Version: v.Name}) - } -} - -func (c *DiscoveryController) addCustomResourceDefinition(obj interface{}) { - castObj := obj.(*apiextensions.CustomResourceDefinition) - glog.V(4).Infof("Adding customresourcedefinition %s", castObj.Name) - c.enqueue(castObj) -} - -func (c *DiscoveryController) updateCustomResourceDefinition(oldObj, newObj interface{}) { - castNewObj := newObj.(*apiextensions.CustomResourceDefinition) - castOldObj := oldObj.(*apiextensions.CustomResourceDefinition) - glog.V(4).Infof("Updating customresourcedefinition %s", castOldObj.Name) - // Enqueue both old and new object to make sure we remove and add appropriate Versions. - // The working queue will resolve any duplicates and only changes will stay in the queue. - c.enqueue(castNewObj) - c.enqueue(castOldObj) -} - -func (c *DiscoveryController) deleteCustomResourceDefinition(obj interface{}) { - castObj, ok := obj.(*apiextensions.CustomResourceDefinition) - if !ok { - tombstone, ok := obj.(cache.DeletedFinalStateUnknown) - if !ok { - glog.Errorf("Couldn't get object from tombstone %#v", obj) - return - } - castObj, ok = tombstone.Obj.(*apiextensions.CustomResourceDefinition) - if !ok { - glog.Errorf("Tombstone contained object that is not expected %#v", obj) - return - } - } - glog.V(4).Infof("Deleting customresourcedefinition %q", castObj.Name) - c.enqueue(castObj) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go deleted file mode 100644 index 7be3711dc..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go +++ /dev/null @@ -1,883 +0,0 @@ -/* -Copyright 2017 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 apiserver - -import ( - "fmt" - "net/http" - "path" - "strings" - "sync" - "sync/atomic" - "time" - - "github.com/go-openapi/spec" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/validate" - "github.com/golang/glog" - - apiequality "k8s.io/apimachinery/pkg/api/equality" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/runtime/serializer/json" - "k8s.io/apimachinery/pkg/runtime/serializer/versioning" - "k8s.io/apimachinery/pkg/types" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apiserver/pkg/admission" - "k8s.io/apiserver/pkg/endpoints/handlers" - "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters" - "k8s.io/apiserver/pkg/endpoints/metrics" - apirequest "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/generic" - genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" - "k8s.io/apiserver/pkg/storage/storagebackend" - utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/client-go/discovery" - "k8s.io/client-go/scale" - "k8s.io/client-go/scale/scheme/autoscalingv1" - "k8s.io/client-go/tools/cache" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apiextensions-apiserver/pkg/apiserver/conversion" - apiservervalidation "k8s.io/apiextensions-apiserver/pkg/apiserver/validation" - informers "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion" - listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion" - "k8s.io/apiextensions-apiserver/pkg/controller/establish" - "k8s.io/apiextensions-apiserver/pkg/controller/finalizer" - apiextensionsfeatures "k8s.io/apiextensions-apiserver/pkg/features" - "k8s.io/apiextensions-apiserver/pkg/registry/customresource" - "k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor" -) - -// crdHandler serves the `/apis` endpoint. -// This is registered as a filter so that it never collides with any explicitly registered endpoints -type crdHandler struct { - versionDiscoveryHandler *versionDiscoveryHandler - groupDiscoveryHandler *groupDiscoveryHandler - - customStorageLock sync.Mutex - // customStorage contains a crdStorageMap - // atomic.Value has a very good read performance compared to sync.RWMutex - // see https://gist.github.com/dim/152e6bf80e1384ea72e17ac717a5000a - // which is suited for most read and rarely write cases - customStorage atomic.Value - - crdLister listers.CustomResourceDefinitionLister - - delegate http.Handler - restOptionsGetter generic.RESTOptionsGetter - admission admission.Interface - - establishingController *establish.EstablishingController - - // MasterCount is used to implement sleep to improve - // CRD establishing process for HA clusters. - masterCount int -} - -// crdInfo stores enough information to serve the storage for the custom resource -type crdInfo struct { - // spec and acceptedNames are used to compare against if a change is made on a CRD. We only update - // the storage if one of these changes. - spec *apiextensions.CustomResourceDefinitionSpec - acceptedNames *apiextensions.CustomResourceDefinitionNames - - // Storage per version - storages map[string]customresource.CustomResourceStorage - - // Request scope per version - requestScopes map[string]handlers.RequestScope - - // Scale scope per version - scaleRequestScopes map[string]handlers.RequestScope - - // Status scope per version - statusRequestScopes map[string]handlers.RequestScope - - // storageVersion is the CRD version used when storing the object in etcd. - storageVersion string -} - -// crdStorageMap goes from customresourcedefinition to its storage -type crdStorageMap map[types.UID]*crdInfo - -func NewCustomResourceDefinitionHandler( - versionDiscoveryHandler *versionDiscoveryHandler, - groupDiscoveryHandler *groupDiscoveryHandler, - crdInformer informers.CustomResourceDefinitionInformer, - delegate http.Handler, - restOptionsGetter generic.RESTOptionsGetter, - admission admission.Interface, - establishingController *establish.EstablishingController, - masterCount int) *crdHandler { - ret := &crdHandler{ - versionDiscoveryHandler: versionDiscoveryHandler, - groupDiscoveryHandler: groupDiscoveryHandler, - customStorage: atomic.Value{}, - crdLister: crdInformer.Lister(), - delegate: delegate, - restOptionsGetter: restOptionsGetter, - admission: admission, - establishingController: establishingController, - masterCount: masterCount, - } - crdInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - UpdateFunc: ret.updateCustomResourceDefinition, - DeleteFunc: func(obj interface{}) { - ret.removeDeadStorage() - }, - }) - - ret.customStorage.Store(crdStorageMap{}) - - return ret -} - -func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - ctx := req.Context() - requestInfo, ok := apirequest.RequestInfoFrom(ctx) - if !ok { - responsewriters.InternalError(w, req, fmt.Errorf("no RequestInfo found in the context")) - return - } - if !requestInfo.IsResourceRequest { - pathParts := splitPath(requestInfo.Path) - // only match /apis// - // only registered under /apis - if len(pathParts) == 3 { - r.versionDiscoveryHandler.ServeHTTP(w, req) - return - } - // only match /apis/ - if len(pathParts) == 2 { - r.groupDiscoveryHandler.ServeHTTP(w, req) - return - } - - r.delegate.ServeHTTP(w, req) - return - } - - crdName := requestInfo.Resource + "." + requestInfo.APIGroup - crd, err := r.crdLister.Get(crdName) - if apierrors.IsNotFound(err) { - r.delegate.ServeHTTP(w, req) - return - } - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - if !apiextensions.HasServedCRDVersion(crd, requestInfo.APIVersion) { - r.delegate.ServeHTTP(w, req) - return - } - // There is a small chance that a CRD is being served because NamesAccepted condition is true, - // but it becomes "unserved" because another names update leads to a conflict - // and EstablishingController wasn't fast enough to put the CRD into the Established condition. - // We accept this as the problem is small and self-healing. - if !apiextensions.IsCRDConditionTrue(crd, apiextensions.NamesAccepted) && - !apiextensions.IsCRDConditionTrue(crd, apiextensions.Established) { - r.delegate.ServeHTTP(w, req) - return - } - - terminating := apiextensions.IsCRDConditionTrue(crd, apiextensions.Terminating) - - crdInfo, err := r.getOrCreateServingInfoFor(crd) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - verb := strings.ToUpper(requestInfo.Verb) - resource := requestInfo.Resource - subresource := requestInfo.Subresource - scope := metrics.CleanScope(requestInfo) - supportedTypes := []string{ - string(types.JSONPatchType), - string(types.MergePatchType), - } - - var handler http.HandlerFunc - switch { - case subresource == "status" && crd.Spec.Subresources != nil && crd.Spec.Subresources.Status != nil: - handler = r.serveStatus(w, req, requestInfo, crdInfo, terminating, supportedTypes) - case subresource == "scale" && crd.Spec.Subresources != nil && crd.Spec.Subresources.Scale != nil: - handler = r.serveScale(w, req, requestInfo, crdInfo, terminating, supportedTypes) - case len(subresource) == 0: - handler = r.serveResource(w, req, requestInfo, crdInfo, terminating, supportedTypes) - default: - http.Error(w, "the server could not find the requested resource", http.StatusNotFound) - } - - if handler != nil { - handler = metrics.InstrumentHandlerFunc(verb, resource, subresource, scope, handler) - handler(w, req) - return - } -} - -func (r *crdHandler) serveResource(w http.ResponseWriter, req *http.Request, requestInfo *apirequest.RequestInfo, crdInfo *crdInfo, terminating bool, supportedTypes []string) http.HandlerFunc { - requestScope := crdInfo.requestScopes[requestInfo.APIVersion] - storage := crdInfo.storages[requestInfo.APIVersion].CustomResource - minRequestTimeout := 1 * time.Minute - - switch requestInfo.Verb { - case "get": - return handlers.GetResource(storage, storage, requestScope) - case "list": - forceWatch := false - return handlers.ListResource(storage, storage, requestScope, forceWatch, minRequestTimeout) - case "watch": - forceWatch := true - return handlers.ListResource(storage, storage, requestScope, forceWatch, minRequestTimeout) - case "create": - if terminating { - http.Error(w, fmt.Sprintf("%v not allowed while CustomResourceDefinition is terminating", requestInfo.Verb), http.StatusMethodNotAllowed) - return nil - } - return handlers.CreateResource(storage, requestScope, r.admission) - case "update": - return handlers.UpdateResource(storage, requestScope, r.admission) - case "patch": - return handlers.PatchResource(storage, requestScope, r.admission, supportedTypes) - case "delete": - allowsOptions := true - return handlers.DeleteResource(storage, allowsOptions, requestScope, r.admission) - case "deletecollection": - checkBody := true - return handlers.DeleteCollection(storage, checkBody, requestScope, r.admission) - default: - http.Error(w, fmt.Sprintf("unhandled verb %q", requestInfo.Verb), http.StatusMethodNotAllowed) - return nil - } -} - -func (r *crdHandler) serveStatus(w http.ResponseWriter, req *http.Request, requestInfo *apirequest.RequestInfo, crdInfo *crdInfo, terminating bool, supportedTypes []string) http.HandlerFunc { - requestScope := crdInfo.statusRequestScopes[requestInfo.APIVersion] - storage := crdInfo.storages[requestInfo.APIVersion].Status - - switch requestInfo.Verb { - case "get": - return handlers.GetResource(storage, nil, requestScope) - case "update": - return handlers.UpdateResource(storage, requestScope, r.admission) - case "patch": - return handlers.PatchResource(storage, requestScope, r.admission, supportedTypes) - default: - http.Error(w, fmt.Sprintf("unhandled verb %q", requestInfo.Verb), http.StatusMethodNotAllowed) - return nil - } -} - -func (r *crdHandler) serveScale(w http.ResponseWriter, req *http.Request, requestInfo *apirequest.RequestInfo, crdInfo *crdInfo, terminating bool, supportedTypes []string) http.HandlerFunc { - requestScope := crdInfo.scaleRequestScopes[requestInfo.APIVersion] - storage := crdInfo.storages[requestInfo.APIVersion].Scale - - switch requestInfo.Verb { - case "get": - return handlers.GetResource(storage, nil, requestScope) - case "update": - return handlers.UpdateResource(storage, requestScope, r.admission) - case "patch": - return handlers.PatchResource(storage, requestScope, r.admission, supportedTypes) - default: - http.Error(w, fmt.Sprintf("unhandled verb %q", requestInfo.Verb), http.StatusMethodNotAllowed) - return nil - } -} - -func (r *crdHandler) updateCustomResourceDefinition(oldObj, newObj interface{}) { - oldCRD := oldObj.(*apiextensions.CustomResourceDefinition) - newCRD := newObj.(*apiextensions.CustomResourceDefinition) - - r.customStorageLock.Lock() - defer r.customStorageLock.Unlock() - - // Add CRD to the establishing controller queue. - // For HA clusters, we want to prevent race conditions when changing status to Established, - // so we want to be sure that CRD is Installing at least for 5 seconds before Establishing it. - // TODO: find a real HA safe checkpointing mechanism instead of an arbitrary wait. - if !apiextensions.IsCRDConditionTrue(newCRD, apiextensions.Established) && - apiextensions.IsCRDConditionTrue(newCRD, apiextensions.NamesAccepted) { - if r.masterCount > 1 { - r.establishingController.QueueCRD(newCRD.Name, 5*time.Second) - } else { - r.establishingController.QueueCRD(newCRD.Name, 0) - } - } - - storageMap := r.customStorage.Load().(crdStorageMap) - oldInfo, found := storageMap[newCRD.UID] - if !found { - return - } - if apiequality.Semantic.DeepEqual(&newCRD.Spec, oldInfo.spec) && apiequality.Semantic.DeepEqual(&newCRD.Status.AcceptedNames, oldInfo.acceptedNames) { - glog.V(6).Infof("Ignoring customresourcedefinition %s update because neither spec, nor accepted names changed", oldCRD.Name) - return - } - - glog.V(4).Infof("Updating customresourcedefinition %s", oldCRD.Name) - - // Copy because we cannot write to storageMap without a race - // as it is used without locking elsewhere. - storageMap2 := storageMap.clone() - if oldInfo, ok := storageMap2[types.UID(oldCRD.UID)]; ok { - for _, storage := range oldInfo.storages { - // destroy only the main storage. Those for the subresources share cacher and etcd clients. - storage.CustomResource.DestroyFunc() - } - delete(storageMap2, types.UID(oldCRD.UID)) - } - - r.customStorage.Store(storageMap2) -} - -// removeDeadStorage removes REST storage that isn't being used -func (r *crdHandler) removeDeadStorage() { - allCustomResourceDefinitions, err := r.crdLister.List(labels.Everything()) - if err != nil { - utilruntime.HandleError(err) - return - } - - r.customStorageLock.Lock() - defer r.customStorageLock.Unlock() - - storageMap := r.customStorage.Load().(crdStorageMap) - // Copy because we cannot write to storageMap without a race - // as it is used without locking elsewhere - storageMap2 := storageMap.clone() - for uid, s := range storageMap2 { - found := false - for _, crd := range allCustomResourceDefinitions { - if crd.UID == uid { - found = true - break - } - } - if !found { - glog.V(4).Infof("Removing dead CRD storage for %s/%s", s.spec.Group, s.spec.Names.Kind) - for _, storage := range s.storages { - // destroy only the main storage. Those for the subresources share cacher and etcd clients. - storage.CustomResource.DestroyFunc() - } - delete(storageMap2, uid) - } - } - r.customStorage.Store(storageMap2) -} - -// GetCustomResourceListerCollectionDeleter returns the ListerCollectionDeleter of -// the given crd. -func (r *crdHandler) GetCustomResourceListerCollectionDeleter(crd *apiextensions.CustomResourceDefinition) (finalizer.ListerCollectionDeleter, error) { - info, err := r.getOrCreateServingInfoFor(crd) - if err != nil { - return nil, err - } - return info.storages[info.storageVersion].CustomResource, nil -} - -var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc() - -func (r *crdHandler) getOrCreateServingInfoFor(crd *apiextensions.CustomResourceDefinition) (*crdInfo, error) { - storageMap := r.customStorage.Load().(crdStorageMap) - if ret, ok := storageMap[crd.UID]; ok { - return ret, nil - } - - r.customStorageLock.Lock() - defer r.customStorageLock.Unlock() - - storageMap = r.customStorage.Load().(crdStorageMap) - if ret, ok := storageMap[crd.UID]; ok { - return ret, nil - } - - storageVersion, err := apiextensions.GetCRDStorageVersion(crd) - if err != nil { - return nil, err - } - - // Scope/Storages per version. - requestScopes := map[string]handlers.RequestScope{} - storages := map[string]customresource.CustomResourceStorage{} - statusScopes := map[string]handlers.RequestScope{} - scaleScopes := map[string]handlers.RequestScope{} - - for _, v := range crd.Spec.Versions { - safeConverter, unsafeConverter := conversion.NewCRDConverter(crd) - // In addition to Unstructured objects (Custom Resources), we also may sometimes need to - // decode unversioned Options objects, so we delegate to parameterScheme for such types. - parameterScheme := runtime.NewScheme() - parameterScheme.AddUnversionedTypes(schema.GroupVersion{Group: crd.Spec.Group, Version: v.Name}, - &metav1.ListOptions{}, - &metav1.ExportOptions{}, - &metav1.GetOptions{}, - &metav1.DeleteOptions{}, - ) - parameterCodec := runtime.NewParameterCodec(parameterScheme) - - kind := schema.GroupVersionKind{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Status.AcceptedNames.Kind} - typer := newUnstructuredObjectTyper(parameterScheme) - creator := unstructuredCreator{} - - validator, _, err := apiservervalidation.NewSchemaValidator(crd.Spec.Validation) - if err != nil { - return nil, err - } - - var statusSpec *apiextensions.CustomResourceSubresourceStatus - var statusValidator *validate.SchemaValidator - if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) && crd.Spec.Subresources != nil && crd.Spec.Subresources.Status != nil { - statusSpec = crd.Spec.Subresources.Status - - // for the status subresource, validate only against the status schema - if crd.Spec.Validation != nil && crd.Spec.Validation.OpenAPIV3Schema != nil && crd.Spec.Validation.OpenAPIV3Schema.Properties != nil { - if statusSchema, ok := crd.Spec.Validation.OpenAPIV3Schema.Properties["status"]; ok { - openapiSchema := &spec.Schema{} - if err := apiservervalidation.ConvertJSONSchemaProps(&statusSchema, openapiSchema); err != nil { - return nil, err - } - statusValidator = validate.NewSchemaValidator(openapiSchema, nil, "", strfmt.Default) - } - } - } - - var scaleSpec *apiextensions.CustomResourceSubresourceScale - if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) && crd.Spec.Subresources != nil && crd.Spec.Subresources.Scale != nil { - scaleSpec = crd.Spec.Subresources.Scale - } - - table, err := tableconvertor.New(crd.Spec.AdditionalPrinterColumns) - if err != nil { - glog.V(2).Infof("The CRD for %v has an invalid printer specification, falling back to default printing: %v", kind, err) - } - - storages[v.Name] = customresource.NewStorage( - schema.GroupResource{Group: crd.Spec.Group, Resource: crd.Status.AcceptedNames.Plural}, - schema.GroupVersionKind{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Status.AcceptedNames.ListKind}, - customresource.NewStrategy( - typer, - crd.Spec.Scope == apiextensions.NamespaceScoped, - kind, - validator, - statusValidator, - statusSpec, - scaleSpec, - ), - crdConversionRESTOptionsGetter{ - RESTOptionsGetter: r.restOptionsGetter, - converter: safeConverter, - decoderVersion: schema.GroupVersion{Group: crd.Spec.Group, Version: v.Name}, - encoderVersion: schema.GroupVersion{Group: crd.Spec.Group, Version: storageVersion}, - }, - crd.Status.AcceptedNames.Categories, - table, - ) - - selfLinkPrefix := "" - switch crd.Spec.Scope { - case apiextensions.ClusterScoped: - selfLinkPrefix = "/" + path.Join("apis", crd.Spec.Group, v.Name) + "/" + crd.Status.AcceptedNames.Plural + "/" - case apiextensions.NamespaceScoped: - selfLinkPrefix = "/" + path.Join("apis", crd.Spec.Group, v.Name, "namespaces") + "/" - } - - clusterScoped := crd.Spec.Scope == apiextensions.ClusterScoped - - requestScopes[v.Name] = handlers.RequestScope{ - Namer: handlers.ContextBasedNaming{ - SelfLinker: meta.NewAccessor(), - ClusterScoped: clusterScoped, - SelfLinkPathPrefix: selfLinkPrefix, - }, - Serializer: unstructuredNegotiatedSerializer{typer: typer, creator: creator, converter: safeConverter}, - ParameterCodec: parameterCodec, - - Creater: creator, - Convertor: safeConverter, - Defaulter: unstructuredDefaulter{parameterScheme}, - Typer: typer, - UnsafeConvertor: unsafeConverter, - - Resource: schema.GroupVersionResource{Group: crd.Spec.Group, Version: v.Name, Resource: crd.Status.AcceptedNames.Plural}, - Kind: kind, - - MetaGroupVersion: metav1.SchemeGroupVersion, - - TableConvertor: storages[v.Name].CustomResource, - } - - // override scaleSpec subresource values - // shallow copy - scaleScope := requestScopes[v.Name] - scaleConverter := scale.NewScaleConverter() - scaleScope.Subresource = "scale" - scaleScope.Serializer = serializer.NewCodecFactory(scaleConverter.Scheme()) - scaleScope.Kind = autoscalingv1.SchemeGroupVersion.WithKind("Scale") - scaleScope.Namer = handlers.ContextBasedNaming{ - SelfLinker: meta.NewAccessor(), - ClusterScoped: clusterScoped, - SelfLinkPathPrefix: selfLinkPrefix, - SelfLinkPathSuffix: "/scale", - } - scaleScopes[v.Name] = scaleScope - - // override status subresource values - // shallow copy - statusScope := requestScopes[v.Name] - statusScope.Subresource = "status" - statusScope.Namer = handlers.ContextBasedNaming{ - SelfLinker: meta.NewAccessor(), - ClusterScoped: clusterScoped, - SelfLinkPathPrefix: selfLinkPrefix, - SelfLinkPathSuffix: "/status", - } - statusScopes[v.Name] = statusScope - } - - ret := &crdInfo{ - spec: &crd.Spec, - acceptedNames: &crd.Status.AcceptedNames, - storages: storages, - requestScopes: requestScopes, - scaleRequestScopes: scaleScopes, - statusRequestScopes: statusScopes, - storageVersion: storageVersion, - } - - // Copy because we cannot write to storageMap without a race - // as it is used without locking elsewhere. - storageMap2 := storageMap.clone() - - storageMap2[crd.UID] = ret - r.customStorage.Store(storageMap2) - - return ret, nil -} - -type unstructuredNegotiatedSerializer struct { - typer runtime.ObjectTyper - creator runtime.ObjectCreater - converter runtime.ObjectConvertor -} - -func (s unstructuredNegotiatedSerializer) SupportedMediaTypes() []runtime.SerializerInfo { - return []runtime.SerializerInfo{ - { - MediaType: "application/json", - EncodesAsText: true, - Serializer: json.NewSerializer(json.DefaultMetaFactory, s.creator, s.typer, false), - PrettySerializer: json.NewSerializer(json.DefaultMetaFactory, s.creator, s.typer, true), - StreamSerializer: &runtime.StreamSerializerInfo{ - EncodesAsText: true, - Serializer: json.NewSerializer(json.DefaultMetaFactory, s.creator, s.typer, false), - Framer: json.Framer, - }, - }, - { - MediaType: "application/yaml", - EncodesAsText: true, - Serializer: json.NewYAMLSerializer(json.DefaultMetaFactory, s.creator, s.typer), - }, - } -} - -func (s unstructuredNegotiatedSerializer) EncoderForVersion(encoder runtime.Encoder, gv runtime.GroupVersioner) runtime.Encoder { - return versioning.NewCodec(encoder, nil, s.converter, Scheme, Scheme, Scheme, gv, nil) -} - -func (s unstructuredNegotiatedSerializer) DecoderToVersion(decoder runtime.Decoder, gv runtime.GroupVersioner) runtime.Decoder { - d := schemaCoercingDecoder{delegate: decoder, validator: unstructuredSchemaCoercer{}} - return versioning.NewDefaultingCodecForScheme(Scheme, nil, d, nil, gv) -} - -type UnstructuredObjectTyper struct { - Delegate runtime.ObjectTyper - UnstructuredTyper runtime.ObjectTyper -} - -func newUnstructuredObjectTyper(Delegate runtime.ObjectTyper) UnstructuredObjectTyper { - return UnstructuredObjectTyper{ - Delegate: Delegate, - UnstructuredTyper: discovery.NewUnstructuredObjectTyper(), - } -} - -func (t UnstructuredObjectTyper) ObjectKinds(obj runtime.Object) ([]schema.GroupVersionKind, bool, error) { - // Delegate for things other than Unstructured. - if _, ok := obj.(runtime.Unstructured); !ok { - return t.Delegate.ObjectKinds(obj) - } - return t.UnstructuredTyper.ObjectKinds(obj) -} - -func (t UnstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool { - return t.Delegate.Recognizes(gvk) || t.UnstructuredTyper.Recognizes(gvk) -} - -type unstructuredCreator struct{} - -func (c unstructuredCreator) New(kind schema.GroupVersionKind) (runtime.Object, error) { - ret := &unstructured.Unstructured{} - ret.SetGroupVersionKind(kind) - return ret, nil -} - -type unstructuredDefaulter struct { - delegate runtime.ObjectDefaulter -} - -func (d unstructuredDefaulter) Default(in runtime.Object) { - // Delegate for things other than Unstructured. - if _, ok := in.(runtime.Unstructured); !ok { - d.delegate.Default(in) - } -} - -type CRDRESTOptionsGetter struct { - StorageConfig storagebackend.Config - StoragePrefix string - EnableWatchCache bool - DefaultWatchCacheSize int - EnableGarbageCollection bool - DeleteCollectionWorkers int -} - -func (t CRDRESTOptionsGetter) GetRESTOptions(resource schema.GroupResource) (generic.RESTOptions, error) { - ret := generic.RESTOptions{ - StorageConfig: &t.StorageConfig, - Decorator: generic.UndecoratedStorage, - EnableGarbageCollection: t.EnableGarbageCollection, - DeleteCollectionWorkers: t.DeleteCollectionWorkers, - ResourcePrefix: resource.Group + "/" + resource.Resource, - } - if t.EnableWatchCache { - ret.Decorator = genericregistry.StorageWithCacher(t.DefaultWatchCacheSize) - } - return ret, nil -} - -// clone returns a clone of the provided crdStorageMap. -// The clone is a shallow copy of the map. -func (in crdStorageMap) clone() crdStorageMap { - if in == nil { - return nil - } - out := make(crdStorageMap, len(in)) - for key, value := range in { - out[key] = value - } - return out -} - -// crdConversionRESTOptionsGetter overrides the codec with one using the -// provided custom converter and custom encoder and decoder version. -type crdConversionRESTOptionsGetter struct { - generic.RESTOptionsGetter - converter runtime.ObjectConvertor - encoderVersion schema.GroupVersion - decoderVersion schema.GroupVersion -} - -func (t crdConversionRESTOptionsGetter) GetRESTOptions(resource schema.GroupResource) (generic.RESTOptions, error) { - ret, err := t.RESTOptionsGetter.GetRESTOptions(resource) - if err == nil { - d := schemaCoercingDecoder{delegate: ret.StorageConfig.Codec, validator: unstructuredSchemaCoercer{ - // drop invalid fields while decoding old CRs (before we had any ObjectMeta validation) - dropInvalidMetadata: true, - }} - c := schemaCoercingConverter{delegate: t.converter, validator: unstructuredSchemaCoercer{}} - ret.StorageConfig.Codec = versioning.NewCodec(ret.StorageConfig.Codec, d, c, &unstructuredCreator{}, discovery.NewUnstructuredObjectTyper(), &unstructuredDefaulter{delegate: Scheme}, t.encoderVersion, t.decoderVersion) - } - return ret, err -} - -// schemaCoercingDecoder calls the delegate decoder, and then applies the Unstructured schema validator -// to coerce the schema. -type schemaCoercingDecoder struct { - delegate runtime.Decoder - validator unstructuredSchemaCoercer -} - -var _ runtime.Decoder = schemaCoercingDecoder{} - -func (d schemaCoercingDecoder) Decode(data []byte, defaults *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) { - obj, gvk, err := d.delegate.Decode(data, defaults, into) - if err != nil { - return nil, gvk, err - } - if u, ok := obj.(*unstructured.Unstructured); ok { - if err := d.validator.apply(u); err != nil { - return nil, gvk, err - } - } - - return obj, gvk, nil -} - -// schemaCoercingConverter calls the delegate converter and applies the Unstructured validator to -// coerce the schema. -type schemaCoercingConverter struct { - delegate runtime.ObjectConvertor - validator unstructuredSchemaCoercer -} - -var _ runtime.ObjectConvertor = schemaCoercingConverter{} - -func (v schemaCoercingConverter) Convert(in, out, context interface{}) error { - if err := v.delegate.Convert(in, out, context); err != nil { - return err - } - - if u, ok := out.(*unstructured.Unstructured); ok { - if err := v.validator.apply(u); err != nil { - return err - } - } - - return nil -} - -func (v schemaCoercingConverter) ConvertToVersion(in runtime.Object, gv runtime.GroupVersioner) (runtime.Object, error) { - out, err := v.delegate.ConvertToVersion(in, gv) - if err != nil { - return nil, err - } - - if u, ok := out.(*unstructured.Unstructured); ok { - if err := v.validator.apply(u); err != nil { - return nil, err - } - } - - return out, nil -} - -func (v schemaCoercingConverter) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { - return v.ConvertFieldLabel(version, kind, label, value) -} - -// unstructuredSchemaCoercer does the validation for Unstructured that json.Unmarshal -// does for native types. This includes: -// - validating and pruning ObjectMeta (here with optional error instead of pruning) -// - TODO: application of an OpenAPI validator (against the whole object or a top-level field of it). -// - TODO: optionally application of post-validation algorithms like defaulting and/or OpenAPI based pruning. -type unstructuredSchemaCoercer struct { - dropInvalidMetadata bool -} - -func (v *unstructuredSchemaCoercer) apply(u *unstructured.Unstructured) error { - // save implicit meta fields that don't have to be specified in the validation spec - kind, foundKind, err := unstructured.NestedString(u.UnstructuredContent(), "kind") - if err != nil { - return err - } - apiVersion, foundApiVersion, err := unstructured.NestedString(u.UnstructuredContent(), "apiVersion") - if err != nil { - return err - } - objectMeta, foundObjectMeta, err := getObjectMeta(u, v.dropInvalidMetadata) - if err != nil { - return err - } - - // restore meta fields, starting clean - if foundKind { - u.SetKind(kind) - } - if foundApiVersion { - u.SetAPIVersion(apiVersion) - } - if foundObjectMeta { - if err := setObjectMeta(u, objectMeta); err != nil { - return err - } - } - - return nil -} - -var encodingjson = json.CaseSensitiveJsonIterator() - -func getObjectMeta(u *unstructured.Unstructured, dropMalformedFields bool) (*metav1.ObjectMeta, bool, error) { - metadata, found := u.UnstructuredContent()["metadata"] - if !found { - return nil, false, nil - } - - // round-trip through JSON first, hoping that unmarshaling just works - objectMeta := &metav1.ObjectMeta{} - metadataBytes, err := encodingjson.Marshal(metadata) - if err != nil { - return nil, false, err - } - if err = encodingjson.Unmarshal(metadataBytes, objectMeta); err == nil { - // if successful, return - return objectMeta, true, nil - } - if !dropMalformedFields { - // if we're not trying to drop malformed fields, return the error - return nil, true, err - } - - metadataMap, ok := metadata.(map[string]interface{}) - if !ok { - return nil, false, fmt.Errorf("invalid metadata: expected object, got %T", metadata) - } - - // Go field by field accumulating into the metadata object. - // This takes advantage of the fact that you can repeatedly unmarshal individual fields into a single struct, - // each iteration preserving the old key-values. - accumulatedObjectMeta := &metav1.ObjectMeta{} - testObjectMeta := &metav1.ObjectMeta{} - for k, v := range metadataMap { - // serialize a single field - if singleFieldBytes, err := encodingjson.Marshal(map[string]interface{}{k: v}); err == nil { - // do a test unmarshal - if encodingjson.Unmarshal(singleFieldBytes, testObjectMeta) == nil { - // if that succeeds, unmarshal for real - encodingjson.Unmarshal(singleFieldBytes, accumulatedObjectMeta) - } - } - } - - return accumulatedObjectMeta, true, nil -} - -func setObjectMeta(u *unstructured.Unstructured, objectMeta *metav1.ObjectMeta) error { - if objectMeta == nil { - unstructured.RemoveNestedField(u.UnstructuredContent(), "metadata") - return nil - } - - metadata, err := runtime.DefaultUnstructuredConverter.ToUnstructured(objectMeta) - if err != nil { - return err - } - - u.UnstructuredContent()["metadata"] = metadata - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler_test.go deleted file mode 100644 index a6d6e23a1..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler_test.go +++ /dev/null @@ -1,308 +0,0 @@ -/* -Copyright 2017 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 apiserver - -import ( - "math/rand" - "reflect" - "testing" - - corev1 "k8s.io/api/core/v1" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apiextensions-apiserver/pkg/apiserver/conversion" - "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/api/testing/fuzzer" - metafuzzer "k8s.io/apimachinery/pkg/apis/meta/fuzzer" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/runtime/serializer/json" - "k8s.io/apimachinery/pkg/util/diff" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" -) - -func TestConvertFieldLabel(t *testing.T) { - tests := []struct { - name string - clusterScoped bool - label string - expectError bool - }{ - { - name: "cluster scoped - name is ok", - clusterScoped: true, - label: "metadata.name", - }, - { - name: "cluster scoped - namespace is not ok", - clusterScoped: true, - label: "metadata.namespace", - expectError: true, - }, - { - name: "cluster scoped - other field is not ok", - clusterScoped: true, - label: "some.other.field", - expectError: true, - }, - { - name: "namespace scoped - name is ok", - label: "metadata.name", - }, - { - name: "namespace scoped - namespace is ok", - label: "metadata.namespace", - }, - { - name: "namespace scoped - other field is not ok", - label: "some.other.field", - expectError: true, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - - crd := apiextensions.CustomResourceDefinition{} - - if test.clusterScoped { - crd.Spec.Scope = apiextensions.ClusterScoped - } else { - crd.Spec.Scope = apiextensions.NamespaceScoped - } - _, c := conversion.NewCRDConverter(&crd) - - label, value, err := c.ConvertFieldLabel("", "", test.label, "value") - if e, a := test.expectError, err != nil; e != a { - t.Fatalf("err: expected %t, got %t", e, a) - } - if test.expectError { - if e, a := "field label not supported: "+test.label, err.Error(); e != a { - t.Errorf("err: expected %s, got %s", e, a) - } - return - } - - if e, a := test.label, label; e != a { - t.Errorf("label: expected %s, got %s", e, a) - } - if e, a := "value", value; e != a { - t.Errorf("value: expected %s, got %s", e, a) - } - }) - } -} - -func TestRoundtripObjectMeta(t *testing.T) { - scheme := runtime.NewScheme() - codecs := serializer.NewCodecFactory(scheme) - codec := json.NewSerializer(json.DefaultMetaFactory, scheme, scheme, false) - seed := rand.Int63() - fuzzer := fuzzer.FuzzerFor(metafuzzer.Funcs, rand.NewSource(seed), codecs) - - N := 1000 - for i := 0; i < N; i++ { - u := &unstructured.Unstructured{Object: map[string]interface{}{}} - original := &metav1.ObjectMeta{} - fuzzer.Fuzz(original) - if err := setObjectMeta(u, original); err != nil { - t.Fatalf("unexpected error setting ObjectMeta: %v", err) - } - o, _, err := getObjectMeta(u, false) - if err != nil { - t.Fatalf("unexpected error getting the Objectmeta: %v", err) - } - - if !equality.Semantic.DeepEqual(original, o) { - t.Errorf("diff: %v\nCodec: %#v", diff.ObjectReflectDiff(original, o), codec) - } - } -} - -// TestMalformedObjectMetaFields sets a number of different random values and types for all -// metadata fields. If json.Unmarshal accepts them, compare that getObjectMeta -// gives the same result. Otherwise, drop malformed fields. -func TestMalformedObjectMetaFields(t *testing.T) { - fuzzer := fuzzer.FuzzerFor(metafuzzer.Funcs, rand.NewSource(rand.Int63()), serializer.NewCodecFactory(runtime.NewScheme())) - spuriousValues := func() []interface{} { - return []interface{}{ - // primitives - nil, - int64(1), - float64(1.5), - true, - "a", - // well-formed complex values - []interface{}{"a", "b"}, - map[string]interface{}{"a": "1", "b": "2"}, - []interface{}{int64(1), int64(2)}, - []interface{}{float64(1.5), float64(2.5)}, - // known things json decoding tolerates - map[string]interface{}{"a": "1", "b": nil}, - // malformed things - map[string]interface{}{"a": "1", "b": []interface{}{"nested"}}, - []interface{}{"a", int64(1), float64(1.5), true, []interface{}{"nested"}}, - } - } - N := 100 - for i := 0; i < N; i++ { - fuzzedObjectMeta := &metav1.ObjectMeta{} - fuzzer.Fuzz(fuzzedObjectMeta) - goodMetaMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(fuzzedObjectMeta.DeepCopy()) - if err != nil { - t.Fatal(err) - } - for _, pth := range jsonPaths(nil, goodMetaMap) { - for _, v := range spuriousValues() { - // skip values of same type, because they can only cause decoding errors further insides - orig, err := JsonPathValue(goodMetaMap, pth, 0) - if err != nil { - t.Fatalf("unexpected to not find something at %v: %v", pth, err) - } - if reflect.TypeOf(v) == reflect.TypeOf(orig) { - continue - } - - // make a spurious map - spuriousMetaMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(fuzzedObjectMeta.DeepCopy()) - if err != nil { - t.Fatal(err) - } - if err := SetJsonPath(spuriousMetaMap, pth, 0, v); err != nil { - t.Fatal(err) - } - - // See if it can unmarshal to object meta - spuriousJSON, err := encodingjson.Marshal(spuriousMetaMap) - if err != nil { - t.Fatalf("error on %v=%#v: %v", pth, v, err) - } - expectedObjectMeta := &metav1.ObjectMeta{} - if err := encodingjson.Unmarshal(spuriousJSON, expectedObjectMeta); err != nil { - // if standard json unmarshal would fail decoding this field, drop the field entirely - truncatedMetaMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(fuzzedObjectMeta.DeepCopy()) - if err != nil { - t.Fatal(err) - } - - // we expect this logic for the different fields: - switch { - default: - // delete complete top-level field by default - DeleteJsonPath(truncatedMetaMap, pth[:1], 0) - } - - truncatedJSON, err := encodingjson.Marshal(truncatedMetaMap) - if err != nil { - t.Fatalf("error on %v=%#v: %v", pth, v, err) - } - expectedObjectMeta = &metav1.ObjectMeta{} - if err := encodingjson.Unmarshal(truncatedJSON, expectedObjectMeta); err != nil { - t.Fatalf("error on %v=%#v: %v", pth, v, err) - } - } - - // make sure dropInvalidTypedFields+getObjectMeta matches what we expect - u := &unstructured.Unstructured{Object: map[string]interface{}{"metadata": spuriousMetaMap}} - actualObjectMeta, _, err := getObjectMeta(u, true) - if err != nil { - t.Errorf("got unexpected error after dropping invalid typed fields on %v=%#v: %v", pth, v, err) - continue - } - - if !equality.Semantic.DeepEqual(expectedObjectMeta, actualObjectMeta) { - t.Errorf("%v=%#v, diff: %v\n", pth, v, diff.ObjectReflectDiff(expectedObjectMeta, actualObjectMeta)) - t.Errorf("expectedObjectMeta %#v", expectedObjectMeta) - } - } - } - } -} - -func TestGetObjectMetaNils(t *testing.T) { - u := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "kind": "Pod", - "apiVersion": "v1", - "metadata": map[string]interface{}{ - "generateName": nil, - "labels": map[string]interface{}{ - "foo": nil, - }, - }, - }, - } - - o, _, err := getObjectMeta(u, true) - if err != nil { - t.Fatal(err) - } - if o.GenerateName != "" { - t.Errorf("expected null json value to be read as \"\" string, but got: %q", o.GenerateName) - } - if got, expected := o.Labels, map[string]string{"foo": ""}; !reflect.DeepEqual(got, expected) { - t.Errorf("unexpected labels, expected=%#v, got=%#v", expected, got) - } - - // double check this what the kube JSON decode is doing - bs, _ := encodingjson.Marshal(u.UnstructuredContent()) - kubeObj, _, err := clientgoscheme.Codecs.UniversalDecoder(corev1.SchemeGroupVersion).Decode(bs, nil, nil) - if err != nil { - t.Fatal(err) - } - pod, ok := kubeObj.(*corev1.Pod) - if !ok { - t.Fatalf("expected v1 Pod, got: %T", pod) - } - if got, expected := o.GenerateName, pod.ObjectMeta.GenerateName; got != expected { - t.Errorf("expected generatedName to be %q, got %q", expected, got) - } - if got, expected := o.Labels, pod.ObjectMeta.Labels; !reflect.DeepEqual(got, expected) { - t.Errorf("expected labels to be %v, got %v", expected, got) - } -} - -func TestGetObjectMeta(t *testing.T) { - for i := 0; i < 100; i++ { - u := &unstructured.Unstructured{Object: map[string]interface{}{ - "metadata": map[string]interface{}{ - "name": "good", - "Name": "bad1", - "nAme": "bad2", - "naMe": "bad3", - "namE": "bad4", - - "namespace": "good", - "Namespace": "bad1", - "nAmespace": "bad2", - "naMespace": "bad3", - "namEspace": "bad4", - - "creationTimestamp": "a", - }, - }} - - meta, _, err := getObjectMeta(u, true) - if err != nil { - t.Fatal(err) - } - if meta.Name != "good" || meta.Namespace != "good" { - t.Fatalf("got %#v", meta) - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/jsonpath_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/jsonpath_test.go deleted file mode 100644 index 8d9bb24f8..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/jsonpath_test.go +++ /dev/null @@ -1,235 +0,0 @@ -/* -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 apiserver - -import ( - "bytes" - "fmt" - - "k8s.io/apimachinery/pkg/runtime" -) - -type ( - jsonPathNode struct { - index *int - field string - } - JsonPath []jsonPathNode -) - -func (p JsonPath) String() string { - var buf bytes.Buffer - for _, n := range p { - if n.index == nil { - buf.WriteString("." + n.field) - } else { - buf.WriteString(fmt.Sprintf("[%d]", *n.index)) - } - } - return buf.String() -} - -func jsonPaths(base JsonPath, j map[string]interface{}) []JsonPath { - res := make([]JsonPath, 0, len(j)) - for k, old := range j { - kPth := append(append([]jsonPathNode(nil), base...), jsonPathNode{field: k}) - res = append(res, kPth) - - switch old := old.(type) { - case map[string]interface{}: - res = append(res, jsonPaths(kPth, old)...) - case []interface{}: - res = append(res, jsonIterSlice(kPth, old)...) - } - } - return res -} - -func jsonIterSlice(base JsonPath, j []interface{}) []JsonPath { - res := make([]JsonPath, 0, len(j)) - for i, old := range j { - index := i - iPth := append(append([]jsonPathNode(nil), base...), jsonPathNode{index: &index}) - res = append(res, iPth) - - switch old := old.(type) { - case map[string]interface{}: - res = append(res, jsonPaths(iPth, old)...) - case []interface{}: - res = append(res, jsonIterSlice(iPth, old)...) - } - } - return res -} - -func JsonPathValue(j map[string]interface{}, pth JsonPath, base int) (interface{}, error) { - if len(pth) == base { - return nil, fmt.Errorf("empty json path is invalid for object") - } - if pth[base].index != nil { - return nil, fmt.Errorf("index json path is invalid for object") - } - field, ok := j[pth[base].field] - if !ok || len(pth) == base+1 { - if len(pth) > base+1 { - return nil, fmt.Errorf("invalid non-terminal json path %q for non-existing field", pth) - } - return j[pth[base].field], nil - } - switch field := field.(type) { - case map[string]interface{}: - return JsonPathValue(field, pth, base+1) - case []interface{}: - return jsonPathValueSlice(field, pth, base+1) - default: - return nil, fmt.Errorf("invalid non-terminal json path %q for field", pth[:base+1]) - } -} - -func jsonPathValueSlice(j []interface{}, pth JsonPath, base int) (interface{}, error) { - if len(pth) == base { - return nil, fmt.Errorf("empty json path %q is invalid for object", pth) - } - if pth[base].index == nil { - return nil, fmt.Errorf("field json path %q is invalid for object", pth[:base+1]) - } - if *pth[base].index >= len(j) { - return nil, fmt.Errorf("invalid index %q for array of size %d", pth[:base+1], len(j)) - } - if len(pth) == base+1 { - return j[*pth[base].index], nil - } - switch item := j[*pth[base].index].(type) { - case map[string]interface{}: - return JsonPathValue(item, pth, base+1) - case []interface{}: - return jsonPathValueSlice(item, pth, base+1) - default: - return nil, fmt.Errorf("invalid non-terminal json path %q for index", pth[:base+1]) - } -} - -func SetJsonPath(j map[string]interface{}, pth JsonPath, base int, value interface{}) error { - if len(pth) == base { - return fmt.Errorf("empty json path is invalid for object") - } - if pth[base].index != nil { - return fmt.Errorf("index json path is invalid for object") - } - field, ok := j[pth[base].field] - if !ok || len(pth) == base+1 { - if len(pth) > base+1 { - return fmt.Errorf("invalid non-terminal json path %q for non-existing field", pth) - } - j[pth[base].field] = runtime.DeepCopyJSONValue(value) - return nil - } - switch field := field.(type) { - case map[string]interface{}: - return SetJsonPath(field, pth, base+1, value) - case []interface{}: - return setJsonPathSlice(field, pth, base+1, value) - default: - return fmt.Errorf("invalid non-terminal json path %q for field", pth[:base+1]) - } -} - -func setJsonPathSlice(j []interface{}, pth JsonPath, base int, value interface{}) error { - if len(pth) == base { - return fmt.Errorf("empty json path %q is invalid for object", pth) - } - if pth[base].index == nil { - return fmt.Errorf("field json path %q is invalid for object", pth[:base+1]) - } - if *pth[base].index >= len(j) { - return fmt.Errorf("invalid index %q for array of size %d", pth[:base+1], len(j)) - } - if len(pth) == base+1 { - j[*pth[base].index] = runtime.DeepCopyJSONValue(value) - return nil - } - switch item := j[*pth[base].index].(type) { - case map[string]interface{}: - return SetJsonPath(item, pth, base+1, value) - case []interface{}: - return setJsonPathSlice(item, pth, base+1, value) - default: - return fmt.Errorf("invalid non-terminal json path %q for index", pth[:base+1]) - } -} - -func DeleteJsonPath(j map[string]interface{}, pth JsonPath, base int) error { - if len(pth) == base { - return fmt.Errorf("empty json path is invalid for object") - } - if pth[base].index != nil { - return fmt.Errorf("index json path is invalid for object") - } - field, ok := j[pth[base].field] - if !ok || len(pth) == base+1 { - if len(pth) > base+1 { - return fmt.Errorf("invalid non-terminal json path %q for non-existing field", pth) - } - delete(j, pth[base].field) - return nil - } - switch field := field.(type) { - case map[string]interface{}: - return DeleteJsonPath(field, pth, base+1) - case []interface{}: - if len(pth) == base+2 { - if pth[base+1].index == nil { - return fmt.Errorf("field json path %q is invalid for object", pth) - } - j[pth[base].field] = append(field[:*pth[base+1].index], field[*pth[base+1].index+1:]...) - return nil - } - return deleteJsonPathSlice(field, pth, base+1) - default: - return fmt.Errorf("invalid non-terminal json path %q for field", pth[:base+1]) - } -} - -func deleteJsonPathSlice(j []interface{}, pth JsonPath, base int) error { - if len(pth) == base { - return fmt.Errorf("empty json path %q is invalid for object", pth) - } - if pth[base].index == nil { - return fmt.Errorf("field json path %q is invalid for object", pth[:base+1]) - } - if *pth[base].index >= len(j) { - return fmt.Errorf("invalid index %q for array of size %d", pth[:base+1], len(j)) - } - if len(pth) == base+1 { - return fmt.Errorf("cannot delete item at index %q in-place", pth[:base]) - } - switch item := j[*pth[base].index].(type) { - case map[string]interface{}: - return DeleteJsonPath(item, pth, base+1) - case []interface{}: - if len(pth) == base+2 { - if pth[base+1].index == nil { - return fmt.Errorf("field json path %q is invalid for object", pth) - } - j[*pth[base].index] = append(item[:*pth[base+1].index], item[*pth[base+1].index+1:]) - return nil - } - return deleteJsonPathSlice(item, pth, base+1) - default: - return fmt.Errorf("invalid non-terminal json path %q for index", pth[:base+1]) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go deleted file mode 100644 index 558ddb1fc..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go +++ /dev/null @@ -1,249 +0,0 @@ -/* -Copyright 2017 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 validation - -import ( - "github.com/go-openapi/spec" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/validate" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" -) - -// NewSchemaValidator creates an openapi schema validator for the given CRD validation. -func NewSchemaValidator(customResourceValidation *apiextensions.CustomResourceValidation) (*validate.SchemaValidator, *spec.Schema, error) { - // Convert CRD schema to openapi schema - openapiSchema := &spec.Schema{} - if customResourceValidation != nil { - if err := ConvertJSONSchemaProps(customResourceValidation.OpenAPIV3Schema, openapiSchema); err != nil { - return nil, nil, err - } - } - return validate.NewSchemaValidator(openapiSchema, nil, "", strfmt.Default), openapiSchema, nil -} - -// ValidateCustomResource validates the Custom Resource against the schema in the CustomResourceDefinition. -// CustomResource is a JSON data structure. -func ValidateCustomResource(customResource interface{}, validator *validate.SchemaValidator) error { - if validator == nil { - return nil - } - - result := validator.Validate(customResource) - if result.AsError() != nil { - return result.AsError() - } - return nil -} - -// ConvertJSONSchemaProps converts the schema from apiextensions.JSONSchemaPropos to go-openapi/spec.Schema -func ConvertJSONSchemaProps(in *apiextensions.JSONSchemaProps, out *spec.Schema) error { - if in == nil { - return nil - } - - out.ID = in.ID - out.Schema = spec.SchemaURL(in.Schema) - out.Description = in.Description - if in.Type != "" { - out.Type = spec.StringOrArray([]string{in.Type}) - } - out.Format = in.Format - out.Title = in.Title - out.Maximum = in.Maximum - out.ExclusiveMaximum = in.ExclusiveMaximum - out.Minimum = in.Minimum - out.ExclusiveMinimum = in.ExclusiveMinimum - out.MaxLength = in.MaxLength - out.MinLength = in.MinLength - out.Pattern = in.Pattern - out.MaxItems = in.MaxItems - out.MinItems = in.MinItems - out.UniqueItems = in.UniqueItems - out.MultipleOf = in.MultipleOf - out.MaxProperties = in.MaxProperties - out.MinProperties = in.MinProperties - out.Required = in.Required - - if in.Default != nil { - out.Default = *(in.Default) - } - if in.Example != nil { - out.Example = *(in.Example) - } - - out.Enum = make([]interface{}, len(in.Enum)) - for k, v := range in.Enum { - out.Enum[k] = v - } - - if err := convertSliceOfJSONSchemaProps(&in.AllOf, &out.AllOf); err != nil { - return err - } - if err := convertSliceOfJSONSchemaProps(&in.OneOf, &out.OneOf); err != nil { - return err - } - if err := convertSliceOfJSONSchemaProps(&in.AnyOf, &out.AnyOf); err != nil { - return err - } - - if in.Not != nil { - in, out := &in.Not, &out.Not - *out = new(spec.Schema) - if err := ConvertJSONSchemaProps(*in, *out); err != nil { - return err - } - } - - var err error - out.Properties, err = convertMapOfJSONSchemaProps(in.Properties) - if err != nil { - return err - } - - out.PatternProperties, err = convertMapOfJSONSchemaProps(in.PatternProperties) - if err != nil { - return err - } - - out.Definitions, err = convertMapOfJSONSchemaProps(in.Definitions) - if err != nil { - return err - } - - if in.Ref != nil { - out.Ref, err = spec.NewRef(*in.Ref) - if err != nil { - return err - } - } - - if in.AdditionalProperties != nil { - in, out := &in.AdditionalProperties, &out.AdditionalProperties - *out = new(spec.SchemaOrBool) - if err := convertJSONSchemaPropsorBool(*in, *out); err != nil { - return err - } - } - - if in.AdditionalItems != nil { - in, out := &in.AdditionalItems, &out.AdditionalItems - *out = new(spec.SchemaOrBool) - if err := convertJSONSchemaPropsorBool(*in, *out); err != nil { - return err - } - } - - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = new(spec.SchemaOrArray) - if err := convertJSONSchemaPropsOrArray(*in, *out); err != nil { - return err - } - } - - if in.Dependencies != nil { - in, out := &in.Dependencies, &out.Dependencies - *out = make(spec.Dependencies, len(*in)) - for key, val := range *in { - newVal := new(spec.SchemaOrStringArray) - if err := convertJSONSchemaPropsOrStringArray(&val, newVal); err != nil { - return err - } - (*out)[key] = *newVal - } - } - - if in.ExternalDocs != nil { - out.ExternalDocs = &spec.ExternalDocumentation{} - out.ExternalDocs.Description = in.ExternalDocs.Description - out.ExternalDocs.URL = in.ExternalDocs.URL - } - - return nil -} - -func convertSliceOfJSONSchemaProps(in *[]apiextensions.JSONSchemaProps, out *[]spec.Schema) error { - if in != nil { - for _, jsonSchemaProps := range *in { - schema := spec.Schema{} - if err := ConvertJSONSchemaProps(&jsonSchemaProps, &schema); err != nil { - return err - } - *out = append(*out, schema) - } - } - return nil -} - -func convertMapOfJSONSchemaProps(in map[string]apiextensions.JSONSchemaProps) (map[string]spec.Schema, error) { - out := make(map[string]spec.Schema) - if len(in) != 0 { - for k, jsonSchemaProps := range in { - schema := spec.Schema{} - if err := ConvertJSONSchemaProps(&jsonSchemaProps, &schema); err != nil { - return nil, err - } - out[k] = schema - } - } - return out, nil -} - -func convertJSONSchemaPropsOrArray(in *apiextensions.JSONSchemaPropsOrArray, out *spec.SchemaOrArray) error { - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(spec.Schema) - if err := ConvertJSONSchemaProps(*in, *out); err != nil { - return err - } - } - if in.JSONSchemas != nil { - in, out := &in.JSONSchemas, &out.Schemas - *out = make([]spec.Schema, len(*in)) - for i := range *in { - if err := ConvertJSONSchemaProps(&(*in)[i], &(*out)[i]); err != nil { - return err - } - } - } - return nil -} - -func convertJSONSchemaPropsorBool(in *apiextensions.JSONSchemaPropsOrBool, out *spec.SchemaOrBool) error { - out.Allows = in.Allows - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(spec.Schema) - if err := ConvertJSONSchemaProps(*in, *out); err != nil { - return err - } - } - return nil -} - -func convertJSONSchemaPropsOrStringArray(in *apiextensions.JSONSchemaPropsOrStringArray, out *spec.SchemaOrStringArray) error { - out.Property = in.Property - if in.Schema != nil { - in, out := &in.Schema, &out.Schema - *out = new(spec.Schema) - if err := ConvertJSONSchemaProps(*in, *out); err != nil { - return err - } - } - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go deleted file mode 100644 index 3d9c50c84..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2017 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 validation - -import ( - "math/rand" - "testing" - - "github.com/go-openapi/spec" - - apiequality "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/api/testing/fuzzer" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apimachinery/pkg/util/json" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - apiextensionsfuzzer "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" -) - -// TestRoundTrip checks the conversion to go-openapi types. -// internal -> go-openapi -> JSON -> external -> internal -func TestRoundTrip(t *testing.T) { - scheme := runtime.NewScheme() - codecs := serializer.NewCodecFactory(scheme) - - // add internal and external types to scheme - if err := apiextensions.AddToScheme(scheme); err != nil { - t.Fatal(err) - } - if err := apiextensionsv1beta1.AddToScheme(scheme); err != nil { - t.Fatal(err) - } - - seed := rand.Int63() - fuzzerFuncs := fuzzer.MergeFuzzerFuncs(apiextensionsfuzzer.Funcs) - f := fuzzer.FuzzerFor(fuzzerFuncs, rand.NewSource(seed), codecs) - - for i := 0; i < 20; i++ { - // fuzz internal types - internal := &apiextensions.JSONSchemaProps{} - f.Fuzz(internal) - - // internal -> go-openapi - openAPITypes := &spec.Schema{} - if err := ConvertJSONSchemaProps(internal, openAPITypes); err != nil { - t.Fatal(err) - } - - // go-openapi -> JSON - openAPIJSON, err := json.Marshal(openAPITypes) - if err != nil { - t.Fatal(err) - } - - // JSON -> external - external := &apiextensionsv1beta1.JSONSchemaProps{} - if err := json.Unmarshal(openAPIJSON, external); err != nil { - t.Fatal(err) - } - - // external -> internal - internalRoundTripped := &apiextensions.JSONSchemaProps{} - if err := scheme.Convert(external, internalRoundTripped, nil); err != nil { - t.Fatal(err) - } - - if !apiequality.Semantic.DeepEqual(internal, internalRoundTripped) { - t.Fatalf("expected\n\t%#v, got \n\t%#v", internal, internalRoundTripped) - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/clientset.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/clientset.go deleted file mode 100644 index 63fcb510a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/clientset.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package clientset - -import ( - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" - discovery "k8s.io/client-go/discovery" - rest "k8s.io/client-go/rest" - flowcontrol "k8s.io/client-go/util/flowcontrol" -) - -type Interface interface { - Discovery() discovery.DiscoveryInterface - ApiextensionsV1beta1() apiextensionsv1beta1.ApiextensionsV1beta1Interface - // Deprecated: please explicitly pick a version if possible. - Apiextensions() apiextensionsv1beta1.ApiextensionsV1beta1Interface -} - -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. -type Clientset struct { - *discovery.DiscoveryClient - apiextensionsV1beta1 *apiextensionsv1beta1.ApiextensionsV1beta1Client -} - -// ApiextensionsV1beta1 retrieves the ApiextensionsV1beta1Client -func (c *Clientset) ApiextensionsV1beta1() apiextensionsv1beta1.ApiextensionsV1beta1Interface { - return c.apiextensionsV1beta1 -} - -// Deprecated: Apiextensions retrieves the default version of ApiextensionsClient. -// Please explicitly pick a version. -func (c *Clientset) Apiextensions() apiextensionsv1beta1.ApiextensionsV1beta1Interface { - return c.apiextensionsV1beta1 -} - -// Discovery retrieves the DiscoveryClient -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - if c == nil { - return nil - } - return c.DiscoveryClient -} - -// NewForConfig creates a new Clientset for the given config. -func NewForConfig(c *rest.Config) (*Clientset, error) { - configShallowCopy := *c - if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { - configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) - } - var cs Clientset - var err error - cs.apiextensionsV1beta1, err = apiextensionsv1beta1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - return &cs, nil -} - -// NewForConfigOrDie creates a new Clientset for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.apiextensionsV1beta1 = apiextensionsv1beta1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs -} - -// New creates a new Clientset for the given RESTClient. -func New(c rest.Interface) *Clientset { - var cs Clientset - cs.apiextensionsV1beta1 = apiextensionsv1beta1.New(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClient(c) - return &cs -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/doc.go deleted file mode 100644 index ee865e56d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package clientset diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/clientset_generated.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/clientset_generated.go deleted file mode 100644 index e65fe63ea..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/clientset_generated.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" - fakeapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/discovery" - fakediscovery "k8s.io/client-go/discovery/fake" - "k8s.io/client-go/testing" -) - -// NewSimpleClientset returns a clientset that will respond with the provided objects. -// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement -// for a real clientset and is mostly useful in simple unit tests. -func NewSimpleClientset(objects ...runtime.Object) *Clientset { - o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - cs := &Clientset{} - cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} - cs.AddReactor("*", "*", testing.ObjectReaction(o)) - cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { - gvr := action.GetResource() - ns := action.GetNamespace() - watch, err := o.Watch(gvr, ns) - if err != nil { - return false, nil, err - } - return true, watch, nil - }) - - return cs -} - -// Clientset implements clientset.Interface. Meant to be embedded into a -// struct to get a default implementation. This makes faking out just the method -// you want to test easier. -type Clientset struct { - testing.Fake - discovery *fakediscovery.FakeDiscovery -} - -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - return c.discovery -} - -var _ clientset.Interface = &Clientset{} - -// ApiextensionsV1beta1 retrieves the ApiextensionsV1beta1Client -func (c *Clientset) ApiextensionsV1beta1() apiextensionsv1beta1.ApiextensionsV1beta1Interface { - return &fakeapiextensionsv1beta1.FakeApiextensionsV1beta1{Fake: &c.Fake} -} - -// Apiextensions retrieves the ApiextensionsV1beta1Client -func (c *Clientset) Apiextensions() apiextensionsv1beta1.ApiextensionsV1beta1Interface { - return &fakeapiextensionsv1beta1.FakeApiextensionsV1beta1{Fake: &c.Fake} -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/doc.go deleted file mode 100644 index 9b99e7167..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated fake clientset. -package fake diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/register.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/register.go deleted file mode 100644 index f37309186..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/register.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var scheme = runtime.NewScheme() -var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) - -func init() { - v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) - AddToScheme(scheme) -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -func AddToScheme(scheme *runtime.Scheme) { - apiextensionsv1beta1.AddToScheme(scheme) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/doc.go deleted file mode 100644 index 7dc375616..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/register.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/register.go deleted file mode 100644 index bd73f1179..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/register.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package scheme - -import ( - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - AddToScheme(Scheme) -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -func AddToScheme(scheme *runtime.Scheme) { - apiextensionsv1beta1.AddToScheme(scheme) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/apiextensions_client.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/apiextensions_client.go deleted file mode 100644 index a1fd337f9..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/apiextensions_client.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - rest "k8s.io/client-go/rest" -) - -type ApiextensionsV1beta1Interface interface { - RESTClient() rest.Interface - CustomResourceDefinitionsGetter -} - -// ApiextensionsV1beta1Client is used to interact with features provided by the apiextensions.k8s.io group. -type ApiextensionsV1beta1Client struct { - restClient rest.Interface -} - -func (c *ApiextensionsV1beta1Client) CustomResourceDefinitions() CustomResourceDefinitionInterface { - return newCustomResourceDefinitions(c) -} - -// NewForConfig creates a new ApiextensionsV1beta1Client for the given config. -func NewForConfig(c *rest.Config) (*ApiextensionsV1beta1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &ApiextensionsV1beta1Client{client}, nil -} - -// NewForConfigOrDie creates a new ApiextensionsV1beta1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *ApiextensionsV1beta1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new ApiextensionsV1beta1Client for the given RESTClient. -func New(c rest.Interface) *ApiextensionsV1beta1Client { - return &ApiextensionsV1beta1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1beta1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *ApiextensionsV1beta1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go deleted file mode 100644 index f25a6ce34..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go +++ /dev/null @@ -1,163 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - scheme "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// CustomResourceDefinitionsGetter has a method to return a CustomResourceDefinitionInterface. -// A group's client should implement this interface. -type CustomResourceDefinitionsGetter interface { - CustomResourceDefinitions() CustomResourceDefinitionInterface -} - -// CustomResourceDefinitionInterface has methods to work with CustomResourceDefinition resources. -type CustomResourceDefinitionInterface interface { - Create(*v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) - Update(*v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) - UpdateStatus(*v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.CustomResourceDefinition, error) - List(opts v1.ListOptions) (*v1beta1.CustomResourceDefinitionList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CustomResourceDefinition, err error) - CustomResourceDefinitionExpansion -} - -// customResourceDefinitions implements CustomResourceDefinitionInterface -type customResourceDefinitions struct { - client rest.Interface -} - -// newCustomResourceDefinitions returns a CustomResourceDefinitions -func newCustomResourceDefinitions(c *ApiextensionsV1beta1Client) *customResourceDefinitions { - return &customResourceDefinitions{ - client: c.RESTClient(), - } -} - -// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any. -func (c *customResourceDefinitions) Get(name string, options v1.GetOptions) (result *v1beta1.CustomResourceDefinition, err error) { - result = &v1beta1.CustomResourceDefinition{} - err = c.client.Get(). - Resource("customresourcedefinitions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *customResourceDefinitions) List(opts v1.ListOptions) (result *v1beta1.CustomResourceDefinitionList, err error) { - result = &v1beta1.CustomResourceDefinitionList{} - err = c.client.Get(). - Resource("customresourcedefinitions"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested customResourceDefinitions. -func (c *customResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Resource("customresourcedefinitions"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *customResourceDefinitions) Create(customResourceDefinition *v1beta1.CustomResourceDefinition) (result *v1beta1.CustomResourceDefinition, err error) { - result = &v1beta1.CustomResourceDefinition{} - err = c.client.Post(). - Resource("customresourcedefinitions"). - Body(customResourceDefinition). - Do(). - Into(result) - return -} - -// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *customResourceDefinitions) Update(customResourceDefinition *v1beta1.CustomResourceDefinition) (result *v1beta1.CustomResourceDefinition, err error) { - result = &v1beta1.CustomResourceDefinition{} - err = c.client.Put(). - Resource("customresourcedefinitions"). - Name(customResourceDefinition.Name). - Body(customResourceDefinition). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *customResourceDefinitions) UpdateStatus(customResourceDefinition *v1beta1.CustomResourceDefinition) (result *v1beta1.CustomResourceDefinition, err error) { - result = &v1beta1.CustomResourceDefinition{} - err = c.client.Put(). - Resource("customresourcedefinitions"). - Name(customResourceDefinition.Name). - SubResource("status"). - Body(customResourceDefinition). - Do(). - Into(result) - return -} - -// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs. -func (c *customResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Resource("customresourcedefinitions"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *customResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - return c.client.Delete(). - Resource("customresourcedefinitions"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched customResourceDefinition. -func (c *customResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CustomResourceDefinition, err error) { - result = &v1beta1.CustomResourceDefinition{} - err = c.client.Patch(pt). - Resource("customresourcedefinitions"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/doc.go deleted file mode 100644 index 771101956..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1beta1 diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/doc.go deleted file mode 100644 index 16f443990..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go deleted file mode 100644 index 288683ef9..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - v1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeApiextensionsV1beta1 struct { - *testing.Fake -} - -func (c *FakeApiextensionsV1beta1) CustomResourceDefinitions() v1beta1.CustomResourceDefinitionInterface { - return &FakeCustomResourceDefinitions{c} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeApiextensionsV1beta1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go deleted file mode 100644 index 11aefe869..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go +++ /dev/null @@ -1,131 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeCustomResourceDefinitions implements CustomResourceDefinitionInterface -type FakeCustomResourceDefinitions struct { - Fake *FakeApiextensionsV1beta1 -} - -var customresourcedefinitionsResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1beta1", Resource: "customresourcedefinitions"} - -var customresourcedefinitionsKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "v1beta1", Kind: "CustomResourceDefinition"} - -// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any. -func (c *FakeCustomResourceDefinitions) Get(name string, options v1.GetOptions) (result *v1beta1.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(customresourcedefinitionsResource, name), &v1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *FakeCustomResourceDefinitions) List(opts v1.ListOptions) (result *v1beta1.CustomResourceDefinitionList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(customresourcedefinitionsResource, customresourcedefinitionsKind, opts), &v1beta1.CustomResourceDefinitionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.CustomResourceDefinitionList{ListMeta: obj.(*v1beta1.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*v1beta1.CustomResourceDefinitionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested customResourceDefinitions. -func (c *FakeCustomResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchAction(customresourcedefinitionsResource, opts)) -} - -// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Create(customResourceDefinition *v1beta1.CustomResourceDefinition) (result *v1beta1.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(customresourcedefinitionsResource, customResourceDefinition), &v1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Update(customResourceDefinition *v1beta1.CustomResourceDefinition) (result *v1beta1.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(customresourcedefinitionsResource, customResourceDefinition), &v1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeCustomResourceDefinitions) UpdateStatus(customResourceDefinition *v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(customresourcedefinitionsResource, "status", customResourceDefinition), &v1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs. -func (c *FakeCustomResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(customresourcedefinitionsResource, name), &v1beta1.CustomResourceDefinition{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeCustomResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(customresourcedefinitionsResource, listOptions) - - _, err := c.Fake.Invokes(action, &v1beta1.CustomResourceDefinitionList{}) - return err -} - -// Patch applies the patch and returns the patched customResourceDefinition. -func (c *FakeCustomResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(customresourcedefinitionsResource, name, data, subresources...), &v1beta1.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/clientset.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/clientset.go deleted file mode 100644 index 152a9fea0..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/clientset.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package internalclientset - -import ( - apiextensionsinternalversion "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion" - discovery "k8s.io/client-go/discovery" - rest "k8s.io/client-go/rest" - flowcontrol "k8s.io/client-go/util/flowcontrol" -) - -type Interface interface { - Discovery() discovery.DiscoveryInterface - Apiextensions() apiextensionsinternalversion.ApiextensionsInterface -} - -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. -type Clientset struct { - *discovery.DiscoveryClient - apiextensions *apiextensionsinternalversion.ApiextensionsClient -} - -// Apiextensions retrieves the ApiextensionsClient -func (c *Clientset) Apiextensions() apiextensionsinternalversion.ApiextensionsInterface { - return c.apiextensions -} - -// Discovery retrieves the DiscoveryClient -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - if c == nil { - return nil - } - return c.DiscoveryClient -} - -// NewForConfig creates a new Clientset for the given config. -func NewForConfig(c *rest.Config) (*Clientset, error) { - configShallowCopy := *c - if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { - configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) - } - var cs Clientset - var err error - cs.apiextensions, err = apiextensionsinternalversion.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - return &cs, nil -} - -// NewForConfigOrDie creates a new Clientset for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.apiextensions = apiextensionsinternalversion.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs -} - -// New creates a new Clientset for the given RESTClient. -func New(c rest.Interface) *Clientset { - var cs Clientset - cs.apiextensions = apiextensionsinternalversion.New(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClient(c) - return &cs -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/doc.go deleted file mode 100644 index 01b3d5e0f..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package internalclientset diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/clientset_generated.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/clientset_generated.go deleted file mode 100644 index 72ab169e9..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/clientset_generated.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset" - apiextensionsinternalversion "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion" - fakeapiextensionsinternalversion "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/discovery" - fakediscovery "k8s.io/client-go/discovery/fake" - "k8s.io/client-go/testing" -) - -// NewSimpleClientset returns a clientset that will respond with the provided objects. -// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement -// for a real clientset and is mostly useful in simple unit tests. -func NewSimpleClientset(objects ...runtime.Object) *Clientset { - o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - cs := &Clientset{} - cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} - cs.AddReactor("*", "*", testing.ObjectReaction(o)) - cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { - gvr := action.GetResource() - ns := action.GetNamespace() - watch, err := o.Watch(gvr, ns) - if err != nil { - return false, nil, err - } - return true, watch, nil - }) - - return cs -} - -// Clientset implements clientset.Interface. Meant to be embedded into a -// struct to get a default implementation. This makes faking out just the method -// you want to test easier. -type Clientset struct { - testing.Fake - discovery *fakediscovery.FakeDiscovery -} - -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - return c.discovery -} - -var _ clientset.Interface = &Clientset{} - -// Apiextensions retrieves the ApiextensionsClient -func (c *Clientset) Apiextensions() apiextensionsinternalversion.ApiextensionsInterface { - return &fakeapiextensionsinternalversion.FakeApiextensions{Fake: &c.Fake} -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/doc.go deleted file mode 100644 index 9b99e7167..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated fake clientset. -package fake diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/register.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/register.go deleted file mode 100644 index 89093fd9f..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/register.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - apiextensionsinternalversion "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var scheme = runtime.NewScheme() -var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) - -func init() { - v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) - AddToScheme(scheme) -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -func AddToScheme(scheme *runtime.Scheme) { - apiextensionsinternalversion.AddToScheme(scheme) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/doc.go deleted file mode 100644 index 7dc375616..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/register.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/register.go deleted file mode 100644 index 01df98a6b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/register.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package scheme - -import ( - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - Install(Scheme) -} - -// Install registers the API group and adds types to a scheme -func Install(scheme *runtime.Scheme) { - apiextensions.Install(scheme) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/apiextensions_client.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/apiextensions_client.go deleted file mode 100644 index 31b34404c..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/apiextensions_client.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package internalversion - -import ( - "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme" - rest "k8s.io/client-go/rest" -) - -type ApiextensionsInterface interface { - RESTClient() rest.Interface - CustomResourceDefinitionsGetter -} - -// ApiextensionsClient is used to interact with features provided by the apiextensions.k8s.io group. -type ApiextensionsClient struct { - restClient rest.Interface -} - -func (c *ApiextensionsClient) CustomResourceDefinitions() CustomResourceDefinitionInterface { - return newCustomResourceDefinitions(c) -} - -// NewForConfig creates a new ApiextensionsClient for the given config. -func NewForConfig(c *rest.Config) (*ApiextensionsClient, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &ApiextensionsClient{client}, nil -} - -// NewForConfigOrDie creates a new ApiextensionsClient for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *ApiextensionsClient { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new ApiextensionsClient for the given RESTClient. -func New(c rest.Interface) *ApiextensionsClient { - return &ApiextensionsClient{c} -} - -func setConfigDefaults(config *rest.Config) error { - config.APIPath = "/apis" - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - if config.GroupVersion == nil || config.GroupVersion.Group != scheme.Scheme.PrioritizedVersionsForGroup("apiextensions.k8s.io")[0].Group { - gv := scheme.Scheme.PrioritizedVersionsForGroup("apiextensions.k8s.io")[0] - config.GroupVersion = &gv - } - config.NegotiatedSerializer = scheme.Codecs - - if config.QPS == 0 { - config.QPS = 5 - } - if config.Burst == 0 { - config.Burst = 10 - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *ApiextensionsClient) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/customresourcedefinition.go deleted file mode 100644 index f3ddc8044..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/customresourcedefinition.go +++ /dev/null @@ -1,163 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package internalversion - -import ( - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - scheme "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// CustomResourceDefinitionsGetter has a method to return a CustomResourceDefinitionInterface. -// A group's client should implement this interface. -type CustomResourceDefinitionsGetter interface { - CustomResourceDefinitions() CustomResourceDefinitionInterface -} - -// CustomResourceDefinitionInterface has methods to work with CustomResourceDefinition resources. -type CustomResourceDefinitionInterface interface { - Create(*apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error) - Update(*apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error) - UpdateStatus(*apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*apiextensions.CustomResourceDefinition, error) - List(opts v1.ListOptions) (*apiextensions.CustomResourceDefinitionList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResourceDefinition, err error) - CustomResourceDefinitionExpansion -} - -// customResourceDefinitions implements CustomResourceDefinitionInterface -type customResourceDefinitions struct { - client rest.Interface -} - -// newCustomResourceDefinitions returns a CustomResourceDefinitions -func newCustomResourceDefinitions(c *ApiextensionsClient) *customResourceDefinitions { - return &customResourceDefinitions{ - client: c.RESTClient(), - } -} - -// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any. -func (c *customResourceDefinitions) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResourceDefinition, err error) { - result = &apiextensions.CustomResourceDefinition{} - err = c.client.Get(). - Resource("customresourcedefinitions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *customResourceDefinitions) List(opts v1.ListOptions) (result *apiextensions.CustomResourceDefinitionList, err error) { - result = &apiextensions.CustomResourceDefinitionList{} - err = c.client.Get(). - Resource("customresourcedefinitions"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested customResourceDefinitions. -func (c *customResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Resource("customresourcedefinitions"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *customResourceDefinitions) Create(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) { - result = &apiextensions.CustomResourceDefinition{} - err = c.client.Post(). - Resource("customresourcedefinitions"). - Body(customResourceDefinition). - Do(). - Into(result) - return -} - -// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *customResourceDefinitions) Update(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) { - result = &apiextensions.CustomResourceDefinition{} - err = c.client.Put(). - Resource("customresourcedefinitions"). - Name(customResourceDefinition.Name). - Body(customResourceDefinition). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *customResourceDefinitions) UpdateStatus(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) { - result = &apiextensions.CustomResourceDefinition{} - err = c.client.Put(). - Resource("customresourcedefinitions"). - Name(customResourceDefinition.Name). - SubResource("status"). - Body(customResourceDefinition). - Do(). - Into(result) - return -} - -// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs. -func (c *customResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Resource("customresourcedefinitions"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *customResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - return c.client.Delete(). - Resource("customresourcedefinitions"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched customResourceDefinition. -func (c *customResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResourceDefinition, err error) { - result = &apiextensions.CustomResourceDefinition{} - err = c.client.Patch(pt). - Resource("customresourcedefinitions"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/doc.go deleted file mode 100644 index 86602442b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package internalversion diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/doc.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/doc.go deleted file mode 100644 index 16f443990..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_apiextensions_client.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_apiextensions_client.go deleted file mode 100644 index 1a601e5b0..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_apiextensions_client.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - internalversion "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeApiextensions struct { - *testing.Fake -} - -func (c *FakeApiextensions) CustomResourceDefinitions() internalversion.CustomResourceDefinitionInterface { - return &FakeCustomResourceDefinitions{c} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeApiextensions) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_customresourcedefinition.go deleted file mode 100644 index 74016362d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_customresourcedefinition.go +++ /dev/null @@ -1,131 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package fake - -import ( - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeCustomResourceDefinitions implements CustomResourceDefinitionInterface -type FakeCustomResourceDefinitions struct { - Fake *FakeApiextensions -} - -var customresourcedefinitionsResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "", Resource: "customresourcedefinitions"} - -var customresourcedefinitionsKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "", Kind: "CustomResourceDefinition"} - -// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any. -func (c *FakeCustomResourceDefinitions) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(customresourcedefinitionsResource, name), &apiextensions.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensions.CustomResourceDefinition), err -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *FakeCustomResourceDefinitions) List(opts v1.ListOptions) (result *apiextensions.CustomResourceDefinitionList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(customresourcedefinitionsResource, customresourcedefinitionsKind, opts), &apiextensions.CustomResourceDefinitionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &apiextensions.CustomResourceDefinitionList{ListMeta: obj.(*apiextensions.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*apiextensions.CustomResourceDefinitionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested customResourceDefinitions. -func (c *FakeCustomResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchAction(customresourcedefinitionsResource, opts)) -} - -// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Create(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(customresourcedefinitionsResource, customResourceDefinition), &apiextensions.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensions.CustomResourceDefinition), err -} - -// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Update(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(customresourcedefinitionsResource, customResourceDefinition), &apiextensions.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensions.CustomResourceDefinition), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeCustomResourceDefinitions) UpdateStatus(customResourceDefinition *apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(customresourcedefinitionsResource, "status", customResourceDefinition), &apiextensions.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensions.CustomResourceDefinition), err -} - -// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs. -func (c *FakeCustomResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteAction(customresourcedefinitionsResource, name), &apiextensions.CustomResourceDefinition{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeCustomResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(customresourcedefinitionsResource, listOptions) - - _, err := c.Fake.Invokes(action, &apiextensions.CustomResourceDefinitionList{}) - return err -} - -// Patch applies the patch and returns the patched customResourceDefinition. -func (c *FakeCustomResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResourceDefinition, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(customresourcedefinitionsResource, name, data, subresources...), &apiextensions.CustomResourceDefinition{}) - if obj == nil { - return nil, err - } - return obj.(*apiextensions.CustomResourceDefinition), err -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/generated_expansion.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/generated_expansion.go deleted file mode 100644 index a88821021..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/generated_expansion.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -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 client-gen. DO NOT EDIT. - -package internalversion - -type CustomResourceDefinitionExpansion interface{} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/interface.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/interface.go deleted file mode 100644 index 7b48c57ca..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/interface.go +++ /dev/null @@ -1,46 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package apiextensions - -import ( - v1beta1 "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1" - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to each of this group's versions. -type Interface interface { - // V1beta1 provides access to shared informers for resources in V1beta1. - V1beta1() v1beta1.Interface -} - -type group struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// V1beta1 returns a new v1beta1.Interface. -func (g *group) V1beta1() v1beta1.Interface { - return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/customresourcedefinition.go deleted file mode 100644 index 589b4b20c..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/customresourcedefinition.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package v1beta1 - -import ( - time "time" - - apiextensions_v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces" - v1beta1 "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// CustomResourceDefinitionInformer provides access to a shared informer and lister for -// CustomResourceDefinitions. -type CustomResourceDefinitionInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1beta1.CustomResourceDefinitionLister -} - -type customResourceDefinitionInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewCustomResourceDefinitionInformer constructs a new informer for CustomResourceDefinition type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewCustomResourceDefinitionInformer(client clientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredCustomResourceDefinitionInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredCustomResourceDefinitionInformer constructs a new informer for CustomResourceDefinition type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredCustomResourceDefinitionInformer(client clientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ApiextensionsV1beta1().CustomResourceDefinitions().List(options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ApiextensionsV1beta1().CustomResourceDefinitions().Watch(options) - }, - }, - &apiextensions_v1beta1.CustomResourceDefinition{}, - resyncPeriod, - indexers, - ) -} - -func (f *customResourceDefinitionInformer) defaultInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredCustomResourceDefinitionInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&apiextensions_v1beta1.CustomResourceDefinition{}, f.defaultInformer) -} - -func (f *customResourceDefinitionInformer) Lister() v1beta1.CustomResourceDefinitionLister { - return v1beta1.NewCustomResourceDefinitionLister(f.Informer().GetIndexer()) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/interface.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/interface.go deleted file mode 100644 index f78edbb59..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/interface.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package v1beta1 - -import ( - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // CustomResourceDefinitions returns a CustomResourceDefinitionInformer. - CustomResourceDefinitions() CustomResourceDefinitionInformer -} - -type version struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// CustomResourceDefinitions returns a CustomResourceDefinitionInformer. -func (v *version) CustomResourceDefinitions() CustomResourceDefinitionInformer { - return &customResourceDefinitionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/factory.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/factory.go deleted file mode 100644 index 94d039c72..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/factory.go +++ /dev/null @@ -1,180 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package externalversions - -import ( - reflect "reflect" - sync "sync" - time "time" - - clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - apiextensions "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions" - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// SharedInformerOption defines the functional option type for SharedInformerFactory. -type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory - -type sharedInformerFactory struct { - client clientset.Interface - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc - lock sync.Mutex - defaultResync time.Duration - customResync map[reflect.Type]time.Duration - - informers map[reflect.Type]cache.SharedIndexInformer - // startedInformers is used for tracking which informers have been started. - // This allows Start() to be called multiple times safely. - startedInformers map[reflect.Type]bool -} - -// WithCustomResyncConfig sets a custom resync period for the specified informer types. -func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - for k, v := range resyncConfig { - factory.customResync[reflect.TypeOf(k)] = v - } - return factory - } -} - -// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.tweakListOptions = tweakListOptions - return factory - } -} - -// WithNamespace limits the SharedInformerFactory to the specified namespace. -func WithNamespace(namespace string) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.namespace = namespace - return factory - } -} - -// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. -func NewSharedInformerFactory(client clientset.Interface, defaultResync time.Duration) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync) -} - -// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. -// Listers obtained via this SharedInformerFactory will be subject to the same filters -// as specified here. -// Deprecated: Please use NewSharedInformerFactoryWithOptions instead -func NewFilteredSharedInformerFactory(client clientset.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) -} - -// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client clientset.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { - factory := &sharedInformerFactory{ - client: client, - namespace: v1.NamespaceAll, - defaultResync: defaultResync, - informers: make(map[reflect.Type]cache.SharedIndexInformer), - startedInformers: make(map[reflect.Type]bool), - customResync: make(map[reflect.Type]time.Duration), - } - - // Apply all options - for _, opt := range options { - factory = opt(factory) - } - - return factory -} - -// Start initializes all requested informers. -func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { - f.lock.Lock() - defer f.lock.Unlock() - - for informerType, informer := range f.informers { - if !f.startedInformers[informerType] { - go informer.Run(stopCh) - f.startedInformers[informerType] = true - } - } -} - -// WaitForCacheSync waits for all started informers' cache were synced. -func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { - informers := func() map[reflect.Type]cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informers := map[reflect.Type]cache.SharedIndexInformer{} - for informerType, informer := range f.informers { - if f.startedInformers[informerType] { - informers[informerType] = informer - } - } - return informers - }() - - res := map[reflect.Type]bool{} - for informType, informer := range informers { - res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) - } - return res -} - -// InternalInformerFor returns the SharedIndexInformer for obj using an internal -// client. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informerType := reflect.TypeOf(obj) - informer, exists := f.informers[informerType] - if exists { - return informer - } - - resyncPeriod, exists := f.customResync[informerType] - if !exists { - resyncPeriod = f.defaultResync - } - - informer = newFunc(f.client, resyncPeriod) - f.informers[informerType] = informer - - return informer -} - -// SharedInformerFactory provides shared informers for resources in all known -// API group versions. -type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory - ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - Apiextensions() apiextensions.Interface -} - -func (f *sharedInformerFactory) Apiextensions() apiextensions.Interface { - return apiextensions.New(f, f.namespace, f.tweakListOptions) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/generic.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/generic.go deleted file mode 100644 index da8a2ab0c..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/generic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package externalversions - -import ( - "fmt" - - v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// GenericInformer is type of SharedIndexInformer which will locate and delegate to other -// sharedInformers based on type -type GenericInformer interface { - Informer() cache.SharedIndexInformer - Lister() cache.GenericLister -} - -type genericInformer struct { - informer cache.SharedIndexInformer - resource schema.GroupResource -} - -// Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer -} - -// Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) -} - -// ForResource gives generic access to a shared informer of the matching type -// TODO extend this to unknown resources with a client pool -func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { - switch resource { - // Group=apiextensions.k8s.io, Version=v1beta1 - case v1beta1.SchemeGroupVersion.WithResource("customresourcedefinitions"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().V1beta1().CustomResourceDefinitions().Informer()}, nil - - } - - return nil, fmt.Errorf("no informer found for %v", resource) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go deleted file mode 100644 index 3b17f5a1a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package internalinterfaces - -import ( - time "time" - - clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - cache "k8s.io/client-go/tools/cache" -) - -type NewInformerFunc func(clientset.Interface, time.Duration) cache.SharedIndexInformer - -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle -type SharedInformerFactory interface { - Start(stopCh <-chan struct{}) - InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer -} - -type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/interface.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/interface.go deleted file mode 100644 index 8236e2acc..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/interface.go +++ /dev/null @@ -1,46 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package apiextensions - -import ( - internalversion "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion" - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces" -) - -// Interface provides access to each of this group's versions. -type Interface interface { - // InternalVersion provides access to shared informers for resources in InternalVersion. - InternalVersion() internalversion.Interface -} - -type group struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// InternalVersion returns a new internalversion.Interface. -func (g *group) InternalVersion() internalversion.Interface { - return internalversion.New(g.factory, g.namespace, g.tweakListOptions) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/customresourcedefinition.go deleted file mode 100644 index 2c54f3ce5..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/customresourcedefinition.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package internalversion - -import ( - time "time" - - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - internalclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset" - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces" - internalversion "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// CustomResourceDefinitionInformer provides access to a shared informer and lister for -// CustomResourceDefinitions. -type CustomResourceDefinitionInformer interface { - Informer() cache.SharedIndexInformer - Lister() internalversion.CustomResourceDefinitionLister -} - -type customResourceDefinitionInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewCustomResourceDefinitionInformer constructs a new informer for CustomResourceDefinition type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewCustomResourceDefinitionInformer(client internalclientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredCustomResourceDefinitionInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredCustomResourceDefinitionInformer constructs a new informer for CustomResourceDefinition type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredCustomResourceDefinitionInformer(client internalclientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.Apiextensions().CustomResourceDefinitions().List(options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.Apiextensions().CustomResourceDefinitions().Watch(options) - }, - }, - &apiextensions.CustomResourceDefinition{}, - resyncPeriod, - indexers, - ) -} - -func (f *customResourceDefinitionInformer) defaultInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredCustomResourceDefinitionInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&apiextensions.CustomResourceDefinition{}, f.defaultInformer) -} - -func (f *customResourceDefinitionInformer) Lister() internalversion.CustomResourceDefinitionLister { - return internalversion.NewCustomResourceDefinitionLister(f.Informer().GetIndexer()) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/interface.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/interface.go deleted file mode 100644 index d9444144b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/interface.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package internalversion - -import ( - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // CustomResourceDefinitions returns a CustomResourceDefinitionInformer. - CustomResourceDefinitions() CustomResourceDefinitionInformer -} - -type version struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// CustomResourceDefinitions returns a CustomResourceDefinitionInformer. -func (v *version) CustomResourceDefinitions() CustomResourceDefinitionInformer { - return &customResourceDefinitionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/factory.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/factory.go deleted file mode 100644 index 84b04523d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/factory.go +++ /dev/null @@ -1,180 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package internalversion - -import ( - reflect "reflect" - sync "sync" - time "time" - - internalclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset" - apiextensions "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions" - internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// SharedInformerOption defines the functional option type for SharedInformerFactory. -type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory - -type sharedInformerFactory struct { - client internalclientset.Interface - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc - lock sync.Mutex - defaultResync time.Duration - customResync map[reflect.Type]time.Duration - - informers map[reflect.Type]cache.SharedIndexInformer - // startedInformers is used for tracking which informers have been started. - // This allows Start() to be called multiple times safely. - startedInformers map[reflect.Type]bool -} - -// WithCustomResyncConfig sets a custom resync period for the specified informer types. -func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - for k, v := range resyncConfig { - factory.customResync[reflect.TypeOf(k)] = v - } - return factory - } -} - -// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.tweakListOptions = tweakListOptions - return factory - } -} - -// WithNamespace limits the SharedInformerFactory to the specified namespace. -func WithNamespace(namespace string) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.namespace = namespace - return factory - } -} - -// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. -func NewSharedInformerFactory(client internalclientset.Interface, defaultResync time.Duration) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync) -} - -// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. -// Listers obtained via this SharedInformerFactory will be subject to the same filters -// as specified here. -// Deprecated: Please use NewSharedInformerFactoryWithOptions instead -func NewFilteredSharedInformerFactory(client internalclientset.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) -} - -// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client internalclientset.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { - factory := &sharedInformerFactory{ - client: client, - namespace: v1.NamespaceAll, - defaultResync: defaultResync, - informers: make(map[reflect.Type]cache.SharedIndexInformer), - startedInformers: make(map[reflect.Type]bool), - customResync: make(map[reflect.Type]time.Duration), - } - - // Apply all options - for _, opt := range options { - factory = opt(factory) - } - - return factory -} - -// Start initializes all requested informers. -func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { - f.lock.Lock() - defer f.lock.Unlock() - - for informerType, informer := range f.informers { - if !f.startedInformers[informerType] { - go informer.Run(stopCh) - f.startedInformers[informerType] = true - } - } -} - -// WaitForCacheSync waits for all started informers' cache were synced. -func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { - informers := func() map[reflect.Type]cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informers := map[reflect.Type]cache.SharedIndexInformer{} - for informerType, informer := range f.informers { - if f.startedInformers[informerType] { - informers[informerType] = informer - } - } - return informers - }() - - res := map[reflect.Type]bool{} - for informType, informer := range informers { - res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) - } - return res -} - -// InternalInformerFor returns the SharedIndexInformer for obj using an internal -// client. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informerType := reflect.TypeOf(obj) - informer, exists := f.informers[informerType] - if exists { - return informer - } - - resyncPeriod, exists := f.customResync[informerType] - if !exists { - resyncPeriod = f.defaultResync - } - - informer = newFunc(f.client, resyncPeriod) - f.informers[informerType] = informer - - return informer -} - -// SharedInformerFactory provides shared informers for resources in all known -// API group versions. -type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory - ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - Apiextensions() apiextensions.Interface -} - -func (f *sharedInformerFactory) Apiextensions() apiextensions.Interface { - return apiextensions.New(f, f.namespace, f.tweakListOptions) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/generic.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/generic.go deleted file mode 100644 index c12c44074..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/generic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package internalversion - -import ( - "fmt" - - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" -) - -// GenericInformer is type of SharedIndexInformer which will locate and delegate to other -// sharedInformers based on type -type GenericInformer interface { - Informer() cache.SharedIndexInformer - Lister() cache.GenericLister -} - -type genericInformer struct { - informer cache.SharedIndexInformer - resource schema.GroupResource -} - -// Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer -} - -// Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) -} - -// ForResource gives generic access to a shared informer of the matching type -// TODO extend this to unknown resources with a client pool -func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { - switch resource { - // Group=apiextensions.k8s.io, Version=internalVersion - case apiextensions.SchemeGroupVersion.WithResource("customresourcedefinitions"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().InternalVersion().CustomResourceDefinitions().Informer()}, nil - - } - - return nil, fmt.Errorf("no informer found for %v", resource) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces/factory_interfaces.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces/factory_interfaces.go deleted file mode 100644 index 5854db0ca..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces/factory_interfaces.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -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 informer-gen. DO NOT EDIT. - -package internalinterfaces - -import ( - time "time" - - internalclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - cache "k8s.io/client-go/tools/cache" -) - -type NewInformerFunc func(internalclientset.Interface, time.Duration) cache.SharedIndexInformer - -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle -type SharedInformerFactory interface { - Start(stopCh <-chan struct{}) - InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer -} - -type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/customresourcedefinition.go deleted file mode 100644 index f64f01d9d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/customresourcedefinition.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -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 lister-gen. DO NOT EDIT. - -package internalversion - -import ( - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// CustomResourceDefinitionLister helps list CustomResourceDefinitions. -type CustomResourceDefinitionLister interface { - // List lists all CustomResourceDefinitions in the indexer. - List(selector labels.Selector) (ret []*apiextensions.CustomResourceDefinition, err error) - // Get retrieves the CustomResourceDefinition from the index for a given name. - Get(name string) (*apiextensions.CustomResourceDefinition, error) - CustomResourceDefinitionListerExpansion -} - -// customResourceDefinitionLister implements the CustomResourceDefinitionLister interface. -type customResourceDefinitionLister struct { - indexer cache.Indexer -} - -// NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister. -func NewCustomResourceDefinitionLister(indexer cache.Indexer) CustomResourceDefinitionLister { - return &customResourceDefinitionLister{indexer: indexer} -} - -// List lists all CustomResourceDefinitions in the indexer. -func (s *customResourceDefinitionLister) List(selector labels.Selector) (ret []*apiextensions.CustomResourceDefinition, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*apiextensions.CustomResourceDefinition)) - }) - return ret, err -} - -// Get retrieves the CustomResourceDefinition from the index for a given name. -func (s *customResourceDefinitionLister) Get(name string) (*apiextensions.CustomResourceDefinition, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(apiextensions.Resource("customresourcedefinition"), name) - } - return obj.(*apiextensions.CustomResourceDefinition), nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/expansion_generated.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/expansion_generated.go deleted file mode 100644 index 5e3ae381d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/expansion_generated.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -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 lister-gen. DO NOT EDIT. - -package internalversion - -// CustomResourceDefinitionListerExpansion allows custom methods to be added to -// CustomResourceDefinitionLister. -type CustomResourceDefinitionListerExpansion interface{} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/customresourcedefinition.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/customresourcedefinition.go deleted file mode 100644 index 87633217b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/customresourcedefinition.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -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 lister-gen. DO NOT EDIT. - -package v1beta1 - -import ( - v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// CustomResourceDefinitionLister helps list CustomResourceDefinitions. -type CustomResourceDefinitionLister interface { - // List lists all CustomResourceDefinitions in the indexer. - List(selector labels.Selector) (ret []*v1beta1.CustomResourceDefinition, err error) - // Get retrieves the CustomResourceDefinition from the index for a given name. - Get(name string) (*v1beta1.CustomResourceDefinition, error) - CustomResourceDefinitionListerExpansion -} - -// customResourceDefinitionLister implements the CustomResourceDefinitionLister interface. -type customResourceDefinitionLister struct { - indexer cache.Indexer -} - -// NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister. -func NewCustomResourceDefinitionLister(indexer cache.Indexer) CustomResourceDefinitionLister { - return &customResourceDefinitionLister{indexer: indexer} -} - -// List lists all CustomResourceDefinitions in the indexer. -func (s *customResourceDefinitionLister) List(selector labels.Selector) (ret []*v1beta1.CustomResourceDefinition, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.CustomResourceDefinition)) - }) - return ret, err -} - -// Get retrieves the CustomResourceDefinition from the index for a given name. -func (s *customResourceDefinitionLister) Get(name string) (*v1beta1.CustomResourceDefinition, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("customresourcedefinition"), name) - } - return obj.(*v1beta1.CustomResourceDefinition), nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/expansion_generated.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/expansion_generated.go deleted file mode 100644 index 429782deb..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/expansion_generated.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -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 lister-gen. DO NOT EDIT. - -package v1beta1 - -// CustomResourceDefinitionListerExpansion allows custom methods to be added to -// CustomResourceDefinitionLister. -type CustomResourceDefinitionListerExpansion interface{} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/start.go b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/start.go deleted file mode 100644 index c36071d8d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/start.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2017 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 server - -import ( - "fmt" - "io" - "net" - - "github.com/spf13/cobra" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/apiserver" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - utilerrors "k8s.io/apimachinery/pkg/util/errors" - genericregistry "k8s.io/apiserver/pkg/registry/generic" - genericapiserver "k8s.io/apiserver/pkg/server" - genericoptions "k8s.io/apiserver/pkg/server/options" -) - -const defaultEtcdPathPrefix = "/registry/apiextensions.kubernetes.io" - -type CustomResourceDefinitionsServerOptions struct { - RecommendedOptions *genericoptions.RecommendedOptions - APIEnablement *genericoptions.APIEnablementOptions - - StdOut io.Writer - StdErr io.Writer -} - -func NewCustomResourceDefinitionsServerOptions(out, errOut io.Writer) *CustomResourceDefinitionsServerOptions { - o := &CustomResourceDefinitionsServerOptions{ - RecommendedOptions: genericoptions.NewRecommendedOptions(defaultEtcdPathPrefix, apiserver.Codecs.LegacyCodec(v1beta1.SchemeGroupVersion)), - APIEnablement: genericoptions.NewAPIEnablementOptions(), - - StdOut: out, - StdErr: errOut, - } - - // the shared informer is not needed for apiextentions apiserver. Disable the kubeconfig flag and the client creation. - o.RecommendedOptions.CoreAPI = nil - - return o -} - -func NewCommandStartCustomResourceDefinitionsServer(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command { - o := NewCustomResourceDefinitionsServerOptions(out, errOut) - - cmd := &cobra.Command{ - Short: "Launch an API extensions API server", - Long: "Launch an API extensions API server", - RunE: func(c *cobra.Command, args []string) error { - if err := o.Complete(); err != nil { - return err - } - if err := o.Validate(args); err != nil { - return err - } - if err := o.RunCustomResourceDefinitionsServer(stopCh); err != nil { - return err - } - return nil - }, - } - - flags := cmd.Flags() - o.RecommendedOptions.AddFlags(flags) - o.APIEnablement.AddFlags(flags) - return cmd -} - -func (o CustomResourceDefinitionsServerOptions) Validate(args []string) error { - errors := []error{} - errors = append(errors, o.RecommendedOptions.Validate()...) - errors = append(errors, o.APIEnablement.Validate(apiserver.Scheme)...) - return utilerrors.NewAggregate(errors) -} - -func (o *CustomResourceDefinitionsServerOptions) Complete() error { - return nil -} - -func (o CustomResourceDefinitionsServerOptions) Config() (*apiserver.Config, error) { - // TODO have a "real" external address - if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil { - return nil, fmt.Errorf("error creating self-signed certificates: %v", err) - } - - serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs) - if err := o.RecommendedOptions.ApplyTo(serverConfig, apiserver.Scheme); err != nil { - return nil, err - } - if err := o.APIEnablement.ApplyTo(&serverConfig.Config, apiserver.DefaultAPIResourceConfigSource(), apiserver.Scheme); err != nil { - return nil, err - } - - config := &apiserver.Config{ - GenericConfig: serverConfig, - ExtraConfig: apiserver.ExtraConfig{ - CRDRESTOptionsGetter: NewCRDRESTOptionsGetter(*o.RecommendedOptions.Etcd), - }, - } - return config, nil -} - -func NewCRDRESTOptionsGetter(etcdOptions genericoptions.EtcdOptions) genericregistry.RESTOptionsGetter { - ret := apiserver.CRDRESTOptionsGetter{ - StorageConfig: etcdOptions.StorageConfig, - StoragePrefix: etcdOptions.StorageConfig.Prefix, - EnableWatchCache: etcdOptions.EnableWatchCache, - DefaultWatchCacheSize: etcdOptions.DefaultWatchCacheSize, - EnableGarbageCollection: etcdOptions.EnableGarbageCollection, - DeleteCollectionWorkers: etcdOptions.DeleteCollectionWorkers, - } - ret.StorageConfig.Codec = unstructured.UnstructuredJSONScheme - - return ret -} - -func (o CustomResourceDefinitionsServerOptions) RunCustomResourceDefinitionsServer(stopCh <-chan struct{}) error { - config, err := o.Config() - if err != nil { - return err - } - - server, err := config.Complete().New(genericapiserver.NewEmptyDelegate()) - if err != nil { - return err - } - return server.GenericAPIServer.PrepareRun().Run(stopCh) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/establish/establishing_controller.go b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/establish/establishing_controller.go deleted file mode 100644 index 5c2ebbcaa..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/establish/establishing_controller.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -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 establish - -import ( - "fmt" - "time" - - "github.com/golang/glog" - apierrors "k8s.io/apimachinery/pkg/api/errors" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - client "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion" - informers "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion" - listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion" -) - -// EstablishingController controls how and when CRD is established. -type EstablishingController struct { - crdClient client.CustomResourceDefinitionsGetter - crdLister listers.CustomResourceDefinitionLister - crdSynced cache.InformerSynced - - // To allow injection for testing. - syncFn func(key string) error - - queue workqueue.RateLimitingInterface -} - -// NewEstablishingController creates new EstablishingController. -func NewEstablishingController(crdInformer informers.CustomResourceDefinitionInformer, - crdClient client.CustomResourceDefinitionsGetter) *EstablishingController { - ec := &EstablishingController{ - crdClient: crdClient, - crdLister: crdInformer.Lister(), - crdSynced: crdInformer.Informer().HasSynced, - queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "crdEstablishing"), - } - - ec.syncFn = ec.sync - - return ec -} - -// QueueCRD adds CRD into the establishing queue. -func (ec *EstablishingController) QueueCRD(key string, timeout time.Duration) { - ec.queue.AddAfter(key, timeout) -} - -// Run starts the EstablishingController. -func (ec *EstablishingController) Run(stopCh <-chan struct{}) { - defer utilruntime.HandleCrash() - defer ec.queue.ShutDown() - - glog.Infof("Starting EstablishingController") - defer glog.Infof("Shutting down EstablishingController") - - if !cache.WaitForCacheSync(stopCh, ec.crdSynced) { - return - } - - // only start one worker thread since its a slow moving API - go wait.Until(ec.runWorker, time.Second, stopCh) - - <-stopCh -} - -func (ec *EstablishingController) runWorker() { - for ec.processNextWorkItem() { - } -} - -// processNextWorkItem deals with one key off the queue. -// It returns false when it's time to quit. -func (ec *EstablishingController) processNextWorkItem() bool { - key, quit := ec.queue.Get() - if quit { - return false - } - defer ec.queue.Done(key) - - err := ec.syncFn(key.(string)) - if err == nil { - return true - } - - utilruntime.HandleError(fmt.Errorf("%v failed with: %v", key, err)) - ec.queue.AddRateLimited(key) - - return true -} - -// sync is used to turn CRDs into the Established state. -func (ec *EstablishingController) sync(key string) error { - cachedCRD, err := ec.crdLister.Get(key) - if apierrors.IsNotFound(err) { - return nil - } - if err != nil { - return err - } - - if !apiextensions.IsCRDConditionTrue(cachedCRD, apiextensions.NamesAccepted) || - apiextensions.IsCRDConditionTrue(cachedCRD, apiextensions.Established) { - return nil - } - - crd := cachedCRD.DeepCopy() - establishedCondition := apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Established, - Status: apiextensions.ConditionTrue, - Reason: "InitialNamesAccepted", - Message: "the initial names have been accepted", - } - apiextensions.SetCRDCondition(crd, establishedCondition) - - // Update server with new CRD condition. - _, err = ec.crdClient.CustomResourceDefinitions().UpdateStatus(crd) - if err != nil { - return err - } - - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go deleted file mode 100644 index f881427ef..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go +++ /dev/null @@ -1,327 +0,0 @@ -/* -Copyright 2017 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 finalizer - -import ( - "fmt" - "reflect" - "time" - - "github.com/golang/glog" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - utilerrors "k8s.io/apimachinery/pkg/util/errors" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apimachinery/pkg/util/wait" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - client "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion" - informers "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion" - listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion" -) - -// CRDFinalizer is a controller that finalizes the CRD by deleting all the CRs associated with it. -type CRDFinalizer struct { - crdClient client.CustomResourceDefinitionsGetter - crClientGetter CRClientGetter - - crdLister listers.CustomResourceDefinitionLister - crdSynced cache.InformerSynced - - // To allow injection for testing. - syncFn func(key string) error - - queue workqueue.RateLimitingInterface -} - -// ListerCollectionDeleter combines rest.Lister and rest.CollectionDeleter. -type ListerCollectionDeleter interface { - rest.Lister - rest.CollectionDeleter -} - -// CRClientGetter knows how to get a ListerCollectionDeleter for a given CRD UID. -type CRClientGetter interface { - // GetCustomResourceListerCollectionDeleter gets the ListerCollectionDeleter for the given CRD - // UID. - GetCustomResourceListerCollectionDeleter(crd *apiextensions.CustomResourceDefinition) (ListerCollectionDeleter, error) -} - -// NewCRDFinalizer creates a new CRDFinalizer. -func NewCRDFinalizer( - crdInformer informers.CustomResourceDefinitionInformer, - crdClient client.CustomResourceDefinitionsGetter, - crClientGetter CRClientGetter, -) *CRDFinalizer { - c := &CRDFinalizer{ - crdClient: crdClient, - crdLister: crdInformer.Lister(), - crdSynced: crdInformer.Informer().HasSynced, - crClientGetter: crClientGetter, - queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "CustomResourceDefinition-CRDFinalizer"), - } - - crdInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: c.addCustomResourceDefinition, - UpdateFunc: c.updateCustomResourceDefinition, - }) - - c.syncFn = c.sync - - return c -} - -func (c *CRDFinalizer) sync(key string) error { - cachedCRD, err := c.crdLister.Get(key) - if apierrors.IsNotFound(err) { - return nil - } - if err != nil { - return err - } - - // no work to do - if cachedCRD.DeletionTimestamp.IsZero() || !apiextensions.CRDHasFinalizer(cachedCRD, apiextensions.CustomResourceCleanupFinalizer) { - return nil - } - - crd := cachedCRD.DeepCopy() - - // update the status condition. This cleanup could take a while. - apiextensions.SetCRDCondition(crd, apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionTrue, - Reason: "InstanceDeletionInProgress", - Message: "CustomResource deletion is in progress", - }) - crd, err = c.crdClient.CustomResourceDefinitions().UpdateStatus(crd) - if err != nil { - return err - } - - // Now we can start deleting items. We should use the REST API to ensure that all normal admission runs. - // Since we control the endpoints, we know that delete collection works. No need to delete if not established. - if apiextensions.IsCRDConditionTrue(crd, apiextensions.Established) { - cond, deleteErr := c.deleteInstances(crd) - apiextensions.SetCRDCondition(crd, cond) - if deleteErr != nil { - crd, err = c.crdClient.CustomResourceDefinitions().UpdateStatus(crd) - if err != nil { - utilruntime.HandleError(err) - } - return deleteErr - } - } else { - apiextensions.SetCRDCondition(crd, apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionFalse, - Reason: "NeverEstablished", - Message: "resource was never established", - }) - } - - apiextensions.CRDRemoveFinalizer(crd, apiextensions.CustomResourceCleanupFinalizer) - crd, err = c.crdClient.CustomResourceDefinitions().UpdateStatus(crd) - if err != nil { - return err - } - - // and now issue another delete, which should clean it all up if no finalizers remain or no-op if they do - return c.crdClient.CustomResourceDefinitions().Delete(crd.Name, nil) -} - -func (c *CRDFinalizer) deleteInstances(crd *apiextensions.CustomResourceDefinition) (apiextensions.CustomResourceDefinitionCondition, error) { - // Now we can start deleting items. While it would be ideal to use a REST API client, doing so - // could incorrectly delete a ThirdPartyResource with the same URL as the CustomResource, so we go - // directly to the storage instead. Since we control the storage, we know that delete collection works. - crClient, err := c.crClientGetter.GetCustomResourceListerCollectionDeleter(crd) - if err != nil { - err = fmt.Errorf("unable to find a custom resource client for %s.%s: %v", crd.Status.AcceptedNames.Plural, crd.Spec.Group, err) - return apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionTrue, - Reason: "InstanceDeletionFailed", - Message: fmt.Sprintf("could not list instances: %v", err), - }, err - } - - ctx := genericapirequest.NewContext() - allResources, err := crClient.List(ctx, nil) - if err != nil { - return apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionTrue, - Reason: "InstanceDeletionFailed", - Message: fmt.Sprintf("could not list instances: %v", err), - }, err - } - - deletedNamespaces := sets.String{} - deleteErrors := []error{} - for _, item := range allResources.(*unstructured.UnstructuredList).Items { - metadata, err := meta.Accessor(&item) - if err != nil { - utilruntime.HandleError(err) - continue - } - if deletedNamespaces.Has(metadata.GetNamespace()) { - continue - } - // don't retry deleting the same namespace - deletedNamespaces.Insert(metadata.GetNamespace()) - nsCtx := genericapirequest.WithNamespace(ctx, metadata.GetNamespace()) - if _, err := crClient.DeleteCollection(nsCtx, nil, nil); err != nil { - deleteErrors = append(deleteErrors, err) - continue - } - } - if deleteError := utilerrors.NewAggregate(deleteErrors); deleteError != nil { - return apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionTrue, - Reason: "InstanceDeletionFailed", - Message: fmt.Sprintf("could not issue all deletes: %v", deleteError), - }, deleteError - } - - // now we need to wait until all the resources are deleted. Start with a simple poll before we do anything fancy. - // TODO not all servers are synchronized on caches. It is possible for a stale one to still be creating things. - // Once we have a mechanism for servers to indicate their states, we should check that for concurrence. - err = wait.PollImmediate(5*time.Second, 1*time.Minute, func() (bool, error) { - listObj, err := crClient.List(ctx, nil) - if err != nil { - return false, err - } - if len(listObj.(*unstructured.UnstructuredList).Items) == 0 { - return true, nil - } - glog.V(2).Infof("%s.%s waiting for %d items to be removed", crd.Status.AcceptedNames.Plural, crd.Spec.Group, len(listObj.(*unstructured.UnstructuredList).Items)) - return false, nil - }) - if err != nil { - return apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionTrue, - Reason: "InstanceDeletionCheck", - Message: fmt.Sprintf("could not confirm zero CustomResources remaining: %v", err), - }, err - } - return apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionFalse, - Reason: "InstanceDeletionCompleted", - Message: "removed all instances", - }, nil -} - -func (c *CRDFinalizer) Run(workers int, stopCh <-chan struct{}) { - defer utilruntime.HandleCrash() - defer c.queue.ShutDown() - - glog.Infof("Starting CRDFinalizer") - defer glog.Infof("Shutting down CRDFinalizer") - - if !cache.WaitForCacheSync(stopCh, c.crdSynced) { - return - } - - for i := 0; i < workers; i++ { - go wait.Until(c.runWorker, time.Second, stopCh) - } - - <-stopCh -} - -func (c *CRDFinalizer) runWorker() { - for c.processNextWorkItem() { - } -} - -// processNextWorkItem deals with one key off the queue. It returns false when it's time to quit. -func (c *CRDFinalizer) processNextWorkItem() bool { - key, quit := c.queue.Get() - if quit { - return false - } - defer c.queue.Done(key) - - err := c.syncFn(key.(string)) - if err == nil { - c.queue.Forget(key) - return true - } - - utilruntime.HandleError(fmt.Errorf("%v failed with: %v", key, err)) - c.queue.AddRateLimited(key) - - return true -} - -func (c *CRDFinalizer) enqueue(obj *apiextensions.CustomResourceDefinition) { - key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) - if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", obj, err)) - return - } - - c.queue.Add(key) -} - -func (c *CRDFinalizer) addCustomResourceDefinition(obj interface{}) { - castObj := obj.(*apiextensions.CustomResourceDefinition) - // only queue deleted things - if !castObj.DeletionTimestamp.IsZero() && apiextensions.CRDHasFinalizer(castObj, apiextensions.CustomResourceCleanupFinalizer) { - c.enqueue(castObj) - } -} - -func (c *CRDFinalizer) updateCustomResourceDefinition(oldObj, newObj interface{}) { - oldCRD := oldObj.(*apiextensions.CustomResourceDefinition) - newCRD := newObj.(*apiextensions.CustomResourceDefinition) - // only queue deleted things that haven't been finalized by us - if newCRD.DeletionTimestamp.IsZero() || !apiextensions.CRDHasFinalizer(newCRD, apiextensions.CustomResourceCleanupFinalizer) { - return - } - - // always requeue resyncs just in case - if oldCRD.ResourceVersion == newCRD.ResourceVersion { - c.enqueue(newCRD) - return - } - - // If the only difference is in the terminating condition, then there's no reason to requeue here. This controller - // is likely to be the originator, so requeuing would hot-loop us. Failures are requeued by the workqueue directly. - // This is a low traffic and scale resource, so the copy is terrible. It's not good, so better ideas - // are welcome. - oldCopy := oldCRD.DeepCopy() - newCopy := newCRD.DeepCopy() - oldCopy.ResourceVersion = "" - newCopy.ResourceVersion = "" - apiextensions.RemoveCRDCondition(oldCopy, apiextensions.Terminating) - apiextensions.RemoveCRDCondition(newCopy, apiextensions.Terminating) - - if !reflect.DeepEqual(oldCopy, newCopy) { - c.enqueue(newCRD) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go deleted file mode 100644 index f00def4b1..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go +++ /dev/null @@ -1,374 +0,0 @@ -/* -Copyright 2017 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 status - -import ( - "fmt" - "reflect" - "strings" - "time" - - "github.com/golang/glog" - - "k8s.io/apimachinery/pkg/api/equality" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - utilerrors "k8s.io/apimachinery/pkg/util/errors" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - client "k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion" - informers "k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion" - listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion" -) - -// This controller is reserving names. To avoid conflicts, be sure to run only one instance of the worker at a time. -// This could eventually be lifted, but starting simple. -type NamingConditionController struct { - crdClient client.CustomResourceDefinitionsGetter - - crdLister listers.CustomResourceDefinitionLister - crdSynced cache.InformerSynced - // crdMutationCache backs our lister and keeps track of committed updates to avoid racy - // write/lookup cycles. It's got 100 slots by default, so it unlikely to overrun - // TODO to revisit this if naming conflicts are found to occur in the wild - crdMutationCache cache.MutationCache - - // To allow injection for testing. - syncFn func(key string) error - - queue workqueue.RateLimitingInterface -} - -func NewNamingConditionController( - crdInformer informers.CustomResourceDefinitionInformer, - crdClient client.CustomResourceDefinitionsGetter, -) *NamingConditionController { - c := &NamingConditionController{ - crdClient: crdClient, - crdLister: crdInformer.Lister(), - crdSynced: crdInformer.Informer().HasSynced, - queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "CustomResourceDefinition-NamingConditionController"), - } - - informerIndexer := crdInformer.Informer().GetIndexer() - c.crdMutationCache = cache.NewIntegerResourceVersionMutationCache(informerIndexer, informerIndexer, 60*time.Second, false) - - crdInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: c.addCustomResourceDefinition, - UpdateFunc: c.updateCustomResourceDefinition, - DeleteFunc: c.deleteCustomResourceDefinition, - }) - - c.syncFn = c.sync - - return c -} - -func (c *NamingConditionController) getAcceptedNamesForGroup(group string) (allResources sets.String, allKinds sets.String) { - allResources = sets.String{} - allKinds = sets.String{} - - list, err := c.crdLister.List(labels.Everything()) - if err != nil { - panic(err) - } - - for _, curr := range list { - if curr.Spec.Group != group { - continue - } - - // for each item here, see if we have a mutation cache entry that is more recent - // this makes sure that if we tight loop on update and run, our mutation cache will show - // us the version of the objects we just updated to. - item := curr - obj, exists, err := c.crdMutationCache.GetByKey(curr.Name) - if exists && err == nil { - item = obj.(*apiextensions.CustomResourceDefinition) - } - - allResources.Insert(item.Status.AcceptedNames.Plural) - allResources.Insert(item.Status.AcceptedNames.Singular) - allResources.Insert(item.Status.AcceptedNames.ShortNames...) - - allKinds.Insert(item.Status.AcceptedNames.Kind) - allKinds.Insert(item.Status.AcceptedNames.ListKind) - } - - return allResources, allKinds -} - -func (c *NamingConditionController) calculateNamesAndConditions(in *apiextensions.CustomResourceDefinition) (apiextensions.CustomResourceDefinitionNames, apiextensions.CustomResourceDefinitionCondition, apiextensions.CustomResourceDefinitionCondition) { - // Get the names that have already been claimed - allResources, allKinds := c.getAcceptedNamesForGroup(in.Spec.Group) - - namesAcceptedCondition := apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.NamesAccepted, - Status: apiextensions.ConditionUnknown, - } - - requestedNames := in.Spec.Names - acceptedNames := in.Status.AcceptedNames - newNames := in.Status.AcceptedNames - - // Check each name for mismatches. If there's a mismatch between spec and status, then try to deconflict. - // Continue on errors so that the status is the best match possible - if err := equalToAcceptedOrFresh(requestedNames.Plural, acceptedNames.Plural, allResources); err != nil { - namesAcceptedCondition.Status = apiextensions.ConditionFalse - namesAcceptedCondition.Reason = "PluralConflict" - namesAcceptedCondition.Message = err.Error() - } else { - newNames.Plural = requestedNames.Plural - } - if err := equalToAcceptedOrFresh(requestedNames.Singular, acceptedNames.Singular, allResources); err != nil { - namesAcceptedCondition.Status = apiextensions.ConditionFalse - namesAcceptedCondition.Reason = "SingularConflict" - namesAcceptedCondition.Message = err.Error() - } else { - newNames.Singular = requestedNames.Singular - } - if !reflect.DeepEqual(requestedNames.ShortNames, acceptedNames.ShortNames) { - errs := []error{} - existingShortNames := sets.NewString(acceptedNames.ShortNames...) - for _, shortName := range requestedNames.ShortNames { - // if the shortname is already ours, then we're fine - if existingShortNames.Has(shortName) { - continue - } - if err := equalToAcceptedOrFresh(shortName, "", allResources); err != nil { - errs = append(errs, err) - } - - } - if err := utilerrors.NewAggregate(errs); err != nil { - namesAcceptedCondition.Status = apiextensions.ConditionFalse - namesAcceptedCondition.Reason = "ShortNamesConflict" - namesAcceptedCondition.Message = err.Error() - } else { - newNames.ShortNames = requestedNames.ShortNames - } - } - - if err := equalToAcceptedOrFresh(requestedNames.Kind, acceptedNames.Kind, allKinds); err != nil { - namesAcceptedCondition.Status = apiextensions.ConditionFalse - namesAcceptedCondition.Reason = "KindConflict" - namesAcceptedCondition.Message = err.Error() - } else { - newNames.Kind = requestedNames.Kind - } - if err := equalToAcceptedOrFresh(requestedNames.ListKind, acceptedNames.ListKind, allKinds); err != nil { - namesAcceptedCondition.Status = apiextensions.ConditionFalse - namesAcceptedCondition.Reason = "ListKindConflict" - namesAcceptedCondition.Message = err.Error() - } else { - newNames.ListKind = requestedNames.ListKind - } - - newNames.Categories = requestedNames.Categories - - // if we haven't changed the condition, then our names must be good. - if namesAcceptedCondition.Status == apiextensions.ConditionUnknown { - namesAcceptedCondition.Status = apiextensions.ConditionTrue - namesAcceptedCondition.Reason = "NoConflicts" - namesAcceptedCondition.Message = "no conflicts found" - } - - // set EstablishedCondition initially to false, then set it to true in establishing controller. - // The Establishing Controller will see the NamesAccepted condition when it arrives through the shared informer. - // At that time the API endpoint handler will serve the endpoint, avoiding a race - // which we had if we set Established to true here. - establishedCondition := apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Established, - Status: apiextensions.ConditionFalse, - Reason: "NotAccepted", - Message: "not all names are accepted", - } - if old := apiextensions.FindCRDCondition(in, apiextensions.Established); old != nil { - establishedCondition = *old - } - if establishedCondition.Status != apiextensions.ConditionTrue && namesAcceptedCondition.Status == apiextensions.ConditionTrue { - establishedCondition = apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Established, - Status: apiextensions.ConditionFalse, - Reason: "Installing", - Message: "the initial names have been accepted", - } - } - - return newNames, namesAcceptedCondition, establishedCondition -} - -func equalToAcceptedOrFresh(requestedName, acceptedName string, usedNames sets.String) error { - if requestedName == acceptedName { - return nil - } - if !usedNames.Has(requestedName) { - return nil - } - - return fmt.Errorf("%q is already in use", requestedName) -} - -func (c *NamingConditionController) sync(key string) error { - inCustomResourceDefinition, err := c.crdLister.Get(key) - if apierrors.IsNotFound(err) { - // CRD was deleted and has freed its names. - // Reconsider all other CRDs in the same group. - if err := c.requeueAllOtherGroupCRDs(key); err != nil { - return err - } - return nil - } - if err != nil { - return err - } - - // Skip checking names if Spec and Status names are same. - if equality.Semantic.DeepEqual(inCustomResourceDefinition.Spec.Names, inCustomResourceDefinition.Status.AcceptedNames) { - return nil - } - - acceptedNames, namingCondition, establishedCondition := c.calculateNamesAndConditions(inCustomResourceDefinition) - - // nothing to do if accepted names and NamesAccepted condition didn't change - if reflect.DeepEqual(inCustomResourceDefinition.Status.AcceptedNames, acceptedNames) && - apiextensions.IsCRDConditionEquivalent(&namingCondition, apiextensions.FindCRDCondition(inCustomResourceDefinition, apiextensions.NamesAccepted)) { - return nil - } - - crd := inCustomResourceDefinition.DeepCopy() - crd.Status.AcceptedNames = acceptedNames - apiextensions.SetCRDCondition(crd, namingCondition) - apiextensions.SetCRDCondition(crd, establishedCondition) - - updatedObj, err := c.crdClient.CustomResourceDefinitions().UpdateStatus(crd) - if err != nil { - return err - } - - // if the update was successful, go ahead and add the entry to the mutation cache - c.crdMutationCache.Mutation(updatedObj) - - // we updated our status, so we may be releasing a name. When this happens, we need to rekick everything in our group - // if we fail to rekick, just return as normal. We'll get everything on a resync - if err := c.requeueAllOtherGroupCRDs(key); err != nil { - return err - } - - return nil -} - -func (c *NamingConditionController) Run(stopCh <-chan struct{}) { - defer utilruntime.HandleCrash() - defer c.queue.ShutDown() - - glog.Infof("Starting NamingConditionController") - defer glog.Infof("Shutting down NamingConditionController") - - if !cache.WaitForCacheSync(stopCh, c.crdSynced) { - return - } - - // only start one worker thread since its a slow moving API and the naming conflict resolution bits aren't thread-safe - go wait.Until(c.runWorker, time.Second, stopCh) - - <-stopCh -} - -func (c *NamingConditionController) runWorker() { - for c.processNextWorkItem() { - } -} - -// processNextWorkItem deals with one key off the queue. It returns false when it's time to quit. -func (c *NamingConditionController) processNextWorkItem() bool { - key, quit := c.queue.Get() - if quit { - return false - } - defer c.queue.Done(key) - - err := c.syncFn(key.(string)) - if err == nil { - c.queue.Forget(key) - return true - } - - utilruntime.HandleError(fmt.Errorf("%v failed with: %v", key, err)) - c.queue.AddRateLimited(key) - - return true -} - -func (c *NamingConditionController) enqueue(obj *apiextensions.CustomResourceDefinition) { - key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) - if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", obj, err)) - return - } - - c.queue.Add(key) -} - -func (c *NamingConditionController) addCustomResourceDefinition(obj interface{}) { - castObj := obj.(*apiextensions.CustomResourceDefinition) - glog.V(4).Infof("Adding %s", castObj.Name) - c.enqueue(castObj) -} - -func (c *NamingConditionController) updateCustomResourceDefinition(obj, _ interface{}) { - castObj := obj.(*apiextensions.CustomResourceDefinition) - glog.V(4).Infof("Updating %s", castObj.Name) - c.enqueue(castObj) -} - -func (c *NamingConditionController) deleteCustomResourceDefinition(obj interface{}) { - castObj, ok := obj.(*apiextensions.CustomResourceDefinition) - if !ok { - tombstone, ok := obj.(cache.DeletedFinalStateUnknown) - if !ok { - glog.Errorf("Couldn't get object from tombstone %#v", obj) - return - } - castObj, ok = tombstone.Obj.(*apiextensions.CustomResourceDefinition) - if !ok { - glog.Errorf("Tombstone contained object that is not expected %#v", obj) - return - } - } - glog.V(4).Infof("Deleting %q", castObj.Name) - c.enqueue(castObj) -} - -func (c *NamingConditionController) requeueAllOtherGroupCRDs(name string) error { - pluralGroup := strings.SplitN(name, ".", 2) - list, err := c.crdLister.List(labels.Everything()) - if err != nil { - return err - } - for _, curr := range list { - if curr.Spec.Group == pluralGroup[1] && curr.Name != name { - c.queue.Add(curr.Name) - } - } - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller_test.go deleted file mode 100644 index 717e52884..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller_test.go +++ /dev/null @@ -1,344 +0,0 @@ -/* -Copyright 2017 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 status - -import ( - "reflect" - "strings" - "testing" - "time" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/tools/cache" -) - -type crdBuilder struct { - curr apiextensions.CustomResourceDefinition -} - -func newCRD(name string) *crdBuilder { - tokens := strings.SplitN(name, ".", 2) - return &crdBuilder{ - curr: apiextensions.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: name}, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: tokens[1], - Names: apiextensions.CustomResourceDefinitionNames{ - Plural: tokens[0], - }, - }, - }, - } -} - -func (b *crdBuilder) SpecNames(plural, singular, kind, listKind string, shortNames ...string) *crdBuilder { - b.curr.Spec.Names.Plural = plural - b.curr.Spec.Names.Singular = singular - b.curr.Spec.Names.Kind = kind - b.curr.Spec.Names.ListKind = listKind - b.curr.Spec.Names.ShortNames = shortNames - - return b -} - -func (b *crdBuilder) StatusNames(plural, singular, kind, listKind string, shortNames ...string) *crdBuilder { - b.curr.Status.AcceptedNames.Plural = plural - b.curr.Status.AcceptedNames.Singular = singular - b.curr.Status.AcceptedNames.Kind = kind - b.curr.Status.AcceptedNames.ListKind = listKind - b.curr.Status.AcceptedNames.ShortNames = shortNames - - return b -} - -func (b *crdBuilder) Condition(c apiextensions.CustomResourceDefinitionCondition) *crdBuilder { - b.curr.Status.Conditions = append(b.curr.Status.Conditions, c) - - return b -} - -func names(plural, singular, kind, listKind string, shortNames ...string) apiextensions.CustomResourceDefinitionNames { - ret := apiextensions.CustomResourceDefinitionNames{ - Plural: plural, - Singular: singular, - Kind: kind, - ListKind: listKind, - ShortNames: shortNames, - } - return ret -} - -func (b *crdBuilder) NewOrDie() *apiextensions.CustomResourceDefinition { - return &b.curr -} - -var acceptedCondition = apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.NamesAccepted, - Status: apiextensions.ConditionTrue, - Reason: "NoConflicts", - Message: "no conflicts found", -} - -var notAcceptedCondition = apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.NamesAccepted, - Status: apiextensions.ConditionFalse, - Reason: "NotAccepted", - Message: "not all names are accepted", -} - -var installingCondition = apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Established, - Status: apiextensions.ConditionFalse, - Reason: "Installing", - Message: "the initial names have been accepted", -} - -var notEstablishedCondition = apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Established, - Status: apiextensions.ConditionFalse, - Reason: "NotAccepted", - Message: "not all names are accepted", -} - -func nameConflictCondition(reason, message string) apiextensions.CustomResourceDefinitionCondition { - return apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.NamesAccepted, - Status: apiextensions.ConditionFalse, - Reason: reason, - Message: message, - } -} - -func TestSync(t *testing.T) { - tests := []struct { - name string - - in *apiextensions.CustomResourceDefinition - existing []*apiextensions.CustomResourceDefinition - expectedNames apiextensions.CustomResourceDefinitionNames - expectedNameConflictCondition apiextensions.CustomResourceDefinitionCondition - expectedEstablishedCondition apiextensions.CustomResourceDefinitionCondition - }{ - { - name: "first resource", - in: newCRD("alfa.bravo.com").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{}, - expectedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "alfa", - }, - expectedNameConflictCondition: acceptedCondition, - expectedEstablishedCondition: installingCondition, - }, - { - name: "different groups", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("alfa.charlie.com").StatusNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - }, - expectedNames: names("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: acceptedCondition, - expectedEstablishedCondition: installingCondition, - }, - { - name: "conflict plural to singular", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "alfa", "", "").NewOrDie(), - }, - expectedNames: names("", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("PluralConflict", `"alfa" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "conflict singular to shortName", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "indias", "", "", "delta-singular").NewOrDie(), - }, - expectedNames: names("alfa", "", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("SingularConflict", `"delta-singular" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "conflict on shortName to shortName", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "indias", "", "", "hotel-shortname-2").NewOrDie(), - }, - expectedNames: names("alfa", "delta-singular", "echo-kind", "foxtrot-listkind"), - expectedNameConflictCondition: nameConflictCondition("ShortNamesConflict", `"hotel-shortname-2" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "conflict on kind to listkind", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "indias", "", "echo-kind").NewOrDie(), - }, - expectedNames: names("alfa", "delta-singular", "", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("KindConflict", `"echo-kind" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "conflict on listkind to kind", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "indias", "foxtrot-listkind", "").NewOrDie(), - }, - expectedNames: names("alfa", "delta-singular", "echo-kind", "", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("ListKindConflict", `"foxtrot-listkind" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "no conflict on resource and kind", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2").NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "echo-kind", "", "").NewOrDie(), - }, - expectedNames: names("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: acceptedCondition, - expectedEstablishedCondition: installingCondition, - }, - { - name: "merge on conflicts", - in: newCRD("alfa.bravo.com"). - SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - StatusNames("zulu", "yankee-singular", "xray-kind", "whiskey-listkind", "victor-shortname-1", "uniform-shortname-2"). - NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "indias", "foxtrot-listkind", "", "delta-singular").NewOrDie(), - }, - expectedNames: names("alfa", "yankee-singular", "echo-kind", "whiskey-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("ListKindConflict", `"foxtrot-listkind" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "merge on conflicts shortNames as one", - in: newCRD("alfa.bravo.com"). - SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - StatusNames("zulu", "yankee-singular", "xray-kind", "whiskey-listkind", "victor-shortname-1", "uniform-shortname-2"). - NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "indias", "foxtrot-listkind", "", "delta-singular", "golf-shortname-1").NewOrDie(), - }, - expectedNames: names("alfa", "yankee-singular", "echo-kind", "whiskey-listkind", "victor-shortname-1", "uniform-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("ListKindConflict", `"foxtrot-listkind" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "no conflicts on self", - in: newCRD("alfa.bravo.com"). - SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - StatusNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("alfa.bravo.com"). - SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - StatusNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - NewOrDie(), - }, - expectedNames: names("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: acceptedCondition, - expectedEstablishedCondition: installingCondition, - }, - { - name: "no conflicts on self, remove shortname", - in: newCRD("alfa.bravo.com"). - SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1"). - StatusNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("alfa.bravo.com"). - SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - StatusNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - NewOrDie(), - }, - expectedNames: names("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1"), - expectedNameConflictCondition: acceptedCondition, - expectedEstablishedCondition: installingCondition, - }, - { - name: "installing before with true condition", - in: newCRD("alfa.bravo.com").Condition(acceptedCondition).NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{}, - expectedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "alfa", - }, - expectedNameConflictCondition: acceptedCondition, - expectedEstablishedCondition: installingCondition, - }, - { - name: "not installing before with false condition", - in: newCRD("alfa.bravo.com").Condition(notAcceptedCondition).NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{}, - expectedNames: apiextensions.CustomResourceDefinitionNames{ - Plural: "alfa", - }, - expectedNameConflictCondition: acceptedCondition, - expectedEstablishedCondition: installingCondition, - }, - { - name: "conflicting, installing before with true condition", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - Condition(acceptedCondition). - NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "alfa", "", "").NewOrDie(), - }, - expectedNames: names("", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("PluralConflict", `"alfa" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - { - name: "conflicting, not installing before with false condition", - in: newCRD("alfa.bravo.com").SpecNames("alfa", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"). - Condition(notAcceptedCondition). - NewOrDie(), - existing: []*apiextensions.CustomResourceDefinition{ - newCRD("india.bravo.com").StatusNames("india", "alfa", "", "").NewOrDie(), - }, - expectedNames: names("", "delta-singular", "echo-kind", "foxtrot-listkind", "golf-shortname-1", "hotel-shortname-2"), - expectedNameConflictCondition: nameConflictCondition("PluralConflict", `"alfa" is already in use`), - expectedEstablishedCondition: notEstablishedCondition, - }, - } - - for _, tc := range tests { - crdIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) - for _, obj := range tc.existing { - crdIndexer.Add(obj) - } - - c := NamingConditionController{ - crdLister: listers.NewCustomResourceDefinitionLister(crdIndexer), - crdMutationCache: cache.NewIntegerResourceVersionMutationCache(crdIndexer, crdIndexer, 60*time.Second, false), - } - actualNames, actualNameConflictCondition, establishedCondition := c.calculateNamesAndConditions(tc.in) - - if e, a := tc.expectedNames, actualNames; !reflect.DeepEqual(e, a) { - t.Errorf("%v expected %v, got %#v", tc.name, e, a) - } - if e, a := tc.expectedNameConflictCondition, actualNameConflictCondition; !apiextensions.IsCRDConditionEquivalent(&e, &a) { - t.Errorf("%v expected %v, got %v", tc.name, e, a) - } - if e, a := tc.expectedEstablishedCondition, establishedCondition; !apiextensions.IsCRDConditionEquivalent(&e, &a) { - t.Errorf("%v expected %v, got %v", tc.name, e, a) - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/features/OWNERS b/vendor/k8s.io/apiextensions-apiserver/pkg/features/OWNERS deleted file mode 100644 index fe7b0144e..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/features/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -approvers: -- feature-approvers diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/features/kube_features.go b/vendor/k8s.io/apiextensions-apiserver/pkg/features/kube_features.go deleted file mode 100644 index 24e72f91e..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/features/kube_features.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2017 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 features - -import ( - utilfeature "k8s.io/apiserver/pkg/util/feature" -) - -const ( - // Every feature gate should add method here following this template: - // - // // owner: @username - // // alpha: v1.4 - // MyFeature() bool - - // owner: @sttts, @nikhita - // alpha: v1.8 - // beta: v1.9 - // - // CustomResourceValidation is a list of validation methods for CustomResources - CustomResourceValidation utilfeature.Feature = "CustomResourceValidation" - - // owner: @sttts, @nikhita - // alpha: v1.10 - // beta: v1.11 - // - // CustomResourceSubresources defines the subresources for CustomResources - CustomResourceSubresources utilfeature.Feature = "CustomResourceSubresources" -) - -func init() { - utilfeature.DefaultFeatureGate.Add(defaultKubernetesFeatureGates) -} - -// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys. -// To add a new feature, define a key for it above and add it here. The features will be -// available throughout Kubernetes binaries. -var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureSpec{ - CustomResourceValidation: {Default: true, PreRelease: utilfeature.Beta}, - CustomResourceSubresources: {Default: true, PreRelease: utilfeature.Beta}, -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go deleted file mode 100644 index d9e8fd97c..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go +++ /dev/null @@ -1,321 +0,0 @@ -/* -Copyright 2017 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 customresource - -import ( - "context" - "fmt" - "strings" - - autoscalingv1 "k8s.io/api/autoscaling/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apiserver/pkg/registry/generic" - genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" - "k8s.io/apiserver/pkg/registry/rest" -) - -// CustomResourceStorage includes dummy storage for CustomResources, and their Status and Scale subresources. -type CustomResourceStorage struct { - CustomResource *REST - Status *StatusREST - Scale *ScaleREST -} - -func NewStorage(resource schema.GroupResource, listKind schema.GroupVersionKind, strategy customResourceStrategy, optsGetter generic.RESTOptionsGetter, categories []string, tableConvertor rest.TableConvertor) CustomResourceStorage { - customResourceREST, customResourceStatusREST := newREST(resource, listKind, strategy, optsGetter, categories, tableConvertor) - customResourceRegistry := NewRegistry(customResourceREST) - - s := CustomResourceStorage{ - CustomResource: customResourceREST, - } - - if strategy.status != nil { - s.Status = customResourceStatusREST - } - - if scale := strategy.scale; scale != nil { - var labelSelectorPath string - if scale.LabelSelectorPath != nil { - labelSelectorPath = *scale.LabelSelectorPath - } - - s.Scale = &ScaleREST{ - registry: customResourceRegistry, - specReplicasPath: scale.SpecReplicasPath, - statusReplicasPath: scale.StatusReplicasPath, - labelSelectorPath: labelSelectorPath, - } - } - - return s -} - -// REST implements a RESTStorage for API services against etcd -type REST struct { - *genericregistry.Store - categories []string -} - -// newREST returns a RESTStorage object that will work against API services. -func newREST(resource schema.GroupResource, listKind schema.GroupVersionKind, strategy customResourceStrategy, optsGetter generic.RESTOptionsGetter, categories []string, tableConvertor rest.TableConvertor) (*REST, *StatusREST) { - store := &genericregistry.Store{ - NewFunc: func() runtime.Object { return &unstructured.Unstructured{} }, - NewListFunc: func() runtime.Object { - // lists are never stored, only manufactured, so stomp in the right kind - ret := &unstructured.UnstructuredList{} - ret.SetGroupVersionKind(listKind) - return ret - }, - PredicateFunc: strategy.MatchCustomResourceDefinitionStorage, - DefaultQualifiedResource: resource, - - CreateStrategy: strategy, - UpdateStrategy: strategy, - DeleteStrategy: strategy, - - TableConvertor: tableConvertor, - } - options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: strategy.GetAttrs} - if err := store.CompleteWithOptions(options); err != nil { - panic(err) // TODO: Propagate error up - } - - statusStore := *store - statusStore.UpdateStrategy = NewStatusStrategy(strategy) - return &REST{store, categories}, &StatusREST{store: &statusStore} -} - -// Implement CategoriesProvider -var _ rest.CategoriesProvider = &REST{} - -// List returns a list of items matching labels and field according to the store's PredicateFunc. -func (e *REST) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) { - l, err := e.Store.List(ctx, options) - if err != nil { - return nil, err - } - - // Shallow copy ObjectMeta in returned list for each item. Native types have `Items []Item` fields and therefore - // implicitly shallow copy ObjectMeta. The generic store sets the self-link for each item. So this is necessary - // to avoid mutation of the objects from the cache. - if ul, ok := l.(*unstructured.UnstructuredList); ok { - for i := range ul.Items { - shallowCopyObjectMeta(&ul.Items[i]) - } - } - - return l, nil -} - -func (r *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - o, err := r.Store.Get(ctx, name, options) - if err != nil { - return nil, err - } - if u, ok := o.(*unstructured.Unstructured); ok { - shallowCopyObjectMeta(u) - } - return o, nil -} - -func shallowCopyObjectMeta(u runtime.Unstructured) { - obj := shallowMapDeepCopy(u.UnstructuredContent()) - if metadata, ok := obj["metadata"]; ok { - if metadata, ok := metadata.(map[string]interface{}); ok { - obj["metadata"] = shallowMapDeepCopy(metadata) - u.SetUnstructuredContent(obj) - } - } -} - -func shallowMapDeepCopy(in map[string]interface{}) map[string]interface{} { - if in == nil { - return nil - } - - out := make(map[string]interface{}, len(in)) - for k, v := range in { - out[k] = v - } - - return out -} - -// Categories implements the CategoriesProvider interface. Returns a list of categories a resource is part of. -func (r *REST) Categories() []string { - return r.categories -} - -// StatusREST implements the REST endpoint for changing the status of a CustomResource -type StatusREST struct { - store *genericregistry.Store -} - -var _ = rest.Patcher(&StatusREST{}) - -func (r *StatusREST) New() runtime.Object { - return &unstructured.Unstructured{} -} - -// Get retrieves the object from the storage. It is required to support Patch. -func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - return r.store.Get(ctx, name, options) -} - -// Update alters the status subset of an object. -func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { - return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) -} - -type ScaleREST struct { - registry Registry - specReplicasPath string - statusReplicasPath string - labelSelectorPath string -} - -// ScaleREST implements Patcher -var _ = rest.Patcher(&ScaleREST{}) -var _ = rest.GroupVersionKindProvider(&ScaleREST{}) - -func (r *ScaleREST) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind { - return autoscalingv1.SchemeGroupVersion.WithKind("Scale") -} - -// New creates a new Scale object -func (r *ScaleREST) New() runtime.Object { - return &autoscalingv1.Scale{} -} - -func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - cr, err := r.registry.GetCustomResource(ctx, name, options) - if err != nil { - return nil, err - } - - scaleObject, replicasFound, err := scaleFromCustomResource(cr, r.specReplicasPath, r.statusReplicasPath, r.labelSelectorPath) - if err != nil { - return nil, err - } - if !replicasFound { - return nil, apierrors.NewInternalError(fmt.Errorf("the spec replicas field %q does not exist", r.specReplicasPath)) - } - return scaleObject, err -} - -func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { - cr, err := r.registry.GetCustomResource(ctx, name, &metav1.GetOptions{}) - if err != nil { - return nil, false, err - } - - const invalidSpecReplicas = -2147483648 // smallest int32 - oldScale, replicasFound, err := scaleFromCustomResource(cr, r.specReplicasPath, r.statusReplicasPath, r.labelSelectorPath) - if err != nil { - return nil, false, err - } - if !replicasFound { - oldScale.Spec.Replicas = invalidSpecReplicas // signal that this was not set before - } - - obj, err := objInfo.UpdatedObject(ctx, oldScale) - if err != nil { - return nil, false, err - } - if obj == nil { - return nil, false, apierrors.NewBadRequest(fmt.Sprintf("nil update passed to Scale")) - } - - scale, ok := obj.(*autoscalingv1.Scale) - if !ok { - return nil, false, apierrors.NewBadRequest(fmt.Sprintf("wrong object passed to Scale update: %v", obj)) - } - - if scale.Spec.Replicas == invalidSpecReplicas { - return nil, false, apierrors.NewBadRequest(fmt.Sprintf("the spec replicas field %q cannot be empty", r.specReplicasPath)) - } - - specReplicasPath := strings.TrimPrefix(r.specReplicasPath, ".") // ignore leading period - if err = unstructured.SetNestedField(cr.Object, int64(scale.Spec.Replicas), strings.Split(specReplicasPath, ".")...); err != nil { - return nil, false, err - } - cr.SetResourceVersion(scale.ResourceVersion) - - cr, err = r.registry.UpdateCustomResource(ctx, cr, createValidation, updateValidation) - if err != nil { - return nil, false, err - } - - newScale, _, err := scaleFromCustomResource(cr, r.specReplicasPath, r.statusReplicasPath, r.labelSelectorPath) - if err != nil { - return nil, false, apierrors.NewBadRequest(err.Error()) - } - return newScale, false, err -} - -// scaleFromCustomResource returns a scale subresource for a customresource and a bool signalling wether -// the specReplicas value was found. -func scaleFromCustomResource(cr *unstructured.Unstructured, specReplicasPath, statusReplicasPath, labelSelectorPath string) (*autoscalingv1.Scale, bool, error) { - specReplicasPath = strings.TrimPrefix(specReplicasPath, ".") // ignore leading period - specReplicas, foundSpecReplicas, err := unstructured.NestedInt64(cr.UnstructuredContent(), strings.Split(specReplicasPath, ".")...) - if err != nil { - return nil, false, err - } else if !foundSpecReplicas { - specReplicas = 0 - } - - statusReplicasPath = strings.TrimPrefix(statusReplicasPath, ".") // ignore leading period - statusReplicas, found, err := unstructured.NestedInt64(cr.UnstructuredContent(), strings.Split(statusReplicasPath, ".")...) - if err != nil { - return nil, false, err - } else if !found { - statusReplicas = 0 - } - - var labelSelector string - if len(labelSelectorPath) > 0 { - labelSelectorPath = strings.TrimPrefix(labelSelectorPath, ".") // ignore leading period - labelSelector, found, err = unstructured.NestedString(cr.UnstructuredContent(), strings.Split(labelSelectorPath, ".")...) - if err != nil { - return nil, false, err - } - } - - scale := &autoscalingv1.Scale{ - ObjectMeta: metav1.ObjectMeta{ - Name: cr.GetName(), - Namespace: cr.GetNamespace(), - UID: cr.GetUID(), - ResourceVersion: cr.GetResourceVersion(), - CreationTimestamp: cr.GetCreationTimestamp(), - }, - Spec: autoscalingv1.ScaleSpec{ - Replicas: int32(specReplicas), - }, - Status: autoscalingv1.ScaleStatus{ - Replicas: int32(statusReplicas), - Selector: labelSelector, - }, - } - - return scale, foundSpecReplicas, nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd_test.go deleted file mode 100644 index 15a242e44..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd_test.go +++ /dev/null @@ -1,575 +0,0 @@ -/* -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 customresource_test - -import ( - "io" - "reflect" - "strings" - "testing" - "time" - - autoscalingv1 "k8s.io/api/autoscaling/v1" - apiequality "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/api/errors" - metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/diff" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/generic" - registrytest "k8s.io/apiserver/pkg/registry/generic/testing" - "k8s.io/apiserver/pkg/registry/rest" - etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing" - "k8s.io/client-go/discovery" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apiextensions-apiserver/pkg/apiserver" - "k8s.io/apiextensions-apiserver/pkg/registry/customresource" - "k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor" -) - -func newStorage(t *testing.T) (customresource.CustomResourceStorage, *etcdtesting.EtcdTestServer) { - server, etcdStorage := etcdtesting.NewUnsecuredEtcd3TestClientServer(t) - etcdStorage.Codec = unstructuredJsonCodec{} - restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "noxus"} - - parameterScheme := runtime.NewScheme() - parameterScheme.AddUnversionedTypes(schema.GroupVersion{Group: "mygroup.example.com", Version: "v1beta1"}, - &metav1.ListOptions{}, - &metav1.ExportOptions{}, - &metav1.GetOptions{}, - &metav1.DeleteOptions{}, - ) - - typer := apiserver.UnstructuredObjectTyper{ - Delegate: parameterScheme, - UnstructuredTyper: discovery.NewUnstructuredObjectTyper(), - } - - kind := schema.GroupVersionKind{Group: "mygroup.example.com", Version: "v1beta1", Kind: "Noxu"} - - labelSelectorPath := ".status.labelSelector" - scale := &apiextensions.CustomResourceSubresourceScale{ - SpecReplicasPath: ".spec.replicas", - StatusReplicasPath: ".status.replicas", - LabelSelectorPath: &labelSelectorPath, - } - - status := &apiextensions.CustomResourceSubresourceStatus{} - - headers := []apiextensions.CustomResourceColumnDefinition{ - {Name: "Age", Type: "date", JSONPath: ".metadata.creationTimestamp"}, - {Name: "Replicas", Type: "integer", JSONPath: ".spec.replicas"}, - {Name: "Missing", Type: "string", JSONPath: ".spec.missing"}, - {Name: "Invalid", Type: "integer", JSONPath: ".spec.string"}, - {Name: "String", Type: "string", JSONPath: ".spec.string"}, - {Name: "StringFloat64", Type: "string", JSONPath: ".spec.float64"}, - {Name: "StringInt64", Type: "string", JSONPath: ".spec.replicas"}, - {Name: "StringBool", Type: "string", JSONPath: ".spec.bool"}, - {Name: "Float64", Type: "number", JSONPath: ".spec.float64"}, - {Name: "Bool", Type: "boolean", JSONPath: ".spec.bool"}, - } - table, _ := tableconvertor.New(headers) - - storage := customresource.NewStorage( - schema.GroupResource{Group: "mygroup.example.com", Resource: "noxus"}, - schema.GroupVersionKind{Group: "mygroup.example.com", Version: "v1beta1", Kind: "NoxuItemList"}, - customresource.NewStrategy( - typer, - true, - kind, - nil, - nil, - status, - scale, - ), - restOptions, - []string{"all"}, - table, - ) - - return storage, server -} - -// createCustomResource is a helper function that returns a CustomResource with the updated resource version. -func createCustomResource(storage *customresource.REST, cr unstructured.Unstructured, t *testing.T) (unstructured.Unstructured, error) { - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), cr.GetNamespace()) - obj, err := storage.Create(ctx, &cr, rest.ValidateAllObjectFunc, false) - if err != nil { - t.Errorf("Failed to create CustomResource, %v", err) - } - newCR := obj.(*unstructured.Unstructured) - return *newCR, nil -} - -func validNewCustomResource() *unstructured.Unstructured { - return &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "mygroup.example.com/v1beta1", - "kind": "Noxu", - "metadata": map[string]interface{}{ - "namespace": "default", - "name": "foo", - "creationTimestamp": time.Now().Add(-time.Hour*12 - 30*time.Minute).UTC().Format(time.RFC3339), - }, - "spec": map[string]interface{}{ - "replicas": int64(7), - "string": "string", - "float64": float64(3.1415926), - "bool": true, - "stringList": []interface{}{"foo", "bar"}, - "mixedList": []interface{}{"foo", int64(42)}, - "nonPrimitiveList": []interface{}{"foo", []interface{}{int64(1), int64(2)}}, - }, - }, - } -} - -var validCustomResource = *validNewCustomResource() - -func TestCreate(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - test := registrytest.New(t, storage.CustomResource.Store) - cr := validNewCustomResource() - cr.SetNamespace("") - test.TestCreate( - cr, - ) -} - -func TestGet(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - test := registrytest.New(t, storage.CustomResource.Store) - test.TestGet(validNewCustomResource()) -} - -func TestList(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - test := registrytest.New(t, storage.CustomResource.Store) - test.TestList(validNewCustomResource()) -} - -func TestDelete(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - test := registrytest.New(t, storage.CustomResource.Store) - test.TestDelete(validNewCustomResource()) -} - -func TestGenerationNumber(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - modifiedRno := *validNewCustomResource() - modifiedRno.SetGeneration(10) - ctx := genericapirequest.NewDefaultContext() - cr, err := createCustomResource(storage.CustomResource, modifiedRno, t) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - etcdCR, err := storage.CustomResource.Get(ctx, cr.GetName(), &metav1.GetOptions{}) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - storedCR, _ := etcdCR.(*unstructured.Unstructured) - - // Generation initialization - if storedCR.GetGeneration() != 1 { - t.Fatalf("Unexpected generation number %v", storedCR.GetGeneration()) - } - - // Updates to spec should increment the generation number - setSpecReplicas(storedCR, getSpecReplicas(storedCR)+1) - if _, _, err := storage.CustomResource.Update(ctx, storedCR.GetName(), rest.DefaultUpdatedObjectInfo(storedCR), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil { - t.Errorf("unexpected error: %v", err) - } - etcdCR, err = storage.CustomResource.Get(ctx, cr.GetName(), &metav1.GetOptions{}) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - storedCR, _ = etcdCR.(*unstructured.Unstructured) - if storedCR.GetGeneration() != 2 { - t.Fatalf("Unexpected generation, spec: %v", storedCR.GetGeneration()) - } - - // Updates to status should not increment the generation number - setStatusReplicas(storedCR, getStatusReplicas(storedCR)+1) - if _, _, err := storage.CustomResource.Update(ctx, storedCR.GetName(), rest.DefaultUpdatedObjectInfo(storedCR), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil { - t.Errorf("unexpected error: %v", err) - } - etcdCR, err = storage.CustomResource.Get(ctx, cr.GetName(), &metav1.GetOptions{}) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - storedCR, _ = etcdCR.(*unstructured.Unstructured) - if storedCR.GetGeneration() != 2 { - t.Fatalf("Unexpected generation, spec: %v", storedCR.GetGeneration()) - } - -} - -func TestCategories(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - - expected := []string{"all"} - actual := storage.CustomResource.Categories() - ok := reflect.DeepEqual(actual, expected) - if !ok { - t.Errorf("categories are not equal. expected = %v actual = %v", expected, actual) - } -} - -func TestColumns(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault) - key := "/noxus/" + metav1.NamespaceDefault + "/foo" - validCustomResource := validNewCustomResource() - if err := storage.CustomResource.Storage.Create(ctx, key, validCustomResource, nil, 0); err != nil { - t.Fatalf("unexpected error: %v", err) - } - - gottenList, err := storage.CustomResource.List(ctx, &metainternal.ListOptions{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - tbl, err := storage.CustomResource.ConvertToTable(ctx, gottenList, &metav1beta1.TableOptions{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - expectedColumns := []struct { - Name, Type string - }{ - {"Name", "string"}, - {"Age", "date"}, - {"Replicas", "integer"}, - {"Missing", "string"}, - {"Invalid", "integer"}, - {"String", "string"}, - {"StringFloat64", "string"}, - {"StringInt64", "string"}, - {"StringBool", "string"}, - {"Float64", "number"}, - {"Bool", "boolean"}, - } - if len(tbl.ColumnDefinitions) != len(expectedColumns) { - t.Fatalf("got %d columns, expected %d. Got: %+v", len(tbl.ColumnDefinitions), len(expectedColumns), tbl.ColumnDefinitions) - } - for i, d := range tbl.ColumnDefinitions { - if d.Name != expectedColumns[i].Name { - t.Errorf("got column %d name %q, expected %q", i, d.Name, expectedColumns[i].Name) - } - if d.Type != expectedColumns[i].Type { - t.Errorf("got column %d type %q, expected %q", i, d.Type, expectedColumns[i].Type) - } - } - - expectedRows := [][]interface{}{ - { - "foo", - "12h", - int64(7), - nil, - nil, - "string", - "3.1415926", - "7", - "true", - float64(3.1415926), - true, - }, - } - for i, r := range tbl.Rows { - if !reflect.DeepEqual(r.Cells, expectedRows[i]) { - t.Errorf("got row %d with cells %#v, expected %#v", i, r.Cells, expectedRows[i]) - } - } -} - -func TestStatusUpdate(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault) - key := "/noxus/" + metav1.NamespaceDefault + "/foo" - validCustomResource := validNewCustomResource() - if err := storage.CustomResource.Storage.Create(ctx, key, validCustomResource, nil, 0); err != nil { - t.Fatalf("unexpected error: %v", err) - } - - gottenObj, err := storage.CustomResource.Get(ctx, "foo", &metav1.GetOptions{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - update := gottenObj.(*unstructured.Unstructured) - updateContent := update.Object - updateContent["status"] = map[string]interface{}{ - "replicas": int64(7), - } - - if _, _, err := storage.Status.Update(ctx, update.GetName(), rest.DefaultUpdatedObjectInfo(update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil { - t.Fatalf("unexpected error: %v", err) - } - - obj, err := storage.CustomResource.Get(ctx, "foo", &metav1.GetOptions{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - cr, ok := obj.(*unstructured.Unstructured) - if !ok { - t.Fatal("unexpected error: custom resource should be of type Unstructured") - } - content := cr.UnstructuredContent() - - spec := content["spec"].(map[string]interface{}) - status := content["status"].(map[string]interface{}) - - if spec["replicas"].(int64) != 7 { - t.Errorf("we expected .spec.replicas to not be updated but it was updated to %v", spec["replicas"].(int64)) - } - if status["replicas"].(int64) != 7 { - t.Errorf("we expected .status.replicas to be updated to %d but it was %v", 7, status["replicas"].(int64)) - } -} - -func TestScaleGet(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - - name := "foo" - - var cr unstructured.Unstructured - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault) - key := "/noxus/" + metav1.NamespaceDefault + "/" + name - if err := storage.CustomResource.Storage.Create(ctx, key, &validCustomResource, &cr, 0); err != nil { - t.Fatalf("error setting new custom resource (key: %s) %v: %v", key, validCustomResource, err) - } - - want := &autoscalingv1.Scale{ - ObjectMeta: metav1.ObjectMeta{ - Name: cr.GetName(), - Namespace: metav1.NamespaceDefault, - UID: cr.GetUID(), - ResourceVersion: cr.GetResourceVersion(), - CreationTimestamp: cr.GetCreationTimestamp(), - }, - Spec: autoscalingv1.ScaleSpec{ - Replicas: int32(7), - }, - } - - obj, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{}) - if err != nil { - t.Fatalf("error fetching scale for %s: %v", name, err) - } - - got := obj.(*autoscalingv1.Scale) - if !apiequality.Semantic.DeepEqual(got, want) { - t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want)) - } -} - -func TestScaleGetWithoutSpecReplicas(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - - name := "foo" - - var cr unstructured.Unstructured - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault) - key := "/noxus/" + metav1.NamespaceDefault + "/" + name - withoutSpecReplicas := validCustomResource.DeepCopy() - unstructured.RemoveNestedField(withoutSpecReplicas.Object, "spec", "replicas") - if err := storage.CustomResource.Storage.Create(ctx, key, withoutSpecReplicas, &cr, 0); err != nil { - t.Fatalf("error setting new custom resource (key: %s) %v: %v", key, withoutSpecReplicas, err) - } - - _, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{}) - if err == nil { - t.Fatalf("error expected for %s", name) - } - if expected := `the spec replicas field ".spec.replicas" does not exist`; !strings.Contains(err.Error(), expected) { - t.Fatalf("expected error string %q, got: %v", expected, err) - } -} - -func TestScaleUpdate(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - - name := "foo" - - var cr unstructured.Unstructured - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault) - key := "/noxus/" + metav1.NamespaceDefault + "/" + name - if err := storage.CustomResource.Storage.Create(ctx, key, &validCustomResource, &cr, 0); err != nil { - t.Fatalf("error setting new custom resource (key: %s) %v: %v", key, validCustomResource, err) - } - - obj, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{}) - if err != nil { - t.Fatalf("error fetching scale for %s: %v", name, err) - } - scale, ok := obj.(*autoscalingv1.Scale) - if !ok { - t.Fatalf("%v is not of the type autoscalingv1.Scale", scale) - } - - replicas := 12 - update := autoscalingv1.Scale{ - ObjectMeta: scale.ObjectMeta, - Spec: autoscalingv1.ScaleSpec{ - Replicas: int32(replicas), - }, - } - - if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil { - t.Fatalf("error updating scale %v: %v", update, err) - } - - obj, err = storage.Scale.Get(ctx, name, &metav1.GetOptions{}) - if err != nil { - t.Fatalf("error fetching scale for %s: %v", name, err) - } - scale = obj.(*autoscalingv1.Scale) - if scale.Spec.Replicas != int32(replicas) { - t.Errorf("wrong replicas count: expected: %d got: %d", replicas, scale.Spec.Replicas) - } - - update.ResourceVersion = scale.ResourceVersion - update.Spec.Replicas = 15 - - if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil && !errors.IsConflict(err) { - t.Fatalf("unexpected error, expecting an update conflict but got %v", err) - } -} - -func TestScaleUpdateWithoutSpecReplicas(t *testing.T) { - storage, server := newStorage(t) - defer server.Terminate(t) - defer storage.CustomResource.Store.DestroyFunc() - - name := "foo" - - var cr unstructured.Unstructured - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault) - key := "/noxus/" + metav1.NamespaceDefault + "/" + name - withoutSpecReplicas := validCustomResource.DeepCopy() - unstructured.RemoveNestedField(withoutSpecReplicas.Object, "spec", "replicas") - if err := storage.CustomResource.Storage.Create(ctx, key, withoutSpecReplicas, &cr, 0); err != nil { - t.Fatalf("error setting new custom resource (key: %s) %v: %v", key, withoutSpecReplicas, err) - } - - replicas := 12 - update := autoscalingv1.Scale{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - ResourceVersion: cr.GetResourceVersion(), - }, - Spec: autoscalingv1.ScaleSpec{ - Replicas: int32(replicas), - }, - } - - if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil { - t.Fatalf("error updating scale %v: %v", update, err) - } - - obj, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{}) - if err != nil { - t.Fatalf("error fetching scale for %s: %v", name, err) - } - scale := obj.(*autoscalingv1.Scale) - if scale.Spec.Replicas != int32(replicas) { - t.Errorf("wrong replicas count: expected: %d got: %d", replicas, scale.Spec.Replicas) - } -} - -type unstructuredJsonCodec struct{} - -func (c unstructuredJsonCodec) Decode(data []byte, defaults *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) { - obj := into.(*unstructured.Unstructured) - err := obj.UnmarshalJSON(data) - if err != nil { - return nil, nil, err - } - gvk := obj.GroupVersionKind() - return obj, &gvk, nil -} - -func (c unstructuredJsonCodec) Encode(obj runtime.Object, w io.Writer) error { - u := obj.(*unstructured.Unstructured) - bs, err := u.MarshalJSON() - if err != nil { - return err - } - w.Write(bs) - return nil -} - -func setSpecReplicas(u *unstructured.Unstructured, replicas int64) { - setNestedField(u, replicas, "spec", "replicas") -} - -func getSpecReplicas(u *unstructured.Unstructured) int64 { - val, found, err := unstructured.NestedInt64(u.Object, "spec", "replicas") - if !found || err != nil { - return 0 - } - return val -} - -func setStatusReplicas(u *unstructured.Unstructured, replicas int64) { - setNestedField(u, replicas, "status", "replicas") -} - -func getStatusReplicas(u *unstructured.Unstructured) int64 { - val, found, err := unstructured.NestedInt64(u.Object, "status", "replicas") - if !found || err != nil { - return 0 - } - return val -} - -func setNestedField(u *unstructured.Unstructured, value interface{}, fields ...string) { - if u.Object == nil { - u.Object = make(map[string]interface{}) - } - unstructured.SetNestedField(u.Object, value, fields...) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/registry.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/registry.go deleted file mode 100644 index e3d468036..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/registry.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -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 customresource - -import ( - "context" - "fmt" - "strings" - - "k8s.io/apimachinery/pkg/api/errors" - metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/apiserver/pkg/registry/rest" -) - -// Registry is an interface for things that know how to store CustomResources. -type Registry interface { - ListCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error) - WatchCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) - GetCustomResource(ctx context.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error) - CreateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc) (*unstructured.Unstructured, error) - UpdateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*unstructured.Unstructured, error) - DeleteCustomResource(ctx context.Context, customResourceID string) error -} - -// storage puts strong typing around storage calls -type storage struct { - rest.StandardStorage -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched -// types will panic. -func NewRegistry(s rest.StandardStorage) Registry { - return &storage{s} -} - -func (s *storage) ListCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (*unstructured.UnstructuredList, error) { - if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { - return nil, fmt.Errorf("field selector not supported yet") - } - obj, err := s.List(ctx, options) - if err != nil { - return nil, err - } - return obj.(*unstructured.UnstructuredList), err -} - -func (s *storage) WatchCustomResources(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) { - return s.Watch(ctx, options) -} - -func (s *storage) GetCustomResource(ctx context.Context, customResourceID string, options *metav1.GetOptions) (*unstructured.Unstructured, error) { - obj, err := s.Get(ctx, customResourceID, options) - customResource, ok := obj.(*unstructured.Unstructured) - if !ok { - return nil, fmt.Errorf("custom resource must be of type Unstructured") - } - - if err != nil { - apiVersion := customResource.GetAPIVersion() - groupVersion := strings.Split(apiVersion, "/") - group := groupVersion[0] - return nil, errors.NewNotFound(schema.GroupResource{Group: group, Resource: "scale"}, customResourceID) - } - return customResource, nil -} - -func (s *storage) CreateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc) (*unstructured.Unstructured, error) { - obj, err := s.Create(ctx, customResource, rest.ValidateAllObjectFunc, false) - if err != nil { - return nil, err - } - return obj.(*unstructured.Unstructured), nil -} - -func (s *storage) UpdateCustomResource(ctx context.Context, customResource *unstructured.Unstructured, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*unstructured.Unstructured, error) { - obj, _, err := s.Update(ctx, customResource.GetName(), rest.DefaultUpdatedObjectInfo(customResource), createValidation, updateValidation) - if err != nil { - return nil, err - } - return obj.(*unstructured.Unstructured), nil -} - -func (s *storage) DeleteCustomResource(ctx context.Context, customResourceID string) error { - _, _, err := s.Delete(ctx, customResourceID, nil) - return err -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go deleted file mode 100644 index 1710eb2e1..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go +++ /dev/null @@ -1,59 +0,0 @@ -/* -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 customresource - -import ( - "context" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" -) - -type statusStrategy struct { - customResourceStrategy -} - -func NewStatusStrategy(strategy customResourceStrategy) statusStrategy { - return statusStrategy{strategy} -} - -func (a statusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { - // update is only allowed to set status - newCustomResourceObject := obj.(*unstructured.Unstructured) - newCustomResource := newCustomResourceObject.UnstructuredContent() - status, ok := newCustomResource["status"] - - // copy old object into new object - oldCustomResourceObject := old.(*unstructured.Unstructured) - // overridding the resourceVersion in metadata is safe here, we have already checked that - // new object and old object have the same resourceVersion. - *newCustomResourceObject = *oldCustomResourceObject.DeepCopy() - - // set status - newCustomResource = newCustomResourceObject.UnstructuredContent() - if ok { - newCustomResource["status"] = status - } else { - delete(newCustomResource, "status") - } -} - -// ValidateUpdate is the default update validation for an end user updating status. -func (a statusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { - return a.customResourceStrategy.validator.ValidateStatusUpdate(ctx, obj, old, a.scale) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy_test.go deleted file mode 100644 index 8a651d12b..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy_test.go +++ /dev/null @@ -1,138 +0,0 @@ -/* -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 customresource - -import ( - "context" - "reflect" - "testing" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" -) - -func TestPrepareForUpdate(t *testing.T) { - strategy := statusStrategy{} - tcs := []struct { - old *unstructured.Unstructured - obj *unstructured.Unstructured - expected *unstructured.Unstructured - }{ - { - // changes to spec are ignored - old: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - }, - }, - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "new", - }, - }, - expected: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - }, - }, - }, - { - // changes to other places are also ignored - old: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - }, - }, - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "new": "new", - }, - }, - expected: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - }, - }, - }, - { - // delete status - old: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - "status": "old", - }, - }, - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - }, - }, - expected: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - }, - }, - }, - { - // update status - old: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - "status": "old", - }, - }, - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "status": "new", - }, - }, - expected: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - "status": "new", - }, - }, - }, - { - // update status and other parts - old: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - "status": "old", - }, - }, - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "new", - "new": "new", - "status": "new", - }, - }, - expected: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "spec": "old", - "status": "new", - }, - }, - }, - } - for index, tc := range tcs { - strategy.PrepareForUpdate(context.TODO(), tc.obj, tc.old) - if !reflect.DeepEqual(tc.obj, tc.expected) { - t.Errorf("test %d failed: expected: %v, got %v", index, tc.expected, tc.obj) - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go deleted file mode 100644 index 4895e287a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go +++ /dev/null @@ -1,185 +0,0 @@ -/* -Copyright 2017 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 customresource - -import ( - "context" - - "github.com/go-openapi/validate" - - apiequality "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/validation/field" - apiserverstorage "k8s.io/apiserver/pkg/storage" - "k8s.io/apiserver/pkg/storage/names" - utilfeature "k8s.io/apiserver/pkg/util/feature" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - apiextensionsfeatures "k8s.io/apiextensions-apiserver/pkg/features" -) - -// customResourceStrategy implements behavior for CustomResources. -type customResourceStrategy struct { - runtime.ObjectTyper - names.NameGenerator - - namespaceScoped bool - validator customResourceValidator - status *apiextensions.CustomResourceSubresourceStatus - scale *apiextensions.CustomResourceSubresourceScale -} - -func NewStrategy(typer runtime.ObjectTyper, namespaceScoped bool, kind schema.GroupVersionKind, schemaValidator, statusSchemaValidator *validate.SchemaValidator, status *apiextensions.CustomResourceSubresourceStatus, scale *apiextensions.CustomResourceSubresourceScale) customResourceStrategy { - return customResourceStrategy{ - ObjectTyper: typer, - NameGenerator: names.SimpleNameGenerator, - namespaceScoped: namespaceScoped, - status: status, - scale: scale, - validator: customResourceValidator{ - namespaceScoped: namespaceScoped, - kind: kind, - schemaValidator: schemaValidator, - statusSchemaValidator: statusSchemaValidator, - }, - } -} - -func (a customResourceStrategy) NamespaceScoped() bool { - return a.namespaceScoped -} - -// PrepareForCreate clears the status of a CustomResource before creation. -func (a customResourceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { - if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) && a.status != nil { - customResourceObject := obj.(*unstructured.Unstructured) - customResource := customResourceObject.UnstructuredContent() - - // create cannot set status - if _, ok := customResource["status"]; ok { - delete(customResource, "status") - } - } - - accessor, _ := meta.Accessor(obj) - accessor.SetGeneration(1) -} - -// PrepareForUpdate clears fields that are not allowed to be set by end users on update. -func (a customResourceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { - if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) || a.status == nil { - return - } - - newCustomResourceObject := obj.(*unstructured.Unstructured) - oldCustomResourceObject := old.(*unstructured.Unstructured) - - newCustomResource := newCustomResourceObject.UnstructuredContent() - oldCustomResource := oldCustomResourceObject.UnstructuredContent() - - // update is not allowed to set status - _, ok1 := newCustomResource["status"] - _, ok2 := oldCustomResource["status"] - switch { - case ok2: - newCustomResource["status"] = oldCustomResource["status"] - case ok1: - delete(newCustomResource, "status") - } - - // Any changes to the spec increment the generation number, any changes to the - // status should reflect the generation number of the corresponding object. We push - // the burden of managing the status onto the clients because we can't (in general) - // know here what version of spec the writer of the status has seen. It may seem like - // we can at first -- since obj contains spec -- but in the future we will probably make - // status its own object, and even if we don't, writes may be the result of a - // read-update-write loop, so the contents of spec may not actually be the spec that - // the CustomResource has *seen*. - newSpec, ok1 := newCustomResource["spec"] - oldSpec, ok2 := oldCustomResource["spec"] - - // spec is changed, created or deleted - if (ok1 && ok2 && !apiequality.Semantic.DeepEqual(oldSpec, newSpec)) || (ok1 && !ok2) || (!ok1 && ok2) { - oldAccessor, _ := meta.Accessor(oldCustomResourceObject) - newAccessor, _ := meta.Accessor(newCustomResourceObject) - newAccessor.SetGeneration(oldAccessor.GetGeneration() + 1) - } -} - -// Validate validates a new CustomResource. -func (a customResourceStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { - return a.validator.Validate(ctx, obj, a.scale) -} - -// Canonicalize normalizes the object after validation. -func (customResourceStrategy) Canonicalize(obj runtime.Object) { -} - -// AllowCreateOnUpdate is false for CustomResources; this means a POST is -// needed to create one. -func (customResourceStrategy) AllowCreateOnUpdate() bool { - return false -} - -// AllowUnconditionalUpdate is the default update policy for CustomResource objects. -func (customResourceStrategy) AllowUnconditionalUpdate() bool { - return false -} - -// ValidateUpdate is the default update validation for an end user updating status. -func (a customResourceStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { - return a.validator.ValidateUpdate(ctx, obj, old, a.scale) -} - -// GetAttrs returns labels and fields of a given object for filtering purposes. -func (a customResourceStrategy) GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) { - accessor, err := meta.Accessor(obj) - if err != nil { - return nil, nil, false, err - } - return labels.Set(accessor.GetLabels()), objectMetaFieldsSet(accessor, a.namespaceScoped), accessor.GetInitializers() != nil, nil -} - -// objectMetaFieldsSet returns a fields that represent the ObjectMeta. -func objectMetaFieldsSet(objectMeta metav1.Object, namespaceScoped bool) fields.Set { - if namespaceScoped { - return fields.Set{ - "metadata.name": objectMeta.GetName(), - "metadata.namespace": objectMeta.GetNamespace(), - } - } - return fields.Set{ - "metadata.name": objectMeta.GetName(), - } -} - -// MatchCustomResourceDefinitionStorage is the filter used by the generic etcd backend to route -// watch events from etcd to clients of the apiserver only interested in specific -// labels/fields. -func (a customResourceStrategy) MatchCustomResourceDefinitionStorage(label labels.Selector, field fields.Selector) apiserverstorage.SelectionPredicate { - return apiserverstorage.SelectionPredicate{ - Label: label, - Field: field, - GetAttrs: a.GetAttrs, - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go deleted file mode 100644 index e1bed809d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go +++ /dev/null @@ -1,172 +0,0 @@ -/* -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 tableconvertor - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "reflect" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apimachinery/pkg/api/meta" - metatable "k8s.io/apimachinery/pkg/api/meta/table" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/client-go/util/jsonpath" -) - -var swaggerMetadataDescriptions = metav1.ObjectMeta{}.SwaggerDoc() - -// New creates a new table convertor for the provided CRD column definition. If the printer definition cannot be parsed, -// error will be returned along with a default table convertor. -func New(crdColumns []apiextensions.CustomResourceColumnDefinition) (rest.TableConvertor, error) { - headers := []metav1beta1.TableColumnDefinition{ - {Name: "Name", Type: "string", Format: "name", Description: swaggerMetadataDescriptions["name"]}, - } - c := &convertor{ - headers: headers, - } - - for _, col := range crdColumns { - path := jsonpath.New(col.Name) - if err := path.Parse(fmt.Sprintf("{%s}", col.JSONPath)); err != nil { - return c, fmt.Errorf("unrecognized column definition %q", col.JSONPath) - } - path.AllowMissingKeys(true) - - desc := fmt.Sprintf("Custom resource definition column (in JSONPath format): %s", col.JSONPath) - if len(col.Description) > 0 { - desc = col.Description - } - - c.additionalColumns = append(c.additionalColumns, path) - c.headers = append(c.headers, metav1beta1.TableColumnDefinition{ - Name: col.Name, - Type: col.Type, - Format: col.Format, - Description: desc, - Priority: col.Priority, - }) - } - - return c, nil -} - -type convertor struct { - headers []metav1beta1.TableColumnDefinition - additionalColumns []*jsonpath.JSONPath -} - -func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { - table := &metav1beta1.Table{ - ColumnDefinitions: c.headers, - } - if m, err := meta.ListAccessor(obj); err == nil { - table.ResourceVersion = m.GetResourceVersion() - table.SelfLink = m.GetSelfLink() - table.Continue = m.GetContinue() - } else { - if m, err := meta.CommonAccessor(obj); err == nil { - table.ResourceVersion = m.GetResourceVersion() - table.SelfLink = m.GetSelfLink() - } - } - - var err error - buf := &bytes.Buffer{} - table.Rows, err = metatable.MetaToTableRow(obj, func(obj runtime.Object, m metav1.Object, name, age string) ([]interface{}, error) { - cells := make([]interface{}, 1, 1+len(c.additionalColumns)) - cells[0] = name - customHeaders := c.headers[1:] - for i, column := range c.additionalColumns { - results, err := column.FindResults(obj.(runtime.Unstructured).UnstructuredContent()) - if err != nil || len(results) == 0 || len(results[0]) == 0 { - cells = append(cells, nil) - continue - } - - // as we only support simple JSON path, we can assume to have only one result (or none, filtered out above) - value := results[0][0].Interface() - if customHeaders[i].Type == "string" { - if err := column.PrintResults(buf, []reflect.Value{reflect.ValueOf(value)}); err == nil { - cells = append(cells, buf.String()) - buf.Reset() - } else { - cells = append(cells, nil) - } - } else { - cells = append(cells, cellForJSONValue(customHeaders[i].Type, value)) - } - } - return cells, nil - }) - return table, err -} - -func cellForJSONValue(headerType string, value interface{}) interface{} { - if value == nil { - return nil - } - - switch headerType { - case "integer": - switch typed := value.(type) { - case int64: - return typed - case float64: - return int64(typed) - case json.Number: - if i64, err := typed.Int64(); err == nil { - return i64 - } - } - case "number": - switch typed := value.(type) { - case int64: - return float64(typed) - case float64: - return typed - case json.Number: - if f, err := typed.Float64(); err == nil { - return f - } - } - case "boolean": - if b, ok := value.(bool); ok { - return b - } - case "string": - if s, ok := value.(string); ok { - return s - } - case "date": - if typed, ok := value.(string); ok { - var timestamp metav1.Time - err := timestamp.UnmarshalQueryParameter(typed) - if err != nil { - return "" - } - return metatable.ConvertToHumanReadableDateType(timestamp) - } - } - - return nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor_test.go deleted file mode 100644 index 179aabb8a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor_test.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -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 tableconvertor - -import ( - "fmt" - "reflect" - "testing" - "time" -) - -func Test_cellForJSONValue(t *testing.T) { - tests := []struct { - headerType string - value interface{} - want interface{} - }{ - {"integer", int64(42), int64(42)}, - {"integer", float64(3.14), int64(3)}, - {"integer", true, nil}, - {"integer", "foo", nil}, - - {"number", int64(42), float64(42)}, - {"number", float64(3.14), float64(3.14)}, - {"number", true, nil}, - {"number", "foo", nil}, - - {"boolean", int64(42), nil}, - {"boolean", float64(3.14), nil}, - {"boolean", true, true}, - {"boolean", "foo", nil}, - - {"string", int64(42), nil}, - {"string", float64(3.14), nil}, - {"string", true, nil}, - {"string", "foo", "foo"}, - - {"date", int64(42), nil}, - {"date", float64(3.14), nil}, - {"date", true, nil}, - {"date", time.Now().Add(-time.Hour*12 - 30*time.Minute).UTC().Format(time.RFC3339), "12h"}, - {"date", time.Now().Add(+time.Hour*12 + 30*time.Minute).UTC().Format(time.RFC3339), ""}, - {"date", "", ""}, - - {"unknown", "foo", nil}, - } - for _, tt := range tests { - t.Run(fmt.Sprintf("%#v of type %s", tt.value, tt.headerType), func(t *testing.T) { - if got := cellForJSONValue(tt.headerType, tt.value); !reflect.DeepEqual(got, tt.want) { - t.Errorf("cellForJSONValue() = %#v, want %#v", got, tt.want) - } - }) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go deleted file mode 100644 index 5206a17eb..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -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 customresource - -import ( - "context" - "fmt" - "math" - "strings" - - "github.com/go-openapi/validate" - - "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/api/validation" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/validation/field" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - apiservervalidation "k8s.io/apiextensions-apiserver/pkg/apiserver/validation" -) - -type customResourceValidator struct { - namespaceScoped bool - kind schema.GroupVersionKind - schemaValidator *validate.SchemaValidator - statusSchemaValidator *validate.SchemaValidator -} - -func (a customResourceValidator) Validate(ctx context.Context, obj runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { - u, ok := obj.(*unstructured.Unstructured) - if !ok { - return field.ErrorList{field.Invalid(field.NewPath(""), u, fmt.Sprintf("has type %T. Must be a pointer to an Unstructured type", u))} - } - accessor, err := meta.Accessor(obj) - if err != nil { - return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} - } - - if errs := a.ValidateTypeMeta(ctx, u); len(errs) > 0 { - return errs - } - - var allErrs field.ErrorList - - allErrs = append(allErrs, validation.ValidateObjectMetaAccessor(accessor, a.namespaceScoped, validation.NameIsDNSSubdomain, field.NewPath("metadata"))...) - if err = apiservervalidation.ValidateCustomResource(u.UnstructuredContent(), a.schemaValidator); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath(""), u.UnstructuredContent(), err.Error())) - } - allErrs = append(allErrs, a.ValidateScaleSpec(ctx, u, scale)...) - allErrs = append(allErrs, a.ValidateScaleStatus(ctx, u, scale)...) - - return allErrs -} - -func (a customResourceValidator) ValidateUpdate(ctx context.Context, obj, old runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { - u, ok := obj.(*unstructured.Unstructured) - if !ok { - return field.ErrorList{field.Invalid(field.NewPath(""), u, fmt.Sprintf("has type %T. Must be a pointer to an Unstructured type", u))} - } - objAccessor, err := meta.Accessor(obj) - if err != nil { - return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} - } - oldAccessor, err := meta.Accessor(old) - if err != nil { - return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} - } - - if errs := a.ValidateTypeMeta(ctx, u); len(errs) > 0 { - return errs - } - - var allErrs field.ErrorList - - allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(objAccessor, oldAccessor, field.NewPath("metadata"))...) - if err = apiservervalidation.ValidateCustomResource(u.UnstructuredContent(), a.schemaValidator); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath(""), u.UnstructuredContent(), err.Error())) - } - allErrs = append(allErrs, a.ValidateScaleSpec(ctx, u, scale)...) - allErrs = append(allErrs, a.ValidateScaleStatus(ctx, u, scale)...) - - return allErrs -} - -func (a customResourceValidator) ValidateStatusUpdate(ctx context.Context, obj, old runtime.Object, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { - u, ok := obj.(*unstructured.Unstructured) - if !ok { - return field.ErrorList{field.Invalid(field.NewPath(""), u, fmt.Sprintf("has type %T. Must be a pointer to an Unstructured type", u))} - } - objAccessor, err := meta.Accessor(obj) - if err != nil { - return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} - } - oldAccessor, err := meta.Accessor(old) - if err != nil { - return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())} - } - - if errs := a.ValidateTypeMeta(ctx, u); len(errs) > 0 { - return errs - } - - var allErrs field.ErrorList - - allErrs = append(allErrs, validation.ValidateObjectMetaAccessorUpdate(objAccessor, oldAccessor, field.NewPath("metadata"))...) - if err = apiservervalidation.ValidateCustomResource(u.UnstructuredContent(), a.schemaValidator); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath(""), u.UnstructuredContent(), err.Error())) - } - allErrs = append(allErrs, a.ValidateScaleStatus(ctx, u, scale)...) - - return allErrs -} - -func (a customResourceValidator) ValidateTypeMeta(ctx context.Context, obj *unstructured.Unstructured) field.ErrorList { - typeAccessor, err := meta.TypeAccessor(obj) - if err != nil { - return field.ErrorList{field.Invalid(field.NewPath("kind"), nil, err.Error())} - } - - var allErrs field.ErrorList - if typeAccessor.GetKind() != a.kind.Kind { - allErrs = append(allErrs, field.Invalid(field.NewPath("kind"), typeAccessor.GetKind(), fmt.Sprintf("must be %v", a.kind.Kind))) - } - if typeAccessor.GetAPIVersion() != a.kind.Group+"/"+a.kind.Version { - allErrs = append(allErrs, field.Invalid(field.NewPath("apiVersion"), typeAccessor.GetAPIVersion(), fmt.Sprintf("must be %v", a.kind.Group+"/"+a.kind.Version))) - } - return allErrs -} - -func (a customResourceValidator) ValidateScaleSpec(ctx context.Context, obj *unstructured.Unstructured, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { - if scale == nil { - return nil - } - - var allErrs field.ErrorList - - // validate specReplicas - specReplicasPath := strings.TrimPrefix(scale.SpecReplicasPath, ".") // ignore leading period - specReplicas, _, err := unstructured.NestedInt64(obj.UnstructuredContent(), strings.Split(specReplicasPath, ".")...) - if err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath(scale.SpecReplicasPath), specReplicas, err.Error())) - } else if specReplicas < 0 { - allErrs = append(allErrs, field.Invalid(field.NewPath(scale.SpecReplicasPath), specReplicas, "should be a non-negative integer")) - } else if specReplicas > math.MaxInt32 { - allErrs = append(allErrs, field.Invalid(field.NewPath(scale.SpecReplicasPath), specReplicas, fmt.Sprintf("should be less than or equal to %v", math.MaxInt32))) - } - - return allErrs -} - -func (a customResourceValidator) ValidateScaleStatus(ctx context.Context, obj *unstructured.Unstructured, scale *apiextensions.CustomResourceSubresourceScale) field.ErrorList { - if scale == nil { - return nil - } - - var allErrs field.ErrorList - - // validate statusReplicas - statusReplicasPath := strings.TrimPrefix(scale.StatusReplicasPath, ".") // ignore leading period - statusReplicas, _, err := unstructured.NestedInt64(obj.UnstructuredContent(), strings.Split(statusReplicasPath, ".")...) - if err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath(scale.StatusReplicasPath), statusReplicas, err.Error())) - } else if statusReplicas < 0 { - allErrs = append(allErrs, field.Invalid(field.NewPath(scale.StatusReplicasPath), statusReplicas, "should be a non-negative integer")) - } else if statusReplicas > math.MaxInt32 { - allErrs = append(allErrs, field.Invalid(field.NewPath(scale.StatusReplicasPath), statusReplicas, fmt.Sprintf("should be less than or equal to %v", math.MaxInt32))) - } - - // validate labelSelector - if scale.LabelSelectorPath != nil { - labelSelectorPath := strings.TrimPrefix(*scale.LabelSelectorPath, ".") // ignore leading period - labelSelector, _, err := unstructured.NestedString(obj.UnstructuredContent(), strings.Split(labelSelectorPath, ".")...) - if err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath(*scale.LabelSelectorPath), labelSelector, err.Error())) - } - } - - return allErrs -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go deleted file mode 100644 index 8d272ad77..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -Copyright 2017 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 customresourcedefinition - -import ( - "context" - "fmt" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apiserver/pkg/registry/generic" - genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" - "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/apiserver/pkg/storage" - storageerr "k8s.io/apiserver/pkg/storage/errors" -) - -// rest implements a RESTStorage for API services against etcd -type REST struct { - *genericregistry.Store -} - -// NewREST returns a RESTStorage object that will work against API services. -func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST { - strategy := NewStrategy(scheme) - - store := &genericregistry.Store{ - NewFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinition{} }, - NewListFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinitionList{} }, - PredicateFunc: MatchCustomResourceDefinition, - DefaultQualifiedResource: apiextensions.Resource("customresourcedefinitions"), - - CreateStrategy: strategy, - UpdateStrategy: strategy, - DeleteStrategy: strategy, - } - options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} - if err := store.CompleteWithOptions(options); err != nil { - panic(err) // TODO: Propagate error up - } - return &REST{store} -} - -// Implement ShortNamesProvider -var _ rest.ShortNamesProvider = &REST{} - -// ShortNames implements the ShortNamesProvider interface. Returns a list of short names for a resource. -func (r *REST) ShortNames() []string { - return []string{"crd", "crds"} -} - -// Delete adds the CRD finalizer to the list -func (r *REST) Delete(ctx context.Context, name string, options *metav1.DeleteOptions) (runtime.Object, bool, error) { - obj, err := r.Get(ctx, name, &metav1.GetOptions{}) - if err != nil { - return nil, false, err - } - - crd := obj.(*apiextensions.CustomResourceDefinition) - - // Ensure we have a UID precondition - if options == nil { - options = metav1.NewDeleteOptions(0) - } - if options.Preconditions == nil { - options.Preconditions = &metav1.Preconditions{} - } - if options.Preconditions.UID == nil { - options.Preconditions.UID = &crd.UID - } else if *options.Preconditions.UID != crd.UID { - err = apierrors.NewConflict( - apiextensions.Resource("customresourcedefinitions"), - name, - fmt.Errorf("Precondition failed: UID in precondition: %v, UID in object meta: %v", *options.Preconditions.UID, crd.UID), - ) - return nil, false, err - } - - // upon first request to delete, add our finalizer and then delegate - if crd.DeletionTimestamp.IsZero() { - key, err := r.Store.KeyFunc(ctx, name) - if err != nil { - return nil, false, err - } - - preconditions := storage.Preconditions{UID: options.Preconditions.UID} - - out := r.Store.NewFunc() - err = r.Store.Storage.GuaranteedUpdate( - ctx, key, out, false, &preconditions, - storage.SimpleUpdate(func(existing runtime.Object) (runtime.Object, error) { - existingCRD, ok := existing.(*apiextensions.CustomResourceDefinition) - if !ok { - // wrong type - return nil, fmt.Errorf("expected *apiextensions.CustomResourceDefinition, got %v", existing) - } - - // Set the deletion timestamp if needed - if existingCRD.DeletionTimestamp.IsZero() { - now := metav1.Now() - existingCRD.DeletionTimestamp = &now - } - - if !apiextensions.CRDHasFinalizer(existingCRD, apiextensions.CustomResourceCleanupFinalizer) { - existingCRD.Finalizers = append(existingCRD.Finalizers, apiextensions.CustomResourceCleanupFinalizer) - } - // update the status condition too - apiextensions.SetCRDCondition(existingCRD, apiextensions.CustomResourceDefinitionCondition{ - Type: apiextensions.Terminating, - Status: apiextensions.ConditionTrue, - Reason: "InstanceDeletionPending", - Message: "CustomResourceDefinition marked for deletion; CustomResource deletion will begin soon", - }) - return existingCRD, nil - }), - ) - - if err != nil { - err = storageerr.InterpretGetError(err, apiextensions.Resource("customresourcedefinitions"), name) - err = storageerr.InterpretUpdateError(err, apiextensions.Resource("customresourcedefinitions"), name) - if _, ok := err.(*apierrors.StatusError); !ok { - err = apierrors.NewInternalError(err) - } - return nil, false, err - } - - return out, false, nil - } - - return r.Store.Delete(ctx, name, options) -} - -// NewStatusREST makes a RESTStorage for status that has more limited options. -// It is based on the original REST so that we can share the same underlying store -func NewStatusREST(scheme *runtime.Scheme, rest *REST) *StatusREST { - statusStore := *rest.Store - statusStore.CreateStrategy = nil - statusStore.DeleteStrategy = nil - statusStore.UpdateStrategy = NewStatusStrategy(scheme) - return &StatusREST{store: &statusStore} -} - -type StatusREST struct { - store *genericregistry.Store -} - -var _ = rest.Patcher(&StatusREST{}) - -func (r *StatusREST) New() runtime.Object { - return &apiextensions.CustomResourceDefinition{} -} - -// Get retrieves the object from the storage. It is required to support Patch. -func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - return r.store.Get(ctx, name, options) -} - -// Update alters the status subset of an object. -func (r *StatusREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) { - return r.store.Update(ctx, name, objInfo, createValidation, updateValidation) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go deleted file mode 100644 index a0bebb7a7..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go +++ /dev/null @@ -1,202 +0,0 @@ -/* -Copyright 2017 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 customresourcedefinition - -import ( - "context" - "fmt" - - apiequality "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/apiserver/pkg/registry/generic" - "k8s.io/apiserver/pkg/storage" - "k8s.io/apiserver/pkg/storage/names" - utilfeature "k8s.io/apiserver/pkg/util/feature" - - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation" - apiextensionsfeatures "k8s.io/apiextensions-apiserver/pkg/features" -) - -// strategy implements behavior for CustomResources. -type strategy struct { - runtime.ObjectTyper - names.NameGenerator -} - -func NewStrategy(typer runtime.ObjectTyper) strategy { - return strategy{typer, names.SimpleNameGenerator} -} - -func (strategy) NamespaceScoped() bool { - return false -} - -// PrepareForCreate clears the status of a CustomResourceDefinition before creation. -func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { - crd := obj.(*apiextensions.CustomResourceDefinition) - crd.Status = apiextensions.CustomResourceDefinitionStatus{} - crd.Generation = 1 - - // if the feature gate is disabled, drop the feature. - if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceValidation) { - crd.Spec.Validation = nil - } - if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) { - crd.Spec.Subresources = nil - } - - for _, v := range crd.Spec.Versions { - if v.Storage { - if !apiextensions.IsStoredVersion(crd, v.Name) { - crd.Status.StoredVersions = append(crd.Status.StoredVersions, v.Name) - } - break - } - } -} - -// PrepareForUpdate clears fields that are not allowed to be set by end users on update. -func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { - newCRD := obj.(*apiextensions.CustomResourceDefinition) - oldCRD := old.(*apiextensions.CustomResourceDefinition) - newCRD.Status = oldCRD.Status - - // Any changes to the spec increment the generation number, any changes to the - // status should reflect the generation number of the corresponding object. We push - // the burden of managing the status onto the clients because we can't (in general) - // know here what version of spec the writer of the status has seen. It may seem like - // we can at first -- since obj contains spec -- but in the future we will probably make - // status its own object, and even if we don't, writes may be the result of a - // read-update-write loop, so the contents of spec may not actually be the spec that - // the controller has *seen*. - if !apiequality.Semantic.DeepEqual(oldCRD.Spec, newCRD.Spec) { - newCRD.Generation = oldCRD.Generation + 1 - } - - if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceValidation) { - newCRD.Spec.Validation = nil - oldCRD.Spec.Validation = nil - } - if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) { - newCRD.Spec.Subresources = nil - oldCRD.Spec.Subresources = nil - } - - for _, v := range newCRD.Spec.Versions { - if v.Storage { - if !apiextensions.IsStoredVersion(newCRD, v.Name) { - newCRD.Status.StoredVersions = append(newCRD.Status.StoredVersions, v.Name) - } - break - } - } -} - -// Validate validates a new CustomResourceDefinition. -func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { - return validation.ValidateCustomResourceDefinition(obj.(*apiextensions.CustomResourceDefinition)) -} - -// AllowCreateOnUpdate is false for CustomResourceDefinition; this means a POST is -// needed to create one. -func (strategy) AllowCreateOnUpdate() bool { - return false -} - -// AllowUnconditionalUpdate is the default update policy for CustomResourceDefinition objects. -func (strategy) AllowUnconditionalUpdate() bool { - return false -} - -// Canonicalize normalizes the object after validation. -func (strategy) Canonicalize(obj runtime.Object) { -} - -// ValidateUpdate is the default update validation for an end user updating status. -func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { - return validation.ValidateCustomResourceDefinitionUpdate(obj.(*apiextensions.CustomResourceDefinition), old.(*apiextensions.CustomResourceDefinition)) -} - -type statusStrategy struct { - runtime.ObjectTyper - names.NameGenerator -} - -func NewStatusStrategy(typer runtime.ObjectTyper) statusStrategy { - return statusStrategy{typer, names.SimpleNameGenerator} -} - -func (statusStrategy) NamespaceScoped() bool { - return false -} - -func (statusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { - newObj := obj.(*apiextensions.CustomResourceDefinition) - oldObj := old.(*apiextensions.CustomResourceDefinition) - newObj.Spec = oldObj.Spec - - // Status updates are for only for updating status, not objectmeta. - // TODO: Update after ResetObjectMetaForStatus is added to meta/v1. - newObj.Labels = oldObj.Labels - newObj.Annotations = oldObj.Annotations - newObj.OwnerReferences = oldObj.OwnerReferences - newObj.Generation = oldObj.Generation - newObj.SelfLink = oldObj.SelfLink -} - -func (statusStrategy) AllowCreateOnUpdate() bool { - return false -} - -func (statusStrategy) AllowUnconditionalUpdate() bool { - return false -} - -func (statusStrategy) Canonicalize(obj runtime.Object) { -} - -func (statusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { - return validation.ValidateUpdateCustomResourceDefinitionStatus(obj.(*apiextensions.CustomResourceDefinition), old.(*apiextensions.CustomResourceDefinition)) -} - -// GetAttrs returns labels and fields of a given object for filtering purposes. -func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) { - apiserver, ok := obj.(*apiextensions.CustomResourceDefinition) - if !ok { - return nil, nil, false, fmt.Errorf("given object is not a CustomResourceDefinition") - } - return labels.Set(apiserver.ObjectMeta.Labels), CustomResourceDefinitionToSelectableFields(apiserver), apiserver.Initializers != nil, nil -} - -// MatchCustomResourceDefinition is the filter used by the generic etcd backend to watch events -// from etcd to clients of the apiserver only interested in specific labels/fields. -func MatchCustomResourceDefinition(label labels.Selector, field fields.Selector) storage.SelectionPredicate { - return storage.SelectionPredicate{ - Label: label, - Field: field, - GetAttrs: GetAttrs, - } -} - -// CustomResourceDefinitionToSelectableFields returns a field set that represents the object. -func CustomResourceDefinitionToSelectableFields(obj *apiextensions.CustomResourceDefinition) fields.Set { - return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.crt b/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.crt deleted file mode 100644 index 0b52619bf..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.crt +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDFTCCAf2gAwIBAgIBATANBgkqhkiG9w0BAQsFADAfMR0wGwYDVQQDDBRsb2Nh -bGhvc3RAMTUxNTQ2MjIwNjAgFw0xODAxMDkwMTQzMjZaGA8yMTE4MDEwOTAxNDMy -NlowHzEdMBsGA1UEAwwUbG9jYWxob3N0QDE1MTU0NjIyMDYwggEiMA0GCSqGSIb3 -DQEBAQUAA4IBDwAwggEKAoIBAQC2hIORzonehlNadYyI30v1Jj8lhhABuiWiTSkl -KCLqZjwBfWfSC4w02zxi2SAH9ju20XCJrUauwPq1qXCp/CqXC/rVgZrzluDlpJpe -gF9AilQvGOxhrZhV4kqpOjGVE78uOmpfxiOyNermoJ0OVE8ugh3s/LLTNK/qmCAX -uEYTQccAvNEiPX3XPBCiaFlSCkUNS0zp12mJNP43+KF9y0CbtYs1gXKHmmJVSpjR -YmcuJJUfHxNrV2YR3ek6O4IIJFIlnLxgpjRBseBPkTenAT3S2YY9MyQkkBrRSPBa -vLM24al3KDvXYikYe3WpxeYNHGNcHIgR+hKlRTQ5VrWlfx9dAgMBAAGjWjBYMA4G -A1UdDwEB/wQEAwICpDATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHRMBAf8EBTAD -AQH/MCAGA1UdEQQZMBeCCWxvY2FsaG9zdIcEfwAAAYcEfwAAATANBgkqhkiG9w0B -AQsFAAOCAQEAFhW8cVTraHPNsE+Jo0ZvcE2ic8lEzeOhWI2O/fpkrUJS5LptPKHS -nTK+CPxA0zhIS/vlJznIabeddXwtq7Xb5SwlJMHYMnHD6f5qwpD22D2dxJJa5sma -3yrK/4CutuEae08qqSeakfgCjcHLL9p7FZWxujkV9/5CEH5lFWYLGumyIoS46Svf -nSfDFKTrOj8P60ncCoWcSpMbdVQBDuKlIZuBMmz9CguC1CtuQWPDUmOGJuPs/+So -yusHbBfj+ATUWDYTg1lLjOIOSJpHGUQkvS+8Bo47SThD/b4w2i6VC72ldxtBuxGf -L7+jALMhMhiQD+Q4qsNuyvvNQLoYcTTFTw== ------END CERTIFICATE----- diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.key b/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.key deleted file mode 100644 index d4878784e..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAtoSDkc6J3oZTWnWMiN9L9SY/JYYQAbolok0pJSgi6mY8AX1n -0guMNNs8YtkgB/Y7ttFwia1GrsD6talwqfwqlwv61YGa85bg5aSaXoBfQIpULxjs -Ya2YVeJKqToxlRO/LjpqX8YjsjXq5qCdDlRPLoId7Pyy0zSv6pggF7hGE0HHALzR -Ij191zwQomhZUgpFDUtM6ddpiTT+N/ihfctAm7WLNYFyh5piVUqY0WJnLiSVHx8T -a1dmEd3pOjuCCCRSJZy8YKY0QbHgT5E3pwE90tmGPTMkJJAa0UjwWryzNuGpdyg7 -12IpGHt1qcXmDRxjXByIEfoSpUU0OVa1pX8fXQIDAQABAoIBAERy2ezaqnXbpnLs -VrIWHCRqHZBzAJnFN8vwaBfZP47snGBqqX7qecBw3+qqRwr1W1uqnCvl4fYzxVJP -o0L8oPRYt89OddAYq2s0GfiK6C4KMpwfGrdfJRxAa4OfoWypJS+vFKmqY0S4V8n6 -Pixbjf6BKbvw4Re4UKkIODDtGMqrZFVKcFe8LCnd3D+7jvt0M/WjEhrepWxscJh3 -aHgDzsLzCv1DNjgZfoRZubkK3bdndMaL6NhaKNBz6S7CT9XmZsJaWkmBXs9zOoyr -0hKP0A11cm6a7LsmxX5h4uaQLh66KHUPbV4KjKgKiGkSS9cnZoXHFZLOplOfozje -1DKitAECgYEA2eWiRNByNIqqRPvBtD8ydavOLk6iLlLt+LkCpGupgELs53WS5fTT -TxbyVq+897qeW2Klir7jZFWG3Q+EaBATxMYON+jb7QnIz8gX9lh1PpUlo88BiQzO -hAIx2uV19KM0ftXYVTSAUh1N2cgoOWGUWLaeMPdxPOlJwvM25hSfp90CgYEA1m8W -vWBO8X5LXM9g+fO1TFSlTnUJW1gWrnOw4VmU2+DbqNmtefpVrqDa5Iw2+mU+EBgA -d3wdAHARXpc2MGcIRnRbHn+gXJVHA+gA7H9LSZ4Yi0qJZbNVAgRySs2iBYUcunsR -AXkS7sPGQinfnjKh6vhYVErh5jA+cvS8CXZtnYECgYBmh61hYAw9OPqB100AebRO -tncgRxP9ZDxiCvx5TcfGeLds+mATIK7FynBh5fOvRfr52WM39DafobcCEiklplsG -/oL2P/YshaweSXMtEdapihjaCbAZQxNx/m5jKBHm+VzcSdev0DKJcQyO66Yxyf65 -98RcGjMIjGWO/E7a2N1/aQKBgCPrY+HBGjg1saYQTuxPuJTasP4deL3GWbZLRtvY -x6i1V9ZG8Fo4ZtXjuAcEvcjf4K+NdbaOIcWLAD3aEoe1GpvCrejD9DbOAqFS4aS8 -Bf6E7xOWHsHccmbuG78QBw3pqFBMgSLABz3bqYA3x2+Wh6z2gMVN7d1DQ5K6EC19 -mwsBAoGBAKZBgqRHRq1Ch3SWb5Q+SgUvNyQ+PAIwCve0vA4mMIK6EGqU/8wbU01B -5/UkCfT+ovDeDuyeaZbTWzwUC4Mrg4C9rThrK5WLc43Dig6G1HhfjdLA+gdKFOjh -FpocOI2FEwbmj5Mka6n3TSFI8c55ubYdyXQu92DoFt4dTOJStUn2 ------END RSA PRIVATE KEY----- diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/basic_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/basic_test.go deleted file mode 100644 index a53c4ca94..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/basic_test.go +++ /dev/null @@ -1,876 +0,0 @@ -/* -Copyright 2017 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 ( - "fmt" - "reflect" - "sort" - "testing" - "time" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/test/integration/testserver" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/dynamic" -) - -func TestServerUp(t *testing.T) { - stopCh, _, _, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) -} - -func TestNamespaceScopedCRUD(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - - testSimpleCRUD(t, ns, noxuDefinition, dynamicClient) - testFieldSelector(t, ns, noxuDefinition, dynamicClient) -} - -func TestClusterScopedCRUD(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "" - testSimpleCRUD(t, ns, noxuDefinition, dynamicClient) - testFieldSelector(t, ns, noxuDefinition, dynamicClient) -} - -func testSimpleCRUD(t *testing.T, ns string, noxuDefinition *apiextensionsv1beta1.CustomResourceDefinition, dynamicClient dynamic.Interface) { - noxuResourceClients := map[string]dynamic.ResourceInterface{} - noxuWatchs := map[string]watch.Interface{} - disabledVersions := map[string]bool{} - for _, v := range noxuDefinition.Spec.Versions { - disabledVersions[v.Name] = !v.Served - } - for _, v := range noxuDefinition.Spec.Versions { - noxuResourceClients[v.Name] = newNamespacedCustomResourceVersionedClient(ns, dynamicClient, noxuDefinition, v.Name) - - noxuWatch, err := noxuResourceClients[v.Name].Watch(metav1.ListOptions{}) - if disabledVersions[v.Name] { - if err == nil { - t.Errorf("expected the watch creation fail for disabled version %s", v.Name) - } - } else { - if err != nil { - t.Fatal(err) - } - noxuWatchs[v.Name] = noxuWatch - } - } - defer func() { - for _, w := range noxuWatchs { - w.Stop() - } - }() - - for version, noxuResourceClient := range noxuResourceClients { - createdNoxuInstance, err := instantiateVersionedCustomResource(t, testserver.NewVersionedNoxuInstance(ns, "foo", version), noxuResourceClient, noxuDefinition, version) - if disabledVersions[version] { - if err == nil { - t.Errorf("expected the CR creation fail for disabled version %s", version) - } - continue - } - if err != nil { - t.Fatalf("unable to create noxu Instance:%v", err) - } - if e, a := noxuDefinition.Spec.Group+"/"+version, createdNoxuInstance.GetAPIVersion(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - for watchVersion, noxuWatch := range noxuWatchs { - select { - case watchEvent := <-noxuWatch.ResultChan(): - if e, a := watch.Added, watchEvent.Type; e != a { - t.Errorf("expected %v, got %v", e, a) - break - } - createdObjectMeta, err := meta.Accessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - // it should have a UUID - if len(createdObjectMeta.GetUID()) == 0 { - t.Errorf("missing uuid: %#v", watchEvent.Object) - } - if e, a := ns, createdObjectMeta.GetNamespace(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - createdTypeMeta, err := meta.TypeAccessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - if e, a := noxuDefinition.Spec.Group+"/"+watchVersion, createdTypeMeta.GetAPIVersion(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := noxuDefinition.Spec.Names.Kind, createdTypeMeta.GetKind(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - case <-time.After(5 * time.Second): - t.Errorf("missing watch event") - } - } - - // Check get for all versions - for version2, noxuResourceClient2 := range noxuResourceClients { - // Get test - gottenNoxuInstance, err := noxuResourceClient2.Get("foo", metav1.GetOptions{}) - - if disabledVersions[version2] { - if err == nil { - t.Errorf("expected the get operation fail for disabled version %s", version2) - } - } else { - if err != nil { - t.Fatal(err) - } - - if e, a := version2, gottenNoxuInstance.GroupVersionKind().Version; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - } - - // List test - listWithItem, err := noxuResourceClient2.List(metav1.ListOptions{}) - if disabledVersions[version2] { - if err == nil { - t.Errorf("expected the list operation fail for disabled version %s", version2) - } - } else { - if err != nil { - t.Fatal(err) - } - if e, a := 1, len(listWithItem.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := version2, listWithItem.GroupVersionKind().Version; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := version2, listWithItem.Items[0].GroupVersionKind().Version; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - } - } - - // Delete test - if err := noxuResourceClient.Delete("foo", metav1.NewDeleteOptions(0)); err != nil { - t.Fatal(err) - } - - listWithoutItem, err := noxuResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 0, len(listWithoutItem.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - for _, noxuWatch := range noxuWatchs { - select { - case watchEvent := <-noxuWatch.ResultChan(): - if e, a := watch.Deleted, watchEvent.Type; e != a { - t.Errorf("expected %v, got %v", e, a) - break - } - deletedObjectMeta, err := meta.Accessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - // it should have a UUID - createdObjectMeta, err := meta.Accessor(createdNoxuInstance) - if err != nil { - t.Fatal(err) - } - if e, a := createdObjectMeta.GetUID(), deletedObjectMeta.GetUID(); e != a { - t.Errorf("expected equal UID for (expected) %v, and (actual) %v", createdNoxuInstance, watchEvent.Object) - } - - case <-time.After(5 * time.Second): - t.Errorf("missing watch event") - } - } - - // Delete test - if err := noxuResourceClient.DeleteCollection(metav1.NewDeleteOptions(0), metav1.ListOptions{}); err != nil { - t.Fatal(err) - } - } -} - -func testFieldSelector(t *testing.T, ns string, noxuDefinition *apiextensionsv1beta1.CustomResourceDefinition, dynamicClient dynamic.Interface) { - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - initialList, err := noxuResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 0, len(initialList.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - initialListTypeMeta, err := meta.TypeAccessor(initialList) - if err != nil { - t.Fatal(err) - } - if e, a := noxuDefinition.Spec.Group+"/"+noxuDefinition.Spec.Versions[0].Name, initialListTypeMeta.GetAPIVersion(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := noxuDefinition.Spec.Names.ListKind, initialListTypeMeta.GetKind(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - initialListListMeta, err := meta.ListAccessor(initialList) - if err != nil { - t.Fatal(err) - } - noxuWatch, err := noxuResourceClient.Watch( - metav1.ListOptions{ - ResourceVersion: initialListListMeta.GetResourceVersion(), - FieldSelector: "metadata.name=foo", - }, - ) - if err != nil { - t.Fatal(err) - } - defer noxuWatch.Stop() - - _, err = instantiateCustomResource(t, testserver.NewNoxuInstance(ns, "bar"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu Instance:%v", err) - } - createdNoxuInstanceFoo, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu Instance:%v", err) - } - - select { - case watchEvent := <-noxuWatch.ResultChan(): - if e, a := watch.Added, watchEvent.Type; e != a { - t.Errorf("expected %v, got %v", e, a) - break - } - createdObjectMeta, err := meta.Accessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - // it should have a UUID - if len(createdObjectMeta.GetUID()) == 0 { - t.Errorf("missing uuid: %#v", watchEvent.Object) - } - if e, a := ns, createdObjectMeta.GetNamespace(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := "foo", createdObjectMeta.GetName(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - createdTypeMeta, err := meta.TypeAccessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - if e, a := noxuDefinition.Spec.Group+"/"+noxuDefinition.Spec.Versions[0].Name, createdTypeMeta.GetAPIVersion(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := noxuDefinition.Spec.Names.Kind, createdTypeMeta.GetKind(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - case <-time.After(5 * time.Second): - t.Errorf("missing watch event") - } - - gottenNoxuInstance, err := noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := createdNoxuInstanceFoo, gottenNoxuInstance; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - - listWithItem, err := noxuResourceClient.List(metav1.ListOptions{FieldSelector: "metadata.name=foo"}) - if err != nil { - t.Fatal(err) - } - if e, a := 1, len(listWithItem.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := *createdNoxuInstanceFoo, listWithItem.Items[0]; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - - if err := noxuResourceClient.Delete("bar", nil); err != nil { - t.Fatal(err) - } - if err := noxuResourceClient.Delete("foo", nil); err != nil { - t.Fatal(err) - } - - listWithoutItem, err := noxuResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 0, len(listWithoutItem.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - select { - case watchEvent := <-noxuWatch.ResultChan(): - if e, a := watch.Deleted, watchEvent.Type; e != a { - t.Errorf("expected %v, got %v", e, a) - break - } - deletedObjectMeta, err := meta.Accessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - // it should have a UUID - createdObjectMeta, err := meta.Accessor(createdNoxuInstanceFoo) - if err != nil { - t.Fatal(err) - } - if e, a := createdObjectMeta.GetUID(), deletedObjectMeta.GetUID(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := ns, createdObjectMeta.GetNamespace(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := "foo", createdObjectMeta.GetName(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - case <-time.After(5 * time.Second): - t.Errorf("missing watch event") - } -} - -func TestDiscovery(t *testing.T) { - group := "mygroup.example.com" - version := "v1beta1" - - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - scope := apiextensionsv1beta1.NamespaceScoped - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(scope) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - // check whether it shows up in discovery properly - resources, err := apiExtensionClient.Discovery().ServerResourcesForGroupVersion(group + "/" + version) - if err != nil { - t.Fatal(err) - } - - if len(resources.APIResources) != 1 { - t.Fatalf("Expected exactly the resource \"noxus\" in group version %v/%v via discovery, got: %v", group, version, resources.APIResources) - } - - r := resources.APIResources[0] - if r.Name != "noxus" { - t.Fatalf("Expected exactly the resource \"noxus\" in group version %v/%v via discovery, got: %v", group, version, r.Name) - } - if r.Kind != "WishIHadChosenNoxu" { - t.Fatalf("Expected exactly the kind \"WishIHadChosenNoxu\" in group version %v/%v via discovery, got: %v", group, version, r.Kind) - } - - s := []string{"foo", "bar", "abc", "def"} - if !reflect.DeepEqual(r.ShortNames, s) { - t.Fatalf("Expected exactly the shortnames `foo, bar, abc, def` in group version %v/%v via discovery, got: %v", group, version, r.ShortNames) - } - - sort.Strings(r.Verbs) - expectedVerbs := []string{"create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"} - if !reflect.DeepEqual([]string(r.Verbs), expectedVerbs) { - t.Fatalf("Unexpected verbs for resource \"noxus\" in group version %v/%v via discovery: expected=%v got=%v", group, version, expectedVerbs, r.Verbs) - } - - if !reflect.DeepEqual(r.Categories, []string{"all"}) { - t.Fatalf("Expected exactly the category \"all\" in group version %v/%v via discovery, got: %v", group, version, r.Categories) - } -} - -func TestNoNamespaceReject(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - initialList, err := noxuResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 0, len(initialList.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - initialListTypeMeta, err := meta.TypeAccessor(initialList) - if err != nil { - t.Fatal(err) - } - if e, a := noxuDefinition.Spec.Group+"/"+noxuDefinition.Spec.Version, initialListTypeMeta.GetAPIVersion(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := noxuDefinition.Spec.Names.ListKind, initialListTypeMeta.GetKind(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - createdNoxuInstance, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err == nil { - t.Fatalf("unexpected non-error: an empty namespace may not be set during creation while creating noxu instance: %v ", createdNoxuInstance) - } -} - -func TestSameNameDiffNamespace(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns1 := "namespace-1" - testSimpleCRUD(t, ns1, noxuDefinition, dynamicClient) - ns2 := "namespace-2" - testSimpleCRUD(t, ns2, noxuDefinition, dynamicClient) - -} - -func TestSelfLink(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - // namespace scoped - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - noxuInstanceToCreate := testserver.NewNoxuInstance(ns, "foo") - createdNoxuInstance, err := noxuNamespacedResourceClient.Create(noxuInstanceToCreate) - if err != nil { - t.Fatal(err) - } - - if e, a := "/apis/mygroup.example.com/v1beta1/namespaces/not-the-default/noxus/foo", createdNoxuInstance.GetSelfLink(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - // cluster scoped - curletDefinition := testserver.NewCurletCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - curletDefinition, err = testserver.CreateNewCustomResourceDefinition(curletDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - curletResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, curletDefinition) - - curletInstanceToCreate := testserver.NewCurletInstance(ns, "foo") - createdCurletInstance, err := curletResourceClient.Create(curletInstanceToCreate) - if err != nil { - t.Fatal(err) - } - - if e, a := "/apis/mygroup.example.com/v1beta1/curlets/foo", createdCurletInstance.GetSelfLink(); e != a { - t.Errorf("expected %v, got %v", e, a) - } -} - -func TestPreserveInt(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - noxuInstanceToCreate := testserver.NewNoxuInstance(ns, "foo") - createdNoxuInstance, err := noxuNamespacedResourceClient.Create(noxuInstanceToCreate) - if err != nil { - t.Fatal(err) - } - - originalJSON, err := runtime.Encode(unstructured.UnstructuredJSONScheme, createdNoxuInstance) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - gottenNoxuInstance, err := runtime.Decode(unstructured.UnstructuredJSONScheme, originalJSON) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // Check if int is preserved. - unstructuredObj := gottenNoxuInstance.(*unstructured.Unstructured).Object - num := unstructuredObj["num"].(map[string]interface{}) - num1 := num["num1"].(int64) - num2 := num["num2"].(int64) - if num1 != 9223372036854775807 || num2 != 1000000 { - t.Errorf("Expected %v, got %v, %v", `9223372036854775807, 1000000`, num1, num2) - } -} - -func TestPatch(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - noxuInstanceToCreate := testserver.NewNoxuInstance(ns, "foo") - createdNoxuInstance, err := noxuNamespacedResourceClient.Create(noxuInstanceToCreate) - if err != nil { - t.Fatal(err) - } - - patch := []byte(`{"num": {"num2":999}}`) - createdNoxuInstance, err = noxuNamespacedResourceClient.Patch("foo", types.MergePatchType, patch) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // a patch with no change - createdNoxuInstance, err = noxuNamespacedResourceClient.Patch("foo", types.MergePatchType, patch) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // an empty patch - createdNoxuInstance, err = noxuNamespacedResourceClient.Patch("foo", types.MergePatchType, []byte(`{}`)) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - originalJSON, err := runtime.Encode(unstructured.UnstructuredJSONScheme, createdNoxuInstance) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - gottenNoxuInstance, err := runtime.Decode(unstructured.UnstructuredJSONScheme, originalJSON) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // Check if int is preserved. - unstructuredObj := gottenNoxuInstance.(*unstructured.Unstructured).Object - num := unstructuredObj["num"].(map[string]interface{}) - num1 := num["num1"].(int64) - num2 := num["num2"].(int64) - if num1 != 9223372036854775807 || num2 != 999 { - t.Errorf("Expected %v, got %v, %v", `9223372036854775807, 999`, num1, num2) - } -} - -func TestCrossNamespaceListWatch(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - initialList, err := noxuResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 0, len(initialList.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - initialListListMeta, err := meta.ListAccessor(initialList) - if err != nil { - t.Fatal(err) - } - - noxuWatch, err := noxuResourceClient.Watch(metav1.ListOptions{ResourceVersion: initialListListMeta.GetResourceVersion()}) - if err != nil { - t.Fatal(err) - } - defer noxuWatch.Stop() - - instances := make(map[string]*unstructured.Unstructured) - ns1 := "namespace-1" - noxuNamespacedResourceClient1 := newNamespacedCustomResourceClient(ns1, dynamicClient, noxuDefinition) - instances[ns1] = createInstanceWithNamespaceHelper(t, ns1, "foo1", noxuNamespacedResourceClient1, noxuDefinition) - noxuNamespacesWatch1, err := noxuNamespacedResourceClient1.Watch(metav1.ListOptions{ResourceVersion: initialListListMeta.GetResourceVersion()}) - defer noxuNamespacesWatch1.Stop() - - ns2 := "namespace-2" - noxuNamespacedResourceClient2 := newNamespacedCustomResourceClient(ns2, dynamicClient, noxuDefinition) - instances[ns2] = createInstanceWithNamespaceHelper(t, ns2, "foo2", noxuNamespacedResourceClient2, noxuDefinition) - noxuNamespacesWatch2, err := noxuNamespacedResourceClient2.Watch(metav1.ListOptions{ResourceVersion: initialListListMeta.GetResourceVersion()}) - defer noxuNamespacesWatch2.Stop() - - createdList, err := noxuResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - - if e, a := 2, len(createdList.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - for _, a := range createdList.Items { - if e := instances[a.GetNamespace()]; !reflect.DeepEqual(e, &a) { - t.Errorf("expected %v, got %v", e, a) - } - } - - addEvents := 0 - for addEvents < 2 { - select { - case watchEvent := <-noxuWatch.ResultChan(): - if e, a := watch.Added, watchEvent.Type; e != a { - t.Fatalf("expected %v, got %v", e, a) - } - createdObjectMeta, err := meta.Accessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - if len(createdObjectMeta.GetUID()) == 0 { - t.Errorf("missing uuid: %#v", watchEvent.Object) - } - createdTypeMeta, err := meta.TypeAccessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - if e, a := noxuDefinition.Spec.Group+"/"+noxuDefinition.Spec.Version, createdTypeMeta.GetAPIVersion(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := noxuDefinition.Spec.Names.Kind, createdTypeMeta.GetKind(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - delete(instances, createdObjectMeta.GetNamespace()) - addEvents++ - case <-time.After(5 * time.Second): - t.Fatalf("missing watch event") - } - } - if e, a := 0, len(instances); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - checkNamespacesWatchHelper(t, ns1, noxuNamespacesWatch1) - checkNamespacesWatchHelper(t, ns2, noxuNamespacesWatch2) -} - -func createInstanceWithNamespaceHelper(t *testing.T, ns string, name string, noxuNamespacedResourceClient dynamic.ResourceInterface, noxuDefinition *apiextensionsv1beta1.CustomResourceDefinition) *unstructured.Unstructured { - createdInstance, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns, name), noxuNamespacedResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu Instance:%v", err) - } - return createdInstance -} - -func checkNamespacesWatchHelper(t *testing.T, ns string, namespacedwatch watch.Interface) { - namespacedAddEvent := 0 - for namespacedAddEvent < 2 { - select { - case watchEvent := <-namespacedwatch.ResultChan(): - // Check that the namespaced watch only has one result - if namespacedAddEvent > 0 { - t.Fatalf("extra watch event") - } - if e, a := watch.Added, watchEvent.Type; e != a { - t.Fatalf("expected %v, got %v", e, a) - } - createdObjectMeta, err := meta.Accessor(watchEvent.Object) - if err != nil { - t.Fatal(err) - } - if e, a := ns, createdObjectMeta.GetNamespace(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - case <-time.After(5 * time.Second): - if namespacedAddEvent != 1 { - t.Fatalf("missing watch event") - } - } - namespacedAddEvent++ - } -} - -func TestNameConflict(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - noxu2Definition := testserver.NewNoxu2CustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - _, err = apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(noxu2Definition) - if err != nil { - t.Fatal(err) - } - - // A NameConflict occurs - err = wait.Poll(500*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) { - crd, err := apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(noxu2Definition.Name, metav1.GetOptions{}) - if err != nil { - return false, err - } - - for _, condition := range crd.Status.Conditions { - if condition.Type == apiextensionsv1beta1.NamesAccepted && condition.Status == apiextensionsv1beta1.ConditionFalse { - return true, nil - } - } - return false, nil - }) - if err != nil { - t.Fatal(err) - } - - err = testserver.DeleteCustomResourceDefinition(noxuDefinition, apiExtensionClient) - if err != nil { - t.Fatal(err) - } - - // Names are now accepted - err = wait.Poll(500*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) { - crd, err := apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(noxu2Definition.Name, metav1.GetOptions{}) - if err != nil { - return false, err - } - - for _, condition := range crd.Status.Conditions { - if condition.Type == apiextensionsv1beta1.NamesAccepted && condition.Status == apiextensionsv1beta1.ConditionTrue { - return true, nil - } - } - return false, nil - }) - if err != nil { - t.Fatal(err) - } -} - -func TestStatusGetAndPatch(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - // make sure we don't get 405 Method Not Allowed from Getting CRD/status subresource - result := &apiextensionsv1beta1.CustomResourceDefinition{} - err = apiExtensionClient.ApiextensionsV1beta1().RESTClient().Get(). - Resource("customresourcedefinitions"). - Name(noxuDefinition.Name). - SubResource("status"). - Do(). - Into(result) - if err != nil { - t.Fatal(err) - } - - // make sure we don't get 405 Method Not Allowed from Patching CRD/status subresource - _, err = apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions(). - Patch(noxuDefinition.Name, types.StrategicMergePatchType, - []byte(fmt.Sprintf(`{"labels":{"test-label":"dummy"}}`)), - "status") - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go deleted file mode 100644 index 4dcf8d727..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go +++ /dev/null @@ -1,165 +0,0 @@ -/* -Copyright 2017 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 ( - "testing" - "time" - - "github.com/stretchr/testify/require" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - - "k8s.io/apiextensions-apiserver/test/integration/testserver" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/wait" -) - -func TestFinalization(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - require.NoError(t, err) - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - require.NoError(t, err) - - ns := "not-the-default" - name := "foo123" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - instance := testserver.NewNoxuInstance(ns, name) - instance.SetFinalizers([]string{"noxu.example.com/finalizer"}) - createdNoxuInstance, err := instantiateCustomResource(t, instance, noxuResourceClient, noxuDefinition) - require.NoError(t, err) - - uid := createdNoxuInstance.GetUID() - err = noxuResourceClient.Delete(name, &metav1.DeleteOptions{ - Preconditions: &metav1.Preconditions{ - UID: &uid, - }, - }) - require.NoError(t, err) - - // Deleting something with a finalizer sets deletion timestamp to a not-nil value but does not - // remove the object from the API server. Here we read it to confirm this. - gottenNoxuInstance, err := noxuResourceClient.Get(name, metav1.GetOptions{}) - require.NoError(t, err) - - require.NotNil(t, gottenNoxuInstance.GetDeletionTimestamp()) - - // Trying to delete it again to confirm it will not remove the object because finalizer is still there. - err = noxuResourceClient.Delete(name, &metav1.DeleteOptions{ - Preconditions: &metav1.Preconditions{ - UID: &uid, - }, - }) - require.NoError(t, err) - - // Removing the finalizers to allow the following delete remove the object. - // This step will fail if previous delete wrongly removed the object. The - // object will be deleted as part of the finalizer update. - for { - gottenNoxuInstance.SetFinalizers(nil) - _, err = noxuResourceClient.Update(gottenNoxuInstance) - if err == nil { - break - } - if !errors.IsConflict(err) { - require.NoError(t, err) // Fail on unexpected error - } - gottenNoxuInstance, err = noxuResourceClient.Get(name, metav1.GetOptions{}) - require.NoError(t, err) - } - - // Check that the object is actually gone. - _, err = noxuResourceClient.Get(name, metav1.GetOptions{}) - require.Error(t, err) - require.True(t, errors.IsNotFound(err), "%#v", err) -} - -func TestFinalizationAndDeletion(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - require.NoError(t, err) - defer close(stopCh) - - // Create a CRD. - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - require.NoError(t, err) - - // Create a CR with a finalizer. - ns := "not-the-default" - name := "foo123" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - instance := testserver.NewNoxuInstance(ns, name) - instance.SetFinalizers([]string{"noxu.example.com/finalizer"}) - createdNoxuInstance, err := instantiateCustomResource(t, instance, noxuResourceClient, noxuDefinition) - require.NoError(t, err) - - // Delete a CR. Because there's a finalizer, it will not get deleted now. - uid := createdNoxuInstance.GetUID() - err = noxuResourceClient.Delete(name, &metav1.DeleteOptions{ - Preconditions: &metav1.Preconditions{ - UID: &uid, - }, - }) - require.NoError(t, err) - - // Check is the CR scheduled for deletion. - gottenNoxuInstance, err := noxuResourceClient.Get(name, metav1.GetOptions{}) - require.NoError(t, err) - require.NotNil(t, gottenNoxuInstance.GetDeletionTimestamp()) - - // Delete the CRD. - testserver.DeleteCustomResourceDefinition(noxuDefinition, apiExtensionClient) - - // Check is CR still there after the CRD deletion. - gottenNoxuInstance, err = noxuResourceClient.Get(name, metav1.GetOptions{}) - require.NoError(t, err) - - // Update the CR to remove the finalizer. - for { - gottenNoxuInstance.SetFinalizers(nil) - _, err = noxuResourceClient.Update(gottenNoxuInstance) - if err == nil { - break - } - if !errors.IsConflict(err) { - require.NoError(t, err) // Fail on unexpected error - } - gottenNoxuInstance, err = noxuResourceClient.Get(name, metav1.GetOptions{}) - require.NoError(t, err) - } - - // Verify the CR is gone. - // It should return the NonFound error. - _, err = noxuResourceClient.Get(name, metav1.GetOptions{}) - if !errors.IsNotFound(err) { - t.Fatalf("unable to delete cr: %v", err) - } - - err = wait.Poll(500*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) { - _, err = apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(noxuDefinition.Name, metav1.GetOptions{}) - return errors.IsNotFound(err), err - }) - if !errors.IsNotFound(err) { - t.Fatalf("unable to delete crd: %v", err) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/helpers.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/helpers.go deleted file mode 100644 index 5aa231d45..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/helpers.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -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 ( - "fmt" - "testing" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/dynamic" -) - -func instantiateCustomResource(t *testing.T, instanceToCreate *unstructured.Unstructured, client dynamic.ResourceInterface, definition *apiextensionsv1beta1.CustomResourceDefinition) (*unstructured.Unstructured, error) { - return instantiateVersionedCustomResource(t, instanceToCreate, client, definition, definition.Spec.Versions[0].Name) -} - -func instantiateVersionedCustomResource(t *testing.T, instanceToCreate *unstructured.Unstructured, client dynamic.ResourceInterface, definition *apiextensionsv1beta1.CustomResourceDefinition, version string) (*unstructured.Unstructured, error) { - createdInstance, err := client.Create(instanceToCreate) - if err != nil { - t.Logf("%#v", createdInstance) - return nil, err - } - createdObjectMeta, err := meta.Accessor(createdInstance) - if err != nil { - t.Fatal(err) - } - // it should have a UUID - if len(createdObjectMeta.GetUID()) == 0 { - t.Errorf("missing uuid: %#v", createdInstance) - } - createdTypeMeta, err := meta.TypeAccessor(createdInstance) - if err != nil { - t.Fatal(err) - } - if e, a := definition.Spec.Group+"/"+version, createdTypeMeta.GetAPIVersion(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - if e, a := definition.Spec.Names.Kind, createdTypeMeta.GetKind(); e != a { - t.Errorf("expected %v, got %v", e, a) - } - return createdInstance, nil -} - -func newNamespacedCustomResourceVersionedClient(ns string, client dynamic.Interface, crd *apiextensionsv1beta1.CustomResourceDefinition, version string) dynamic.ResourceInterface { - gvr := schema.GroupVersionResource{Group: crd.Spec.Group, Version: version, Resource: crd.Spec.Names.Plural} - - if crd.Spec.Scope != apiextensionsv1beta1.ClusterScoped { - return client.Resource(gvr).Namespace(ns) - } - return client.Resource(gvr) -} - -func newNamespacedCustomResourceClient(ns string, client dynamic.Interface, crd *apiextensionsv1beta1.CustomResourceDefinition) dynamic.ResourceInterface { - return newNamespacedCustomResourceVersionedClient(ns, client, crd, crd.Spec.Versions[0].Name) -} - -// updateCustomResourceDefinitionWithRetry updates a CRD, retrying up to 5 times on version conflict errors. -func updateCustomResourceDefinitionWithRetry(client clientset.Interface, name string, update func(*apiextensionsv1beta1.CustomResourceDefinition)) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - for i := 0; i < 5; i++ { - crd, err := client.ApiextensionsV1beta1().CustomResourceDefinitions().Get(name, metav1.GetOptions{}) - if err != nil { - return nil, fmt.Errorf("failed to get CustomResourceDefinition %q: %v", name, err) - } - update(crd) - crd, err = client.ApiextensionsV1beta1().CustomResourceDefinitions().Update(crd) - if err == nil { - return crd, nil - } - if !errors.IsConflict(err) { - return nil, fmt.Errorf("failed to update CustomResourceDefinition %q: %v", name, err) - } - } - return nil, fmt.Errorf("too many retries after conflicts updating CustomResourceDefinition %q", name) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/objectmeta_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/objectmeta_test.go deleted file mode 100644 index 50f656bf1..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/objectmeta_test.go +++ /dev/null @@ -1,166 +0,0 @@ -/* -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 ( - "path" - "reflect" - "strings" - "testing" - - "github.com/coreos/etcd/clientv3" - "github.com/coreos/etcd/pkg/transport" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apiextensions-apiserver/test/integration/testserver" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/json" - genericapirequest "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/client-go/dynamic" -) - -func TestPostInvalidObjectMeta(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - noxuResourceClient := newNamespacedCustomResourceClient("default", dynamicClient, noxuDefinition) - - obj := testserver.NewNoxuInstance("default", "foo") - unstructured.SetNestedField(obj.UnstructuredContent(), int64(42), "metadata", "unknown") - unstructured.SetNestedField(obj.UnstructuredContent(), map[string]interface{}{"foo": int64(42), "bar": "abc"}, "metadata", "labels") - _, err = instantiateCustomResource(t, obj, noxuResourceClient, noxuDefinition) - if err == nil { - t.Fatalf("unexpected non-error, expected invalid labels to be rejected: %v", err) - } - if status, ok := err.(errors.APIStatus); !ok { - t.Fatalf("expected APIStatus error, but got: %#v", err) - } else if !errors.IsBadRequest(err) { - t.Fatalf("expected BadRequst error, but got: %v", errors.ReasonForError(err)) - } else if !strings.Contains(status.Status().Message, "cannot be handled") { - t.Fatalf("expected 'cannot be handled' error message, got: %v", status.Status().Message) - } - - unstructured.SetNestedField(obj.UnstructuredContent(), map[string]interface{}{"bar": "abc"}, "metadata", "labels") - obj, err = instantiateCustomResource(t, obj, noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - if unknown, found, err := unstructured.NestedInt64(obj.UnstructuredContent(), "metadata", "unknown"); err != nil { - t.Errorf("unexpected error getting metadata.unknown: %v", err) - } else if found { - t.Errorf("unexpected metadata.unknown=%#v: expected this to be pruned", unknown) - } -} - -func TestInvalidObjectMetaInStorage(t *testing.T) { - serverConfig, err := testserver.DefaultServerConfig() - if err != nil { - t.Fatal(err) - } - - stopCh, config, err := testserver.StartServer(serverConfig) - defer close(stopCh) - if err != nil { - t.Fatal(err) - } - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - restOptions, err := serverConfig.GenericConfig.RESTOptionsGetter.GetRESTOptions(schema.GroupResource{Group: noxuDefinition.Spec.Group, Resource: noxuDefinition.Spec.Names.Plural}) - if err != nil { - t.Fatal(err) - } - tlsInfo := transport.TLSInfo{ - CertFile: restOptions.StorageConfig.CertFile, - KeyFile: restOptions.StorageConfig.KeyFile, - CAFile: restOptions.StorageConfig.CAFile, - } - tlsConfig, err := tlsInfo.ClientConfig() - if err != nil { - t.Fatal(err) - } - etcdConfig := clientv3.Config{ - Endpoints: restOptions.StorageConfig.ServerList, - TLS: tlsConfig, - } - etcdclient, err := clientv3.New(etcdConfig) - if err != nil { - t.Fatal(err) - } - - t.Logf("Creating object with invalid labels manually in etcd") - - original := testserver.NewNoxuInstance("default", "foo") - unstructured.SetNestedField(original.UnstructuredContent(), int64(42), "metadata", "unknown") - unstructured.SetNestedField(original.UnstructuredContent(), map[string]interface{}{"foo": int64(42), "bar": "abc"}, "metadata", "labels") - - ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault) - key := path.Join("/", restOptions.StorageConfig.Prefix, noxuDefinition.Spec.Group, "noxus/default/foo") - val, _ := json.Marshal(original.UnstructuredContent()) - if _, err := etcdclient.Put(ctx, key, string(val)); err != nil { - t.Fatalf("unexpected error: %v", err) - } - - t.Logf("Checking that ObjectMeta is pruned from unknown fields") - - noxuResourceClient := newNamespacedCustomResourceClient("default", dynamicClient, noxuDefinition) - obj, err := noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - if unknown, found, err := unstructured.NestedFieldNoCopy(obj.UnstructuredContent(), "metadata", "unknown"); err != nil { - t.Errorf("unexpected error: %v", err) - } else if found { - t.Errorf("unexpected to find metadata.unknown=%#v", unknown) - } - - t.Logf("Checking that ObjectMeta is pruned from invalid typed fields") - - if labels, found, err := unstructured.NestedStringMap(obj.UnstructuredContent(), "metadata", "labels"); err != nil { - t.Errorf("unexpected error: %v", err) - } else if found && !reflect.DeepEqual(labels, map[string]string{"bar": "abc"}) { - t.Errorf("unexpected to find metadata.lables=%#v", labels) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/registration_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/registration_test.go deleted file mode 100644 index 9cb33ac70..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/registration_test.go +++ /dev/null @@ -1,469 +0,0 @@ -/* -Copyright 2017 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 ( - "context" - "encoding/json" - "fmt" - "os" - "path" - "reflect" - "testing" - "time" - - "github.com/coreos/etcd/clientv3" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - extensionsapiserver "k8s.io/apiextensions-apiserver/pkg/apiserver" - apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apiextensions-apiserver/test/integration/testserver" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/dynamic" -) - -func TestMultipleResourceInstances(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - ns := "not-the-default" - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - noxuList, err := noxuNamespacedResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - - noxuListListMeta, err := meta.ListAccessor(noxuList) - if err != nil { - t.Fatal(err) - } - - noxuNamespacedWatch, err := noxuNamespacedResourceClient.Watch(metav1.ListOptions{ResourceVersion: noxuListListMeta.GetResourceVersion()}) - if err != nil { - t.Fatal(err) - } - defer noxuNamespacedWatch.Stop() - - instances := map[string]*struct { - Added bool - Deleted bool - Instance *unstructured.Unstructured - }{ - "foo": {}, - "bar": {}, - } - - for key, val := range instances { - val.Instance, err = instantiateCustomResource(t, testserver.NewNoxuInstance(ns, key), noxuNamespacedResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create Noxu Instance %q:%v", key, err) - } - } - - addEvents := 0 - for addEvents < len(instances) { - select { - case watchEvent := <-noxuNamespacedWatch.ResultChan(): - if e, a := watch.Added, watchEvent.Type; e != a { - t.Fatalf("expected %v, got %v", e, a) - } - name, err := meta.NewAccessor().Name(watchEvent.Object) - if err != nil { - t.Fatalf("unable to retrieve object name:%v", err) - } - if instances[name].Added { - t.Fatalf("Add event already registered for %q", name) - } - instances[name].Added = true - addEvents++ - case <-time.After(5 * time.Second): - t.Fatalf("missing watch event") - } - } - - for key, val := range instances { - gottenNoxuInstace, err := noxuNamespacedResourceClient.Get(key, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := val.Instance, gottenNoxuInstace; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - } - listWithItem, err := noxuNamespacedResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := len(instances), len(listWithItem.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - for _, a := range listWithItem.Items { - if e := instances[a.GetName()].Instance; !reflect.DeepEqual(e, &a) { - t.Errorf("expected %v, got %v", e, a) - } - } - for key := range instances { - if err := noxuNamespacedResourceClient.Delete(key, nil); err != nil { - t.Fatalf("unable to delete %s:%v", key, err) - } - } - listWithoutItem, err := noxuNamespacedResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 0, len(listWithoutItem.Items); e != a { - t.Errorf("expected %v, got %v", e, a) - } - - deleteEvents := 0 - for deleteEvents < len(instances) { - select { - case watchEvent := <-noxuNamespacedWatch.ResultChan(): - if e, a := watch.Deleted, watchEvent.Type; e != a { - t.Errorf("expected %v, got %v", e, a) - break - } - name, err := meta.NewAccessor().Name(watchEvent.Object) - if err != nil { - t.Errorf("unable to retrieve object name:%v", err) - } - if instances[name].Deleted { - t.Errorf("Delete event already registered for %q", name) - } - instances[name].Deleted = true - deleteEvents++ - case <-time.After(5 * time.Second): - t.Errorf("missing watch event") - } - } -} - -func TestMultipleRegistration(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - ns := "not-the-default" - sameInstanceName := "foo" - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - createdNoxuInstance, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns, sameInstanceName), noxuNamespacedResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu Instance:%v", err) - } - - gottenNoxuInstance, err := noxuNamespacedResourceClient.Get(sameInstanceName, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := createdNoxuInstance, gottenNoxuInstance; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - - curletDefinition := testserver.NewCurletCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - curletDefinition, err = testserver.CreateNewCustomResourceDefinition(curletDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - curletNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, curletDefinition) - createdCurletInstance, err := instantiateCustomResource(t, testserver.NewCurletInstance(ns, sameInstanceName), curletNamespacedResourceClient, curletDefinition) - if err != nil { - t.Fatalf("unable to create noxu Instance:%v", err) - } - gottenCurletInstance, err := curletNamespacedResourceClient.Get(sameInstanceName, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := createdCurletInstance, gottenCurletInstance; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - - // now re-GET noxu - gottenNoxuInstance2, err := noxuNamespacedResourceClient.Get(sameInstanceName, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := createdNoxuInstance, gottenNoxuInstance2; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } -} - -func TestDeRegistrationAndReRegistration(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - ns := "not-the-default" - sameInstanceName := "foo" - func() { - noxuDefinition, err := testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - if _, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns, sameInstanceName), noxuNamespacedResourceClient, noxuDefinition); err != nil { - t.Fatal(err) - } - if err := testserver.DeleteCustomResourceDefinition(noxuDefinition, apiExtensionClient); err != nil { - t.Fatal(err) - } - if _, err := apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(noxuDefinition.Name, metav1.GetOptions{}); err == nil || !errors.IsNotFound(err) { - t.Fatalf("expected a NotFound error, got:%v", err) - } - if _, err = noxuNamespacedResourceClient.List(metav1.ListOptions{}); err == nil || !errors.IsNotFound(err) { - t.Fatalf("expected a NotFound error, got:%v", err) - } - if _, err = noxuNamespacedResourceClient.Get("foo", metav1.GetOptions{}); err == nil || !errors.IsNotFound(err) { - t.Fatalf("expected a NotFound error, got:%v", err) - } - }() - - func() { - if _, err := apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(noxuDefinition.Name, metav1.GetOptions{}); err == nil || !errors.IsNotFound(err) { - t.Fatalf("expected a NotFound error, got:%v", err) - } - noxuDefinition, err := testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - initialList, err := noxuNamespacedResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if _, err = noxuNamespacedResourceClient.Get(sameInstanceName, metav1.GetOptions{}); err == nil || !errors.IsNotFound(err) { - t.Fatalf("expected a NotFound error, got:%v", err) - } - if e, a := 0, len(initialList.Items); e != a { - t.Fatalf("expected %v, got %v", e, a) - } - createdNoxuInstance, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns, sameInstanceName), noxuNamespacedResourceClient, noxuDefinition) - if err != nil { - t.Fatal(err) - } - gottenNoxuInstance, err := noxuNamespacedResourceClient.Get(sameInstanceName, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := createdNoxuInstance, gottenNoxuInstance; !reflect.DeepEqual(e, a) { - t.Fatalf("expected %v, got %v", e, a) - } - listWithItem, err := noxuNamespacedResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 1, len(listWithItem.Items); e != a { - t.Fatalf("expected %v, got %v", e, a) - } - if e, a := *createdNoxuInstance, listWithItem.Items[0]; !reflect.DeepEqual(e, a) { - t.Fatalf("expected %v, got %v", e, a) - } - - if err := noxuNamespacedResourceClient.Delete(sameInstanceName, nil); err != nil { - t.Fatal(err) - } - if _, err = noxuNamespacedResourceClient.Get(sameInstanceName, metav1.GetOptions{}); err == nil || !errors.IsNotFound(err) { - t.Fatalf("expected a NotFound error, got:%v", err) - } - listWithoutItem, err := noxuNamespacedResourceClient.List(metav1.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := 0, len(listWithoutItem.Items); e != a { - t.Fatalf("expected %v, got %v", e, a) - } - }() -} - -func TestEtcdStorage(t *testing.T) { - config, err := testserver.DefaultServerConfig() - if err != nil { - t.Fatal(err) - } - stopCh, clientConfig, err := testserver.StartServer(config) - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := apiextensionsclientset.NewForConfig(clientConfig) - if err != nil { - t.Fatal(err) - } - dynamicClient, err := dynamic.NewForConfig(clientConfig) - if err != nil { - t.Fatal(err) - } - - etcdPrefix := getPrefixFromConfig(t, config) - - ns1 := "another-default-is-possible" - curletDefinition := testserver.NewCurletCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - curletDefinition, err = testserver.CreateNewCustomResourceDefinition(curletDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - curletNamespacedResourceClient := newNamespacedCustomResourceClient(ns1, dynamicClient, curletDefinition) - if _, err := instantiateCustomResource(t, testserver.NewCurletInstance(ns1, "bar"), curletNamespacedResourceClient, curletDefinition); err != nil { - t.Fatalf("unable to create curlet cluster scoped Instance:%v", err) - } - - ns2 := "the-cruel-default" - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns2, dynamicClient, noxuDefinition) - if _, err := instantiateCustomResource(t, testserver.NewNoxuInstance(ns2, "foo"), noxuNamespacedResourceClient, noxuDefinition); err != nil { - t.Fatalf("unable to create noxu namespace scoped Instance:%v", err) - } - - testcases := map[string]struct { - etcdPath string - expectedObject *metaObject - }{ - "namespacedNoxuDefinition": { - etcdPath: "apiextensions.k8s.io/customresourcedefinitions/noxus.mygroup.example.com", - expectedObject: &metaObject{ - Kind: "CustomResourceDefinition", - APIVersion: "apiextensions.k8s.io/v1beta1", - Metadata: Metadata{ - Name: "noxus.mygroup.example.com", - Namespace: "", - SelfLink: "", - }, - }, - }, - "namespacedNoxuInstance": { - etcdPath: "mygroup.example.com/noxus/the-cruel-default/foo", - expectedObject: &metaObject{ - Kind: "WishIHadChosenNoxu", - APIVersion: "mygroup.example.com/v1beta1", - Metadata: Metadata{ - Name: "foo", - Namespace: "the-cruel-default", - SelfLink: "", // TODO double check: empty? - }, - }, - }, - - "clusteredCurletDefinition": { - etcdPath: "apiextensions.k8s.io/customresourcedefinitions/curlets.mygroup.example.com", - expectedObject: &metaObject{ - Kind: "CustomResourceDefinition", - APIVersion: "apiextensions.k8s.io/v1beta1", - Metadata: Metadata{ - Name: "curlets.mygroup.example.com", - Namespace: "", - SelfLink: "", - }, - }, - }, - - "clusteredCurletInstance": { - etcdPath: "mygroup.example.com/curlets/bar", - expectedObject: &metaObject{ - Kind: "Curlet", - APIVersion: "mygroup.example.com/v1beta1", - Metadata: Metadata{ - Name: "bar", - Namespace: "", - SelfLink: "", // TODO double check: empty? - }, - }, - }, - } - - etcdURL, ok := os.LookupEnv("KUBE_INTEGRATION_ETCD_URL") - if !ok { - etcdURL = "http://127.0.0.1:2379" - } - cfg := clientv3.Config{ - Endpoints: []string{etcdURL}, - } - c, err := clientv3.New(cfg) - if err != nil { - t.Fatal(err) - } - kv := clientv3.NewKV(c) - for testName, tc := range testcases { - output, err := getFromEtcd(kv, etcdPrefix, tc.etcdPath) - if err != nil { - t.Fatalf("%s - no path gotten from etcd:%v", testName, err) - } - if e, a := tc.expectedObject, output; !reflect.DeepEqual(e, a) { - t.Errorf("%s - expected %#v\n got %#v\n", testName, e, a) - } - } -} - -func getPrefixFromConfig(t *testing.T, config *extensionsapiserver.Config) string { - extensionsOptionsGetter, ok := config.ExtraConfig.CRDRESTOptionsGetter.(extensionsapiserver.CRDRESTOptionsGetter) - if !ok { - t.Fatal("can't obtain etcd prefix: unable to cast config.CRDRESTOptionsGetter to extensionsapiserver.CRDRESTOptionsGetter") - } - return extensionsOptionsGetter.StoragePrefix -} - -func getFromEtcd(keys clientv3.KV, prefix, localPath string) (*metaObject, error) { - internalPath := path.Join("/", prefix, localPath) // TODO: Double check, should we concatenate two prefixes? - response, err := keys.Get(context.Background(), internalPath) - if err != nil { - return nil, err - } - if response.More || response.Count != 1 || len(response.Kvs) != 1 { - return nil, fmt.Errorf("Invalid etcd response (not found == %v): %#v", response.Count == 0, response) - } - obj := &metaObject{} - if err := json.Unmarshal(response.Kvs[0].Value, obj); err != nil { - return nil, err - } - return obj, nil -} - -type metaObject struct { - Kind string `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"` - APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,2,opt,name=apiVersion"` - Metadata `json:"metadata,omitempty" protobuf:"bytes,3,opt,name=metadata"` -} - -type Metadata struct { - Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` - Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"` - SelfLink string `json:"selfLink,omitempty" protobuf:"bytes,3,opt,name=selfLink"` -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/subresources_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/subresources_test.go deleted file mode 100644 index bce63a4a5..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/subresources_test.go +++ /dev/null @@ -1,744 +0,0 @@ -/* -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 ( - "math" - "reflect" - "sort" - "strings" - "testing" - - autoscaling "k8s.io/api/autoscaling/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/dynamic" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apiextensions-apiserver/test/integration/testserver" -) - -var labelSelectorPath = ".status.labelSelector" - -func NewNoxuSubresourcesCRD(scope apiextensionsv1beta1.ResourceScope) *apiextensionsv1beta1.CustomResourceDefinition { - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "noxus.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1beta1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "noxus", - Singular: "nonenglishnoxu", - Kind: "WishIHadChosenNoxu", - ShortNames: []string{"foo", "bar", "abc", "def"}, - ListKind: "NoxuItemList", - }, - Scope: scope, - Subresources: &apiextensionsv1beta1.CustomResourceSubresources{ - Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{}, - Scale: &apiextensionsv1beta1.CustomResourceSubresourceScale{ - SpecReplicasPath: ".spec.replicas", - StatusReplicasPath: ".status.replicas", - LabelSelectorPath: &labelSelectorPath, - }, - }, - }, - } -} - -func NewNoxuSubresourceInstance(namespace, name string) *unstructured.Unstructured { - return &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "mygroup.example.com/v1beta1", - "kind": "WishIHadChosenNoxu", - "metadata": map[string]interface{}{ - "namespace": namespace, - "name": name, - }, - "spec": map[string]interface{}{ - "num": int64(10), - "replicas": int64(3), - }, - "status": map[string]interface{}{ - "replicas": int64(7), - }, - }, - } -} - -func TestStatusSubresource(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - _, err = instantiateCustomResource(t, NewNoxuSubresourceInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } - - gottenNoxuInstance, err := noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - - // status should not be set after creation - if val, ok := gottenNoxuInstance.Object["status"]; ok { - t.Fatalf("status should not be set after creation, got %v", val) - } - - // .status.num = 20 - err = unstructured.SetNestedField(gottenNoxuInstance.Object, int64(20), "status", "num") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // .spec.num = 20 - err = unstructured.SetNestedField(gottenNoxuInstance.Object, int64(20), "spec", "num") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // UpdateStatus should not update spec. - // Check that .spec.num = 10 and .status.num = 20 - updatedStatusInstance, err := noxuResourceClient.UpdateStatus(gottenNoxuInstance) - if err != nil { - t.Fatalf("unable to update status: %v", err) - } - - specNum, found, err := unstructured.NestedInt64(updatedStatusInstance.Object, "spec", "num") - if !found || err != nil { - t.Fatalf("unable to get .spec.num") - } - if specNum != int64(10) { - t.Fatalf(".spec.num: expected: %v, got: %v", int64(10), specNum) - } - - statusNum, found, err := unstructured.NestedInt64(updatedStatusInstance.Object, "status", "num") - if !found || err != nil { - t.Fatalf("unable to get .status.num") - } - if statusNum != int64(20) { - t.Fatalf(".status.num: expected: %v, got: %v", int64(20), statusNum) - } - - gottenNoxuInstance, err = noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - - // .status.num = 40 - err = unstructured.SetNestedField(gottenNoxuInstance.Object, int64(40), "status", "num") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // .spec.num = 40 - err = unstructured.SetNestedField(gottenNoxuInstance.Object, int64(40), "spec", "num") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // Update should not update status. - // Check that .spec.num = 40 and .status.num = 20 - updatedInstance, err := noxuResourceClient.Update(gottenNoxuInstance) - if err != nil { - t.Fatalf("unable to update instance: %v", err) - } - - specNum, found, err = unstructured.NestedInt64(updatedInstance.Object, "spec", "num") - if !found || err != nil { - t.Fatalf("unable to get .spec.num") - } - if specNum != int64(40) { - t.Fatalf(".spec.num: expected: %v, got: %v", int64(40), specNum) - } - - statusNum, found, err = unstructured.NestedInt64(updatedInstance.Object, "status", "num") - if !found || err != nil { - t.Fatalf("unable to get .status.num") - } - if statusNum != int64(20) { - t.Fatalf(".status.num: expected: %v, got: %v", int64(20), statusNum) - } -} - -func TestScaleSubresource(t *testing.T) { - groupResource := schema.GroupResource{ - Group: "mygroup.example.com", - Resource: "noxus", - } - - stopCh, config, err := testserver.StartDefaultServer() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) - - // set invalid json path for specReplicasPath - noxuDefinition.Spec.Subresources.Scale.SpecReplicasPath = "foo,bar" - _, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err == nil { - t.Fatalf("unexpected non-error: specReplicasPath should be a valid json path under .spec") - } - - noxuDefinition.Spec.Subresources.Scale.SpecReplicasPath = ".spec.replicas" - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - _, err = instantiateCustomResource(t, NewNoxuSubresourceInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } - - scaleClient, err := testserver.CreateNewScaleClient(noxuDefinition, config) - if err != nil { - t.Fatal(err) - } - - // set .status.labelSelector = bar - gottenNoxuInstance, err := noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - err = unstructured.SetNestedField(gottenNoxuInstance.Object, "bar", "status", "labelSelector") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - _, err = noxuResourceClient.UpdateStatus(gottenNoxuInstance) - if err != nil { - t.Fatalf("unable to update status: %v", err) - } - - // get the scale object - gottenScale, err := scaleClient.Scales("not-the-default").Get(groupResource, "foo") - if err != nil { - t.Fatal(err) - } - if gottenScale.Spec.Replicas != 3 { - t.Fatalf("Scale.Spec.Replicas: expected: %v, got: %v", 3, gottenScale.Spec.Replicas) - } - if gottenScale.Status.Selector != "bar" { - t.Fatalf("Scale.Status.Selector: expected: %v, got: %v", "bar", gottenScale.Status.Selector) - } - - // check self link - expectedSelfLink := "/apis/mygroup.example.com/v1beta1/namespaces/not-the-default/noxus/foo/scale" - if gottenScale.GetSelfLink() != expectedSelfLink { - t.Fatalf("Scale.Metadata.SelfLink: expected: %v, got: %v", expectedSelfLink, gottenScale.GetSelfLink()) - } - - // update the scale object - // check that spec is updated, but status is not - gottenScale.Spec.Replicas = 5 - gottenScale.Status.Selector = "baz" - updatedScale, err := scaleClient.Scales("not-the-default").Update(groupResource, gottenScale) - if err != nil { - t.Fatal(err) - } - if updatedScale.Spec.Replicas != 5 { - t.Fatalf("replicas: expected: %v, got: %v", 5, updatedScale.Spec.Replicas) - } - if updatedScale.Status.Selector != "bar" { - t.Fatalf("scale should not update status: expected %v, got: %v", "bar", updatedScale.Status.Selector) - } - - // check that .spec.replicas = 5, but status is not updated - updatedNoxuInstance, err := noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - specReplicas, found, err := unstructured.NestedInt64(updatedNoxuInstance.Object, "spec", "replicas") - if !found || err != nil { - t.Fatalf("unable to get .spec.replicas") - } - if specReplicas != 5 { - t.Fatalf("replicas: expected: %v, got: %v", 5, specReplicas) - } - statusLabelSelector, found, err := unstructured.NestedString(updatedNoxuInstance.Object, "status", "labelSelector") - if !found || err != nil { - t.Fatalf("unable to get .status.labelSelector") - } - if statusLabelSelector != "bar" { - t.Fatalf("scale should not update status: expected %v, got: %v", "bar", statusLabelSelector) - } - - // validate maximum value - // set .spec.replicas = math.MaxInt64 - gottenNoxuInstance, err = noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - err = unstructured.SetNestedField(gottenNoxuInstance.Object, int64(math.MaxInt64), "spec", "replicas") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - _, err = noxuResourceClient.Update(gottenNoxuInstance) - if err == nil { - t.Fatalf("unexpected non-error: .spec.replicas should be less than 2147483647") - } -} - -func TestValidationSchema(t *testing.T) { - stopCh, config, err := testserver.StartDefaultServer() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - // fields other than properties in root schema are not allowed - noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition.Spec.Subresources = &apiextensionsv1beta1.CustomResourceSubresources{ - Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{}, - } - _, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err == nil { - t.Fatalf(`unexpected non-error, expected: must only have "properties" or "required" at the root if the status subresource is enabled`) - } - - // make sure we are not restricting fields to properties even in subschemas - noxuDefinition.Spec.Validation.OpenAPIV3Schema = &apiextensionsv1beta1.JSONSchemaProps{ - Properties: map[string]apiextensionsv1beta1.JSONSchemaProps{ - "spec": { - Description: "Validation for spec", - Properties: map[string]apiextensionsv1beta1.JSONSchemaProps{ - "replicas": { - Type: "integer", - }, - }, - }, - }, - Required: []string{"spec"}, - Description: "This is a description at the root of the schema", - } - _, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatalf("unable to created crd %v: %v", noxuDefinition.Name, err) - } -} - -func TestValidateOnlyStatus(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - // UpdateStatus should validate only status - // 1. create a crd with max value of .spec.num = 10 and .status.num = 10 - // 2. create a cr with .spec.num = 10 and .status.num = 10 (valid) - // 3. update the spec of the cr with .spec.num = 15 (spec is invalid), expect no error - // 4. update the spec of the cr with .spec.num = 15 (spec is invalid), expect error - - // max value of spec.num = 10 and status.num = 10 - schema := &apiextensionsv1beta1.JSONSchemaProps{ - Properties: map[string]apiextensionsv1beta1.JSONSchemaProps{ - "spec": { - Properties: map[string]apiextensionsv1beta1.JSONSchemaProps{ - "num": { - Type: "integer", - Maximum: float64Ptr(10), - }, - }, - }, - "status": { - Properties: map[string]apiextensionsv1beta1.JSONSchemaProps{ - "num": { - Type: "integer", - Maximum: float64Ptr(10), - }, - }, - }, - }, - } - - noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition.Spec.Validation = &apiextensionsv1beta1.CustomResourceValidation{ - OpenAPIV3Schema: schema, - } - - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - // set .spec.num = 10 and .status.num = 10 - noxuInstance := NewNoxuSubresourceInstance(ns, "foo") - err = unstructured.SetNestedField(noxuInstance.Object, int64(10), "status", "num") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - createdNoxuInstance, err := instantiateCustomResource(t, noxuInstance, noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } - - // update the spec with .spec.num = 15, expecting no error - err = unstructured.SetNestedField(createdNoxuInstance.Object, int64(15), "spec", "num") - if err != nil { - t.Fatalf("unexpected error setting .spec.num: %v", err) - } - createdNoxuInstance, err = noxuResourceClient.UpdateStatus(createdNoxuInstance) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - - // update with .status.num = 15, expecting an error - err = unstructured.SetNestedField(createdNoxuInstance.Object, int64(15), "status", "num") - if err != nil { - t.Fatalf("unexpected error setting .status.num: %v", err) - } - createdNoxuInstance, err = noxuResourceClient.UpdateStatus(createdNoxuInstance) - if err == nil { - t.Fatal("expected error, but got none") - } - statusError, isStatus := err.(*apierrors.StatusError) - if !isStatus || statusError == nil { - t.Fatalf("expected status error, got %T: %v", err, err) - } - if !strings.Contains(statusError.Error(), "Invalid value") { - t.Fatalf("expected 'Invalid value' in error, got: %v", err) - } -} - -func TestSubresourcesDiscovery(t *testing.T) { - stopCh, config, err := testserver.StartDefaultServer() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - group := "mygroup.example.com" - version := "v1beta1" - - resources, err := apiExtensionClient.Discovery().ServerResourcesForGroupVersion(group + "/" + version) - if err != nil { - t.Fatal(err) - } - - if len(resources.APIResources) != 3 { - t.Fatalf("Expected exactly the resources \"noxus\", \"noxus/status\" and \"noxus/scale\" in group version %v/%v via discovery, got: %v", group, version, resources.APIResources) - } - - // check discovery info for status - status := resources.APIResources[1] - - if status.Name != "noxus/status" { - t.Fatalf("incorrect status via discovery: expected name: %v, got: %v", "noxus/status", status.Name) - } - - if status.Namespaced != true { - t.Fatalf("incorrect status via discovery: expected namespace: %v, got: %v", true, status.Namespaced) - } - - if status.Kind != "WishIHadChosenNoxu" { - t.Fatalf("incorrect status via discovery: expected kind: %v, got: %v", "WishIHadChosenNoxu", status.Kind) - } - - expectedVerbs := []string{"get", "patch", "update"} - sort.Strings(status.Verbs) - if !reflect.DeepEqual([]string(status.Verbs), expectedVerbs) { - t.Fatalf("incorrect status via discovery: expected: %v, got: %v", expectedVerbs, status.Verbs) - } - - // check discovery info for scale - scale := resources.APIResources[2] - - if scale.Group != autoscaling.GroupName { - t.Fatalf("incorrect scale via discovery: expected group: %v, got: %v", autoscaling.GroupName, scale.Group) - } - - if scale.Version != "v1" { - t.Fatalf("incorrect scale via discovery: expected version: %v, got %v", "v1", scale.Version) - } - - if scale.Name != "noxus/scale" { - t.Fatalf("incorrect scale via discovery: expected name: %v, got: %v", "noxus/scale", scale.Name) - } - - if scale.Namespaced != true { - t.Fatalf("incorrect scale via discovery: expected namespace: %v, got: %v", true, scale.Namespaced) - } - - if scale.Kind != "Scale" { - t.Fatalf("incorrect scale via discovery: expected kind: %v, got: %v", "Scale", scale.Kind) - } - - sort.Strings(scale.Verbs) - if !reflect.DeepEqual([]string(scale.Verbs), expectedVerbs) { - t.Fatalf("incorrect scale via discovery: expected: %v, got: %v", expectedVerbs, scale.Verbs) - } -} - -func TestGeneration(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - _, err = instantiateCustomResource(t, NewNoxuSubresourceInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } - - // .metadata.generation = 1 - gottenNoxuInstance, err := noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if gottenNoxuInstance.GetGeneration() != 1 { - t.Fatalf(".metadata.generation should be 1 after creation") - } - - // .status.num = 20 - err = unstructured.SetNestedField(gottenNoxuInstance.Object, int64(20), "status", "num") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // UpdateStatus does not increment generation - updatedStatusInstance, err := noxuResourceClient.UpdateStatus(gottenNoxuInstance) - if err != nil { - t.Fatalf("unable to update status: %v", err) - } - if updatedStatusInstance.GetGeneration() != 1 { - t.Fatalf("updating status should not increment .metadata.generation: expected: %v, got: %v", 1, updatedStatusInstance.GetGeneration()) - } - - gottenNoxuInstance, err = noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - - // .spec.num = 20 - err = unstructured.SetNestedField(gottenNoxuInstance.Object, int64(20), "spec", "num") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // Update increments generation - updatedInstance, err := noxuResourceClient.Update(gottenNoxuInstance) - if err != nil { - t.Fatalf("unable to update instance: %v", err) - } - if updatedInstance.GetGeneration() != 2 { - t.Fatalf("updating spec should increment .metadata.generation: expected: %v, got: %v", 2, updatedStatusInstance.GetGeneration()) - } -} - -func TestSubresourcePatch(t *testing.T) { - groupResource := schema.GroupResource{ - Group: "mygroup.example.com", - Resource: "noxus", - } - - stopCh, config, err := testserver.StartDefaultServer() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - _, err = instantiateCustomResource(t, NewNoxuSubresourceInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } - - scaleClient, err := testserver.CreateNewScaleClient(noxuDefinition, config) - if err != nil { - t.Fatal(err) - } - - patch := []byte(`{"spec": {"num":999}, "status": {"num":999}}`) - patchedNoxuInstance, err := noxuResourceClient.Patch("foo", types.MergePatchType, patch, "status") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // .spec.num should remain 10 - specNum, found, err := unstructured.NestedInt64(patchedNoxuInstance.Object, "spec", "num") - if !found || err != nil { - t.Fatalf("unable to get .spec.num") - } - if specNum != 10 { - t.Fatalf(".spec.num: expected: %v, got: %v", 10, specNum) - } - - // .status.num should be 999 - statusNum, found, err := unstructured.NestedInt64(patchedNoxuInstance.Object, "status", "num") - if !found || err != nil { - t.Fatalf("unable to get .status.num") - } - if statusNum != 999 { - t.Fatalf(".status.num: expected: %v, got: %v", 999, statusNum) - } - - // this call waits for the resourceVersion to be reached in the cache before returning. - // We need to do this because the patch gets its initial object from the storage, and the cache serves that. - // If it is out of date, then our initial patch is applied to an old resource version, which conflicts - // and then the updated object shows a conflicting diff, which permanently fails the patch. - // This gives expected stability in the patch without retrying on an known number of conflicts below in the test. - // See https://issue.k8s.io/42644 - _, err = noxuResourceClient.Get("foo", metav1.GetOptions{ResourceVersion: patchedNoxuInstance.GetResourceVersion()}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // no-op patch - _, err = noxuResourceClient.Patch("foo", types.MergePatchType, patch, "status") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // empty patch - _, err = noxuResourceClient.Patch("foo", types.MergePatchType, []byte(`{}`), "status") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - patch = []byte(`{"spec": {"replicas":7}, "status": {"replicas":7}}`) - patchedNoxuInstance, err = noxuResourceClient.Patch("foo", types.MergePatchType, patch, "scale") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // this call waits for the resourceVersion to be reached in the cache before returning. - // We need to do this because the patch gets its initial object from the storage, and the cache serves that. - // If it is out of date, then our initial patch is applied to an old resource version, which conflicts - // and then the updated object shows a conflicting diff, which permanently fails the patch. - // This gives expected stability in the patch without retrying on an known number of conflicts below in the test. - // See https://issue.k8s.io/42644 - _, err = noxuResourceClient.Get("foo", metav1.GetOptions{ResourceVersion: patchedNoxuInstance.GetResourceVersion()}) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // Scale.Spec.Replicas = 7 but Scale.Status.Replicas should remain 7 - gottenScale, err := scaleClient.Scales("not-the-default").Get(groupResource, "foo") - if err != nil { - t.Fatal(err) - } - if gottenScale.Spec.Replicas != 7 { - t.Fatalf("Scale.Spec.Replicas: expected: %v, got: %v", 7, gottenScale.Spec.Replicas) - } - if gottenScale.Status.Replicas != 0 { - t.Fatalf("Scale.Status.Replicas: expected: %v, got: %v", 0, gottenScale.Spec.Replicas) - } - - // no-op patch - _, err = noxuResourceClient.Patch("foo", types.MergePatchType, patch, "scale") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // empty patch - _, err = noxuResourceClient.Patch("foo", types.MergePatchType, []byte(`{}`), "scale") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - - // make sure strategic merge patch is not supported for both status and scale - _, err = noxuResourceClient.Patch("foo", types.StrategicMergePatchType, patch, "status") - if err == nil { - t.Fatalf("unexpected non-error: strategic merge patch is not supported for custom resources") - } - - _, err = noxuResourceClient.Patch("foo", types.StrategicMergePatchType, patch, "scale") - if err == nil { - t.Fatalf("unexpected non-error: strategic merge patch is not supported for custom resources") - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/table_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/table_test.go deleted file mode 100644 index 0c3ac609a..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/table_test.go +++ /dev/null @@ -1,185 +0,0 @@ -/* -Copyright 2017 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 ( - "fmt" - "testing" - - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/rest" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/test/integration/testserver" -) - -func newTableCRD() *apiextensionsv1beta1.CustomResourceDefinition { - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "tables.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1beta1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "tables", - Singular: "table", - Kind: "Table", - ListKind: "TablemList", - }, - Scope: apiextensionsv1beta1.ClusterScoped, - AdditionalPrinterColumns: []apiextensionsv1beta1.CustomResourceColumnDefinition{ - {Name: "Age", Type: "date", JSONPath: ".metadata.creationTimestamp"}, - {Name: "Alpha", Type: "string", JSONPath: ".spec.alpha"}, - {Name: "Beta", Type: "integer", Description: "the beta field", Format: "int64", Priority: 42, JSONPath: ".spec.beta"}, - {Name: "Gamma", Type: "integer", Description: "a column with wrongly typed values", JSONPath: ".spec.gamma"}, - }, - }, - } -} - -func newTableInstance(name string) *unstructured.Unstructured { - return &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "mygroup.example.com/v1beta1", - "kind": "Table", - "metadata": map[string]interface{}{ - "name": name, - }, - "spec": map[string]interface{}{ - "alpha": "foo_123", - "beta": 10, - "gamma": "bar", - "delta": "hello", - }, - }, - } -} - -func TestTableGet(t *testing.T) { - stopCh, config, err := testserver.StartDefaultServer() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - crd := newTableCRD() - crd, err = testserver.CreateNewCustomResourceDefinition(crd, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - crd, err = apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(crd.Name, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - t.Logf("table crd created: %#v", crd) - - crClient := newNamespacedCustomResourceClient("", dynamicClient, crd) - foo, err := crClient.Create(newTableInstance("foo")) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } - t.Logf("foo created: %#v", foo.UnstructuredContent()) - - gv := schema.GroupVersion{Group: crd.Spec.Group, Version: crd.Spec.Version} - gvk := gv.WithKind(crd.Spec.Names.Kind) - - scheme := runtime.NewScheme() - codecs := serializer.NewCodecFactory(scheme) - parameterCodec := runtime.NewParameterCodec(scheme) - metav1.AddToGroupVersion(scheme, gv) - scheme.AddKnownTypes(gv, &metav1beta1.Table{}, &metav1beta1.TableOptions{}) - scheme.AddKnownTypes(metav1beta1.SchemeGroupVersion, &metav1beta1.Table{}, &metav1beta1.TableOptions{}) - - crConfig := *config - crConfig.GroupVersion = &gv - crConfig.APIPath = "/apis" - crConfig.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: codecs} - crRestClient, err := rest.RESTClientFor(&crConfig) - if err != nil { - t.Fatal(err) - } - - ret, err := crRestClient.Get(). - Resource(crd.Spec.Names.Plural). - SetHeader("Accept", fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", metav1beta1.SchemeGroupVersion.Version, metav1beta1.GroupName)). - VersionedParams(&metav1beta1.TableOptions{}, parameterCodec). - Do(). - Get() - if err != nil { - t.Fatalf("failed to list %v resources: %v", gvk, err) - } - - tbl, ok := ret.(*metav1beta1.Table) - if !ok { - t.Fatalf("expected metav1beta1.Table, got %T", ret) - } - t.Logf("%v table list: %#v", gvk, tbl) - - if got, expected := len(tbl.ColumnDefinitions), 5; got != expected { - t.Errorf("expected %d headers, got %d", expected, got) - } else { - alpha := metav1beta1.TableColumnDefinition{Name: "Alpha", Type: "string", Format: "", Description: "Custom resource definition column (in JSONPath format): .spec.alpha", Priority: 0} - if got, expected := tbl.ColumnDefinitions[2], alpha; got != expected { - t.Errorf("expected column definition %#v, got %#v", expected, got) - } - - beta := metav1beta1.TableColumnDefinition{Name: "Beta", Type: "integer", Format: "int64", Description: "the beta field", Priority: 42} - if got, expected := tbl.ColumnDefinitions[3], beta; got != expected { - t.Errorf("expected column definition %#v, got %#v", expected, got) - } - - gamma := metav1beta1.TableColumnDefinition{Name: "Gamma", Type: "integer", Description: "a column with wrongly typed values"} - if got, expected := tbl.ColumnDefinitions[4], gamma; got != expected { - t.Errorf("expected column definition %#v, got %#v", expected, got) - } - } - if got, expected := len(tbl.Rows), 1; got != expected { - t.Errorf("expected %d rows, got %d", expected, got) - } else if got, expected := len(tbl.Rows[0].Cells), 5; got != expected { - t.Errorf("expected %d cells, got %d", expected, got) - } else { - if got, expected := tbl.Rows[0].Cells[0], "foo"; got != expected { - t.Errorf("expected cell[0] to equal %q, got %q", expected, got) - } - if got, expected := tbl.Rows[0].Cells[2], "foo_123"; got != expected { - t.Errorf("expected cell[2] to equal %q, got %q", expected, got) - } - if got, expected := tbl.Rows[0].Cells[3], int64(10); got != expected { - t.Errorf("expected cell[3] to equal %#v, got %#v", expected, got) - } - if got, expected := tbl.Rows[0].Cells[4], interface{}(nil); got != expected { - t.Errorf("expected cell[3] to equal %#v although the type does not match the column, got %#v", expected, got) - } - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/testserver/resources.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/testserver/resources.go deleted file mode 100644 index f341b002f..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/testserver/resources.go +++ /dev/null @@ -1,377 +0,0 @@ -/* -Copyright 2017 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 testserver - -import ( - "fmt" - "time" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/apiserver/pkg/storage/names" - "k8s.io/client-go/discovery" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/rest" - "k8s.io/client-go/restmapper" - "k8s.io/client-go/scale" -) - -const ( - noxuInstanceNum int64 = 9223372036854775807 -) - -//NewRandomNameCustomResourceDefinition generates a CRD with random name to avoid name conflict in e2e tests -func NewRandomNameCustomResourceDefinition(scope apiextensionsv1beta1.ResourceScope) *apiextensionsv1beta1.CustomResourceDefinition { - // ensure the singular doesn't end in an s for now - gName := names.SimpleNameGenerator.GenerateName("foo") + "a" - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: gName + "s.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1beta1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: gName + "s", - Singular: gName, - Kind: gName, - ListKind: gName + "List", - }, - Scope: scope, - }, - } -} - -func NewNoxuCustomResourceDefinition(scope apiextensionsv1beta1.ResourceScope) *apiextensionsv1beta1.CustomResourceDefinition { - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "noxus.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1beta1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "noxus", - Singular: "nonenglishnoxu", - Kind: "WishIHadChosenNoxu", - ShortNames: []string{"foo", "bar", "abc", "def"}, - ListKind: "NoxuItemList", - Categories: []string{"all"}, - }, - Scope: scope, - }, - } -} - -func NewVersionedNoxuInstance(namespace, name, version string) *unstructured.Unstructured { - return &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "mygroup.example.com/" + version, - "kind": "WishIHadChosenNoxu", - "metadata": map[string]interface{}{ - "namespace": namespace, - "name": name, - }, - "content": map[string]interface{}{ - "key": "value", - }, - "num": map[string]interface{}{ - "num1": noxuInstanceNum, - "num2": 1000000, - }, - }, - } -} - -func NewNoxuInstance(namespace, name string) *unstructured.Unstructured { - return NewVersionedNoxuInstance(namespace, name, "v1beta1") -} - -func NewMultipleVersionNoxuCRD(scope apiextensionsv1beta1.ResourceScope) *apiextensionsv1beta1.CustomResourceDefinition { - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "noxus.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1beta1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "noxus", - Singular: "nonenglishnoxu", - Kind: "WishIHadChosenNoxu", - ShortNames: []string{"foo", "bar", "abc", "def"}, - ListKind: "NoxuItemList", - Categories: []string{"all"}, - }, - Scope: scope, - Versions: []apiextensionsv1beta1.CustomResourceDefinitionVersion{ - { - Name: "v1beta1", - Served: true, - Storage: false, - }, - { - Name: "v1beta2", - Served: true, - Storage: true, - }, - { - Name: "v0", - Served: false, - Storage: false, - }, - }, - }, - } -} - -func NewNoxu2CustomResourceDefinition(scope apiextensionsv1beta1.ResourceScope) *apiextensionsv1beta1.CustomResourceDefinition { - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "noxus2.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1alpha1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "noxus2", - Singular: "nonenglishnoxu2", - Kind: "WishIHadChosenNoxu2", - ShortNames: []string{"foo", "bar", "abc", "def"}, - ListKind: "Noxu2ItemList", - }, - Scope: scope, - }, - } -} - -func NewCurletCustomResourceDefinition(scope apiextensionsv1beta1.ResourceScope) *apiextensionsv1beta1.CustomResourceDefinition { - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "curlets.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1beta1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "curlets", - Singular: "curlet", - Kind: "Curlet", - ListKind: "CurletList", - }, - Scope: scope, - }, - } -} - -func NewCurletInstance(namespace, name string) *unstructured.Unstructured { - return &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "mygroup.example.com/v1beta1", - "kind": "Curlet", - "metadata": map[string]interface{}{ - "namespace": namespace, - "name": name, - }, - "content": map[string]interface{}{ - "key": "value", - }, - }, - } -} - -func servedVersions(crd *apiextensionsv1beta1.CustomResourceDefinition) []string { - if len(crd.Spec.Versions) == 0 { - return []string{crd.Spec.Version} - } - var versions []string - for _, v := range crd.Spec.Versions { - if v.Served { - versions = append(versions, v.Name) - } - } - return versions -} - -func existsInDiscovery(crd *apiextensionsv1beta1.CustomResourceDefinition, apiExtensionsClient clientset.Interface, version string) (bool, error) { - groupResource, err := apiExtensionsClient.Discovery().ServerResourcesForGroupVersion(crd.Spec.Group + "/" + version) - if err != nil { - if errors.IsNotFound(err) { - return false, nil - } - return false, err - } - for _, g := range groupResource.APIResources { - if g.Name == crd.Spec.Names.Plural { - return true, nil - } - } - return false, nil -} - -// CreateNewCustomResourceDefinitionWatchUnsafe creates the CRD and makes sure -// the apiextension apiserver has installed the CRD. But it's not safe to watch -// the created CR. Please call CreateNewCustomResourceDefinition if you need to -// watch the CR. -func CreateNewCustomResourceDefinitionWatchUnsafe(crd *apiextensionsv1beta1.CustomResourceDefinition, apiExtensionsClient clientset.Interface) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - crd, err := apiExtensionsClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd) - if err != nil { - return nil, err - } - - // wait until all resources appears in discovery - for _, version := range servedVersions(crd) { - err := wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) { - return existsInDiscovery(crd, apiExtensionsClient, version) - }) - if err != nil { - return nil, err - } - } - - return crd, err -} - -func CreateNewCustomResourceDefinition(crd *apiextensionsv1beta1.CustomResourceDefinition, apiExtensionsClient clientset.Interface, dynamicClientSet dynamic.Interface) (*apiextensionsv1beta1.CustomResourceDefinition, error) { - crd, err := CreateNewCustomResourceDefinitionWatchUnsafe(crd, apiExtensionsClient) - if err != nil { - return nil, err - } - - // This is only for a test. We need the watch cache to have a resource version that works for the test. - // When new REST storage is created, the storage cacher for the CR starts asynchronously. - // REST API operations return like list use the RV of etcd, but the storage cacher's reflector's list - // can get a different RV because etcd can be touched in between the initial list operation (if that's what you're doing first) - // and the storage cache reflector starting. - // Later, you can issue a watch with the REST apis list.RV and end up earlier than the storage cacher. - // The general working model is that if you get a "resourceVersion too old" message, you re-list and rewatch. - // For this test, we'll actually cycle, "list/watch/create/delete" until we get an RV from list that observes the create and not an error. - // This way all the tests that are checking for watches don't have to worry about RV too old problems because crazy things *could* happen - // before like the created RV could be too old to watch. - for _, version := range servedVersions(crd) { - err := wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) { - return isWatchCachePrimed(crd, dynamicClientSet, version) - }) - if err != nil { - return nil, err - } - } - return crd, nil -} - -// isWatchCachePrimed returns true if the watch is primed for an specified version of CRD watch -func isWatchCachePrimed(crd *apiextensionsv1beta1.CustomResourceDefinition, dynamicClientSet dynamic.Interface, version string) (bool, error) { - ns := "" - if crd.Spec.Scope != apiextensionsv1beta1.ClusterScoped { - ns = "aval" - } - - gvr := schema.GroupVersionResource{Group: crd.Spec.Group, Version: version, Resource: crd.Spec.Names.Plural} - var resourceClient dynamic.ResourceInterface - if crd.Spec.Scope != apiextensionsv1beta1.ClusterScoped { - resourceClient = dynamicClientSet.Resource(gvr).Namespace(ns) - } else { - resourceClient = dynamicClientSet.Resource(gvr) - } - instanceName := "setup-instance" - instance := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": crd.Spec.Group + "/" + version, - "kind": crd.Spec.Names.Kind, - "metadata": map[string]interface{}{ - "namespace": ns, - "name": instanceName, - }, - "alpha": "foo_123", - "beta": 10, - "gamma": "bar", - "delta": "hello", - "epsilon": "foobar", - "spec": map[string]interface{}{}, - }, - } - createdInstance, err := resourceClient.Create(instance) - if err != nil { - return false, err - } - err = resourceClient.Delete(createdInstance.GetName(), nil) - if err != nil { - return false, err - } - - noxuWatch, err := resourceClient.Watch(metav1.ListOptions{ResourceVersion: createdInstance.GetResourceVersion()}) - if err != nil { - return false, err - } - defer noxuWatch.Stop() - - select { - case watchEvent := <-noxuWatch.ResultChan(): - if watch.Error == watchEvent.Type { - return false, nil - } - if watch.Deleted != watchEvent.Type { - return false, fmt.Errorf("expected DELETE, but got %#v", watchEvent) - } - return true, nil - case <-time.After(5 * time.Second): - return false, fmt.Errorf("gave up waiting for watch event") - } -} - -func DeleteCustomResourceDefinition(crd *apiextensionsv1beta1.CustomResourceDefinition, apiExtensionsClient clientset.Interface) error { - if err := apiExtensionsClient.Apiextensions().CustomResourceDefinitions().Delete(crd.Name, nil); err != nil { - return err - } - for _, version := range servedVersions(crd) { - err := wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) { - exists, err := existsInDiscovery(crd, apiExtensionsClient, version) - return !exists, err - }) - if err != nil { - return err - } - } - return nil -} - -func CreateNewScaleClient(crd *apiextensionsv1beta1.CustomResourceDefinition, config *rest.Config) (scale.ScalesGetter, error) { - discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) - if err != nil { - return nil, err - } - groupResource, err := discoveryClient.ServerResourcesForGroupVersion(crd.Spec.Group + "/" + crd.Spec.Version) - if err != nil { - return nil, err - } - - resources := []*restmapper.APIGroupResources{ - { - Group: metav1.APIGroup{ - Name: crd.Spec.Group, - Versions: []metav1.GroupVersionForDiscovery{ - {Version: crd.Spec.Version}, - }, - PreferredVersion: metav1.GroupVersionForDiscovery{Version: crd.Spec.Version}, - }, - VersionedResources: map[string][]metav1.APIResource{ - crd.Spec.Version: groupResource.APIResources, - }, - }, - } - - restMapper := restmapper.NewDiscoveryRESTMapper(resources) - resolver := scale.NewDiscoveryScaleKindResolver(discoveryClient) - - return scale.NewForConfig(config, restMapper, dynamic.LegacyAPIPathResolverFunc, resolver) -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/testserver/start.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/testserver/start.go deleted file mode 100644 index 22b9fa286..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/testserver/start.go +++ /dev/null @@ -1,161 +0,0 @@ -/* -Copyright 2017 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 testserver - -import ( - "fmt" - "net" - "os" - "time" - - "github.com/pborman/uuid" - - extensionsapiserver "k8s.io/apiextensions-apiserver/pkg/apiserver" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apiextensions-apiserver/pkg/cmd/server" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/util/wait" - genericapiserver "k8s.io/apiserver/pkg/server" - genericapiserveroptions "k8s.io/apiserver/pkg/server/options" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/rest" -) - -func DefaultServerConfig() (*extensionsapiserver.Config, error) { - listener, port, err := genericapiserveroptions.CreateListener("tcp", "127.0.0.1:0") - if err != nil { - return nil, err - } - - options := server.NewCustomResourceDefinitionsServerOptions(os.Stdout, os.Stderr) - options.RecommendedOptions.Audit.LogOptions.Path = "-" - options.RecommendedOptions.SecureServing.BindPort = port - options.RecommendedOptions.Authentication = nil // disable - options.RecommendedOptions.Authorization = nil // disable - options.RecommendedOptions.Admission = nil // disable - options.RecommendedOptions.SecureServing.BindAddress = net.ParseIP("127.0.0.1") - options.RecommendedOptions.SecureServing.Listener = listener - etcdURL, ok := os.LookupEnv("KUBE_INTEGRATION_ETCD_URL") - if !ok { - etcdURL = "http://127.0.0.1:2379" - } - options.RecommendedOptions.Etcd.StorageConfig.ServerList = []string{etcdURL} - options.RecommendedOptions.Etcd.StorageConfig.Prefix = uuid.New() - - genericConfig := genericapiserver.NewRecommendedConfig(extensionsapiserver.Codecs) - - if err := options.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil { - return nil, fmt.Errorf("error creating self-signed certificates: %v", err) - } - if err := options.RecommendedOptions.ApplyTo(genericConfig, nil); err != nil { - return nil, err - } - if err := options.APIEnablement.ApplyTo(&genericConfig.Config, extensionsapiserver.DefaultAPIResourceConfigSource(), extensionsapiserver.Scheme); err != nil { - return nil, err - } - - customResourceDefinitionRESTOptionsGetter := extensionsapiserver.CRDRESTOptionsGetter{ - StorageConfig: options.RecommendedOptions.Etcd.StorageConfig, - StoragePrefix: options.RecommendedOptions.Etcd.StorageConfig.Prefix, - EnableWatchCache: options.RecommendedOptions.Etcd.EnableWatchCache, - DefaultWatchCacheSize: options.RecommendedOptions.Etcd.DefaultWatchCacheSize, - EnableGarbageCollection: options.RecommendedOptions.Etcd.EnableGarbageCollection, - DeleteCollectionWorkers: options.RecommendedOptions.Etcd.DeleteCollectionWorkers, - } - customResourceDefinitionRESTOptionsGetter.StorageConfig.Codec = unstructured.UnstructuredJSONScheme - - config := &extensionsapiserver.Config{ - GenericConfig: genericConfig, - ExtraConfig: extensionsapiserver.ExtraConfig{ - CRDRESTOptionsGetter: customResourceDefinitionRESTOptionsGetter, - }, - } - - return config, nil -} - -func StartServer(config *extensionsapiserver.Config) (chan struct{}, *rest.Config, error) { - stopCh := make(chan struct{}) - server, err := config.Complete().New(genericapiserver.NewEmptyDelegate()) - if err != nil { - return nil, nil, err - } - go func() { - err := server.GenericAPIServer.PrepareRun().Run(stopCh) - if err != nil { - close(stopCh) - panic(err) - } - }() - - // wait until the server is healthy - err = wait.PollImmediate(30*time.Millisecond, 30*time.Second, func() (bool, error) { - healthClient, err := clientset.NewForConfig(server.GenericAPIServer.LoopbackClientConfig) - if err != nil { - return false, nil - } - healthResult := healthClient.Discovery().RESTClient().Get().AbsPath("/healthz").Do() - if healthResult.Error() != nil { - return false, nil - } - rawHealth, err := healthResult.Raw() - if err != nil { - return false, nil - } - if string(rawHealth) != "ok" { - return false, nil - } - - return true, nil - }) - if err != nil { - close(stopCh) - return nil, nil, err - } - - return stopCh, config.GenericConfig.LoopbackClientConfig, nil -} - -func StartDefaultServer() (chan struct{}, *rest.Config, error) { - config, err := DefaultServerConfig() - if err != nil { - return nil, nil, err - } - - return StartServer(config) -} - -func StartDefaultServerWithClients() (chan struct{}, clientset.Interface, dynamic.Interface, error) { - stopCh, config, err := StartDefaultServer() - if err != nil { - return nil, nil, nil, err - } - - apiExtensionsClient, err := clientset.NewForConfig(config) - if err != nil { - close(stopCh) - return nil, nil, nil, err - } - - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - close(stopCh) - return nil, nil, nil, err - } - - return stopCh, apiExtensionsClient, dynamicClient, nil -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/validation_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/validation_test.go deleted file mode 100644 index cb761330d..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/validation_test.go +++ /dev/null @@ -1,431 +0,0 @@ -/* -Copyright 2017 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 ( - "strings" - "testing" - "time" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/util/wait" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/test/integration/testserver" -) - -func TestForProperValidationErrors(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - tests := []struct { - name string - instanceFn func() *unstructured.Unstructured - expectedError string - }{ - { - name: "bad version", - instanceFn: func() *unstructured.Unstructured { - instance := testserver.NewVersionedNoxuInstance(ns, "foo", "v2") - return instance - }, - expectedError: "the API version in the data (mygroup.example.com/v2) does not match the expected API version (mygroup.example.com/v1beta1)", - }, - { - name: "bad kind", - instanceFn: func() *unstructured.Unstructured { - instance := testserver.NewNoxuInstance(ns, "foo") - instance.Object["kind"] = "SomethingElse" - return instance - }, - expectedError: `SomethingElse.mygroup.example.com "foo" is invalid: kind: Invalid value: "SomethingElse": must be WishIHadChosenNoxu`, - }, - } - - for _, tc := range tests { - _, err := noxuResourceClient.Create(tc.instanceFn()) - if err == nil { - t.Errorf("%v: expected %v", tc.name, tc.expectedError) - continue - } - // this only works when status errors contain the expect kind and version, so this effectively tests serializations too - if !strings.Contains(err.Error(), tc.expectedError) { - t.Errorf("%v: expected %v, got %v", tc.name, tc.expectedError, err) - continue - } - } -} - -func newNoxuValidationCRD(scope apiextensionsv1beta1.ResourceScope) *apiextensionsv1beta1.CustomResourceDefinition { - return &apiextensionsv1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{Name: "noxus.mygroup.example.com"}, - Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{ - Group: "mygroup.example.com", - Version: "v1beta1", - Names: apiextensionsv1beta1.CustomResourceDefinitionNames{ - Plural: "noxus", - Singular: "nonenglishnoxu", - Kind: "WishIHadChosenNoxu", - ShortNames: []string{"foo", "bar", "abc", "def"}, - ListKind: "NoxuItemList", - }, - Scope: apiextensionsv1beta1.NamespaceScoped, - Validation: &apiextensionsv1beta1.CustomResourceValidation{ - OpenAPIV3Schema: &apiextensionsv1beta1.JSONSchemaProps{ - Required: []string{"alpha", "beta"}, - AdditionalProperties: &apiextensionsv1beta1.JSONSchemaPropsOrBool{ - Allows: true, - }, - Properties: map[string]apiextensionsv1beta1.JSONSchemaProps{ - "alpha": { - Description: "Alpha is an alphanumeric string with underscores", - Type: "string", - Pattern: "^[a-zA-Z0-9_]*$", - }, - "beta": { - Description: "Minimum value of beta is 10", - Type: "number", - Minimum: float64Ptr(10), - }, - "gamma": { - Description: "Gamma is restricted to foo, bar and baz", - Type: "string", - Enum: []apiextensionsv1beta1.JSON{ - { - Raw: []byte(`"foo"`), - }, - { - Raw: []byte(`"bar"`), - }, - { - Raw: []byte(`"baz"`), - }, - }, - }, - "delta": { - Description: "Delta is a string with a maximum length of 5 or a number with a minimum value of 0", - AnyOf: []apiextensionsv1beta1.JSONSchemaProps{ - { - Type: "string", - MaxLength: int64Ptr(5), - }, - { - Type: "number", - Minimum: float64Ptr(0), - }, - }, - }, - }, - }, - }, - }, - } -} - -func newNoxuValidationInstance(namespace, name string) *unstructured.Unstructured { - return &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "mygroup.example.com/v1beta1", - "kind": "WishIHadChosenNoxu", - "metadata": map[string]interface{}{ - "namespace": namespace, - "name": name, - }, - "alpha": "foo_123", - "beta": 10, - "gamma": "bar", - "delta": "hello", - }, - } -} - -func TestCustomResourceValidation(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - _, err = instantiateCustomResource(t, newNoxuValidationInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } -} - -func TestCustomResourceUpdateValidation(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - _, err = instantiateCustomResource(t, newNoxuValidationInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err != nil { - t.Fatalf("unable to create noxu instance: %v", err) - } - - gottenNoxuInstance, err := noxuResourceClient.Get("foo", metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - - // invalidate the instance - gottenNoxuInstance.Object = map[string]interface{}{ - "apiVersion": "mygroup.example.com/v1beta1", - "kind": "WishIHadChosenNoxu", - "metadata": map[string]interface{}{ - "namespace": "not-the-default", - "name": "foo", - }, - "gamma": "bar", - "delta": "hello", - } - - _, err = noxuResourceClient.Update(gottenNoxuInstance) - if err == nil { - t.Fatalf("unexpected non-error: alpha and beta should be present while updating %v", gottenNoxuInstance) - } -} - -func TestCustomResourceValidationErrors(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - tests := []struct { - name string - instanceFn func() *unstructured.Unstructured - expectedError string - }{ - { - name: "bad alpha", - instanceFn: func() *unstructured.Unstructured { - instance := newNoxuValidationInstance(ns, "foo") - instance.Object["alpha"] = "foo_123!" - return instance - }, - expectedError: "alpha in body should match '^[a-zA-Z0-9_]*$'", - }, - { - name: "bad beta", - instanceFn: func() *unstructured.Unstructured { - instance := newNoxuValidationInstance(ns, "foo") - instance.Object["beta"] = 5 - return instance - }, - expectedError: "beta in body should be greater than or equal to 10", - }, - { - name: "bad gamma", - instanceFn: func() *unstructured.Unstructured { - instance := newNoxuValidationInstance(ns, "foo") - instance.Object["gamma"] = "qux" - return instance - }, - expectedError: "gamma in body should be one of [foo bar baz]", - }, - { - name: "bad delta", - instanceFn: func() *unstructured.Unstructured { - instance := newNoxuValidationInstance(ns, "foo") - instance.Object["delta"] = "foobarbaz" - return instance - }, - expectedError: "must validate at least one schema (anyOf)\ndelta in body should be at most 5 chars long", - }, - { - name: "absent alpha and beta", - instanceFn: func() *unstructured.Unstructured { - instance := newNoxuValidationInstance(ns, "foo") - instance.Object = map[string]interface{}{ - "apiVersion": "mygroup.example.com/v1beta1", - "kind": "WishIHadChosenNoxu", - "metadata": map[string]interface{}{ - "namespace": "not-the-default", - "name": "foo", - }, - "gamma": "bar", - "delta": "hello", - } - return instance - }, - expectedError: ".alpha in body is required\n.beta in body is required", - }, - } - - for _, tc := range tests { - _, err := noxuResourceClient.Create(tc.instanceFn()) - if err == nil { - t.Errorf("%v: expected %v", tc.name, tc.expectedError) - continue - } - // this only works when status errors contain the expect kind and version, so this effectively tests serializations too - if !strings.Contains(err.Error(), tc.expectedError) { - t.Errorf("%v: expected %v, got %v", tc.name, tc.expectedError, err) - continue - } - } -} - -func TestCRValidationOnCRDUpdate(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) - - // set stricter schema - noxuDefinition.Spec.Validation.OpenAPIV3Schema.Required = []string{"alpha", "beta", "epsilon"} - - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - ns := "not-the-default" - noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) - - // CR is rejected - _, err = instantiateCustomResource(t, newNoxuValidationInstance(ns, "foo"), noxuResourceClient, noxuDefinition) - if err == nil { - t.Fatalf("unexpected non-error: CR should be rejected") - } - - // update the CRD to a less stricter schema - _, err = updateCustomResourceDefinitionWithRetry(apiExtensionClient, "noxus.mygroup.example.com", func(crd *apiextensionsv1beta1.CustomResourceDefinition) { - crd.Spec.Validation.OpenAPIV3Schema.Required = []string{"alpha", "beta"} - }) - if err != nil { - t.Fatal(err) - } - - // CR is now accepted - err = wait.Poll(500*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) { - _, err := noxuResourceClient.Create(newNoxuValidationInstance(ns, "foo")) - if statusError, isStatus := err.(*apierrors.StatusError); isStatus { - if strings.Contains(statusError.Error(), "is invalid") { - return false, nil - } - } - if err != nil { - return false, err - } - return true, nil - }) - if err != nil { - t.Fatal(err) - } -} - -func TestForbiddenFieldsInSchema(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition.Spec.Validation.OpenAPIV3Schema.AdditionalProperties.Allows = false - - _, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err == nil { - t.Fatalf("unexpected non-error: additionalProperties cannot be set to false") - } - - noxuDefinition.Spec.Validation.OpenAPIV3Schema.Properties["zeta"] = apiextensionsv1beta1.JSONSchemaProps{ - Type: "array", - UniqueItems: true, - } - noxuDefinition.Spec.Validation.OpenAPIV3Schema.AdditionalProperties.Allows = true - - _, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err == nil { - t.Fatalf("unexpected non-error: uniqueItems cannot be set to true") - } - - noxuDefinition.Spec.Validation.OpenAPIV3Schema.Ref = strPtr("#/definition/zeta") - noxuDefinition.Spec.Validation.OpenAPIV3Schema.Properties["zeta"] = apiextensionsv1beta1.JSONSchemaProps{ - Type: "array", - UniqueItems: false, - } - - _, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err == nil { - t.Fatal("unexpected non-error: $ref cannot be non-empty string") - } - - noxuDefinition.Spec.Validation.OpenAPIV3Schema.Ref = nil - - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } -} - -func float64Ptr(f float64) *float64 { - return &f -} - -func int64Ptr(f int64) *int64 { - return &f -} - -func strPtr(str string) *string { - return &str -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/versioning_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/versioning_test.go deleted file mode 100644 index 55d0c17af..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/versioning_test.go +++ /dev/null @@ -1,138 +0,0 @@ -/* -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 ( - "reflect" - "testing" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/test/integration/testserver" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func TestVersionedNamspacedScopedCRD(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewMultipleVersionNoxuCRD(apiextensionsv1beta1.NamespaceScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "not-the-default" - testSimpleCRUD(t, ns, noxuDefinition, dynamicClient) -} - -func TestVersionedClusterScopedCRD(t *testing.T) { - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition := testserver.NewMultipleVersionNoxuCRD(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - ns := "" - testSimpleCRUD(t, ns, noxuDefinition, dynamicClient) -} - -func TestStoragedVersionInNamespacedCRDStatus(t *testing.T) { - noxuDefinition := testserver.NewMultipleVersionNoxuCRD(apiextensionsv1beta1.NamespaceScoped) - ns := "not-the-default" - testStoragedVersionInCRDStatus(t, ns, noxuDefinition) -} - -func TestStoragedVersionInClusterScopedCRDStatus(t *testing.T) { - noxuDefinition := testserver.NewMultipleVersionNoxuCRD(apiextensionsv1beta1.ClusterScoped) - ns := "" - testStoragedVersionInCRDStatus(t, ns, noxuDefinition) -} - -func testStoragedVersionInCRDStatus(t *testing.T, ns string, noxuDefinition *apiextensionsv1beta1.CustomResourceDefinition) { - versionsV1Beta1Storage := []apiextensionsv1beta1.CustomResourceDefinitionVersion{ - { - Name: "v1beta1", - Served: true, - Storage: true, - }, - { - Name: "v1beta2", - Served: true, - Storage: false, - }, - } - versionsV1Beta2Storage := []apiextensionsv1beta1.CustomResourceDefinitionVersion{ - { - Name: "v1beta1", - Served: true, - Storage: false, - }, - { - Name: "v1beta2", - Served: true, - Storage: true, - }, - } - stopCh, apiExtensionClient, dynamicClient, err := testserver.StartDefaultServerWithClients() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - noxuDefinition.Spec.Versions = versionsV1Beta1Storage - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - // The storage version list should be initilized to storage version - crd, err := apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(noxuDefinition.Name, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := []string{"v1beta1"}, crd.Status.StoredVersions; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - - // Changing CRD storage version should be reflected immediately - crd.Spec.Versions = versionsV1Beta2Storage - _, err = apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Update(crd) - if err != nil { - t.Fatal(err) - } - crd, err = apiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(noxuDefinition.Name, metav1.GetOptions{}) - if err != nil { - t.Fatal(err) - } - if e, a := []string{"v1beta1", "v1beta2"}, crd.Status.StoredVersions; !reflect.DeepEqual(e, a) { - t.Errorf("expected %v, got %v", e, a) - } - - err = testserver.DeleteCustomResourceDefinition(crd, apiExtensionClient) - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/yaml_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/yaml_test.go deleted file mode 100644 index 2dc279559..000000000 --- a/vendor/k8s.io/apiextensions-apiserver/test/integration/yaml_test.go +++ /dev/null @@ -1,541 +0,0 @@ -/* -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 ( - "encoding/json" - "fmt" - "net/http" - "testing" - - "github.com/ghodss/yaml" - - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/dynamic" - - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apiextensions-apiserver/test/integration/testserver" -) - -func TestYAML(t *testing.T) { - stopCh, config, err := testserver.StartDefaultServer() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - kind := noxuDefinition.Spec.Names.Kind - listKind := noxuDefinition.Spec.Names.ListKind - apiVersion := noxuDefinition.Spec.Group + "/" + noxuDefinition.Spec.Version - - rest := apiExtensionClient.Discovery().RESTClient() - - // Discovery - { - result, err := rest.Get(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version). - DoRaw() - if err != nil { - t.Fatal(err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetAPIVersion() != "v1" || obj.GetKind() != "APIResourceList" { - t.Fatalf("unexpected discovery kind: %s", string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "groupVersion"); v != apiVersion || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } - - // Error - { - result, err := rest.Get(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "missingname"). - DoRaw() - if !errors.IsNotFound(err) { - t.Fatalf("expected not found, got %v", err) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetAPIVersion() != "v1" || obj.GetKind() != "Status" { - t.Fatalf("unexpected discovery kind: %s", string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "reason"); v != "NotFound" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } - - uid := types.UID("") - resourceVersion := "" - - // Create - { - yamlBody := []byte(fmt.Sprintf(` -apiVersion: %s -kind: %s -metadata: - name: mytest -values: - numVal: 1 - boolVal: true - stringVal: "1"`, apiVersion, kind)) - - result, err := rest.Post(). - SetHeader("Accept", "application/yaml"). - SetHeader("Content-Type", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural). - Body(yamlBody). - DoRaw() - if err != nil { - t.Fatal(err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != kind { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "values", "numVal"); v != 1 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedBool(obj.Object, "values", "boolVal"); v != true || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "values", "stringVal"); v != "1" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - uid = obj.GetUID() - resourceVersion = obj.GetResourceVersion() - } - - // Get - { - result, err := rest.Get(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest"). - DoRaw() - if err != nil { - t.Fatal(err) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err, string(result)) - } - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != kind { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "values", "numVal"); v != 1 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedBool(obj.Object, "values", "boolVal"); v != true || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "values", "stringVal"); v != "1" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } - - // List - { - result, err := rest.Get(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural). - DoRaw() - if err != nil { - t.Fatal(err, string(result)) - } - listObj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if listObj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, listObj.GetAPIVersion()) - } - if listObj.GetKind() != listKind { - t.Fatalf("expected %s, got %s", kind, listObj.GetKind()) - } - items, ok, err := unstructured.NestedSlice(listObj.Object, "items") - if !ok || err != nil || len(items) != 1 { - t.Fatalf("expected one item, got %v %v %v", items, ok, err) - } - obj := unstructured.Unstructured{Object: items[0].(map[string]interface{})} - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != kind { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "values", "numVal"); v != 1 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedBool(obj.Object, "values", "boolVal"); v != true || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "values", "stringVal"); v != "1" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } - - // Watch rejects yaml (no streaming support) - { - result, err := rest.Get(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural). - Param("watch", "true"). - DoRaw() - if !errors.IsNotAcceptable(err) { - t.Fatalf("expected not acceptable error, got %v (%s)", err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetAPIVersion() != "v1" || obj.GetKind() != "Status" { - t.Fatalf("unexpected result: %s", string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "reason"); v != "NotAcceptable" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "code"); v != http.StatusNotAcceptable || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } - - // Update - { - yamlBody := []byte(fmt.Sprintf(` -apiVersion: %s -kind: %s -metadata: - name: mytest - uid: %s - resourceVersion: "%s" -values: - numVal: 2 - boolVal: false - stringVal: "2"`, apiVersion, kind, uid, resourceVersion)) - result, err := rest.Put(). - SetHeader("Accept", "application/yaml"). - SetHeader("Content-Type", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest"). - Body(yamlBody). - DoRaw() - if err != nil { - t.Fatal(err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != kind { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "values", "numVal"); v != 2 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedBool(obj.Object, "values", "boolVal"); v != false || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "values", "stringVal"); v != "2" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if obj.GetUID() != uid { - t.Fatalf("uid changed: %v vs %v", uid, obj.GetUID()) - } - } - - // Patch rejects yaml requests (only JSON mime types are allowed) - { - yamlBody := []byte(fmt.Sprintf(` -values: - numVal: 3`)) - result, err := rest.Patch(types.MergePatchType). - SetHeader("Accept", "application/yaml"). - SetHeader("Content-Type", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest"). - Body(yamlBody). - DoRaw() - if !errors.IsUnsupportedMediaType(err) { - t.Fatalf("Expected bad request, got %v\n%s", err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetAPIVersion() != "v1" || obj.GetKind() != "Status" { - t.Fatalf("expected %s %s, got %s %s", "v1", "Status", obj.GetAPIVersion(), obj.GetKind()) - } - if v, ok, err := unstructured.NestedString(obj.Object, "reason"); v != "UnsupportedMediaType" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } - - // Delete - { - result, err := rest.Delete(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest"). - DoRaw() - if err != nil { - t.Fatal(err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetAPIVersion() != "v1" || obj.GetKind() != "Status" { - t.Fatalf("unexpected response: %s", string(result)) - } - if v, ok, err := unstructured.NestedString(obj.Object, "status"); v != "Success" || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } -} - -func TestYAMLSubresource(t *testing.T) { - stopCh, config, err := testserver.StartDefaultServer() - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - apiExtensionClient, err := clientset.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - dynamicClient, err := dynamic.NewForConfig(config) - if err != nil { - t.Fatal(err) - } - - noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.ClusterScoped) - noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) - if err != nil { - t.Fatal(err) - } - - kind := noxuDefinition.Spec.Names.Kind - apiVersion := noxuDefinition.Spec.Group + "/" + noxuDefinition.Spec.Version - - rest := apiExtensionClient.Discovery().RESTClient() - - uid := types.UID("") - resourceVersion := "" - - // Create - { - yamlBody := []byte(fmt.Sprintf(` -apiVersion: %s -kind: %s -metadata: - name: mytest -spec: - replicas: 3`, apiVersion, kind)) - - result, err := rest.Post(). - SetHeader("Accept", "application/yaml"). - SetHeader("Content-Type", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural). - Body(yamlBody). - DoRaw() - if err != nil { - t.Fatal(err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != kind { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "spec", "replicas"); v != 3 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - uid = obj.GetUID() - resourceVersion = obj.GetResourceVersion() - } - - // Get at /status - { - result, err := rest.Get(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "status"). - DoRaw() - if err != nil { - t.Fatal(err) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err, string(result)) - } - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != kind { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "spec", "replicas"); v != 3 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } - - // Update at /status - { - yamlBody := []byte(fmt.Sprintf(` -apiVersion: %s -kind: %s -metadata: - name: mytest - uid: %s - resourceVersion: "%s" -spec: - replicas: 5 -status: - replicas: 3`, apiVersion, kind, uid, resourceVersion)) - result, err := rest.Put(). - SetHeader("Accept", "application/yaml"). - SetHeader("Content-Type", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "status"). - Body(yamlBody). - DoRaw() - if err != nil { - t.Fatal(err, string(result)) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err) - } - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != apiVersion { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != kind { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "spec", "replicas"); v != 3 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "status", "replicas"); v != 3 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if obj.GetUID() != uid { - t.Fatalf("uid changed: %v vs %v", uid, obj.GetUID()) - } - } - - // Get at /scale - { - result, err := rest.Get(). - SetHeader("Accept", "application/yaml"). - AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "scale"). - DoRaw() - if err != nil { - t.Fatal(err) - } - obj, err := decodeYAML(result) - if err != nil { - t.Fatal(err, string(result)) - } - if obj.GetName() != "mytest" { - t.Fatalf("expected mytest, got %s", obj.GetName()) - } - if obj.GetAPIVersion() != "autoscaling/v1" { - t.Fatalf("expected %s, got %s", apiVersion, obj.GetAPIVersion()) - } - if obj.GetKind() != "Scale" { - t.Fatalf("expected %s, got %s", kind, obj.GetKind()) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "spec", "replicas"); v != 3 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - if v, ok, err := unstructured.NestedFloat64(obj.Object, "status", "replicas"); v != 3 || !ok || err != nil { - t.Fatal(v, ok, err, string(result)) - } - } -} - -func decodeYAML(data []byte) (*unstructured.Unstructured, error) { - retval := &unstructured.Unstructured{Object: map[string]interface{}{}} - // ensure this isn't JSON - if json.Unmarshal(data, &retval.Object) == nil { - return nil, fmt.Errorf("data is JSON, not YAML: %s", string(data)) - } - // ensure it is YAML - retval.Object = map[string]interface{}{} - if err := yaml.Unmarshal(data, &retval.Object); err != nil { - return nil, fmt.Errorf("error decoding YAML: %v\noriginal YAML: %s", err, string(data)) - } - return retval, nil -} diff --git a/vendor/k8s.io/kube-openapi/.gitignore b/vendor/k8s.io/kube-openapi/.gitignore new file mode 100644 index 000000000..e36047774 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/.gitignore @@ -0,0 +1,20 @@ +# Binaries for programs and plugins +*.exe +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 +.glide/ + +# Intellij IDEA files +.idea/ +*.iml +.vscode + diff --git a/vendor/k8s.io/kube-openapi/.travis.yml b/vendor/k8s.io/kube-openapi/.travis.yml new file mode 100644 index 000000000..996a4df0e --- /dev/null +++ b/vendor/k8s.io/kube-openapi/.travis.yml @@ -0,0 +1,4 @@ +language: go +go_import_path: k8s.io/kube-openapi +script: go test ./pkg/... + diff --git a/vendor/k8s.io/kube-openapi/Godeps/Godeps.json b/vendor/k8s.io/kube-openapi/Godeps/Godeps.json new file mode 100644 index 000000000..38032f652 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/Godeps/Godeps.json @@ -0,0 +1,401 @@ +{ + "ImportPath": "k8s.io/kube-openapi", + "GoVersion": "go1.8", + "GodepVersion": "v79", + "Packages": [ + "./..." + ], + "Deps": [ + { + "ImportPath": "bitbucket.org/ww/goautoneg", + "Comment": "null-5", + "Rev": "75cd24fc2f2c2a2088577d12123ddee5f54e0675" + }, + { + "ImportPath": "github.com/NYTimes/gziphandler", + "Rev": "56545f4a5d46df9a6648819d1664c3a03a13ffdb" + }, + { + "ImportPath": "github.com/PuerkitoBio/purell", + "Comment": "v1.0.0", + "Rev": "8a290539e2e8629dbc4e6bad948158f790ec31f4" + }, + { + "ImportPath": "github.com/PuerkitoBio/urlesc", + "Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e" + }, + { + "ImportPath": "github.com/davecgh/go-spew/spew", + "Rev": "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d" + }, + { + "ImportPath": "github.com/emicklei/go-restful", + "Comment": "2.2.0-4-gff4f55a", + "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" + }, + { + "ImportPath": "github.com/emicklei/go-restful/log", + "Comment": "2.2.0-4-gff4f55a", + "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" + }, + { + "ImportPath": "github.com/ghodss/yaml", + "Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee" + }, + { + "ImportPath": "github.com/go-openapi/jsonpointer", + "Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98" + }, + { + "ImportPath": "github.com/go-openapi/jsonreference", + "Rev": "13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272" + }, + { + "ImportPath": "github.com/go-openapi/spec", + "Rev": "6aced65f8501fe1217321abf0749d354824ba2ff" + }, + { + "ImportPath": "github.com/go-openapi/swag", + "Rev": "1d0bd113de87027671077d3c71eb3ac5d7dbba72" + }, + { + "ImportPath": "github.com/golang/glog", + "Rev": "44145f04b68cf362d9c4df2182967c2275eaefed" + }, + { + "ImportPath": "github.com/golang/protobuf/proto", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes/any", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes/duration", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/golang/protobuf/ptypes/timestamp", + "Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" + }, + { + "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", + "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + }, + { + "ImportPath": "github.com/googleapis/gnostic/compiler", + "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + }, + { + "ImportPath": "github.com/googleapis/gnostic/extensions", + "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + }, + { + "ImportPath": "github.com/mailru/easyjson/buffer", + "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" + }, + { + "ImportPath": "github.com/mailru/easyjson/jlexer", + "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" + }, + { + "ImportPath": "github.com/mailru/easyjson/jwriter", + "Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0" + }, + { + "ImportPath": "github.com/onsi/ginkgo", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/config", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/codelocation", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/containernode", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/failer", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/leafnodes", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/remote", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/spec", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/spec_iterator", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/specrunner", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/suite", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/testingtproxy", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/internal/writer", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/reporters", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/reporters/stenographer", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/ginkgo/types", + "Comment": "v1.4.0-4-g11459a8", + "Rev": "11459a886d9cd66b319dac7ef1e917ee221372c9" + }, + { + "ImportPath": "github.com/onsi/gomega", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/format", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/internal/assertion", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/internal/asyncassertion", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/internal/oraclematcher", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/internal/testingtsupport", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/matchers", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/matchers/support/goraph/bipartitegraph", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/matchers/support/goraph/edge", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/matchers/support/goraph/node", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/matchers/support/goraph/util", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/onsi/gomega/types", + "Comment": "v1.2.0-2-gdcabb60", + "Rev": "dcabb60a477c2b6f456df65037cb6708210fbb02" + }, + { + "ImportPath": "github.com/pmezard/go-difflib/difflib", + "Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d" + }, + { + "ImportPath": "github.com/spf13/pflag", + "Rev": "9ff6c6923cfffbcd502984b8e0c80539a94968b7" + }, + { + "ImportPath": "github.com/stretchr/testify/assert", + "Comment": "v1.0-88-ge3a8ff8", + "Rev": "e3a8ff8ce36581f87a15341206f205b1da467059" + }, + { + "ImportPath": "golang.org/x/net/html", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/html/atom", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/html/charset", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/net/idna", + "Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d" + }, + { + "ImportPath": "golang.org/x/sys/unix", + "Rev": "bb24a47a89eac6c1227fbcb2ae37a8b9ed323366" + }, + { + "ImportPath": "golang.org/x/text/cases", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/charmap", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/htmlindex", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/internal", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/internal/identifier", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/japanese", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/korean", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/simplifiedchinese", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/traditionalchinese", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/encoding/unicode", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/internal/tag", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/internal/utf8internal", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/language", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/runes", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/secure/bidirule", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/secure/precis", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/transform", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/unicode/bidi", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/unicode/norm", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "golang.org/x/text/width", + "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" + }, + { + "ImportPath": "gopkg.in/yaml.v2", + "Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77" + }, + { + "ImportPath": "k8s.io/gengo/args", + "Rev": "75356185a9af8f0464efa792e2e9508d5b4be83c" + }, + { + "ImportPath": "k8s.io/gengo/generator", + "Rev": "75356185a9af8f0464efa792e2e9508d5b4be83c" + }, + { + "ImportPath": "k8s.io/gengo/namer", + "Rev": "75356185a9af8f0464efa792e2e9508d5b4be83c" + }, + { + "ImportPath": "k8s.io/gengo/parser", + "Rev": "75356185a9af8f0464efa792e2e9508d5b4be83c" + }, + { + "ImportPath": "k8s.io/gengo/types", + "Rev": "75356185a9af8f0464efa792e2e9508d5b4be83c" + } + ] +} diff --git a/vendor/k8s.io/apiextensions-apiserver/Godeps/Readme b/vendor/k8s.io/kube-openapi/Godeps/Readme similarity index 100% rename from vendor/k8s.io/apiextensions-apiserver/Godeps/Readme rename to vendor/k8s.io/kube-openapi/Godeps/Readme diff --git a/vendor/k8s.io/apiextensions-apiserver/LICENSE b/vendor/k8s.io/kube-openapi/LICENSE similarity index 100% rename from vendor/k8s.io/apiextensions-apiserver/LICENSE rename to vendor/k8s.io/kube-openapi/LICENSE diff --git a/vendor/k8s.io/kube-openapi/OWNERS b/vendor/k8s.io/kube-openapi/OWNERS new file mode 100755 index 000000000..e8c62bfa2 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/OWNERS @@ -0,0 +1,11 @@ +reviewers: +- yujuhong +- gmarek +- mbohlool +- philips +- seans3 +- apelisse +approvers: +- mbohlool +- lavalamp +- seans3 diff --git a/vendor/k8s.io/kube-openapi/README.md b/vendor/k8s.io/kube-openapi/README.md new file mode 100644 index 000000000..babadde1f --- /dev/null +++ b/vendor/k8s.io/kube-openapi/README.md @@ -0,0 +1,14 @@ +# Kube OpenAPI + +This repo is the home for Kubernetes OpenAPI discovery spec generation. The goal +is to support a subset of OpenAPI features to satisfy kubernetes use-cases but +implement that subset with little to no assumption about the structure of the +code or routes. Thus, there should be no kubernetes specific code in this repo. + + +There are two main parts: + - A model generator that goes through .go files, find and generate model +definitions. + - The spec generator that is responsible for dynamically generate +the final OpenAPI spec using web service routes or combining other +OpenAPI/Json specs. diff --git a/vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go b/vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go new file mode 100644 index 000000000..9dc20e06b --- /dev/null +++ b/vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go @@ -0,0 +1,67 @@ +/* +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 ( + "log" + "os" + "path/filepath" + + "k8s.io/gengo/args" + "k8s.io/kube-openapi/pkg/generators" +) + +const ( + outputBase = "pkg" + outputPackage = "generated" + outputBaseFilename = "openapi_generated" +) + +func main() { + + // Assumes all parameters are input directories. + // TODO: Input directories as flags; add initial flag parsing. + testdataDirs := []string{} + if len(os.Args) == 1 { + log.Fatalln("Missing parameter: no input directories") + } else { + for _, dir := range os.Args[1:] { + testdataDirs = append(testdataDirs, dir) + } + } + log.Printf("Input directories: %s", testdataDirs) + + // Set up the gengo arguments for code generation. + // TODO: Generated output filename as a parameter. + generatedFilepath := filepath.Join(outputBase, outputPackage, outputBaseFilename+".go") + log.Printf("Generated File: %s", generatedFilepath) + arguments := args.Default() + arguments.InputDirs = testdataDirs + arguments.OutputBase = outputBase + arguments.OutputPackagePath = outputPackage + arguments.OutputFileBaseName = outputBaseFilename + + // Generates the code for the OpenAPIDefinitions. + if err := arguments.Execute( + generators.NameSystems(), + generators.DefaultNameSystem(), + generators.Packages, + ); err != nil { + log.Fatalf("OpenAPI code generation error: %v", err) + } + log.Println("Code for OpenAPI definitions generated") +} diff --git a/vendor/k8s.io/apiextensions-apiserver/code-of-conduct.md b/vendor/k8s.io/kube-openapi/code-of-conduct.md similarity index 100% rename from vendor/k8s.io/apiextensions-apiserver/code-of-conduct.md rename to vendor/k8s.io/kube-openapi/code-of-conduct.md diff --git a/vendor/k8s.io/kube-openapi/pkg/aggregator/aggregator.go b/vendor/k8s.io/kube-openapi/pkg/aggregator/aggregator.go new file mode 100644 index 000000000..f05b50172 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/aggregator/aggregator.go @@ -0,0 +1,389 @@ +/* +Copyright 2017 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 aggregator + +import ( + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/go-openapi/spec" + + "k8s.io/kube-openapi/pkg/util" +) + +const ( + definitionPrefix = "#/definitions/" +) + +// Run a walkRefCallback method on all references of an OpenAPI spec +type referenceWalker struct { + // walkRefCallback will be called on each reference and the return value + // will replace that reference. This will allow the callers to change + // all/some references of an spec (e.g. useful in renaming definitions). + walkRefCallback func(ref spec.Ref) spec.Ref + + // The spec to walk through. + root *spec.Swagger + + // Keep track of visited references + alreadyVisited map[string]bool +} + +func walkOnAllReferences(walkRef func(ref spec.Ref) spec.Ref, sp *spec.Swagger) { + walker := &referenceWalker{walkRefCallback: walkRef, root: sp, alreadyVisited: map[string]bool{}} + walker.Start() +} + +func (s *referenceWalker) walkRef(ref spec.Ref) spec.Ref { + refStr := ref.String() + // References that start with #/definitions/ has a definition + // inside the same spec file. If that is the case, walk through + // those definitions too. + // We do not support external references yet. + if !s.alreadyVisited[refStr] && strings.HasPrefix(refStr, definitionPrefix) { + s.alreadyVisited[refStr] = true + k := refStr[len(definitionPrefix):] + def := s.root.Definitions[k] + s.walkSchema(&def) + // Make sure we don't assign to nil map + if s.root.Definitions == nil { + s.root.Definitions = spec.Definitions{} + } + s.root.Definitions[k] = def + } + return s.walkRefCallback(ref) +} + +func (s *referenceWalker) walkSchema(schema *spec.Schema) { + if schema == nil { + return + } + schema.Ref = s.walkRef(schema.Ref) + for k, v := range schema.Definitions { + s.walkSchema(&v) + schema.Definitions[k] = v + } + for k, v := range schema.Properties { + s.walkSchema(&v) + schema.Properties[k] = v + } + for k, v := range schema.PatternProperties { + s.walkSchema(&v) + schema.PatternProperties[k] = v + } + for i, _ := range schema.AllOf { + s.walkSchema(&schema.AllOf[i]) + } + for i, _ := range schema.AnyOf { + s.walkSchema(&schema.AnyOf[i]) + } + for i, _ := range schema.OneOf { + s.walkSchema(&schema.OneOf[i]) + } + if schema.Not != nil { + s.walkSchema(schema.Not) + } + if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil { + s.walkSchema(schema.AdditionalProperties.Schema) + } + if schema.AdditionalItems != nil && schema.AdditionalItems.Schema != nil { + s.walkSchema(schema.AdditionalItems.Schema) + } + if schema.Items != nil { + if schema.Items.Schema != nil { + s.walkSchema(schema.Items.Schema) + } + for i, _ := range schema.Items.Schemas { + s.walkSchema(&schema.Items.Schemas[i]) + } + } +} + +func (s *referenceWalker) walkParams(params []spec.Parameter) { + if params == nil { + return + } + for _, param := range params { + param.Ref = s.walkRef(param.Ref) + s.walkSchema(param.Schema) + if param.Items != nil { + param.Items.Ref = s.walkRef(param.Items.Ref) + } + } +} + +func (s *referenceWalker) walkResponse(resp *spec.Response) { + if resp == nil { + return + } + resp.Ref = s.walkRef(resp.Ref) + s.walkSchema(resp.Schema) +} + +func (s *referenceWalker) walkOperation(op *spec.Operation) { + if op == nil { + return + } + s.walkParams(op.Parameters) + if op.Responses == nil { + return + } + s.walkResponse(op.Responses.Default) + for _, r := range op.Responses.StatusCodeResponses { + s.walkResponse(&r) + } +} + +func (s *referenceWalker) Start() { + if s.root.Paths == nil { + return + } + for _, pathItem := range s.root.Paths.Paths { + s.walkParams(pathItem.Parameters) + s.walkOperation(pathItem.Delete) + s.walkOperation(pathItem.Get) + s.walkOperation(pathItem.Head) + s.walkOperation(pathItem.Options) + s.walkOperation(pathItem.Patch) + s.walkOperation(pathItem.Post) + s.walkOperation(pathItem.Put) + } +} + +// usedDefinitionForSpec returns a map with all used definitions in the provided spec as keys and true as values. +func usedDefinitionForSpec(sp *spec.Swagger) map[string]bool { + usedDefinitions := map[string]bool{} + walkOnAllReferences(func(ref spec.Ref) spec.Ref { + if refStr := ref.String(); refStr != "" && strings.HasPrefix(refStr, definitionPrefix) { + usedDefinitions[refStr[len(definitionPrefix):]] = true + } + return ref + }, sp) + return usedDefinitions +} + +// FilterSpecByPaths removes unnecessary paths and definitions used by those paths. +// i.e. if a Path removed by this function, all definitions used by it and not used +// anywhere else will also be removed. +func FilterSpecByPaths(sp *spec.Swagger, keepPathPrefixes []string) { + // Walk all references to find all used definitions. This function + // want to only deal with unused definitions resulted from filtering paths. + // Thus a definition will be removed only if it has been used before but + // it is unused because of a path prune. + initialUsedDefinitions := usedDefinitionForSpec(sp) + + // First remove unwanted paths + prefixes := util.NewTrie(keepPathPrefixes) + orgPaths := sp.Paths + if orgPaths == nil { + return + } + sp.Paths = &spec.Paths{ + VendorExtensible: orgPaths.VendorExtensible, + Paths: map[string]spec.PathItem{}, + } + for path, pathItem := range orgPaths.Paths { + if !prefixes.HasPrefix(path) { + continue + } + sp.Paths.Paths[path] = pathItem + } + + // Walk all references to find all definition references. + usedDefinitions := usedDefinitionForSpec(sp) + + // Remove unused definitions + orgDefinitions := sp.Definitions + sp.Definitions = spec.Definitions{} + for k, v := range orgDefinitions { + if usedDefinitions[k] || !initialUsedDefinitions[k] { + sp.Definitions[k] = v + } + } +} + +func renameDefinition(s *spec.Swagger, old, new string) { + oldRef := definitionPrefix + old + newRef := definitionPrefix + new + walkOnAllReferences(func(ref spec.Ref) spec.Ref { + if ref.String() == oldRef { + return spec.MustCreateRef(newRef) + } + return ref + }, s) + // Make sure we don't assign to nil map + if s.Definitions == nil { + s.Definitions = spec.Definitions{} + } + s.Definitions[new] = s.Definitions[old] + delete(s.Definitions, old) +} + +// MergeSpecsIgnorePathConflict is the same as MergeSpecs except it will ignore any path +// conflicts by keeping the paths of destination. It will rename definition conflicts. +func MergeSpecsIgnorePathConflict(dest, source *spec.Swagger) error { + return mergeSpecs(dest, source, true, true) +} + +// MergeSpecsFailOnDefinitionConflict is differ from MergeSpecs as it fails if there is +// a definition conflict. +func MergeSpecsFailOnDefinitionConflict(dest, source *spec.Swagger) error { + return mergeSpecs(dest, source, false, false) +} + +// MergeSpecs copies paths and definitions from source to dest, rename definitions if needed. +// dest will be mutated, and source will not be changed. It will fail on path conflicts. +func MergeSpecs(dest, source *spec.Swagger) error { + return mergeSpecs(dest, source, true, false) +} + +func mergeSpecs(dest, source *spec.Swagger, renameModelConflicts, ignorePathConflicts bool) (err error) { + specCloned := false + // Paths may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering). + if source.Paths == nil { + source.Paths = &spec.Paths{} + } + if dest.Paths == nil { + dest.Paths = &spec.Paths{} + } + if ignorePathConflicts { + keepPaths := []string{} + hasConflictingPath := false + for k := range source.Paths.Paths { + if _, found := dest.Paths.Paths[k]; !found { + keepPaths = append(keepPaths, k) + } else { + hasConflictingPath = true + } + } + if len(keepPaths) == 0 { + // There is nothing to merge. All paths are conflicting. + return nil + } + if hasConflictingPath { + source, err = CloneSpec(source) + if err != nil { + return err + } + specCloned = true + FilterSpecByPaths(source, keepPaths) + } + } + // Check for model conflicts + conflicts := false + for k, v := range source.Definitions { + v2, found := dest.Definitions[k] + if found && !reflect.DeepEqual(v, v2) { + if !renameModelConflicts { + return fmt.Errorf("model name conflict in merging OpenAPI spec: %s", k) + } + conflicts = true + break + } + } + + if conflicts { + if !specCloned { + source, err = CloneSpec(source) + if err != nil { + return err + } + } + specCloned = true + usedNames := map[string]bool{} + for k := range dest.Definitions { + usedNames[k] = true + } + type Rename struct { + from, to string + } + renames := []Rename{} + + OUTERLOOP: + for k, v := range source.Definitions { + if usedNames[k] { + v2, found := dest.Definitions[k] + // Reuse model if they are exactly the same. + if found && reflect.DeepEqual(v, v2) { + continue + } + + // Reuse previously renamed model if one exists + var newName string + i := 1 + for found { + i++ + newName = fmt.Sprintf("%s_v%d", k, i) + v2, found = dest.Definitions[newName] + if found && reflect.DeepEqual(v, v2) { + renames = append(renames, Rename{from: k, to: newName}) + continue OUTERLOOP + } + } + + _, foundInSource := source.Definitions[newName] + for usedNames[newName] || foundInSource { + i++ + newName = fmt.Sprintf("%s_v%d", k, i) + _, foundInSource = source.Definitions[newName] + } + renames = append(renames, Rename{from: k, to: newName}) + usedNames[newName] = true + } + } + for _, r := range renames { + renameDefinition(source, r.from, r.to) + } + } + for k, v := range source.Definitions { + if _, found := dest.Definitions[k]; !found { + if dest.Definitions == nil { + dest.Definitions = spec.Definitions{} + } + dest.Definitions[k] = v + } + } + // Check for path conflicts + for k, v := range source.Paths.Paths { + if _, found := dest.Paths.Paths[k]; found { + return fmt.Errorf("unable to merge: duplicated path %s", k) + } + // PathItem may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering). + if dest.Paths.Paths == nil { + dest.Paths.Paths = map[string]spec.PathItem{} + } + dest.Paths.Paths[k] = v + } + return nil +} + +// CloneSpec clones OpenAPI spec +func CloneSpec(source *spec.Swagger) (*spec.Swagger, error) { + // TODO(mehdy): Find a faster way to clone an spec + bytes, err := json.Marshal(source) + if err != nil { + return nil, err + } + var ret spec.Swagger + err = json.Unmarshal(bytes, &ret) + if err != nil { + return nil, err + } + return &ret, nil +} diff --git a/vendor/k8s.io/kube-openapi/pkg/aggregator/aggregator_test.go b/vendor/k8s.io/kube-openapi/pkg/aggregator/aggregator_test.go new file mode 100644 index 000000000..12c49e4aa --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/aggregator/aggregator_test.go @@ -0,0 +1,1858 @@ +/* +Copyright 2017 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 aggregator + +import ( + "encoding/json" + "fmt" + "testing" + + "github.com/ghodss/yaml" + "github.com/go-openapi/spec" + "github.com/stretchr/testify/assert" +) + +type DebugSpec struct { + *spec.Swagger +} + +func (d DebugSpec) String() string { + bytes, err := json.MarshalIndent(d.Swagger, "", " ") + if err != nil { + return fmt.Sprintf("DebugSpec.String failed: %s", err) + } + return string(bytes) +} +func TestFilterSpecs(t *testing.T) { + var spec1, spec1_filtered *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" +`), &spec1_filtered) + + assert := assert.New(t) + FilterSpecByPaths(spec1, []string{"/test"}) + assert.Equal(DebugSpec{spec1_filtered}, DebugSpec{spec1}) +} + +func TestFilterSpecsWithUnusedDefinitions(t *testing.T) { + var spec1, spec1Filtered *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" + Unused: + type: "object" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" + Unused: + type: "object" +`), &spec1Filtered) + + assert := assert.New(t) + FilterSpecByPaths(spec1, []string{"/test"}) + assert.Equal(DebugSpec{spec1Filtered}, DebugSpec{spec1}) +} + +func TestMergeSpecsSimple(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +func TestMergeSpecsEmptyDefinitions(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + responses: + 405: + description: "Invalid input" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + responses: + 405: + description: "Invalid input" + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +func TestMergeSpecsEmptyPaths(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test2" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" + Test2: + type: "object" + properties: + other: + $ref: "#/definitions/Other" + Other: + type: "string" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +func TestMergeSpecsReuseModel(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +func TestMergeSpecsRenameModel(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + InvalidInput: + type: "string" + format: "string" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test" +definitions: + Test: + description: "This Test has a description" + type: "object" + properties: + id: + type: "integer" + format: "int64" + InvalidInput: + type: "string" + format: "string" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + tags: + - "test" + summary: "Test API" + operationId: "addTest" + parameters: + - in: "body" + name: "body" + description: "test object" + required: true + schema: + $ref: "#/definitions/Test" + responses: + 405: + description: "Invalid input" + $ref: "#/definitions/InvalidInput" + /othertest: + post: + tags: + - "test2" + summary: "Test2 API" + operationId: "addTest2" + consumes: + - "application/json" + produces: + - "application/xml" + parameters: + - in: "body" + name: "body" + description: "test2 object" + required: true + schema: + $ref: "#/definitions/Test_v2" +definitions: + Test: + type: "object" + properties: + id: + type: "integer" + format: "int64" + status: + type: "string" + description: "Status" + Test_v2: + description: "This Test has a description" + type: "object" + properties: + id: + type: "integer" + format: "int64" + InvalidInput: + type: "string" + format: "string" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +func TestMergeSpecsRenameModelWithExistingV2InDestination(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /testv2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v2" +definitions: + Test: + type: "object" + Test_v2: + description: "This is an existing Test_v2 in destination schema" + type: "object" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + description: "This Test has a description" + type: "object" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /testv2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v2" + /othertest: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v3" +definitions: + Test: + type: "object" + Test_v2: + description: "This is an existing Test_v2 in destination schema" + type: "object" + Test_v3: + description: "This Test has a description" + type: "object" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +func TestMergeSpecsRenameModelWithExistingV2InSource(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + type: "object" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /testv2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v2" +definitions: + Test: + description: "This Test has a description" + type: "object" + Test_v2: + description: "This is an existing Test_v2 in source schema" + type: "object" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /testv2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v2" + /othertest: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v3" +definitions: + Test: + type: "object" + Test_v2: + description: "This is an existing Test_v2 in source schema" + type: "object" + Test_v3: + description: "This Test has a description" + type: "object" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +// This tests if there are three specs, where the first two use the same object definition, +// while the third one uses its own. +// We expect the merged schema to contain two versions of the object, not three +func TestTwoMergeSpecsFirstTwoSchemasHaveSameDefinition(t *testing.T) { + var spec1, spec2, spec3, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + description: "spec1 and spec2 use the same object definition, while spec3 doesn't" + type: "object" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + description: "spec1 and spec2 use the same object definition, while spec3 doesn't" + type: "object" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test3: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + description: "spec3 has its own definition (the description doesn't match)" + type: "object" +`), &spec3) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /test2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /test3: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v2" +definitions: + Test: + description: "spec1 and spec2 use the same object definition, while spec3 doesn't" + type: "object" + Test_v2: + description: "spec3 has its own definition (the description doesn't match)" + type: "object" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + if !assert.NoError(MergeSpecs(spec1, spec3)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +// This tests if there are three specs, where the last two use the same object definition, +// while the first one uses its own. +// We expect the merged schema to contain two versions of the object, not three +func TestTwoMergeSpecsLastTwoSchemasHaveSameDefinition(t *testing.T) { + var spec1, spec2, spec3, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + type: "object" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + description: "spec2 and spec3 use the same object definition, while spec1 doesn't" + type: "object" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /othertest2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + description: "spec2 and spec3 use the same object definition, while spec1 doesn't" + type: "object" +`), &spec3) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /othertest: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v2" + /othertest2: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test_v2" +definitions: + Test: + type: "object" + Test_v2: + description: "spec2 and spec3 use the same object definition, while spec1 doesn't" + type: "object" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + if !assert.NoError(MergeSpecs(spec1, spec3)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} + +func TestSafeMergeSpecsSimple(t *testing.T) { + var fooSpec, barSpec, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &fooSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /bar: + post: + summary: "Bar API" + operationId: "barTest" + parameters: + - in: "body" + name: "body" + description: "bar object" + required: true + schema: + $ref: "#/definitions/Bar" + responses: + 200: + description: "OK" +definitions: + Bar: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &barSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" + /bar: + post: + summary: "Bar API" + operationId: "barTest" + parameters: + - in: "body" + name: "body" + description: "bar object" + required: true + schema: + $ref: "#/definitions/Bar" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" + Bar: + type: "object" + properties: + id: + type: "integer" + format: "int64" + `), &expected) + + assert := assert.New(t) + actual, err := CloneSpec(fooSpec) + if !assert.NoError(err) { + return + } + if !assert.NoError(MergeSpecsFailOnDefinitionConflict(actual, barSpec)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{actual}) +} + +func TestSafeMergeSpecsReuseModel(t *testing.T) { + var fooSpec, barSpec, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &fooSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /refoo: + post: + summary: "Refoo API" + operationId: "refooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &barSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" + /refoo: + post: + summary: "Refoo API" + operationId: "refooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" + `), &expected) + + assert := assert.New(t) + actual, err := CloneSpec(fooSpec) + if !assert.NoError(err) { + return + } + if !assert.NoError(MergeSpecsFailOnDefinitionConflict(actual, barSpec)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{actual}) +} + +func TestSafeMergeSpecsReuseModelFails(t *testing.T) { + var fooSpec, barSpec, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &fooSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /refoo: + post: + summary: "Refoo API" + operationId: "refooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" + new_field: + type: "string" +`), &barSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" + /refoo: + post: + summary: "Refoo API" + operationId: "refooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" + `), &expected) + + assert := assert.New(t) + actual, err := CloneSpec(fooSpec) + if !assert.NoError(err) { + return + } + assert.Error(MergeSpecsFailOnDefinitionConflict(actual, barSpec)) +} + +func TestMergeSpecsIgnorePathConflicts(t *testing.T) { + var fooSpec, barSpec, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &fooSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Should be ignored" + /bar: + post: + summary: "Bar API" + operationId: "barTest" + parameters: + - in: "body" + name: "body" + description: "bar object" + required: true + schema: + $ref: "#/definitions/Bar" + responses: + 200: + description: "OK" +definitions: + Bar: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &barSpec) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" + /bar: + post: + summary: "Bar API" + operationId: "barTest" + parameters: + - in: "body" + name: "body" + description: "bar object" + required: true + schema: + $ref: "#/definitions/Bar" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" + Bar: + type: "object" + properties: + id: + type: "integer" + format: "int64" + `), &expected) + + assert := assert.New(t) + actual, err := CloneSpec(fooSpec) + if !assert.NoError(err) { + return + } + if !assert.Error(MergeSpecs(actual, barSpec)) { + return + } + actual, err = CloneSpec(fooSpec) + if !assert.NoError(err) { + return + } + if !assert.NoError(MergeSpecsIgnorePathConflict(actual, barSpec)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{actual}) +} + +func TestMergeSpecsIgnorePathConflictsAllConflicting(t *testing.T) { + var fooSpec *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /foo: + post: + summary: "Foo API" + operationId: "fooTest" + parameters: + - in: "body" + name: "body" + description: "foo object" + required: true + schema: + $ref: "#/definitions/Foo" + responses: + 200: + description: "OK" +definitions: + Foo: + type: "object" + properties: + id: + type: "integer" + format: "int64" +`), &fooSpec) + + assert := assert.New(t) + foo2Spec, err := CloneSpec(fooSpec) + actual, err := CloneSpec(fooSpec) + if !assert.NoError(err) { + return + } + if !assert.NoError(MergeSpecsIgnorePathConflict(actual, foo2Spec)) { + return + } + assert.Equal(DebugSpec{fooSpec}, DebugSpec{actual}) +} + +func TestMergeSpecReplacesAllPossibleRefs(t *testing.T) { + var spec1, spec2, expected *spec.Swagger + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" +definitions: + Test: + type: "object" + properties: + foo: + $ref: "#/definitions/TestProperty" + TestProperty: + type: "object" +`), &spec1) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test2: + post: + parameters: + - name: "test2" + schema: + $ref: "#/definitions/Test2" + - name: "test3" + schema: + $ref: "#/definitions/Test3" + - name: "test4" + schema: + $ref: "#/definitions/Test4" + - name: "test5" + schema: + $ref: "#/definitions/Test5" +definitions: + Test2: + $ref: "#/definitions/TestProperty" + Test3: + type: "object" + properties: + withRef: + $ref: "#/definitions/TestProperty" + withAllOf: + type: "object" + allOf: + - $ref: "#/definitions/TestProperty" + - type: object + properties: + test: + $ref: "#/definitions/TestProperty" + withAnyOf: + type: "object" + anyOf: + - $ref: "#/definitions/TestProperty" + - type: object + properties: + test: + $ref: "#/definitions/TestProperty" + withOneOf: + type: "object" + oneOf: + - $ref: "#/definitions/TestProperty" + - type: object + properties: + test: + $ref: "#/definitions/TestProperty" + withNot: + type: "object" + not: + $ref: "#/definitions/TestProperty" + patternProperties: + "prefix.*": + $ref: "#/definitions/TestProperty" + additionalProperties: + $ref: "#/definitions/TestProperty" + definitions: + SomeDefinition: + $ref: "#/definitions/TestProperty" + Test4: + type: "array" + items: + $ref: "#/definitions/TestProperty" + additionalItems: + $ref: "#/definitions/TestProperty" + Test5: + type: "array" + items: + - $ref: "#/definitions/TestProperty" + - $ref: "#/definitions/TestProperty" + TestProperty: + description: "This TestProperty is different from the one in spec1" + type: "object" +`), &spec2) + + yaml.Unmarshal([]byte(` +swagger: "2.0" +paths: + /test: + post: + parameters: + - name: "body" + schema: + $ref: "#/definitions/Test" + /test2: + post: + parameters: + - name: "test2" + schema: + $ref: "#/definitions/Test2" + - name: "test3" + schema: + $ref: "#/definitions/Test3" + - name: "test4" + schema: + $ref: "#/definitions/Test4" + - name: "test5" + schema: + $ref: "#/definitions/Test5" +definitions: + Test: + type: "object" + properties: + foo: + $ref: "#/definitions/TestProperty" + TestProperty: + type: "object" + Test2: + $ref: "#/definitions/TestProperty_v2" + Test3: + type: "object" + properties: + withRef: + $ref: "#/definitions/TestProperty_v2" + withAllOf: + type: "object" + allOf: + - $ref: "#/definitions/TestProperty_v2" + - type: object + properties: + test: + $ref: "#/definitions/TestProperty_v2" + withAnyOf: + type: "object" + anyOf: + - $ref: "#/definitions/TestProperty_v2" + - type: object + properties: + test: + $ref: "#/definitions/TestProperty_v2" + withOneOf: + type: "object" + oneOf: + - $ref: "#/definitions/TestProperty_v2" + - type: object + properties: + test: + $ref: "#/definitions/TestProperty_v2" + withNot: + type: "object" + not: + $ref: "#/definitions/TestProperty_v2" + patternProperties: + "prefix.*": + $ref: "#/definitions/TestProperty_v2" + additionalProperties: + $ref: "#/definitions/TestProperty_v2" + definitions: + SomeDefinition: + $ref: "#/definitions/TestProperty_v2" + Test4: + type: "array" + items: + $ref: "#/definitions/TestProperty_v2" + additionalItems: + $ref: "#/definitions/TestProperty_v2" + Test5: + type: "array" + items: + - $ref: "#/definitions/TestProperty_v2" + - $ref: "#/definitions/TestProperty_v2" + TestProperty_v2: + description: "This TestProperty is different from the one in spec1" + type: "object" +`), &expected) + + assert := assert.New(t) + if !assert.NoError(MergeSpecs(spec1, spec2)) { + return + } + assert.Equal(DebugSpec{expected}, DebugSpec{spec1}) +} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/doc.go b/vendor/k8s.io/kube-openapi/pkg/builder/doc.go similarity index 65% rename from vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/doc.go rename to vendor/k8s.io/kube-openapi/pkg/builder/doc.go index 41721ca52..c3109067f 100644 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/doc.go +++ b/vendor/k8s.io/kube-openapi/pkg/builder/doc.go @@ -1,5 +1,5 @@ /* -Copyright The Kubernetes Authors. +Copyright 2016 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. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package versioned +// Package builder contains code to generate OpenAPI discovery spec (which +// initial version of it also known as Swagger 2.0). +// For more details: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md +package builder diff --git a/vendor/k8s.io/kube-openapi/pkg/builder/openapi.go b/vendor/k8s.io/kube-openapi/pkg/builder/openapi.go new file mode 100644 index 000000000..f48700d54 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/builder/openapi.go @@ -0,0 +1,457 @@ +/* +Copyright 2016 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 builder + +import ( + "encoding/json" + "fmt" + "net/http" + "reflect" + "strings" + + restful "github.com/emicklei/go-restful" + "github.com/go-openapi/spec" + + "k8s.io/kube-openapi/pkg/common" + "k8s.io/kube-openapi/pkg/util" +) + +const ( + OpenAPIVersion = "2.0" + // TODO: Make this configurable. + extensionPrefix = "x-kubernetes-" +) + +type openAPI struct { + config *common.Config + swagger *spec.Swagger + protocolList []string + definitions map[string]common.OpenAPIDefinition +} + +// BuildOpenAPISpec builds OpenAPI spec given a list of webservices (containing routes) and common.Config to customize it. +func BuildOpenAPISpec(webServices []*restful.WebService, config *common.Config) (*spec.Swagger, error) { + o := newOpenAPI(config) + err := o.buildPaths(webServices) + if err != nil { + return nil, err + } + return o.finalizeSwagger() +} + +// BuildOpenAPIDefinitionsForResource builds a partial OpenAPI spec given a sample object and common.Config to customize it. +func BuildOpenAPIDefinitionsForResource(model interface{}, config *common.Config) (*spec.Definitions, error) { + o := newOpenAPI(config) + // We can discard the return value of toSchema because all we care about is the side effect of calling it. + // All the models created for this resource get added to o.swagger.Definitions + _, err := o.toSchema(getCanonicalTypeName(model)) + if err != nil { + return nil, err + } + swagger, err := o.finalizeSwagger() + if err != nil { + return nil, err + } + return &swagger.Definitions, nil +} + +// BuildOpenAPIDefinitionsForResources returns the OpenAPI spec which includes the definitions for the +// passed type names. +func BuildOpenAPIDefinitionsForResources(config *common.Config, names ...string) (*spec.Swagger, error) { + o := newOpenAPI(config) + // We can discard the return value of toSchema because all we care about is the side effect of calling it. + // All the models created for this resource get added to o.swagger.Definitions + for _, name := range names { + _, err := o.toSchema(name) + if err != nil { + return nil, err + } + } + return o.finalizeSwagger() +} + +// newOpenAPI sets up the openAPI object so we can build the spec. +func newOpenAPI(config *common.Config) openAPI { + o := openAPI{ + config: config, + swagger: &spec.Swagger{ + SwaggerProps: spec.SwaggerProps{ + Swagger: OpenAPIVersion, + Definitions: spec.Definitions{}, + Paths: &spec.Paths{Paths: map[string]spec.PathItem{}}, + Info: config.Info, + }, + }, + } + if o.config.GetOperationIDAndTags == nil { + o.config.GetOperationIDAndTags = func(r *restful.Route) (string, []string, error) { + return r.Operation, nil, nil + } + } + if o.config.GetDefinitionName == nil { + o.config.GetDefinitionName = func(name string) (string, spec.Extensions) { + return name[strings.LastIndex(name, "/")+1:], nil + } + } + o.definitions = o.config.GetDefinitions(func(name string) spec.Ref { + defName, _ := o.config.GetDefinitionName(name) + return spec.MustCreateRef("#/definitions/" + common.EscapeJsonPointer(defName)) + }) + if o.config.CommonResponses == nil { + o.config.CommonResponses = map[int]spec.Response{} + } + return o +} + +// finalizeSwagger is called after the spec is built and returns the final spec. +// NOTE: finalizeSwagger also make changes to the final spec, as specified in the config. +func (o *openAPI) finalizeSwagger() (*spec.Swagger, error) { + if o.config.SecurityDefinitions != nil { + o.swagger.SecurityDefinitions = *o.config.SecurityDefinitions + o.swagger.Security = o.config.DefaultSecurity + } + if o.config.PostProcessSpec != nil { + var err error + o.swagger, err = o.config.PostProcessSpec(o.swagger) + if err != nil { + return nil, err + } + } + + return o.swagger, nil +} + +func getCanonicalTypeName(model interface{}) string { + t := reflect.TypeOf(model) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + if t.PkgPath() == "" { + return t.Name() + } + path := t.PkgPath() + if strings.Contains(path, "/vendor/") { + path = path[strings.Index(path, "/vendor/")+len("/vendor/"):] + } + return path + "." + t.Name() +} + +func (o *openAPI) buildDefinitionRecursively(name string) error { + uniqueName, extensions := o.config.GetDefinitionName(name) + if _, ok := o.swagger.Definitions[uniqueName]; ok { + return nil + } + if item, ok := o.definitions[name]; ok { + schema := spec.Schema{ + VendorExtensible: item.Schema.VendorExtensible, + SchemaProps: item.Schema.SchemaProps, + SwaggerSchemaProps: item.Schema.SwaggerSchemaProps, + } + if extensions != nil { + if schema.Extensions == nil { + schema.Extensions = spec.Extensions{} + } + for k, v := range extensions { + schema.Extensions[k] = v + } + } + o.swagger.Definitions[uniqueName] = schema + for _, v := range item.Dependencies { + if err := o.buildDefinitionRecursively(v); err != nil { + return err + } + } + } else { + return fmt.Errorf("cannot find model definition for %v. If you added a new type, you may need to add +k8s:openapi-gen=true to the package or type and run code-gen again", name) + } + return nil +} + +// buildDefinitionForType build a definition for a given type and return a referable name to its definition. +// This is the main function that keep track of definitions used in this spec and is depend on code generated +// by k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen. +func (o *openAPI) buildDefinitionForType(name string) (string, error) { + if err := o.buildDefinitionRecursively(name); err != nil { + return "", err + } + defName, _ := o.config.GetDefinitionName(name) + return "#/definitions/" + common.EscapeJsonPointer(defName), nil +} + +// buildPaths builds OpenAPI paths using go-restful's web services. +func (o *openAPI) buildPaths(webServices []*restful.WebService) error { + pathsToIgnore := util.NewTrie(o.config.IgnorePrefixes) + duplicateOpId := make(map[string]string) + for _, w := range webServices { + rootPath := w.RootPath() + if pathsToIgnore.HasPrefix(rootPath) { + continue + } + commonParams, err := o.buildParameters(w.PathParameters()) + if err != nil { + return err + } + for path, routes := range groupRoutesByPath(w.Routes()) { + // go-swagger has special variable definition {$NAME:*} that can only be + // used at the end of the path and it is not recognized by OpenAPI. + if strings.HasSuffix(path, ":*}") { + path = path[:len(path)-3] + "}" + } + if pathsToIgnore.HasPrefix(path) { + continue + } + // Aggregating common parameters make API spec (and generated clients) simpler + inPathCommonParamsMap, err := o.findCommonParameters(routes) + if err != nil { + return err + } + pathItem, exists := o.swagger.Paths.Paths[path] + if exists { + return fmt.Errorf("duplicate webservice route has been found for path: %v", path) + } + pathItem = spec.PathItem{ + PathItemProps: spec.PathItemProps{ + Parameters: make([]spec.Parameter, 0), + }, + } + // add web services's parameters as well as any parameters appears in all ops, as common parameters + pathItem.Parameters = append(pathItem.Parameters, commonParams...) + for _, p := range inPathCommonParamsMap { + pathItem.Parameters = append(pathItem.Parameters, p) + } + sortParameters(pathItem.Parameters) + for _, route := range routes { + op, err := o.buildOperations(route, inPathCommonParamsMap) + sortParameters(op.Parameters) + if err != nil { + return err + } + dpath, exists := duplicateOpId[op.ID] + if exists { + return fmt.Errorf("duplicate Operation ID %v for path %v and %v", op.ID, dpath, path) + } else { + duplicateOpId[op.ID] = path + } + switch strings.ToUpper(route.Method) { + case "GET": + pathItem.Get = op + case "POST": + pathItem.Post = op + case "HEAD": + pathItem.Head = op + case "PUT": + pathItem.Put = op + case "DELETE": + pathItem.Delete = op + case "OPTIONS": + pathItem.Options = op + case "PATCH": + pathItem.Patch = op + } + } + o.swagger.Paths.Paths[path] = pathItem + } + } + return nil +} + +// buildOperations builds operations for each webservice path +func (o *openAPI) buildOperations(route restful.Route, inPathCommonParamsMap map[interface{}]spec.Parameter) (ret *spec.Operation, err error) { + ret = &spec.Operation{ + OperationProps: spec.OperationProps{ + Description: route.Doc, + Consumes: route.Consumes, + Produces: route.Produces, + Schemes: o.config.ProtocolList, + Responses: &spec.Responses{ + ResponsesProps: spec.ResponsesProps{ + StatusCodeResponses: make(map[int]spec.Response), + }, + }, + }, + } + for k, v := range route.Metadata { + if strings.HasPrefix(k, extensionPrefix) { + if ret.Extensions == nil { + ret.Extensions = spec.Extensions{} + } + ret.Extensions.Add(k, v) + } + } + if ret.ID, ret.Tags, err = o.config.GetOperationIDAndTags(&route); err != nil { + return ret, err + } + + // Build responses + for _, resp := range route.ResponseErrors { + ret.Responses.StatusCodeResponses[resp.Code], err = o.buildResponse(resp.Model, resp.Message) + if err != nil { + return ret, err + } + } + // If there is no response but a write sample, assume that write sample is an http.StatusOK response. + if len(ret.Responses.StatusCodeResponses) == 0 && route.WriteSample != nil { + ret.Responses.StatusCodeResponses[http.StatusOK], err = o.buildResponse(route.WriteSample, "OK") + if err != nil { + return ret, err + } + } + for code, resp := range o.config.CommonResponses { + if _, exists := ret.Responses.StatusCodeResponses[code]; !exists { + ret.Responses.StatusCodeResponses[code] = resp + } + } + // If there is still no response, use default response provided. + if len(ret.Responses.StatusCodeResponses) == 0 { + ret.Responses.Default = o.config.DefaultResponse + } + + // Build non-common Parameters + ret.Parameters = make([]spec.Parameter, 0) + for _, param := range route.ParameterDocs { + if _, isCommon := inPathCommonParamsMap[mapKeyFromParam(param)]; !isCommon { + openAPIParam, err := o.buildParameter(param.Data(), route.ReadSample) + if err != nil { + return ret, err + } + ret.Parameters = append(ret.Parameters, openAPIParam) + } + } + return ret, nil +} + +func (o *openAPI) buildResponse(model interface{}, description string) (spec.Response, error) { + schema, err := o.toSchema(getCanonicalTypeName(model)) + if err != nil { + return spec.Response{}, err + } + return spec.Response{ + ResponseProps: spec.ResponseProps{ + Description: description, + Schema: schema, + }, + }, nil +} + +func (o *openAPI) findCommonParameters(routes []restful.Route) (map[interface{}]spec.Parameter, error) { + commonParamsMap := make(map[interface{}]spec.Parameter, 0) + paramOpsCountByName := make(map[interface{}]int, 0) + paramNameKindToDataMap := make(map[interface{}]restful.ParameterData, 0) + for _, route := range routes { + routeParamDuplicateMap := make(map[interface{}]bool) + s := "" + for _, param := range route.ParameterDocs { + m, _ := json.Marshal(param.Data()) + s += string(m) + "\n" + key := mapKeyFromParam(param) + if routeParamDuplicateMap[key] { + msg, _ := json.Marshal(route.ParameterDocs) + return commonParamsMap, fmt.Errorf("duplicate parameter %v for route %v, %v", param.Data().Name, string(msg), s) + } + routeParamDuplicateMap[key] = true + paramOpsCountByName[key]++ + paramNameKindToDataMap[key] = param.Data() + } + } + for key, count := range paramOpsCountByName { + paramData := paramNameKindToDataMap[key] + if count == len(routes) && paramData.Kind != restful.BodyParameterKind { + openAPIParam, err := o.buildParameter(paramData, nil) + if err != nil { + return commonParamsMap, err + } + commonParamsMap[key] = openAPIParam + } + } + return commonParamsMap, nil +} + +func (o *openAPI) toSchema(name string) (_ *spec.Schema, err error) { + if openAPIType, openAPIFormat := common.GetOpenAPITypeFormat(name); openAPIType != "" { + return &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{openAPIType}, + Format: openAPIFormat, + }, + }, nil + } else { + ref, err := o.buildDefinitionForType(name) + if err != nil { + return nil, err + } + return &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: spec.MustCreateRef(ref), + }, + }, nil + } +} + +func (o *openAPI) buildParameter(restParam restful.ParameterData, bodySample interface{}) (ret spec.Parameter, err error) { + ret = spec.Parameter{ + ParamProps: spec.ParamProps{ + Name: restParam.Name, + Description: restParam.Description, + Required: restParam.Required, + }, + } + switch restParam.Kind { + case restful.BodyParameterKind: + if bodySample != nil { + ret.In = "body" + ret.Schema, err = o.toSchema(getCanonicalTypeName(bodySample)) + return ret, err + } else { + // There is not enough information in the body parameter to build the definition. + // Body parameter has a data type that is a short name but we need full package name + // of the type to create a definition. + return ret, fmt.Errorf("restful body parameters are not supported: %v", restParam.DataType) + } + case restful.PathParameterKind: + ret.In = "path" + if !restParam.Required { + return ret, fmt.Errorf("path parameters should be marked at required for parameter %v", restParam) + } + case restful.QueryParameterKind: + ret.In = "query" + case restful.HeaderParameterKind: + ret.In = "header" + case restful.FormParameterKind: + ret.In = "formData" + default: + return ret, fmt.Errorf("unknown restful operation kind : %v", restParam.Kind) + } + openAPIType, openAPIFormat := common.GetOpenAPITypeFormat(restParam.DataType) + if openAPIType == "" { + return ret, fmt.Errorf("non-body Restful parameter type should be a simple type, but got : %v", restParam.DataType) + } + ret.Type = openAPIType + ret.Format = openAPIFormat + ret.UniqueItems = !restParam.AllowMultiple + return ret, nil +} + +func (o *openAPI) buildParameters(restParam []*restful.Parameter) (ret []spec.Parameter, err error) { + ret = make([]spec.Parameter, len(restParam)) + for i, v := range restParam { + ret[i], err = o.buildParameter(v.Data(), nil) + if err != nil { + return ret, err + } + } + return ret, nil +} diff --git a/vendor/k8s.io/kube-openapi/pkg/builder/openapi_test.go b/vendor/k8s.io/kube-openapi/pkg/builder/openapi_test.go new file mode 100644 index 000000000..4087c6d65 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/builder/openapi_test.go @@ -0,0 +1,475 @@ +/* +Copyright 2016 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 builder + +import ( + "encoding/json" + "fmt" + "net/http" + "strings" + "testing" + + "github.com/emicklei/go-restful" + "github.com/go-openapi/spec" + "github.com/stretchr/testify/assert" + openapi "k8s.io/kube-openapi/pkg/common" +) + +// setUp is a convenience function for setting up for (most) tests. +func setUp(t *testing.T, fullMethods bool) (*openapi.Config, *restful.Container, *assert.Assertions) { + assert := assert.New(t) + config, container := getConfig(fullMethods) + return config, container, assert +} + +func noOp(request *restful.Request, response *restful.Response) {} + +// Test input +type TestInput struct { + // Name of the input + Name string `json:"name,omitempty"` + // ID of the input + ID int `json:"id,omitempty"` + Tags []string `json:"tags,omitempty"` +} + +// Test output +type TestOutput struct { + // Name of the output + Name string `json:"name,omitempty"` + // Number of outputs + Count int `json:"count,omitempty"` +} + +func (_ TestInput) OpenAPIDefinition() *openapi.OpenAPIDefinition { + schema := spec.Schema{} + schema.Description = "Test input" + schema.Properties = map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the input", + Type: []string{"string"}, + Format: "", + }, + }, + "id": { + SchemaProps: spec.SchemaProps{ + Description: "ID of the input", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "tags": { + SchemaProps: spec.SchemaProps{ + Description: "", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } + schema.Extensions = spec.Extensions{"x-test": "test"} + return &openapi.OpenAPIDefinition{ + Schema: schema, + Dependencies: []string{}, + } +} + +func (_ TestOutput) OpenAPIDefinition() *openapi.OpenAPIDefinition { + schema := spec.Schema{} + schema.Description = "Test output" + schema.Properties = map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the output", + Type: []string{"string"}, + Format: "", + }, + }, + "count": { + SchemaProps: spec.SchemaProps{ + Description: "Number of outputs", + Type: []string{"integer"}, + Format: "int32", + }, + }, + } + return &openapi.OpenAPIDefinition{ + Schema: schema, + Dependencies: []string{}, + } +} + +var _ openapi.OpenAPIDefinitionGetter = TestInput{} +var _ openapi.OpenAPIDefinitionGetter = TestOutput{} + +func getTestRoute(ws *restful.WebService, method string, additionalParams bool, opPrefix string) *restful.RouteBuilder { + ret := ws.Method(method). + Path("/test/{path:*}"). + Doc(fmt.Sprintf("%s test input", method)). + Operation(fmt.Sprintf("%s%sTestInput", method, opPrefix)). + Produces(restful.MIME_JSON). + Consumes(restful.MIME_JSON). + Param(ws.PathParameter("path", "path to the resource").DataType("string")). + Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")). + Reads(TestInput{}). + Returns(200, "OK", TestOutput{}). + Writes(TestOutput{}). + To(noOp) + if additionalParams { + ret.Param(ws.HeaderParameter("hparam", "a test head parameter").DataType("integer")) + ret.Param(ws.FormParameter("fparam", "a test form parameter").DataType("number")) + } + return ret +} + +func getConfig(fullMethods bool) (*openapi.Config, *restful.Container) { + mux := http.NewServeMux() + container := restful.NewContainer() + container.ServeMux = mux + ws := new(restful.WebService) + ws.Path("/foo") + ws.Route(getTestRoute(ws, "get", true, "foo")) + if fullMethods { + ws.Route(getTestRoute(ws, "post", false, "foo")). + Route(getTestRoute(ws, "put", false, "foo")). + Route(getTestRoute(ws, "head", false, "foo")). + Route(getTestRoute(ws, "patch", false, "foo")). + Route(getTestRoute(ws, "options", false, "foo")). + Route(getTestRoute(ws, "delete", false, "foo")) + + } + ws.Path("/bar") + ws.Route(getTestRoute(ws, "get", true, "bar")) + if fullMethods { + ws.Route(getTestRoute(ws, "post", false, "bar")). + Route(getTestRoute(ws, "put", false, "bar")). + Route(getTestRoute(ws, "head", false, "bar")). + Route(getTestRoute(ws, "patch", false, "bar")). + Route(getTestRoute(ws, "options", false, "bar")). + Route(getTestRoute(ws, "delete", false, "bar")) + + } + container.Add(ws) + return &openapi.Config{ + ProtocolList: []string{"https"}, + Info: &spec.Info{ + InfoProps: spec.InfoProps{ + Title: "TestAPI", + Description: "Test API", + Version: "unversioned", + }, + }, + GetDefinitions: func(_ openapi.ReferenceCallback) map[string]openapi.OpenAPIDefinition { + return map[string]openapi.OpenAPIDefinition{ + "k8s.io/kube-openapi/pkg/builder.TestInput": *TestInput{}.OpenAPIDefinition(), + "k8s.io/kube-openapi/pkg/builder.TestOutput": *TestOutput{}.OpenAPIDefinition(), + // Bazel changes the package name, this is ok for testing, but we need to fix it if it happened + // in the main code. + "k8s.io/kube-openapi/pkg/builder/go_default_test.TestInput": *TestInput{}.OpenAPIDefinition(), + "k8s.io/kube-openapi/pkg/builder/go_default_test.TestOutput": *TestOutput{}.OpenAPIDefinition(), + } + }, + GetDefinitionName: func(name string) (string, spec.Extensions) { + friendlyName := name[strings.LastIndex(name, "/")+1:] + if strings.HasPrefix(friendlyName, "go_default_test") { + friendlyName = "builder" + friendlyName[len("go_default_test"):] + } + return friendlyName, spec.Extensions{"x-test2": "test2"} + }, + }, container +} + +func getTestOperation(method string, opPrefix string) *spec.Operation { + return &spec.Operation{ + OperationProps: spec.OperationProps{ + Description: fmt.Sprintf("%s test input", method), + Consumes: []string{"application/json"}, + Produces: []string{"application/json"}, + Schemes: []string{"https"}, + Parameters: []spec.Parameter{}, + Responses: getTestResponses(), + ID: fmt.Sprintf("%s%sTestInput", method, opPrefix), + }, + } +} + +func getTestPathItem(allMethods bool, opPrefix string) spec.PathItem { + ret := spec.PathItem{ + PathItemProps: spec.PathItemProps{ + Get: getTestOperation("get", opPrefix), + Parameters: getTestCommonParameters(), + }, + } + ret.Get.Parameters = getAdditionalTestParameters() + if allMethods { + ret.Put = getTestOperation("put", opPrefix) + ret.Put.Parameters = getTestParameters() + ret.Post = getTestOperation("post", opPrefix) + ret.Post.Parameters = getTestParameters() + ret.Head = getTestOperation("head", opPrefix) + ret.Head.Parameters = getTestParameters() + ret.Patch = getTestOperation("patch", opPrefix) + ret.Patch.Parameters = getTestParameters() + ret.Delete = getTestOperation("delete", opPrefix) + ret.Delete.Parameters = getTestParameters() + ret.Options = getTestOperation("options", opPrefix) + ret.Options.Parameters = getTestParameters() + } + return ret +} + +func getRefSchema(ref string) *spec.Schema { + return &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: spec.MustCreateRef(ref), + }, + } +} + +func getTestResponses() *spec.Responses { + ret := spec.Responses{ + ResponsesProps: spec.ResponsesProps{ + StatusCodeResponses: map[int]spec.Response{}, + }, + } + ret.StatusCodeResponses[200] = spec.Response{ + ResponseProps: spec.ResponseProps{ + Description: "OK", + Schema: getRefSchema("#/definitions/builder.TestOutput"), + }, + } + return &ret +} + +func getTestCommonParameters() []spec.Parameter { + ret := make([]spec.Parameter, 2) + ret[0] = spec.Parameter{ + SimpleSchema: spec.SimpleSchema{ + Type: "string", + }, + ParamProps: spec.ParamProps{ + Description: "path to the resource", + Name: "path", + In: "path", + Required: true, + }, + CommonValidations: spec.CommonValidations{ + UniqueItems: true, + }, + } + ret[1] = spec.Parameter{ + SimpleSchema: spec.SimpleSchema{ + Type: "string", + }, + ParamProps: spec.ParamProps{ + Description: "If 'true', then the output is pretty printed.", + Name: "pretty", + In: "query", + }, + CommonValidations: spec.CommonValidations{ + UniqueItems: true, + }, + } + return ret +} + +func getTestParameters() []spec.Parameter { + ret := make([]spec.Parameter, 1) + ret[0] = spec.Parameter{ + ParamProps: spec.ParamProps{ + Name: "body", + In: "body", + Required: true, + Schema: getRefSchema("#/definitions/builder.TestInput"), + }, + } + return ret +} + +func getAdditionalTestParameters() []spec.Parameter { + ret := make([]spec.Parameter, 3) + ret[0] = spec.Parameter{ + ParamProps: spec.ParamProps{ + Name: "body", + In: "body", + Required: true, + Schema: getRefSchema("#/definitions/builder.TestInput"), + }, + } + ret[1] = spec.Parameter{ + ParamProps: spec.ParamProps{ + Name: "fparam", + Description: "a test form parameter", + In: "formData", + }, + SimpleSchema: spec.SimpleSchema{ + Type: "number", + }, + CommonValidations: spec.CommonValidations{ + UniqueItems: true, + }, + } + ret[2] = spec.Parameter{ + SimpleSchema: spec.SimpleSchema{ + Type: "integer", + }, + ParamProps: spec.ParamProps{ + Description: "a test head parameter", + Name: "hparam", + In: "header", + }, + CommonValidations: spec.CommonValidations{ + UniqueItems: true, + }, + } + return ret +} + +func getTestInputDefinition() spec.Schema { + return spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Test input", + Properties: map[string]spec.Schema{ + "id": { + SchemaProps: spec.SchemaProps{ + Description: "ID of the input", + Type: spec.StringOrArray{"integer"}, + Format: "int32", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the input", + Type: spec.StringOrArray{"string"}, + }, + }, + "tags": { + SchemaProps: spec.SchemaProps{ + Type: spec.StringOrArray{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: spec.StringOrArray{"string"}, + }, + }, + }, + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-test": "test", + "x-test2": "test2", + }, + }, + } +} + +func getTestOutputDefinition() spec.Schema { + return spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Test output", + Properties: map[string]spec.Schema{ + "count": { + SchemaProps: spec.SchemaProps{ + Description: "Number of outputs", + Type: spec.StringOrArray{"integer"}, + Format: "int32", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the output", + Type: spec.StringOrArray{"string"}, + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-test2": "test2", + }, + }, + } +} + +func TestBuildOpenAPISpec(t *testing.T) { + config, container, assert := setUp(t, true) + expected := &spec.Swagger{ + SwaggerProps: spec.SwaggerProps{ + Info: &spec.Info{ + InfoProps: spec.InfoProps{ + Title: "TestAPI", + Description: "Test API", + Version: "unversioned", + }, + }, + Swagger: "2.0", + Paths: &spec.Paths{ + Paths: map[string]spec.PathItem{ + "/foo/test/{path}": getTestPathItem(true, "foo"), + "/bar/test/{path}": getTestPathItem(true, "bar"), + }, + }, + Definitions: spec.Definitions{ + "builder.TestInput": getTestInputDefinition(), + "builder.TestOutput": getTestOutputDefinition(), + }, + }, + } + swagger, err := BuildOpenAPISpec(container.RegisteredWebServices(), config) + if !assert.NoError(err) { + return + } + expected_json, err := json.Marshal(expected) + if !assert.NoError(err) { + return + } + actual_json, err := json.Marshal(swagger) + if !assert.NoError(err) { + return + } + assert.Equal(string(expected_json), string(actual_json)) +} + +func TestBuildOpenAPIDefinitionsForResource(t *testing.T) { + config, _, assert := setUp(t, true) + expected := &spec.Definitions{ + "builder.TestInput": getTestInputDefinition(), + } + swagger, err := BuildOpenAPIDefinitionsForResource(TestInput{}, config) + if !assert.NoError(err) { + return + } + expected_json, err := json.Marshal(expected) + if !assert.NoError(err) { + return + } + actual_json, err := json.Marshal(swagger) + if !assert.NoError(err) { + return + } + assert.Equal(string(expected_json), string(actual_json)) +} diff --git a/vendor/k8s.io/kube-openapi/pkg/builder/util.go b/vendor/k8s.io/kube-openapi/pkg/builder/util.go new file mode 100644 index 000000000..5e9a56a6b --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/builder/util.go @@ -0,0 +1,61 @@ +/* +Copyright 2016 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 builder + +import ( + "sort" + + "github.com/emicklei/go-restful" + "github.com/go-openapi/spec" +) + +type parameters []spec.Parameter + +func (s parameters) Len() int { return len(s) } +func (s parameters) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// byNameIn used in sorting parameters by Name and In fields. +type byNameIn struct { + parameters +} + +func (s byNameIn) Less(i, j int) bool { + return s.parameters[i].Name < s.parameters[j].Name || (s.parameters[i].Name == s.parameters[j].Name && s.parameters[i].In < s.parameters[j].In) +} + +// SortParameters sorts parameters by Name and In fields. +func sortParameters(p []spec.Parameter) { + sort.Sort(byNameIn{p}) +} + +func groupRoutesByPath(routes []restful.Route) map[string][]restful.Route { + pathToRoutes := make(map[string][]restful.Route) + for _, r := range routes { + pathToRoutes[r.Path] = append(pathToRoutes[r.Path], r) + } + return pathToRoutes +} + +func mapKeyFromParam(param *restful.Parameter) interface{} { + return struct { + Name string + Kind int + }{ + Name: param.Data().Name, + Kind: param.Data().Kind, + } +} diff --git a/vendor/k8s.io/kube-openapi/pkg/common/common.go b/vendor/k8s.io/kube-openapi/pkg/common/common.go new file mode 100644 index 000000000..0d235876d --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/common/common.go @@ -0,0 +1,168 @@ +/* +Copyright 2016 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 common + +import ( + "net/http" + "strings" + + "github.com/emicklei/go-restful" + "github.com/go-openapi/spec" +) + +// OpenAPIDefinition describes single type. Normally these definitions are auto-generated using gen-openapi. +type OpenAPIDefinition struct { + Schema spec.Schema + Dependencies []string +} + +type ReferenceCallback func(path string) spec.Ref + +// GetOpenAPIDefinitions is collection of all definitions. +type GetOpenAPIDefinitions func(ReferenceCallback) map[string]OpenAPIDefinition + +// OpenAPIDefinitionGetter gets openAPI definitions for a given type. If a type implements this interface, +// the definition returned by it will be used, otherwise the auto-generated definitions will be used. See +// GetOpenAPITypeFormat for more information about trade-offs of using this interface or GetOpenAPITypeFormat method when +// possible. +type OpenAPIDefinitionGetter interface { + OpenAPIDefinition() *OpenAPIDefinition +} + +type PathHandler interface { + Handle(path string, handler http.Handler) +} + +// Config is set of configuration for openAPI spec generation. +type Config struct { + // List of supported protocols such as https, http, etc. + ProtocolList []string + + // Info is general information about the API. + Info *spec.Info + + // DefaultResponse will be used if an operation does not have any responses listed. It + // will show up as ... "responses" : {"default" : $DefaultResponse} in the spec. + DefaultResponse *spec.Response + + // CommonResponses will be added as a response to all operation specs. This is a good place to add common + // responses such as authorization failed. + CommonResponses map[int]spec.Response + + // List of webservice's path prefixes to ignore + IgnorePrefixes []string + + // OpenAPIDefinitions should provide definition for all models used by routes. Failure to provide this map + // or any of the models will result in spec generation failure. + GetDefinitions GetOpenAPIDefinitions + + // GetOperationIDAndTags returns operation id and tags for a restful route. It is an optional function to customize operation IDs. + GetOperationIDAndTags func(r *restful.Route) (string, []string, error) + + // GetDefinitionName returns a friendly name for a definition base on the serving path. parameter `name` is the full name of the definition. + // It is an optional function to customize model names. + GetDefinitionName func(name string) (string, spec.Extensions) + + // PostProcessSpec runs after the spec is ready to serve. It allows a final modification to the spec before serving. + PostProcessSpec func(*spec.Swagger) (*spec.Swagger, error) + + // SecurityDefinitions is list of all security definitions for OpenAPI service. If this is not nil, the user of config + // is responsible to provide DefaultSecurity and (maybe) add unauthorized response to CommonResponses. + SecurityDefinitions *spec.SecurityDefinitions + + // DefaultSecurity for all operations. This will pass as spec.SwaggerProps.Security to OpenAPI. + // For most cases, this will be list of acceptable definitions in SecurityDefinitions. + DefaultSecurity []map[string][]string +} + +var schemaTypeFormatMap = map[string][]string{ + "uint": {"integer", "int32"}, + "uint8": {"integer", "byte"}, + "uint16": {"integer", "int32"}, + "uint32": {"integer", "int64"}, + "uint64": {"integer", "int64"}, + "int": {"integer", "int32"}, + "int8": {"integer", "byte"}, + "int16": {"integer", "int32"}, + "int32": {"integer", "int32"}, + "int64": {"integer", "int64"}, + "byte": {"integer", "byte"}, + "float64": {"number", "double"}, + "float32": {"number", "float"}, + "bool": {"boolean", ""}, + "time.Time": {"string", "date-time"}, + "string": {"string", ""}, + "integer": {"integer", ""}, + "number": {"number", ""}, + "boolean": {"boolean", ""}, + "[]byte": {"string", "byte"}, // base64 encoded characters + "interface{}": {"object", ""}, +} + +// This function is a reference for converting go (or any custom type) to a simple open API type,format pair. There are +// two ways to customize spec for a type. If you add it here, a type will be converted to a simple type and the type +// comment (the comment that is added before type definition) will be lost. The spec will still have the property +// comment. The second way is to implement OpenAPIDefinitionGetter interface. That function can customize the spec (so +// the spec does not need to be simple type,format) or can even return a simple type,format (e.g. IntOrString). For simple +// type formats, the benefit of adding OpenAPIDefinitionGetter interface is to keep both type and property documentation. +// Example: +// type Sample struct { +// ... +// // port of the server +// port IntOrString +// ... +// } +// // IntOrString documentation... +// type IntOrString { ... } +// +// Adding IntOrString to this function: +// "port" : { +// format: "string", +// type: "int-or-string", +// Description: "port of the server" +// } +// +// Implement OpenAPIDefinitionGetter for IntOrString: +// +// "port" : { +// $Ref: "#/definitions/IntOrString" +// Description: "port of the server" +// } +// ... +// definitions: +// { +// "IntOrString": { +// format: "string", +// type: "int-or-string", +// Description: "IntOrString documentation..." // new +// } +// } +// +func GetOpenAPITypeFormat(typeName string) (string, string) { + mapped, ok := schemaTypeFormatMap[typeName] + if !ok { + return "", "" + } + return mapped[0], mapped[1] +} + +func EscapeJsonPointer(p string) string { + // Escaping reference name using rfc6901 + p = strings.Replace(p, "~", "~0", -1) + p = strings.Replace(p, "/", "~1", -1) + return p +} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/doc.go b/vendor/k8s.io/kube-openapi/pkg/common/doc.go similarity index 77% rename from vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/doc.go rename to vendor/k8s.io/kube-openapi/pkg/common/doc.go index 16f443990..2ba6d247b 100644 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/doc.go +++ b/vendor/k8s.io/kube-openapi/pkg/common/doc.go @@ -1,5 +1,5 @@ /* -Copyright The Kubernetes Authors. +Copyright 2016 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. @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake +// package common holds shared code and types between open API code +// generator and spec generator. +package common diff --git a/vendor/k8s.io/kube-openapi/pkg/generators/README b/vendor/k8s.io/kube-openapi/pkg/generators/README new file mode 100644 index 000000000..feb19b401 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/generators/README @@ -0,0 +1,46 @@ +# Generate OpenAPI definitions + +- To generate definition for a specific type or package add "+k8s:openapi-gen=true" tag to the type/package comment lines. +- To exclude a type or a member from a tagged package/type, add "+k8s:openapi-gen=false" tag to the comment lines. + +# OpenAPI Extensions +OpenAPI spec can have extensions on types. To define one or more extensions on a type or its member +add `+k8s:openapi-gen=x-kubernetes-$NAME:`$VALUE`` to the comment lines before type/member. A type/member can +have multiple extensions. The rest of the line in the comment will be used as $VALUE so there is no need to +escape or quote the value string. Extensions can be used to pass more information to client generators or +documentation generators. For example a type might have a friendly name to be displayed in documentation or +being used in a client's fluent interface. + +# Custom OpenAPI type definitions + +Custom types which otherwise don't map directly to OpenAPI can override their +OpenAPI definition by implementing a function named "OpenAPIDefinition" with +the following signature: + + import openapi "k8s.io/kube-openapi/pkg/common" + + // ... + + type Time struct { + time.Time + } + + func (_ Time) OpenAPIDefinition() openapi.OpenAPIDefinition { + return openapi.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "date-time", + }, + }, + } + } + +Alternatively, the type can avoid the "openapi" import by defining the following +methods. The following example produces the same OpenAPI definition as the +example above: + + func (_ Time) OpenAPISchemaType() []string { return []string{"string"} } + func (_ Time) OpenAPISchemaFormat() string { return "date-time" } + +TODO(mehdy): Make k8s:openapi-gen a parameter to the generator now that OpenAPI has its own repo. diff --git a/vendor/k8s.io/kube-openapi/pkg/generators/extension.go b/vendor/k8s.io/kube-openapi/pkg/generators/extension.go new file mode 100644 index 000000000..befe38db2 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/generators/extension.go @@ -0,0 +1,182 @@ +/* +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 generators + +import ( + "fmt" + "sort" + "strings" + + "k8s.io/gengo/examples/set-gen/sets" + "k8s.io/gengo/types" +) + +const extensionPrefix = "x-kubernetes-" + +// extensionAttributes encapsulates common traits for particular extensions. +type extensionAttributes struct { + xName string + kind types.Kind + allowedValues sets.String +} + +// Extension tag to openapi extension attributes +var tagToExtension = map[string]extensionAttributes{ + "patchMergeKey": extensionAttributes{ + xName: "x-kubernetes-patch-merge-key", + kind: types.Slice, + }, + "patchStrategy": extensionAttributes{ + xName: "x-kubernetes-patch-strategy", + kind: types.Slice, + allowedValues: sets.NewString("merge", "retainKeys"), + }, + "listMapKey": extensionAttributes{ + xName: "x-kubernetes-list-map-keys", + kind: types.Slice, + }, + "listType": extensionAttributes{ + xName: "x-kubernetes-list-type", + kind: types.Slice, + allowedValues: sets.NewString("atomic", "set", "map"), + }, +} + +// Extension encapsulates information necessary to generate an OpenAPI extension. +type extension struct { + idlTag string // Example: listType + xName string // Example: x-kubernetes-list-type + values []string // Example: [atomic] +} + +func (e extension) hasAllowedValues() bool { + return tagToExtension[e.idlTag].allowedValues.Len() > 0 +} + +func (e extension) allowedValues() sets.String { + return tagToExtension[e.idlTag].allowedValues +} + +func (e extension) hasKind() bool { + return len(tagToExtension[e.idlTag].kind) > 0 +} + +func (e extension) kind() types.Kind { + return tagToExtension[e.idlTag].kind +} + +func (e extension) validateAllowedValues() error { + // allowedValues not set means no restrictions on values. + if !e.hasAllowedValues() { + return nil + } + // Check for missing value. + if len(e.values) == 0 { + return fmt.Errorf("%s needs a value, none given.", e.idlTag) + } + // For each extension value, validate that it is allowed. + allowedValues := e.allowedValues() + if !allowedValues.HasAll(e.values...) { + return fmt.Errorf("%v not allowed for %s. Allowed values: %v", + e.values, e.idlTag, allowedValues.List()) + } + return nil +} + +func (e extension) validateType(kind types.Kind) error { + // If this extension class has no kind, then don't validate the type. + if !e.hasKind() { + return nil + } + if kind != e.kind() { + return fmt.Errorf("tag %s on type %v; only allowed on type %v", + e.idlTag, kind, e.kind()) + } + return nil +} + +func (e extension) hasMultipleValues() bool { + return len(e.values) > 1 +} + +// Returns sorted list of map keys. Needed for deterministic testing. +func sortedMapKeys(m map[string][]string) []string { + keys := make([]string, len(m)) + i := 0 + for k := range m { + keys[i] = k + i++ + } + sort.Strings(keys) + return keys +} + +// Parses comments to return openapi extensions. Returns a list of +// extensions which parsed correctly, as well as a list of the +// parse errors. Validating extensions is performed separately. +// NOTE: Non-empty errors does not mean extensions is empty. +func parseExtensions(comments []string) ([]extension, []error) { + extensions := []extension{} + errors := []error{} + // First, generate extensions from "+k8s:openapi-gen=x-kubernetes-*" annotations. + values := getOpenAPITagValue(comments) + for _, val := range values { + // Example: x-kubernetes-member-tag:member_test + if strings.HasPrefix(val, extensionPrefix) { + parts := strings.SplitN(val, ":", 2) + if len(parts) != 2 { + errors = append(errors, fmt.Errorf("invalid extension value: %v", val)) + continue + } + e := extension{ + idlTag: tagName, // Example: k8s:openapi-gen + xName: parts[0], // Example: x-kubernetes-member-tag + values: []string{parts[1]}, // Example: member_test + } + extensions = append(extensions, e) + } + } + // Next, generate extensions from "idlTags" (e.g. +listType) + tagValues := types.ExtractCommentTags("+", comments) + for _, idlTag := range sortedMapKeys(tagValues) { + xAttrs, exists := tagToExtension[idlTag] + if !exists { + continue + } + values := tagValues[idlTag] + e := extension{ + idlTag: idlTag, // listType + xName: xAttrs.xName, // x-kubernetes-list-type + values: values, // [atomic] + } + extensions = append(extensions, e) + } + return extensions, errors +} + +func validateMemberExtensions(extensions []extension, m *types.Member) []error { + errors := []error{} + for _, e := range extensions { + if err := e.validateAllowedValues(); err != nil { + errors = append(errors, err) + } + if err := e.validateType(m.Type.Kind); err != nil { + errors = append(errors, err) + } + } + return errors +} diff --git a/vendor/k8s.io/kube-openapi/pkg/generators/extension_test.go b/vendor/k8s.io/kube-openapi/pkg/generators/extension_test.go new file mode 100644 index 000000000..d1214bd9a --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/generators/extension_test.go @@ -0,0 +1,454 @@ +/* +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 generators + +import ( + "reflect" + "strings" + "testing" + + "k8s.io/gengo/examples/set-gen/sets" + "k8s.io/gengo/types" +) + +func TestSingleTagExtension(t *testing.T) { + + // Comments only contain one tag extension and one value. + var tests = []struct { + comments []string + extensionTag string + extensionName string + extensionValues []string + }{ + { + comments: []string{"+patchMergeKey=name"}, + extensionTag: "patchMergeKey", + extensionName: "x-kubernetes-patch-merge-key", + extensionValues: []string{"name"}, + }, + { + comments: []string{"+patchStrategy=merge"}, + extensionTag: "patchStrategy", + extensionName: "x-kubernetes-patch-strategy", + extensionValues: []string{"merge"}, + }, + { + comments: []string{"+listType=atomic"}, + extensionTag: "listType", + extensionName: "x-kubernetes-list-type", + extensionValues: []string{"atomic"}, + }, + { + comments: []string{"+listMapKey=port"}, + extensionTag: "listMapKey", + extensionName: "x-kubernetes-list-map-keys", + extensionValues: []string{"port"}, + }, + { + comments: []string{"+k8s:openapi-gen=x-kubernetes-member-tag:member_test"}, + extensionTag: "k8s:openapi-gen", + extensionName: "x-kubernetes-member-tag", + extensionValues: []string{"member_test"}, + }, + { + comments: []string{"+k8s:openapi-gen=x-kubernetes-member-tag:member_test:member_test2"}, + extensionTag: "k8s:openapi-gen", + extensionName: "x-kubernetes-member-tag", + extensionValues: []string{"member_test:member_test2"}, + }, + { + // Test that poorly formatted extensions aren't added. + comments: []string{ + "+k8s:openapi-gen=x-kubernetes-no-value", + "+k8s:openapi-gen=x-kubernetes-member-success:success", + "+k8s:openapi-gen=x-kubernetes-wrong-separator;error", + }, + extensionTag: "k8s:openapi-gen", + extensionName: "x-kubernetes-member-success", + extensionValues: []string{"success"}, + }, + } + for _, test := range tests { + extensions, _ := parseExtensions(test.comments) + actual := extensions[0] + if actual.idlTag != test.extensionTag { + t.Errorf("Extension Tag: expected (%s), actual (%s)\n", test.extensionTag, actual.idlTag) + } + if actual.xName != test.extensionName { + t.Errorf("Extension Name: expected (%s), actual (%s)\n", test.extensionName, actual.xName) + } + if !reflect.DeepEqual(actual.values, test.extensionValues) { + t.Errorf("Extension Values: expected (%s), actual (%s)\n", test.extensionValues, actual.values) + } + if actual.hasMultipleValues() { + t.Errorf("%s: hasMultipleValues() should be false\n", actual.xName) + } + } + +} + +func TestMultipleTagExtensions(t *testing.T) { + + var tests = []struct { + comments []string + extensionTag string + extensionName string + extensionValues []string + }{ + { + comments: []string{ + "+listMapKey=port", + "+listMapKey=protocol", + }, + extensionTag: "listMapKey", + extensionName: "x-kubernetes-list-map-keys", + extensionValues: []string{"port", "protocol"}, + }, + } + for _, test := range tests { + extensions, errors := parseExtensions(test.comments) + if len(errors) > 0 { + t.Errorf("Unexpected errors: %v\n", errors) + } + actual := extensions[0] + if actual.idlTag != test.extensionTag { + t.Errorf("Extension Tag: expected (%s), actual (%s)\n", test.extensionTag, actual.idlTag) + } + if actual.xName != test.extensionName { + t.Errorf("Extension Name: expected (%s), actual (%s)\n", test.extensionName, actual.xName) + } + if !reflect.DeepEqual(actual.values, test.extensionValues) { + t.Errorf("Extension Values: expected (%s), actual (%s)\n", test.extensionValues, actual.values) + } + if !actual.hasMultipleValues() { + t.Errorf("%s: hasMultipleValues() should be true\n", actual.xName) + } + } + +} + +func TestExtensionParseErrors(t *testing.T) { + + var tests = []struct { + comments []string + errorMessage string + }{ + { + // Missing extension value should be an error. + comments: []string{ + "+k8s:openapi-gen=x-kubernetes-no-value", + }, + errorMessage: "x-kubernetes-no-value", + }, + { + // Wrong separator should be an error. + comments: []string{ + "+k8s:openapi-gen=x-kubernetes-wrong-separator;error", + }, + errorMessage: "x-kubernetes-wrong-separator;error", + }, + } + + for _, test := range tests { + _, errors := parseExtensions(test.comments) + if len(errors) == 0 { + t.Errorf("Expected errors while parsing: %v\n", test.comments) + } + error := errors[0] + if !strings.Contains(error.Error(), test.errorMessage) { + t.Errorf("Error (%v) should contain substring (%s)\n", error, test.errorMessage) + } + } +} + +func TestExtensionAllowedValues(t *testing.T) { + + var methodTests = []struct { + e extension + allowedValues sets.String + }{ + { + e: extension{ + idlTag: "patchStrategy", + }, + allowedValues: sets.NewString("merge", "retainKeys"), + }, + { + e: extension{ + idlTag: "patchMergeKey", + }, + allowedValues: nil, + }, + { + e: extension{ + idlTag: "listType", + }, + allowedValues: sets.NewString("atomic", "set", "map"), + }, + { + e: extension{ + idlTag: "listMapKey", + }, + allowedValues: nil, + }, + { + e: extension{ + idlTag: "k8s:openapi-gen", + }, + allowedValues: nil, + }, + } + for _, test := range methodTests { + if test.allowedValues != nil { + if !test.e.hasAllowedValues() { + t.Errorf("hasAllowedValues() expected (true), but received: false") + } + if !reflect.DeepEqual(test.allowedValues, test.e.allowedValues()) { + t.Errorf("allowedValues() expected (%v), but received: %v", + test.allowedValues, test.e.allowedValues()) + } + } + if test.allowedValues == nil && test.e.hasAllowedValues() { + t.Errorf("hasAllowedValues() expected (false), but received: true") + } + } + + var successTests = []struct { + e extension + }{ + { + e: extension{ + idlTag: "patchStrategy", + xName: "x-kubernetes-patch-strategy", + values: []string{"merge"}, + }, + }, + { + // Validate multiple values. + e: extension{ + idlTag: "patchStrategy", + xName: "x-kubernetes-patch-strategy", + values: []string{"merge", "retainKeys"}, + }, + }, + { + e: extension{ + idlTag: "patchMergeKey", + xName: "x-kubernetes-patch-merge-key", + values: []string{"key1"}, + }, + }, + { + e: extension{ + idlTag: "listType", + xName: "x-kubernetes-list-type", + values: []string{"atomic"}, + }, + }, + } + for _, test := range successTests { + actualErr := test.e.validateAllowedValues() + if actualErr != nil { + t.Errorf("Expected no error for (%v), but received: %v\n", test.e, actualErr) + } + } + + var failureTests = []struct { + e extension + }{ + { + // Every value must be allowed. + e: extension{ + idlTag: "patchStrategy", + xName: "x-kubernetes-patch-strategy", + values: []string{"disallowed", "merge"}, + }, + }, + { + e: extension{ + idlTag: "patchStrategy", + xName: "x-kubernetes-patch-strategy", + values: []string{"foo"}, + }, + }, + { + e: extension{ + idlTag: "listType", + xName: "x-kubernetes-list-type", + values: []string{"not-allowed"}, + }, + }, + } + for _, test := range failureTests { + actualErr := test.e.validateAllowedValues() + if actualErr == nil { + t.Errorf("Expected error, but received none: %v\n", test.e) + } + } + +} + +func TestExtensionKind(t *testing.T) { + + var methodTests = []struct { + e extension + kind types.Kind + }{ + { + e: extension{ + idlTag: "patchStrategy", + }, + kind: types.Slice, + }, + { + e: extension{ + idlTag: "patchMergeKey", + }, + kind: types.Slice, + }, + { + e: extension{ + idlTag: "listType", + }, + kind: types.Slice, + }, + { + e: extension{ + idlTag: "listMapKey", + }, + kind: types.Slice, + }, + { + e: extension{ + idlTag: "k8s:openapi-gen", + }, + kind: "", + }, + } + for _, test := range methodTests { + if len(test.kind) > 0 { + if !test.e.hasKind() { + t.Errorf("%v: hasKind() expected (true), but received: false", test.e) + } + if test.kind != test.e.kind() { + t.Errorf("%v: kind() expected (%v), but received: %v", test.e, test.kind, test.e.kind()) + } + } else { + if test.e.hasKind() { + t.Errorf("%v: hasKind() expected (false), but received: true", test.e) + } + } + } +} + +func TestValidateMemberExtensions(t *testing.T) { + + patchStrategyExtension := extension{ + idlTag: "patchStrategy", + xName: "x-kubernetes-patch-strategy", + values: []string{"merge"}, + } + patchMergeKeyExtension := extension{ + idlTag: "patchMergeKey", + xName: "x-kubernetes-patch-merge-key", + values: []string{"key1", "key2"}, + } + listTypeExtension := extension{ + idlTag: "listType", + xName: "x-kubernetes-list-type", + values: []string{"atomic"}, + } + listMapKeysExtension := extension{ + idlTag: "listMapKey", + xName: "x-kubernetes-map-keys", + values: []string{"key1"}, + } + genExtension := extension{ + idlTag: "k8s:openapi-gen", + xName: "x-kubernetes-member-type", + values: []string{"value1"}, + } + + sliceField := types.Member{ + Name: "Containers", + Type: &types.Type{ + Kind: types.Slice, + }, + } + mapField := types.Member{ + Name: "Containers", + Type: &types.Type{ + Kind: types.Map, + }, + } + + var successTests = []struct { + extensions []extension + member types.Member + }{ + // Test single member extension + { + extensions: []extension{patchStrategyExtension}, + member: sliceField, + }, + // Test multiple member extensions + { + extensions: []extension{ + patchMergeKeyExtension, + listTypeExtension, + listMapKeysExtension, + genExtension, // Should not generate errors during type validation + }, + member: sliceField, + }, + } + for _, test := range successTests { + errors := validateMemberExtensions(test.extensions, &test.member) + if len(errors) > 0 { + t.Errorf("validateMemberExtensions: %v should have produced no errors. Errors: %v", + test.extensions, errors) + } + } + + var failureTests = []struct { + extensions []extension + member types.Member + }{ + // Test single member extension + { + extensions: []extension{patchStrategyExtension}, + member: mapField, + }, + // Test multiple member extensions + { + extensions: []extension{ + patchMergeKeyExtension, + listTypeExtension, + listMapKeysExtension, + }, + member: mapField, + }, + } + for _, test := range failureTests { + errors := validateMemberExtensions(test.extensions, &test.member) + if len(errors) != len(test.extensions) { + t.Errorf("validateMemberExtensions: %v should have produced all errors. Errors: %v", + test.extensions, errors) + } + } + +} diff --git a/vendor/k8s.io/kube-openapi/pkg/generators/openapi.go b/vendor/k8s.io/kube-openapi/pkg/generators/openapi.go new file mode 100644 index 000000000..2f4aff547 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/generators/openapi.go @@ -0,0 +1,665 @@ +/* +Copyright 2016 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 generators + +import ( + "bytes" + "fmt" + "io" + "path/filepath" + "reflect" + "sort" + "strings" + + "k8s.io/gengo/args" + "k8s.io/gengo/generator" + "k8s.io/gengo/namer" + "k8s.io/gengo/types" + openapi "k8s.io/kube-openapi/pkg/common" + + "github.com/golang/glog" +) + +// This is the comment tag that carries parameters for open API generation. +const tagName = "k8s:openapi-gen" +const tagOptional = "optional" + +// Known values for the tag. +const ( + tagValueTrue = "true" + tagValueFalse = "false" +) + +// Used for temporary validation of patch struct tags. +// TODO: Remove patch struct tag validation because they we are now consuming OpenAPI on server. +var tempPatchTags = [...]string{ + "patchMergeKey", + "patchStrategy", +} + +func getOpenAPITagValue(comments []string) []string { + return types.ExtractCommentTags("+", comments)[tagName] +} + +func getSingleTagsValue(comments []string, tag string) (string, error) { + tags, ok := types.ExtractCommentTags("+", comments)[tag] + if !ok || len(tags) == 0 { + return "", nil + } + if len(tags) > 1 { + return "", fmt.Errorf("multiple values are not allowed for tag %s", tag) + } + return tags[0], nil +} + +func hasOpenAPITagValue(comments []string, value string) bool { + tagValues := getOpenAPITagValue(comments) + for _, val := range tagValues { + if val == value { + return true + } + } + return false +} + +// hasOptionalTag returns true if the member has +optional in its comments or +// omitempty in its json tags. +func hasOptionalTag(m *types.Member) bool { + hasOptionalCommentTag := types.ExtractCommentTags( + "+", m.CommentLines)[tagOptional] != nil + hasOptionalJsonTag := strings.Contains( + reflect.StructTag(m.Tags).Get("json"), "omitempty") + return hasOptionalCommentTag || hasOptionalJsonTag +} + +type identityNamer struct{} + +func (_ identityNamer) Name(t *types.Type) string { + return t.Name.String() +} + +var _ namer.Namer = identityNamer{} + +// NameSystems returns the name system used by the generators in this package. +func NameSystems() namer.NameSystems { + return namer.NameSystems{ + "raw": namer.NewRawNamer("", nil), + "sorting_namer": identityNamer{}, + } +} + +// DefaultNameSystem returns the default name system for ordering the types to be +// processed by the generators in this package. +func DefaultNameSystem() string { + return "sorting_namer" +} + +func Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages { + boilerplate, err := arguments.LoadGoBoilerplate() + if err != nil { + glog.Fatalf("Failed loading boilerplate: %v", err) + } + header := append([]byte(fmt.Sprintf("// +build !%s\n\n", arguments.GeneratedBuildTag)), boilerplate...) + header = append(header, []byte( + ` +// This file was autogenerated by openapi-gen. Do not edit it manually! + +`)...) + + return generator.Packages{ + &generator.DefaultPackage{ + PackageName: filepath.Base(arguments.OutputPackagePath), + PackagePath: arguments.OutputPackagePath, + HeaderText: header, + GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { + return []generator.Generator{NewOpenAPIGen(arguments.OutputFileBaseName, arguments.OutputPackagePath, context)} + }, + FilterFunc: func(c *generator.Context, t *types.Type) bool { + // There is a conflict between this codegen and codecgen, we should avoid types generated for codecgen + if strings.HasPrefix(t.Name.Name, "codecSelfer") { + return false + } + pkg := context.Universe.Package(t.Name.Package) + if hasOpenAPITagValue(pkg.Comments, tagValueTrue) { + return !hasOpenAPITagValue(t.CommentLines, tagValueFalse) + } + if hasOpenAPITagValue(t.CommentLines, tagValueTrue) { + return true + } + return false + }, + }, + } +} + +const ( + specPackagePath = "github.com/go-openapi/spec" + openAPICommonPackagePath = "k8s.io/kube-openapi/pkg/common" +) + +// openApiGen produces a file with auto-generated OpenAPI functions. +type openAPIGen struct { + generator.DefaultGen + // TargetPackage is the package that will get GetOpenAPIDefinitions function returns all open API definitions. + targetPackage string + imports namer.ImportTracker + types []*types.Type + context *generator.Context +} + +func NewOpenAPIGen(sanitizedName string, targetPackage string, context *generator.Context) generator.Generator { + return &openAPIGen{ + DefaultGen: generator.DefaultGen{ + OptionalName: sanitizedName, + }, + imports: generator.NewImportTracker(), + targetPackage: targetPackage, + context: context, + } +} + +const nameTmpl = "schema_$.type|private$" + +func (g *openAPIGen) Namers(c *generator.Context) namer.NameSystems { + // Have the raw namer for this file track what it imports. + return namer.NameSystems{ + "raw": namer.NewRawNamer(g.targetPackage, g.imports), + "private": &namer.NameStrategy{ + Join: func(pre string, in []string, post string) string { + return strings.Join(in, "_") + }, + PrependPackageNames: 4, // enough to fully qualify from k8s.io/api/... + }, + } +} + +func (g *openAPIGen) Filter(c *generator.Context, t *types.Type) bool { + // There is a conflict between this codegen and codecgen, we should avoid types generated for codecgen + if strings.HasPrefix(t.Name.Name, "codecSelfer") { + return false + } + g.types = append(g.types, t) + return true +} + +func (g *openAPIGen) isOtherPackage(pkg string) bool { + if pkg == g.targetPackage { + return false + } + if strings.HasSuffix(pkg, "\""+g.targetPackage+"\"") { + return false + } + return true +} + +func (g *openAPIGen) Imports(c *generator.Context) []string { + importLines := []string{} + for _, singleImport := range g.imports.ImportLines() { + importLines = append(importLines, singleImport) + } + return importLines +} + +func argsFromType(t *types.Type) generator.Args { + return generator.Args{ + "type": t, + "ReferenceCallback": types.Ref(openAPICommonPackagePath, "ReferenceCallback"), + "OpenAPIDefinition": types.Ref(openAPICommonPackagePath, "OpenAPIDefinition"), + "SpecSchemaType": types.Ref(specPackagePath, "Schema"), + } +} + +func (g *openAPIGen) Init(c *generator.Context, w io.Writer) error { + sw := generator.NewSnippetWriter(w, c, "$", "$") + sw.Do("func GetOpenAPIDefinitions(ref $.ReferenceCallback|raw$) map[string]$.OpenAPIDefinition|raw$ {\n", argsFromType(nil)) + sw.Do("return map[string]$.OpenAPIDefinition|raw${\n", argsFromType(nil)) + + for _, t := range g.types { + err := newOpenAPITypeWriter(sw).generateCall(t) + if err != nil { + return err + } + } + + sw.Do("}\n", nil) + sw.Do("}\n\n", nil) + + return sw.Error() +} + +func (g *openAPIGen) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error { + glog.V(5).Infof("generating for type %v", t) + sw := generator.NewSnippetWriter(w, c, "$", "$") + err := newOpenAPITypeWriter(sw).generate(t) + if err != nil { + return err + } + return sw.Error() +} + +func getJsonTags(m *types.Member) []string { + jsonTag := reflect.StructTag(m.Tags).Get("json") + if jsonTag == "" { + return []string{} + } + return strings.Split(jsonTag, ",") +} + +func getReferableName(m *types.Member) string { + jsonTags := getJsonTags(m) + if len(jsonTags) > 0 { + if jsonTags[0] == "-" { + return "" + } else { + return jsonTags[0] + } + } else { + return m.Name + } +} + +func shouldInlineMembers(m *types.Member) bool { + jsonTags := getJsonTags(m) + return len(jsonTags) > 1 && jsonTags[1] == "inline" +} + +type openAPITypeWriter struct { + *generator.SnippetWriter + refTypes map[string]*types.Type + GetDefinitionInterface *types.Type +} + +func newOpenAPITypeWriter(sw *generator.SnippetWriter) openAPITypeWriter { + return openAPITypeWriter{ + SnippetWriter: sw, + refTypes: map[string]*types.Type{}, + } +} + +func methodReturnsValue(mt *types.Type, pkg, name string) bool { + if len(mt.Signature.Parameters) != 0 || len(mt.Signature.Results) != 1 { + return false + } + r := mt.Signature.Results[0] + return r.Name.Name == name && r.Name.Package == pkg +} + +func hasOpenAPIDefinitionMethod(t *types.Type) bool { + for mn, mt := range t.Methods { + if mn != "OpenAPIDefinition" { + continue + } + return methodReturnsValue(mt, openAPICommonPackagePath, "OpenAPIDefinition") + } + return false +} + +func hasOpenAPIDefinitionMethods(t *types.Type) bool { + var hasSchemaTypeMethod, hasOpenAPISchemaFormat bool + for mn, mt := range t.Methods { + switch mn { + case "OpenAPISchemaType": + hasSchemaTypeMethod = methodReturnsValue(mt, "", "[]string") + case "OpenAPISchemaFormat": + hasOpenAPISchemaFormat = methodReturnsValue(mt, "", "string") + } + } + return hasSchemaTypeMethod && hasOpenAPISchemaFormat +} + +// typeShortName returns short package name (e.g. the name x appears in package x definition) dot type name. +func typeShortName(t *types.Type) string { + return filepath.Base(t.Name.Package) + "." + t.Name.Name +} + +func (g openAPITypeWriter) generateMembers(t *types.Type, required []string) ([]string, error) { + var err error + for _, m := range t.Members { + if hasOpenAPITagValue(m.CommentLines, tagValueFalse) { + continue + } + if shouldInlineMembers(&m) { + required, err = g.generateMembers(m.Type, required) + if err != nil { + return required, err + } + continue + } + name := getReferableName(&m) + if name == "" { + continue + } + if !hasOptionalTag(&m) { + required = append(required, name) + } + if err = g.generateProperty(&m, t); err != nil { + glog.Errorf("Error when generating: %v, %v\n", name, m) + return required, err + } + } + return required, nil +} + +func (g openAPITypeWriter) generateCall(t *types.Type) error { + // Only generate for struct type and ignore the rest + switch t.Kind { + case types.Struct: + args := argsFromType(t) + g.Do("\"$.$\": ", t.Name) + if hasOpenAPIDefinitionMethod(t) { + g.Do("$.type|raw${}.OpenAPIDefinition(),\n", args) + } else { + g.Do(nameTmpl+"(ref),\n", args) + } + } + return g.Error() +} + +func (g openAPITypeWriter) generate(t *types.Type) error { + // Only generate for struct type and ignore the rest + switch t.Kind { + case types.Struct: + if hasOpenAPIDefinitionMethod(t) { + // already invoked directly + return nil + } + + args := argsFromType(t) + g.Do("func "+nameTmpl+"(ref $.ReferenceCallback|raw$) $.OpenAPIDefinition|raw$ {\n", args) + if hasOpenAPIDefinitionMethods(t) { + g.Do("return $.OpenAPIDefinition|raw${\n"+ + "Schema: spec.Schema{\n"+ + "SchemaProps: spec.SchemaProps{\n", args) + g.generateDescription(t.CommentLines) + g.Do("Type:$.type|raw${}.OpenAPISchemaType(),\n"+ + "Format:$.type|raw${}.OpenAPISchemaFormat(),\n"+ + "},\n"+ + "},\n"+ + "}\n}\n\n", args) + return nil + } + g.Do("return $.OpenAPIDefinition|raw${\nSchema: spec.Schema{\nSchemaProps: spec.SchemaProps{\n", args) + g.generateDescription(t.CommentLines) + g.Do("Properties: map[string]$.SpecSchemaType|raw${\n", args) + required, err := g.generateMembers(t, []string{}) + if err != nil { + return err + } + g.Do("},\n", nil) + if len(required) > 0 { + g.Do("Required: []string{\"$.$\"},\n", strings.Join(required, "\",\"")) + } + g.Do("},\n", nil) + if err := g.generateStructExtensions(t); err != nil { + return err + } + g.Do("},\n", nil) + g.Do("Dependencies: []string{\n", args) + // Map order is undefined, sort them or we may get a different file generated each time. + keys := []string{} + for k := range g.refTypes { + keys = append(keys, k) + } + sort.Strings(keys) + for _, k := range keys { + v := g.refTypes[k] + if t, _ := openapi.GetOpenAPITypeFormat(v.String()); t != "" { + // This is a known type, we do not need a reference to it + // Will eliminate special case of time.Time + continue + } + g.Do("\"$.$\",", k) + } + g.Do("},\n}\n}\n\n", nil) + } + return nil +} + +func (g openAPITypeWriter) generateStructExtensions(t *types.Type) error { + extensions, errors := parseExtensions(t.CommentLines) + // Initially, we will only log struct extension errors. + if len(errors) > 0 { + for _, e := range errors { + glog.V(2).Infof("[%s]: %s\n", t.String(), e) + } + } + // TODO(seans3): Validate struct extensions here. + g.emitExtensions(extensions) + return nil +} + +func (g openAPITypeWriter) generateMemberExtensions(m *types.Member, parent *types.Type) error { + extensions, parseErrors := parseExtensions(m.CommentLines) + validationErrors := validateMemberExtensions(extensions, m) + errors := append(parseErrors, validationErrors...) + // Initially, we will only log member extension errors. + if len(errors) > 0 { + errorPrefix := fmt.Sprintf("[%s] %s:", parent.String(), m.String()) + for _, e := range errors { + glog.V(2).Infof("%s %s\n", errorPrefix, e) + } + } + g.emitExtensions(extensions) + return nil +} + +func (g openAPITypeWriter) emitExtensions(extensions []extension) { + // If any extensions exist, then emit code to create them. + if len(extensions) == 0 { + return + } + g.Do("VendorExtensible: spec.VendorExtensible{\nExtensions: spec.Extensions{\n", nil) + for _, extension := range extensions { + g.Do("\"$.$\": ", extension.xName) + if extension.hasMultipleValues() { + g.Do("[]string{\n", nil) + } + for _, value := range extension.values { + g.Do("\"$.$\",\n", value) + } + if extension.hasMultipleValues() { + g.Do("},\n", nil) + } + } + g.Do("},\n},\n", nil) +} + +// TODO(#44005): Move this validation outside of this generator (probably to policy verifier) +func (g openAPITypeWriter) validatePatchTags(m *types.Member, parent *types.Type) error { + // TODO: Remove patch struct tag validation because they we are now consuming OpenAPI on server. + for _, tagKey := range tempPatchTags { + structTagValue := reflect.StructTag(m.Tags).Get(tagKey) + commentTagValue, err := getSingleTagsValue(m.CommentLines, tagKey) + if err != nil { + return err + } + if structTagValue != commentTagValue { + return fmt.Errorf("Tags in comment and struct should match for member (%s) of (%s)", + m.Name, parent.Name.String()) + } + } + return nil +} + +func (g openAPITypeWriter) generateDescription(CommentLines []string) { + var buffer bytes.Buffer + delPrevChar := func() { + if buffer.Len() > 0 { + buffer.Truncate(buffer.Len() - 1) // Delete the last " " or "\n" + } + } + + for _, line := range CommentLines { + // Ignore all lines after --- + if line == "---" { + break + } + line = strings.TrimRight(line, " ") + leading := strings.TrimLeft(line, " ") + switch { + case len(line) == 0: // Keep paragraphs + delPrevChar() + buffer.WriteString("\n\n") + case strings.HasPrefix(leading, "TODO"): // Ignore one line TODOs + case strings.HasPrefix(leading, "+"): // Ignore instructions to go2idl + default: + if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") { + delPrevChar() + line = "\n" + line + "\n" // Replace it with newline. This is useful when we have a line with: "Example:\n\tJSON-someting..." + } else { + line += " " + } + buffer.WriteString(line) + } + } + + postDoc := strings.TrimRight(buffer.String(), "\n") + postDoc = strings.Replace(postDoc, "\\\"", "\"", -1) // replace user's \" to " + postDoc = strings.Replace(postDoc, "\"", "\\\"", -1) // Escape " + postDoc = strings.Replace(postDoc, "\n", "\\n", -1) + postDoc = strings.Replace(postDoc, "\t", "\\t", -1) + postDoc = strings.Trim(postDoc, " ") + if postDoc != "" { + g.Do("Description: \"$.$\",\n", postDoc) + } +} + +func (g openAPITypeWriter) generateProperty(m *types.Member, parent *types.Type) error { + name := getReferableName(m) + if name == "" { + return nil + } + if err := g.validatePatchTags(m, parent); err != nil { + return err + } + g.Do("\"$.$\": {\n", name) + if err := g.generateMemberExtensions(m, parent); err != nil { + return err + } + g.Do("SchemaProps: spec.SchemaProps{\n", nil) + g.generateDescription(m.CommentLines) + jsonTags := getJsonTags(m) + if len(jsonTags) > 1 && jsonTags[1] == "string" { + g.generateSimpleProperty("string", "") + g.Do("},\n},\n", nil) + return nil + } + t := resolveAliasAndPtrType(m.Type) + // If we can get a openAPI type and format for this type, we consider it to be simple property + typeString, format := openapi.GetOpenAPITypeFormat(t.String()) + if typeString != "" { + g.generateSimpleProperty(typeString, format) + g.Do("},\n},\n", nil) + return nil + } + switch t.Kind { + case types.Builtin: + return fmt.Errorf("please add type %v to getOpenAPITypeFormat function", t) + case types.Map: + if err := g.generateMapProperty(t); err != nil { + return err + } + case types.Slice, types.Array: + if err := g.generateSliceProperty(t); err != nil { + return err + } + case types.Struct, types.Interface: + g.generateReferenceProperty(t) + default: + return fmt.Errorf("cannot generate spec for type %v", t) + } + g.Do("},\n},\n", nil) + return g.Error() +} + +func (g openAPITypeWriter) generateSimpleProperty(typeString, format string) { + g.Do("Type: []string{\"$.$\"},\n", typeString) + g.Do("Format: \"$.$\",\n", format) +} + +func (g openAPITypeWriter) generateReferenceProperty(t *types.Type) { + g.refTypes[t.Name.String()] = t + g.Do("Ref: ref(\"$.$\"),\n", t.Name.String()) +} + +func resolveAliasAndPtrType(t *types.Type) *types.Type { + var prev *types.Type + for prev != t { + prev = t + if t.Kind == types.Alias { + t = t.Underlying + } + if t.Kind == types.Pointer { + t = t.Elem + } + } + return t +} + +func (g openAPITypeWriter) generateMapProperty(t *types.Type) error { + keyType := resolveAliasAndPtrType(t.Key) + elemType := resolveAliasAndPtrType(t.Elem) + + // According to OpenAPI examples, only map from string is supported + if keyType.Name.Name != "string" { + return fmt.Errorf("map with non-string keys are not supported by OpenAPI in %v", t) + } + g.Do("Type: []string{\"object\"},\n", nil) + g.Do("AdditionalProperties: &spec.SchemaOrBool{\nSchema: &spec.Schema{\nSchemaProps: spec.SchemaProps{\n", nil) + typeString, format := openapi.GetOpenAPITypeFormat(elemType.String()) + if typeString != "" { + g.generateSimpleProperty(typeString, format) + g.Do("},\n},\n},\n", nil) + return nil + } + switch elemType.Kind { + case types.Builtin: + return fmt.Errorf("please add type %v to getOpenAPITypeFormat function", elemType) + case types.Struct: + g.generateReferenceProperty(elemType) + case types.Slice, types.Array: + g.generateSliceProperty(elemType) + default: + return fmt.Errorf("map Element kind %v is not supported in %v", elemType.Kind, t.Name) + } + g.Do("},\n},\n},\n", nil) + return nil +} + +func (g openAPITypeWriter) generateSliceProperty(t *types.Type) error { + elemType := resolveAliasAndPtrType(t.Elem) + g.Do("Type: []string{\"array\"},\n", nil) + g.Do("Items: &spec.SchemaOrArray{\nSchema: &spec.Schema{\nSchemaProps: spec.SchemaProps{\n", nil) + typeString, format := openapi.GetOpenAPITypeFormat(elemType.String()) + if typeString != "" { + g.generateSimpleProperty(typeString, format) + g.Do("},\n},\n},\n", nil) + return nil + } + switch elemType.Kind { + case types.Builtin: + return fmt.Errorf("please add type %v to getOpenAPITypeFormat function", elemType) + case types.Struct: + g.generateReferenceProperty(elemType) + case types.Slice, types.Array: + g.generateSliceProperty(elemType) + default: + return fmt.Errorf("slice Element kind %v is not supported in %v", elemType.Kind, t) + } + g.Do("},\n},\n},\n", nil) + return nil +} diff --git a/vendor/k8s.io/kube-openapi/pkg/generators/openapi_test.go b/vendor/k8s.io/kube-openapi/pkg/generators/openapi_test.go new file mode 100644 index 000000000..6713b8324 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/generators/openapi_test.go @@ -0,0 +1,625 @@ +/* +Copyright 2016 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 generators + +import ( + "bytes" + "fmt" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "k8s.io/gengo/generator" + "k8s.io/gengo/namer" + "k8s.io/gengo/parser" + "k8s.io/gengo/types" +) + +func construct(t *testing.T, files map[string]string, testNamer namer.Namer) (*parser.Builder, types.Universe, []*types.Type) { + b := parser.New() + for name, src := range files { + if err := b.AddFileForTest(filepath.Dir(name), name, []byte(src)); err != nil { + t.Fatal(err) + } + } + u, err := b.FindTypes() + if err != nil { + t.Fatal(err) + } + orderer := namer.Orderer{Namer: testNamer} + o := orderer.OrderUniverse(u) + return b, u, o +} + +func testOpenAPITypeWriter(t *testing.T, code string) (error, error, *assert.Assertions, *bytes.Buffer, *bytes.Buffer) { + assert := assert.New(t) + var testFiles = map[string]string{ + "base/foo/bar.go": code, + } + rawNamer := namer.NewRawNamer("o", nil) + namers := namer.NameSystems{ + "raw": namer.NewRawNamer("", nil), + "private": &namer.NameStrategy{ + Join: func(pre string, in []string, post string) string { + return strings.Join(in, "_") + }, + PrependPackageNames: 4, // enough to fully qualify from k8s.io/api/... + }, + } + builder, universe, _ := construct(t, testFiles, rawNamer) + context, err := generator.NewContext(builder, namers, "raw") + if err != nil { + t.Fatal(err) + } + blahT := universe.Type(types.Name{Package: "base/foo", Name: "Blah"}) + + callBuffer := &bytes.Buffer{} + callSW := generator.NewSnippetWriter(callBuffer, context, "$", "$") + callError := newOpenAPITypeWriter(callSW).generateCall(blahT) + + funcBuffer := &bytes.Buffer{} + funcSW := generator.NewSnippetWriter(funcBuffer, context, "$", "$") + funcError := newOpenAPITypeWriter(funcSW).generate(blahT) + + return callError, funcError, assert, callBuffer, funcBuffer +} + +func TestSimple(t *testing.T) { + callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, ` +package foo + +// Blah is a test. +// +k8s:openapi-gen=true +// +k8s:openapi-gen=x-kubernetes-type-tag:type_test +type Blah struct { + // A simple string + String string + // A simple int + Int int `+"`"+`json:",omitempty"`+"`"+` + // An int considered string simple int + IntString int `+"`"+`json:",string"`+"`"+` + // A simple int64 + Int64 int64 + // A simple int32 + Int32 int32 + // A simple int16 + Int16 int16 + // A simple int8 + Int8 int8 + // A simple int + Uint uint + // A simple int64 + Uint64 uint64 + // A simple int32 + Uint32 uint32 + // A simple int16 + Uint16 uint16 + // A simple int8 + Uint8 uint8 + // A simple byte + Byte byte + // A simple boolean + Bool bool + // A simple float64 + Float64 float64 + // A simple float32 + Float32 float32 + // a base64 encoded characters + ByteArray []byte + // a member with an extension + // +k8s:openapi-gen=x-kubernetes-member-tag:member_test + WithExtension string + // a member with struct tag as extension + // +patchStrategy=merge + // +patchMergeKey=pmk + WithStructTagExtension string `+"`"+`patchStrategy:"merge" patchMergeKey:"pmk"`+"`"+` + // a member with a list type + // +listType=atomic + WithListType []string +} + `) + if callErr != nil { + t.Fatal(callErr) + } + if funcErr != nil { + t.Fatal(funcErr) + } + assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref), +`, callBuffer.String()) + assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition { +return common.OpenAPIDefinition{ +Schema: spec.Schema{ +SchemaProps: spec.SchemaProps{ +Description: "Blah is a test.", +Properties: map[string]spec.Schema{ +"String": { +SchemaProps: spec.SchemaProps{ +Description: "A simple string", +Type: []string{"string"}, +Format: "", +}, +}, +"Int64": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int64", +Type: []string{"integer"}, +Format: "int64", +}, +}, +"Int32": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int32", +Type: []string{"integer"}, +Format: "int32", +}, +}, +"Int16": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int16", +Type: []string{"integer"}, +Format: "int32", +}, +}, +"Int8": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int8", +Type: []string{"integer"}, +Format: "byte", +}, +}, +"Uint": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int", +Type: []string{"integer"}, +Format: "int32", +}, +}, +"Uint64": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int64", +Type: []string{"integer"}, +Format: "int64", +}, +}, +"Uint32": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int32", +Type: []string{"integer"}, +Format: "int64", +}, +}, +"Uint16": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int16", +Type: []string{"integer"}, +Format: "int32", +}, +}, +"Uint8": { +SchemaProps: spec.SchemaProps{ +Description: "A simple int8", +Type: []string{"integer"}, +Format: "byte", +}, +}, +"Byte": { +SchemaProps: spec.SchemaProps{ +Description: "A simple byte", +Type: []string{"integer"}, +Format: "byte", +}, +}, +"Bool": { +SchemaProps: spec.SchemaProps{ +Description: "A simple boolean", +Type: []string{"boolean"}, +Format: "", +}, +}, +"Float64": { +SchemaProps: spec.SchemaProps{ +Description: "A simple float64", +Type: []string{"number"}, +Format: "double", +}, +}, +"Float32": { +SchemaProps: spec.SchemaProps{ +Description: "A simple float32", +Type: []string{"number"}, +Format: "float", +}, +}, +"ByteArray": { +SchemaProps: spec.SchemaProps{ +Description: "a base64 encoded characters", +Type: []string{"string"}, +Format: "byte", +}, +}, +"WithExtension": { +VendorExtensible: spec.VendorExtensible{ +Extensions: spec.Extensions{ +"x-kubernetes-member-tag": "member_test", +}, +}, +SchemaProps: spec.SchemaProps{ +Description: "a member with an extension", +Type: []string{"string"}, +Format: "", +}, +}, +"WithStructTagExtension": { +VendorExtensible: spec.VendorExtensible{ +Extensions: spec.Extensions{ +"x-kubernetes-patch-merge-key": "pmk", +"x-kubernetes-patch-strategy": "merge", +}, +}, +SchemaProps: spec.SchemaProps{ +Description: "a member with struct tag as extension", +Type: []string{"string"}, +Format: "", +}, +}, +"WithListType": { +VendorExtensible: spec.VendorExtensible{ +Extensions: spec.Extensions{ +"x-kubernetes-list-type": "atomic", +}, +}, +SchemaProps: spec.SchemaProps{ +Description: "a member with a list type", +Type: []string{"array"}, +Items: &spec.SchemaOrArray{ +Schema: &spec.Schema{ +SchemaProps: spec.SchemaProps{ +Type: []string{"string"}, +Format: "", +}, +}, +}, +}, +}, +}, +Required: []string{"String","Int64","Int32","Int16","Int8","Uint","Uint64","Uint32","Uint16","Uint8","Byte","Bool","Float64","Float32","ByteArray","WithExtension","WithStructTagExtension","WithListType"}, +}, +VendorExtensible: spec.VendorExtensible{ +Extensions: spec.Extensions{ +"x-kubernetes-type-tag": "type_test", +}, +}, +}, +Dependencies: []string{ +}, +} +} + +`, funcBuffer.String()) +} + +func TestFailingSample1(t *testing.T) { + _, funcErr, assert, _, _ := testOpenAPITypeWriter(t, ` +package foo + +// Map sample tests openAPIGen.generateMapProperty method. +type Blah struct { + // A sample String to String map + StringToArray map[string]map[string]string +} + `) + if assert.Error(funcErr, "An error was expected") { + assert.Equal(funcErr, fmt.Errorf("map Element kind Map is not supported in map[string]map[string]string")) + } +} + +func TestFailingSample2(t *testing.T) { + _, funcErr, assert, _, _ := testOpenAPITypeWriter(t, ` +package foo + +// Map sample tests openAPIGen.generateMapProperty method. +type Blah struct { + // A sample String to String map + StringToArray map[int]string +} `) + if assert.Error(funcErr, "An error was expected") { + assert.Equal(funcErr, fmt.Errorf("map with non-string keys are not supported by OpenAPI in map[int]string")) + } +} + +func TestCustomDef(t *testing.T) { + callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, ` +package foo + +import openapi "k8s.io/kube-openapi/pkg/common" + +type Blah struct { +} + +func (_ Blah) OpenAPIDefinition() openapi.OpenAPIDefinition { + return openapi.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "date-time", + }, + }, + } +} +`) + if callErr != nil { + t.Fatal(callErr) + } + if funcErr != nil { + t.Fatal(funcErr) + } + assert.Equal(`"base/foo.Blah": foo.Blah{}.OpenAPIDefinition(), +`, callBuffer.String()) + assert.Equal(``, funcBuffer.String()) +} + +func TestCustomDefs(t *testing.T) { + callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, ` +package foo + +// Blah is a custom type +type Blah struct { +} + +func (_ Blah) OpenAPISchemaType() []string { return []string{"string"} } +func (_ Blah) OpenAPISchemaFormat() string { return "date-time" } +`) + if callErr != nil { + t.Fatal(callErr) + } + if funcErr != nil { + t.Fatal(funcErr) + } + assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref), +`, callBuffer.String()) + assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition { +return common.OpenAPIDefinition{ +Schema: spec.Schema{ +SchemaProps: spec.SchemaProps{ +Description: "Blah is a custom type", +Type:foo.Blah{}.OpenAPISchemaType(), +Format:foo.Blah{}.OpenAPISchemaFormat(), +}, +}, +} +} + +`, funcBuffer.String()) +} + +func TestPointer(t *testing.T) { + callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, ` +package foo + +// PointerSample demonstrate pointer's properties +type Blah struct { + // A string pointer + StringPointer *string + // A struct pointer + StructPointer *Blah + // A slice pointer + SlicePointer *[]string + // A map pointer + MapPointer *map[string]string +} + `) + if callErr != nil { + t.Fatal(callErr) + } + if funcErr != nil { + t.Fatal(funcErr) + } + assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref), +`, callBuffer.String()) + assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition { +return common.OpenAPIDefinition{ +Schema: spec.Schema{ +SchemaProps: spec.SchemaProps{ +Description: "PointerSample demonstrate pointer's properties", +Properties: map[string]spec.Schema{ +"StringPointer": { +SchemaProps: spec.SchemaProps{ +Description: "A string pointer", +Type: []string{"string"}, +Format: "", +}, +}, +"StructPointer": { +SchemaProps: spec.SchemaProps{ +Description: "A struct pointer", +Ref: ref("base/foo.Blah"), +}, +}, +"SlicePointer": { +SchemaProps: spec.SchemaProps{ +Description: "A slice pointer", +Type: []string{"array"}, +Items: &spec.SchemaOrArray{ +Schema: &spec.Schema{ +SchemaProps: spec.SchemaProps{ +Type: []string{"string"}, +Format: "", +}, +}, +}, +}, +}, +"MapPointer": { +SchemaProps: spec.SchemaProps{ +Description: "A map pointer", +Type: []string{"object"}, +AdditionalProperties: &spec.SchemaOrBool{ +Schema: &spec.Schema{ +SchemaProps: spec.SchemaProps{ +Type: []string{"string"}, +Format: "", +}, +}, +}, +}, +}, +}, +Required: []string{"StringPointer","StructPointer","SlicePointer","MapPointer"}, +}, +}, +Dependencies: []string{ +"base/foo.Blah",}, +} +} + +`, funcBuffer.String()) +} + +func TestNestedLists(t *testing.T) { + callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, ` +package foo + +// Blah is a test. +// +k8s:openapi-gen=true +// +k8s:openapi-gen=x-kubernetes-type-tag:type_test +type Blah struct { + // Nested list + NestedList [][]int64 +} +`) + if callErr != nil { + t.Fatal(callErr) + } + if funcErr != nil { + t.Fatal(funcErr) + } + assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref), +`, callBuffer.String()) + assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition { +return common.OpenAPIDefinition{ +Schema: spec.Schema{ +SchemaProps: spec.SchemaProps{ +Description: "Blah is a test.", +Properties: map[string]spec.Schema{ +"NestedList": { +SchemaProps: spec.SchemaProps{ +Description: "Nested list", +Type: []string{"array"}, +Items: &spec.SchemaOrArray{ +Schema: &spec.Schema{ +SchemaProps: spec.SchemaProps{ +Type: []string{"array"}, +Items: &spec.SchemaOrArray{ +Schema: &spec.Schema{ +SchemaProps: spec.SchemaProps{ +Type: []string{"integer"}, +Format: "int64", +}, +}, +}, +}, +}, +}, +}, +}, +}, +Required: []string{"NestedList"}, +}, +VendorExtensible: spec.VendorExtensible{ +Extensions: spec.Extensions{ +"x-kubernetes-type-tag": "type_test", +}, +}, +}, +Dependencies: []string{ +}, +} +} + +`, funcBuffer.String()) +} + +func TestExtensions(t *testing.T) { + callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, ` +package foo + +// Blah is a test. +// +k8s:openapi-gen=true +// +k8s:openapi-gen=x-kubernetes-type-tag:type_test +type Blah struct { + // a member with a list type + // +listType=map + // +listMapKey=port + // +listMapKey=protocol + WithListField []string +} + `) + if callErr != nil { + t.Fatal(callErr) + } + if funcErr != nil { + t.Fatal(funcErr) + } + assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref), +`, callBuffer.String()) + assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition { +return common.OpenAPIDefinition{ +Schema: spec.Schema{ +SchemaProps: spec.SchemaProps{ +Description: "Blah is a test.", +Properties: map[string]spec.Schema{ +"WithListField": { +VendorExtensible: spec.VendorExtensible{ +Extensions: spec.Extensions{ +"x-kubernetes-list-map-keys": []string{ +"port", +"protocol", +}, +"x-kubernetes-list-type": "map", +}, +}, +SchemaProps: spec.SchemaProps{ +Description: "a member with a list type", +Type: []string{"array"}, +Items: &spec.SchemaOrArray{ +Schema: &spec.Schema{ +SchemaProps: spec.SchemaProps{ +Type: []string{"string"}, +Format: "", +}, +}, +}, +}, +}, +}, +Required: []string{"WithListField"}, +}, +VendorExtensible: spec.VendorExtensible{ +Extensions: spec.Extensions{ +"x-kubernetes-type-tag": "type_test", +}, +}, +}, +Dependencies: []string{ +}, +} +} + +`, funcBuffer.String()) +} diff --git a/vendor/k8s.io/kube-openapi/pkg/handler/handler.go b/vendor/k8s.io/kube-openapi/pkg/handler/handler.go new file mode 100644 index 000000000..c4bbc0bff --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/handler/handler.go @@ -0,0 +1,272 @@ +/* +Copyright 2017 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 handler + +import ( + "bytes" + "compress/gzip" + "crypto/sha512" + "encoding/json" + "fmt" + "mime" + "net/http" + "strings" + "sync" + "time" + + "bitbucket.org/ww/goautoneg" + + yaml "gopkg.in/yaml.v2" + + "github.com/NYTimes/gziphandler" + restful "github.com/emicklei/go-restful" + "github.com/go-openapi/spec" + "github.com/golang/protobuf/proto" + openapi_v2 "github.com/googleapis/gnostic/OpenAPIv2" + "github.com/googleapis/gnostic/compiler" + + "k8s.io/kube-openapi/pkg/builder" + "k8s.io/kube-openapi/pkg/common" +) + +const ( + jsonExt = ".json" + + mimeJson = "application/json" + // TODO(mehdy): change @68f4ded to a version tag when gnostic add version tags. + mimePb = "application/com.github.googleapis.gnostic.OpenAPIv2@68f4ded+protobuf" + mimePbGz = "application/x-gzip" +) + +// OpenAPIService is the service responsible for serving OpenAPI spec. It has +// the ability to safely change the spec while serving it. +type OpenAPIService struct { + // rwMutex protects All members of this service. + rwMutex sync.RWMutex + + lastModified time.Time + + specBytes []byte + specPb []byte + specPbGz []byte + + specBytesETag string + specPbETag string + specPbGzETag string +} + +func init() { + mime.AddExtensionType(".json", mimeJson) + mime.AddExtensionType(".pb-v1", mimePb) + mime.AddExtensionType(".gz", mimePbGz) +} + +func computeETag(data []byte) string { + return fmt.Sprintf("\"%X\"", sha512.Sum512(data)) +} + +// NOTE: [DEPRECATION] We will announce deprecation for format-separated endpoints for OpenAPI spec, +// and switch to a single /openapi/v2 endpoint in Kubernetes 1.10. The design doc and deprecation process +// are tracked at: https://docs.google.com/document/d/19lEqE9lc4yHJ3WJAJxS_G7TcORIJXGHyq3wpwcH28nU. +// +// BuildAndRegisterOpenAPIService builds the spec and registers a handler to provide access to it. +// Use this method if your OpenAPI spec is static. If you want to update the spec, use BuildOpenAPISpec then RegisterOpenAPIService. +func BuildAndRegisterOpenAPIService(servePath string, webServices []*restful.WebService, config *common.Config, handler common.PathHandler) (*OpenAPIService, error) { + spec, err := builder.BuildOpenAPISpec(webServices, config) + if err != nil { + return nil, err + } + return RegisterOpenAPIService(spec, servePath, handler) +} + +// NOTE: [DEPRECATION] We will announce deprecation for format-separated endpoints for OpenAPI spec, +// and switch to a single /openapi/v2 endpoint in Kubernetes 1.10. The design doc and deprecation process +// are tracked at: https://docs.google.com/document/d/19lEqE9lc4yHJ3WJAJxS_G7TcORIJXGHyq3wpwcH28nU. +// +// RegisterOpenAPIService registers a handler to provide access to provided swagger spec. +// Note: servePath should end with ".json" as the RegisterOpenAPIService assume it is serving a +// json file and will also serve .pb and .gz files. +func RegisterOpenAPIService(openapiSpec *spec.Swagger, servePath string, handler common.PathHandler) (*OpenAPIService, error) { + if !strings.HasSuffix(servePath, jsonExt) { + return nil, fmt.Errorf("serving path must end with \"%s\"", jsonExt) + } + + servePathBase := strings.TrimSuffix(servePath, jsonExt) + + o := OpenAPIService{} + if err := o.UpdateSpec(openapiSpec); err != nil { + return nil, err + } + + type fileInfo struct { + ext string + getDataAndETag func() ([]byte, string, time.Time) + } + + files := []fileInfo{ + {".json", o.getSwaggerBytes}, + {"-2.0.0.json", o.getSwaggerBytes}, + {"-2.0.0.pb-v1", o.getSwaggerPbBytes}, + {"-2.0.0.pb-v1.gz", o.getSwaggerPbGzBytes}, + } + + for _, file := range files { + path := servePathBase + file.ext + getDataAndETag := file.getDataAndETag + handler.Handle(path, gziphandler.GzipHandler(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + data, etag, lastModified := getDataAndETag() + w.Header().Set("Etag", etag) + + // ServeContent will take care of caching using eTag. + http.ServeContent(w, r, path, lastModified, bytes.NewReader(data)) + }), + )) + } + + return &o, nil +} + +func (o *OpenAPIService) getSwaggerBytes() ([]byte, string, time.Time) { + o.rwMutex.RLock() + defer o.rwMutex.RUnlock() + return o.specBytes, o.specBytesETag, o.lastModified +} + +func (o *OpenAPIService) getSwaggerPbBytes() ([]byte, string, time.Time) { + o.rwMutex.RLock() + defer o.rwMutex.RUnlock() + return o.specPb, o.specPbETag, o.lastModified +} + +func (o *OpenAPIService) getSwaggerPbGzBytes() ([]byte, string, time.Time) { + o.rwMutex.RLock() + defer o.rwMutex.RUnlock() + return o.specPbGz, o.specPbGzETag, o.lastModified +} + +func (o *OpenAPIService) UpdateSpec(openapiSpec *spec.Swagger) (err error) { + specBytes, err := json.MarshalIndent(openapiSpec, " ", " ") + if err != nil { + return err + } + specPb, err := toProtoBinary(specBytes) + if err != nil { + return err + } + specPbGz := toGzip(specPb) + + specBytesETag := computeETag(specBytes) + specPbETag := computeETag(specPb) + specPbGzETag := computeETag(specPbGz) + + lastModified := time.Now() + + o.rwMutex.Lock() + defer o.rwMutex.Unlock() + + o.specBytes = specBytes + o.specPb = specPb + o.specPbGz = specPbGz + o.specBytesETag = specBytesETag + o.specPbETag = specPbETag + o.specPbGzETag = specPbGzETag + o.lastModified = lastModified + + return nil +} + +func toProtoBinary(spec []byte) ([]byte, error) { + var info yaml.MapSlice + err := yaml.Unmarshal(spec, &info) + if err != nil { + return nil, err + } + document, err := openapi_v2.NewDocument(info, compiler.NewContext("$root", nil)) + if err != nil { + return nil, err + } + return proto.Marshal(document) +} + +func toGzip(data []byte) []byte { + var buf bytes.Buffer + zw := gzip.NewWriter(&buf) + zw.Write(data) + zw.Close() + return buf.Bytes() +} + +// RegisterOpenAPIVersionedService registers a handler to provide access to provided swagger spec. +func RegisterOpenAPIVersionedService(openapiSpec *spec.Swagger, servePath string, handler common.PathHandler) (*OpenAPIService, error) { + o := OpenAPIService{} + if err := o.UpdateSpec(openapiSpec); err != nil { + return nil, err + } + + accepted := []struct { + Type string + SubType string + GetDataAndETag func() ([]byte, string, time.Time) + }{ + {"application", "json", o.getSwaggerBytes}, + {"application", "com.github.proto-openapi.spec.v2@v1.0+protobuf", o.getSwaggerPbBytes}, + } + + handler.Handle(servePath, gziphandler.GzipHandler(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + decipherableFormats := r.Header.Get("Accept") + if decipherableFormats == "" { + decipherableFormats = "*/*" + } + clauses := goautoneg.ParseAccept(decipherableFormats) + w.Header().Add("Vary", "Accept") + for _, clause := range clauses { + for _, accepts := range accepted { + if clause.Type != accepts.Type && clause.Type != "*" { + continue + } + if clause.SubType != accepts.SubType && clause.SubType != "*" { + continue + } + + // serve the first matching media type in the sorted clause list + data, etag, lastModified := accepts.GetDataAndETag() + w.Header().Set("Etag", etag) + // ServeContent will take care of caching using eTag. + http.ServeContent(w, r, servePath, lastModified, bytes.NewReader(data)) + return + } + } + // Return 406 for not acceptable format + w.WriteHeader(406) + return + }), + )) + + return &o, nil +} + +// BuildAndRegisterOpenAPIVersionedService builds the spec and registers a handler to provide access to it. +// Use this method if your OpenAPI spec is static. If you want to update the spec, use BuildOpenAPISpec then RegisterOpenAPIVersionedService. +func BuildAndRegisterOpenAPIVersionedService(servePath string, webServices []*restful.WebService, config *common.Config, handler common.PathHandler) (*OpenAPIService, error) { + spec, err := builder.BuildOpenAPISpec(webServices, config) + if err != nil { + return nil, err + } + return RegisterOpenAPIVersionedService(spec, servePath, handler) +} diff --git a/vendor/k8s.io/kube-openapi/pkg/handler/handler_test.go b/vendor/k8s.io/kube-openapi/pkg/handler/handler_test.go new file mode 100644 index 000000000..8d7146c10 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/handler/handler_test.go @@ -0,0 +1,89 @@ +package handler + +import ( + "encoding/json" + "io/ioutil" + "net/http" + "net/http/httptest" + "reflect" + "testing" + + "github.com/go-openapi/spec" +) + +var returnedSwagger = []byte(`{ + "swagger": "2.0", + "info": { + "title": "Kubernetes", + "version": "v1.11.0" + }}`) + +func TestRegisterOpenAPIVersionedService(t *testing.T) { + var s spec.Swagger + err := s.UnmarshalJSON(returnedSwagger) + if err != nil { + t.Errorf("Unexpected error in unmarshalling SwaggerJSON: %v", err) + } + + returnedJSON, err := json.MarshalIndent(s, " ", " ") + if err != nil { + t.Errorf("Unexpected error in preparing returnedJSON: %v", err) + } + returnedPb, err := toProtoBinary(returnedJSON) + if err != nil { + t.Errorf("Unexpected error in preparing returnedPb: %v", err) + } + + mux := http.NewServeMux() + _, err = RegisterOpenAPIVersionedService(&s, "/openapi/v2", mux) + if err != nil { + t.Errorf("Unexpected error in register OpenAPI versioned service: %v", err) + } + server := httptest.NewServer(mux) + defer server.Close() + client := server.Client() + + tcs := []struct { + acceptHeader string + respStatus int + respBody []byte + }{ + {"", 200, returnedJSON}, + {"*/*", 200, returnedJSON}, + {"application/*", 200, returnedJSON}, + {"application/json", 200, returnedJSON}, + {"test/test", 406, []byte{}}, + {"application/test", 406, []byte{}}, + {"application/test, */*", 200, returnedJSON}, + {"application/test, application/json", 200, returnedJSON}, + {"application/com.github.proto-openapi.spec.v2@v1.0+protobuf", 200, returnedPb}, + {"application/json, application/com.github.proto-openapi.spec.v2@v1.0+protobuf", 200, returnedJSON}, + {"application/com.github.proto-openapi.spec.v2@v1.0+protobuf, application/json", 200, returnedPb}, + {"application/com.github.proto-openapi.spec.v2@v1.0+protobuf; q=0.5, application/json", 200, returnedJSON}, + } + + for _, tc := range tcs { + req, err := http.NewRequest("GET", server.URL+"/openapi/v2", nil) + if err != nil { + t.Errorf("Accept: %v: Unexpected error in creating new request: %v", tc.acceptHeader, err) + } + + req.Header.Add("Accept", tc.acceptHeader) + resp, err := client.Do(req) + if err != nil { + t.Errorf("Accept: %v: Unexpected error in serving HTTP request: %v", tc.acceptHeader, err) + } + + if resp.StatusCode != tc.respStatus { + t.Errorf("Accept: %v: Unexpected response status code, want: %v, got: %v", tc.acceptHeader, tc.respStatus, resp.StatusCode) + } + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Errorf("Accept: %v: Unexpected error in reading response body: %v", tc.acceptHeader, err) + } + if !reflect.DeepEqual(body, tc.respBody) { + t.Errorf("Accept: %v: Response body mismatches, want: %v, got: %v", tc.acceptHeader, tc.respBody, body) + } + } +} diff --git a/vendor/k8s.io/kube-openapi/pkg/idl/doc.go b/vendor/k8s.io/kube-openapi/pkg/idl/doc.go new file mode 100644 index 000000000..9d59aaf0e --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/idl/doc.go @@ -0,0 +1,140 @@ +/* +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. +*/ + +// The IDL package describes comment directives that may be applied to +// API types and fields. +package idl + +// ListType annotates a list to further describe its topology. It may +// have 3 possible values: "atomic", "map", or "set". Note that there is +// no default, and the generation step will fail if a list is found that +// is missing the tag. +// +// This tag MUST only be used on lists, or the generation step will +// fail. +// +// Atomic +// +// Example: +// +listType=atomic +// +// Atomic lists will be entirely replaced when updated. This tag may be +// used on any type of list (struct, scalar, ...). +// +// Using this tag will generate the following OpenAPI extension: +// "x-kubernetes-list-type": "atomic" +// +// Map +// +// Example: +// +listType=map +// +// These lists are like maps in that their elements have a non-index key +// used to identify them. Order is preserved upon merge. Using the map +// tag on a list with non-struct elements will result in an error during +// the generation step. +// +// Using this tag will generate the following OpenAPI extension: +// "x-kubernetes-list-type": "map" +// +// Set +// +// Example: +// +listType=set +// +// Sets are lists that must not have multiple times the same value. Each +// value must be a scalar (or another atomic type). +// +// Using this tag will generate the following OpenAPI extension: +// "x-kubernetes-list-type": "set" +type ListType string + +// ListMapKey annotates map lists by specifying the key used as the index of the map. +// +// This tag MUST only be used on lists that have the listType=map +// attribute, or the generation step will fail. Also, the value +// specified for this attribute must be a scalar typed field of the +// child structure (no nesting is supported). +// +// An example of how this can be used is shown in the ListType (map) example. +// +// Example: +// +listMapKey=name +// +// Using this tag will generate the following OpenAPI extension: +// "x-kubernetes-list-map-key": "name" +type ListMapKey string + +// MapType annotates a map to further describe its topology. It may +// have only one value: "atomic". Atomic means that the entire map is +// considered as a whole, rather than as distinct values. +// +// By default, a map will be considered as a set of distinct values that +// can be updated individually. This default WILL NOT generate any +// openapi extension, as this will also be interpreted as the default +// behavior in the openapi definition. +// +// This tag MUST only be used on maps, or the generation step will fail. +// +// Atomic +// +// Example: +// +mapType=atomic +// +// Atomic maps will be entirely replaced when updated. This tag may be +// used on any map. +// +// Using this tag will generate the following OpenAPI extension: +// "x-kubernetes-map-type": "atomic" +type MapType string + +// OpenAPIGen needs to be described. +type OpenAPIGen string + +// Optional needs to be described. +type Optional string + +// PatchMergeKey needs to be described. +type PatchMergeKey string + +// PatchStrategy needs to be described. +type PatchStrategy string + +// StructType annotates a struct to further describe its topology. It may +// have only one value: "atomic". Atomic means that the entire struct is +// considered as a whole, rather than as distinct values. +// +// By default, a struct will be considered as a set of distinct values that +// can be updated individually. This default WILL NOT generate any +// openapi extension, as this will also be interpreted as the default +// behavior in the openapi definition. +// +// This tag MUST only be used on structs, or the generation step will fail. +// +// Atomic +// +// Example: +// +structType=atomic +// +// Atomic structs will be entirely replaced when updated. This tag may be +// used on any struct. +// +// Using this tag will generate the following OpenAPI extension: +// "x-kubernetes-struct-type": "atomic" +type StructType string + +// Union is TBD. +type Union string diff --git a/vendor/k8s.io/kube-openapi/pkg/idl/listtype_test.go b/vendor/k8s.io/kube-openapi/pkg/idl/listtype_test.go new file mode 100644 index 000000000..2fcc148e2 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/idl/listtype_test.go @@ -0,0 +1,56 @@ +/* +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 idl_test + +// This example shows how to use the listType map attribute and how to +// specify a key to identify elements of the list. The listMapKey +// attribute is used to specify that Name is the key of the map. +func ExampleListType_map() { + type SomeStruct struct { + Name string + Value string + } + type SomeAPI struct { + // +listType=map + // +listMapKey=name + elements []SomeStruct + } +} + +// This example shows how to use the listType set attribute to specify +// that this list should be treated as a set: items in the list can't be +// duplicated. +func ExampleListType_set() { + type SomeAPI struct { + // +listType=set + keys []string + } +} + +// This example shows how to use the listType atomic attribute to +// specify that this list should be treated as a whole. +func ExampleListType_atomic() { + type SomeStruct struct { + Name string + Value string + } + + type SomeAPI struct { + // +listType=atomic + elements []SomeStruct + } +} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/generated_expansion.go b/vendor/k8s.io/kube-openapi/pkg/idl/maptype_test.go similarity index 65% rename from vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/generated_expansion.go rename to vendor/k8s.io/kube-openapi/pkg/idl/maptype_test.go index 2a989d4be..c791b1a54 100644 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/generated_expansion.go +++ b/vendor/k8s.io/kube-openapi/pkg/idl/maptype_test.go @@ -1,5 +1,5 @@ /* -Copyright The Kubernetes Authors. +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. @@ -14,8 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by client-gen. DO NOT EDIT. +package idl_test -package v1beta1 - -type CustomResourceDefinitionExpansion interface{} +// This example shows how to use the mapType atomic attribute to +// specify that this map should be treated as a whole. +func ExampleMapType_atomic() { + type SomeAPI struct { + // +mapType=atomic + elements map[string]string + } +} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/register.go b/vendor/k8s.io/kube-openapi/pkg/idl/structtype_test.go similarity index 60% rename from vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/register.go rename to vendor/k8s.io/kube-openapi/pkg/idl/structtype_test.go index 6eb299eca..a7d8f933d 100644 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/register.go +++ b/vendor/k8s.io/kube-openapi/pkg/idl/structtype_test.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +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. @@ -14,8 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cr +package idl_test -const ( - GroupName = "cr.example.apiextensions.k8s.io" -) +// This example shows how to use the structType atomic attribute to +// specify that this struct should be treated as a whole. +func ExampleStructType_atomic() { + type SomeStruct struct { + Name string + Value string + } + type SomeAPI struct { + // +structType=atomic + elements SomeStruct + } +} diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/doc.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/doc.go similarity index 75% rename from vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/doc.go rename to vendor/k8s.io/kube-openapi/pkg/util/proto/doc.go index 73d79a45d..11ed8a6b7 100644 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/doc.go +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/doc.go @@ -14,8 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -// +k8s:deepcopy-gen=package - -// Package v1 is the v1 version of the API. -// +groupName=cr.example.apiextensions.k8s.io -package v1 +// Package proto is a collection of libraries for parsing and indexing the type definitions. +// The openapi spec contains the object model definitions and extensions metadata. +package proto diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/document.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/document.go new file mode 100644 index 000000000..a57dcd363 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/document.go @@ -0,0 +1,299 @@ +/* +Copyright 2017 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 proto + +import ( + "fmt" + "sort" + "strings" + + "github.com/googleapis/gnostic/OpenAPIv2" + "gopkg.in/yaml.v2" +) + +func newSchemaError(path *Path, format string, a ...interface{}) error { + err := fmt.Sprintf(format, a...) + if path.Len() == 0 { + return fmt.Errorf("SchemaError: %v", err) + } + return fmt.Errorf("SchemaError(%v): %v", path, err) +} + +// VendorExtensionToMap converts openapi VendorExtension to a map. +func VendorExtensionToMap(e []*openapi_v2.NamedAny) map[string]interface{} { + values := map[string]interface{}{} + + for _, na := range e { + if na.GetName() == "" || na.GetValue() == nil { + continue + } + if na.GetValue().GetYaml() == "" { + continue + } + var value interface{} + err := yaml.Unmarshal([]byte(na.GetValue().GetYaml()), &value) + if err != nil { + continue + } + + values[na.GetName()] = value + } + + return values +} + +// Definitions is an implementation of `Models`. It looks for +// models in an openapi Schema. +type Definitions struct { + models map[string]Schema +} + +var _ Models = &Definitions{} + +// NewOpenAPIData creates a new `Models` out of the openapi document. +func NewOpenAPIData(doc *openapi_v2.Document) (Models, error) { + definitions := Definitions{ + models: map[string]Schema{}, + } + + // Save the list of all models first. This will allow us to + // validate that we don't have any dangling reference. + for _, namedSchema := range doc.GetDefinitions().GetAdditionalProperties() { + definitions.models[namedSchema.GetName()] = nil + } + + // Now, parse each model. We can validate that references exists. + for _, namedSchema := range doc.GetDefinitions().GetAdditionalProperties() { + path := NewPath(namedSchema.GetName()) + schema, err := definitions.ParseSchema(namedSchema.GetValue(), &path) + if err != nil { + return nil, err + } + definitions.models[namedSchema.GetName()] = schema + } + + return &definitions, nil +} + +// We believe the schema is a reference, verify that and returns a new +// Schema +func (d *Definitions) parseReference(s *openapi_v2.Schema, path *Path) (Schema, error) { + if len(s.GetProperties().GetAdditionalProperties()) > 0 { + return nil, newSchemaError(path, "unallowed embedded type definition") + } + if len(s.GetType().GetValue()) > 0 { + return nil, newSchemaError(path, "definition reference can't have a type") + } + + if !strings.HasPrefix(s.GetXRef(), "#/definitions/") { + return nil, newSchemaError(path, "unallowed reference to non-definition %q", s.GetXRef()) + } + reference := strings.TrimPrefix(s.GetXRef(), "#/definitions/") + if _, ok := d.models[reference]; !ok { + return nil, newSchemaError(path, "unknown model in reference: %q", reference) + } + return &Ref{ + BaseSchema: d.parseBaseSchema(s, path), + reference: reference, + definitions: d, + }, nil +} + +func (d *Definitions) parseBaseSchema(s *openapi_v2.Schema, path *Path) BaseSchema { + return BaseSchema{ + Description: s.GetDescription(), + Extensions: VendorExtensionToMap(s.GetVendorExtension()), + Path: *path, + } +} + +// We believe the schema is a map, verify and return a new schema +func (d *Definitions) parseMap(s *openapi_v2.Schema, path *Path) (Schema, error) { + if len(s.GetType().GetValue()) != 0 && s.GetType().GetValue()[0] != object { + return nil, newSchemaError(path, "invalid object type") + } + var sub Schema + if s.GetAdditionalProperties().GetSchema() == nil { + sub = &Arbitrary{ + BaseSchema: d.parseBaseSchema(s, path), + } + } else { + var err error + sub, err = d.ParseSchema(s.GetAdditionalProperties().GetSchema(), path) + if err != nil { + return nil, err + } + } + return &Map{ + BaseSchema: d.parseBaseSchema(s, path), + SubType: sub, + }, nil +} + +func (d *Definitions) parsePrimitive(s *openapi_v2.Schema, path *Path) (Schema, error) { + var t string + if len(s.GetType().GetValue()) > 1 { + return nil, newSchemaError(path, "primitive can't have more than 1 type") + } + if len(s.GetType().GetValue()) == 1 { + t = s.GetType().GetValue()[0] + } + switch t { + case String: // do nothing + case Number: // do nothing + case Integer: // do nothing + case Boolean: // do nothing + default: + return nil, newSchemaError(path, "Unknown primitive type: %q", t) + } + return &Primitive{ + BaseSchema: d.parseBaseSchema(s, path), + Type: t, + Format: s.GetFormat(), + }, nil +} + +func (d *Definitions) parseArray(s *openapi_v2.Schema, path *Path) (Schema, error) { + if len(s.GetType().GetValue()) != 1 { + return nil, newSchemaError(path, "array should have exactly one type") + } + if s.GetType().GetValue()[0] != array { + return nil, newSchemaError(path, `array should have type "array"`) + } + if len(s.GetItems().GetSchema()) != 1 { + return nil, newSchemaError(path, "array should have exactly one sub-item") + } + sub, err := d.ParseSchema(s.GetItems().GetSchema()[0], path) + if err != nil { + return nil, err + } + return &Array{ + BaseSchema: d.parseBaseSchema(s, path), + SubType: sub, + }, nil +} + +func (d *Definitions) parseKind(s *openapi_v2.Schema, path *Path) (Schema, error) { + if len(s.GetType().GetValue()) != 0 && s.GetType().GetValue()[0] != object { + return nil, newSchemaError(path, "invalid object type") + } + if s.GetProperties() == nil { + return nil, newSchemaError(path, "object doesn't have properties") + } + + fields := map[string]Schema{} + + for _, namedSchema := range s.GetProperties().GetAdditionalProperties() { + var err error + path := path.FieldPath(namedSchema.GetName()) + fields[namedSchema.GetName()], err = d.ParseSchema(namedSchema.GetValue(), &path) + if err != nil { + return nil, err + } + } + + return &Kind{ + BaseSchema: d.parseBaseSchema(s, path), + RequiredFields: s.GetRequired(), + Fields: fields, + }, nil +} + +func (d *Definitions) parseArbitrary(s *openapi_v2.Schema, path *Path) (Schema, error) { + return &Arbitrary{ + BaseSchema: d.parseBaseSchema(s, path), + }, nil +} + +// ParseSchema creates a walkable Schema from an openapi schema. While +// this function is public, it doesn't leak through the interface. +func (d *Definitions) ParseSchema(s *openapi_v2.Schema, path *Path) (Schema, error) { + if s.GetXRef() != "" { + return d.parseReference(s, path) + } + objectTypes := s.GetType().GetValue() + switch len(objectTypes) { + case 0: + // in the OpenAPI schema served by older k8s versions, object definitions created from structs did not include + // the type:object property (they only included the "properties" property), so we need to handle this case + if s.GetProperties() != nil { + return d.parseKind(s, path) + } else { + // Definition has no type and no properties. Treat it as an arbitrary value + // TODO: what if it has additionalProperties or patternProperties? + return d.parseArbitrary(s, path) + } + case 1: + t := objectTypes[0] + switch t { + case object: + if s.GetProperties() != nil { + return d.parseKind(s, path) + } else { + return d.parseMap(s, path) + } + case array: + return d.parseArray(s, path) + } + return d.parsePrimitive(s, path) + default: + // the OpenAPI generator never generates (nor it ever did in the past) OpenAPI type definitions with multiple types + return nil, newSchemaError(path, "definitions with multiple types aren't supported") + } +} + +// LookupModel is public through the interface of Models. It +// returns a visitable schema from the given model name. +func (d *Definitions) LookupModel(model string) Schema { + return d.models[model] +} + +func (d *Definitions) ListModels() []string { + models := []string{} + + for model := range d.models { + models = append(models, model) + } + + sort.Strings(models) + return models +} + +type Ref struct { + BaseSchema + + reference string + definitions *Definitions +} + +var _ Reference = &Ref{} + +func (r *Ref) Reference() string { + return r.reference +} + +func (r *Ref) SubSchema() Schema { + return r.definitions.models[r.reference] +} + +func (r *Ref) Accept(v SchemaVisitor) { + v.VisitReference(r) +} + +func (r *Ref) GetName() string { + return fmt.Sprintf("Reference to %q", r.reference) +} diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi.go new file mode 100644 index 000000000..f26b5ef88 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi.go @@ -0,0 +1,276 @@ +/* +Copyright 2017 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 proto + +import ( + "fmt" + "sort" + "strings" +) + +// Defines openapi types. +const ( + Integer = "integer" + Number = "number" + String = "string" + Boolean = "boolean" + + // These types are private as they should never leak, and are + // represented by actual structs. + array = "array" + object = "object" +) + +// Models interface describe a model provider. They can give you the +// schema for a specific model. +type Models interface { + LookupModel(string) Schema + ListModels() []string +} + +// SchemaVisitor is an interface that you need to implement if you want +// to "visit" an openapi schema. A dispatch on the Schema type will call +// the appropriate function based on its actual type: +// - Array is a list of one and only one given subtype +// - Map is a map of string to one and only one given subtype +// - Primitive can be string, integer, number and boolean. +// - Kind is an object with specific fields mapping to specific types. +// - Reference is a link to another definition. +type SchemaVisitor interface { + VisitArray(*Array) + VisitMap(*Map) + VisitPrimitive(*Primitive) + VisitKind(*Kind) + VisitReference(Reference) +} + +// SchemaVisitorArbitrary is an additional visitor interface which handles +// arbitrary types. For backwards compatibility, it's a separate interface +// which is checked for at runtime. +type SchemaVisitorArbitrary interface { + SchemaVisitor + VisitArbitrary(*Arbitrary) +} + +// Schema is the base definition of an openapi type. +type Schema interface { + // Giving a visitor here will let you visit the actual type. + Accept(SchemaVisitor) + + // Pretty print the name of the type. + GetName() string + // Describes how to access this field. + GetPath() *Path + // Describes the field. + GetDescription() string + // Returns type extensions. + GetExtensions() map[string]interface{} +} + +// Path helps us keep track of type paths +type Path struct { + parent *Path + key string +} + +func NewPath(key string) Path { + return Path{key: key} +} + +func (p *Path) Get() []string { + if p == nil { + return []string{} + } + if p.key == "" { + return p.parent.Get() + } + return append(p.parent.Get(), p.key) +} + +func (p *Path) Len() int { + return len(p.Get()) +} + +func (p *Path) String() string { + return strings.Join(p.Get(), "") +} + +// ArrayPath appends an array index and creates a new path +func (p *Path) ArrayPath(i int) Path { + return Path{ + parent: p, + key: fmt.Sprintf("[%d]", i), + } +} + +// FieldPath appends a field name and creates a new path +func (p *Path) FieldPath(field string) Path { + return Path{ + parent: p, + key: fmt.Sprintf(".%s", field), + } +} + +// BaseSchema holds data used by each types of schema. +type BaseSchema struct { + Description string + Extensions map[string]interface{} + + Path Path +} + +func (b *BaseSchema) GetDescription() string { + return b.Description +} + +func (b *BaseSchema) GetExtensions() map[string]interface{} { + return b.Extensions +} + +func (b *BaseSchema) GetPath() *Path { + return &b.Path +} + +// Array must have all its element of the same `SubType`. +type Array struct { + BaseSchema + + SubType Schema +} + +var _ Schema = &Array{} + +func (a *Array) Accept(v SchemaVisitor) { + v.VisitArray(a) +} + +func (a *Array) GetName() string { + return fmt.Sprintf("Array of %s", a.SubType.GetName()) +} + +// Kind is a complex object. It can have multiple different +// subtypes for each field, as defined in the `Fields` field. Mandatory +// fields are listed in `RequiredFields`. The key of the object is +// always of type `string`. +type Kind struct { + BaseSchema + + // Lists names of required fields. + RequiredFields []string + // Maps field names to types. + Fields map[string]Schema +} + +var _ Schema = &Kind{} + +func (k *Kind) Accept(v SchemaVisitor) { + v.VisitKind(k) +} + +func (k *Kind) GetName() string { + properties := []string{} + for key := range k.Fields { + properties = append(properties, key) + } + return fmt.Sprintf("Kind(%v)", properties) +} + +// IsRequired returns true if `field` is a required field for this type. +func (k *Kind) IsRequired(field string) bool { + for _, f := range k.RequiredFields { + if f == field { + return true + } + } + return false +} + +// Keys returns a alphabetically sorted list of keys. +func (k *Kind) Keys() []string { + keys := make([]string, 0) + for key := range k.Fields { + keys = append(keys, key) + } + sort.Strings(keys) + return keys +} + +// Map is an object who values must all be of the same `SubType`. +// The key of the object is always of type `string`. +type Map struct { + BaseSchema + + SubType Schema +} + +var _ Schema = &Map{} + +func (m *Map) Accept(v SchemaVisitor) { + v.VisitMap(m) +} + +func (m *Map) GetName() string { + return fmt.Sprintf("Map of %s", m.SubType.GetName()) +} + +// Primitive is a literal. There can be multiple types of primitives, +// and this subtype can be visited through the `subType` field. +type Primitive struct { + BaseSchema + + // Type of a primitive must be one of: integer, number, string, boolean. + Type string + Format string +} + +var _ Schema = &Primitive{} + +func (p *Primitive) Accept(v SchemaVisitor) { + v.VisitPrimitive(p) +} + +func (p *Primitive) GetName() string { + if p.Format == "" { + return p.Type + } + return fmt.Sprintf("%s (%s)", p.Type, p.Format) +} + +// Arbitrary is a value of any type (primitive, object or array) +type Arbitrary struct { + BaseSchema +} + +var _ Schema = &Arbitrary{} + +func (a *Arbitrary) Accept(v SchemaVisitor) { + if visitor, ok := v.(SchemaVisitorArbitrary); ok { + visitor.VisitArbitrary(a) + } +} + +func (a *Arbitrary) GetName() string { + return "Arbitrary value (primitive, object or array)" +} + +// Reference implementation depends on the type of document. +type Reference interface { + Schema + + Reference() string + SubSchema() Schema +} diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi_suite_test.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi_suite_test.go new file mode 100644 index 000000000..24b5168e4 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi_suite_test.go @@ -0,0 +1,49 @@ +/* +Copyright 2017 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 proto_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/config" + . "github.com/onsi/ginkgo/types" + . "github.com/onsi/gomega" + + "fmt" + "testing" +) + +func TestOpenapi(t *testing.T) { + RegisterFailHandler(Fail) + 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") } diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi_test.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi_test.go new file mode 100644 index 000000000..b6e237256 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/openapi_test.go @@ -0,0 +1,265 @@ +/* +Copyright 2017 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 proto_test + +import ( + "path/filepath" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "k8s.io/kube-openapi/pkg/util/proto" + "k8s.io/kube-openapi/pkg/util/proto/testing" +) + +var fakeSchema = testing.Fake{Path: filepath.Join("testdata", "swagger.json")} +var fakeSchemaNext = testing.Fake{Path: filepath.Join("testdata", "swagger_next.json")} + +var _ = Describe("Reading apps/v1beta1/Deployment from v1.8 openAPIData", func() { + var models proto.Models + BeforeEach(func() { + s, err := fakeSchema.OpenAPISchema() + Expect(err).To(BeNil()) + models, err = proto.NewOpenAPIData(s) + Expect(err).To(BeNil()) + }) + + model := "io.k8s.api.apps.v1beta1.Deployment" + var schema proto.Schema + It("should lookup the Schema by its model name", func() { + schema = models.LookupModel(model) + Expect(schema).ToNot(BeNil()) + }) + + var deployment *proto.Kind + It("should be a Kind", func() { + deployment = schema.(*proto.Kind) + Expect(deployment).ToNot(BeNil()) + }) + + It("should have a path", func() { + Expect(deployment.GetPath().Get()).To(Equal([]string{"io.k8s.api.apps.v1beta1.Deployment"})) + }) + + It("should have a kind key of type string", func() { + Expect(deployment.Fields).To(HaveKey("kind")) + key := deployment.Fields["kind"].(*proto.Primitive) + Expect(key).ToNot(BeNil()) + Expect(key.Type).To(Equal("string")) + Expect(key.GetPath().Get()).To(Equal([]string{"io.k8s.api.apps.v1beta1.Deployment", ".kind"})) + }) + + It("should have a apiVersion key of type string", func() { + Expect(deployment.Fields).To(HaveKey("apiVersion")) + key := deployment.Fields["apiVersion"].(*proto.Primitive) + Expect(key).ToNot(BeNil()) + Expect(key.Type).To(Equal("string")) + Expect(key.GetPath().Get()).To(Equal([]string{"io.k8s.api.apps.v1beta1.Deployment", ".apiVersion"})) + }) + + It("should have a metadata key of type Reference", func() { + Expect(deployment.Fields).To(HaveKey("metadata")) + key := deployment.Fields["metadata"].(proto.Reference) + Expect(key).ToNot(BeNil()) + Expect(key.Reference()).To(Equal("io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta")) + subSchema := key.SubSchema().(*proto.Kind) + Expect(subSchema).ToNot(BeNil()) + }) + + var status *proto.Kind + It("should have a status key of type Reference", func() { + Expect(deployment.Fields).To(HaveKey("status")) + key := deployment.Fields["status"].(proto.Reference) + Expect(key).ToNot(BeNil()) + Expect(key.Reference()).To(Equal("io.k8s.api.apps.v1beta1.DeploymentStatus")) + status = key.SubSchema().(*proto.Kind) + Expect(status).ToNot(BeNil()) + }) + + It("should have a valid DeploymentStatus", func() { + By("having availableReplicas key") + Expect(status.Fields).To(HaveKey("availableReplicas")) + replicas := status.Fields["availableReplicas"].(*proto.Primitive) + Expect(replicas).ToNot(BeNil()) + Expect(replicas.Type).To(Equal("integer")) + + By("having conditions key") + Expect(status.Fields).To(HaveKey("conditions")) + conditions := status.Fields["conditions"].(*proto.Array) + Expect(conditions).ToNot(BeNil()) + Expect(conditions.GetName()).To(Equal(`Array of Reference to "io.k8s.api.apps.v1beta1.DeploymentCondition"`)) + Expect(conditions.GetExtensions()).To(Equal(map[string]interface{}{ + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge", + })) + condition := conditions.SubType.(proto.Reference) + Expect(condition.Reference()).To(Equal("io.k8s.api.apps.v1beta1.DeploymentCondition")) + }) + + var spec *proto.Kind + It("should have a spec key of type Reference", func() { + Expect(deployment.Fields).To(HaveKey("spec")) + key := deployment.Fields["spec"].(proto.Reference) + Expect(key).ToNot(BeNil()) + Expect(key.Reference()).To(Equal("io.k8s.api.apps.v1beta1.DeploymentSpec")) + spec = key.SubSchema().(*proto.Kind) + Expect(spec).ToNot(BeNil()) + }) + + It("should have a spec with no gvk", func() { + _, found := spec.GetExtensions()["x-kubernetes-group-version-kind"] + Expect(found).To(BeFalse()) + }) + + It("should have a spec with a PodTemplateSpec sub-field", func() { + Expect(spec.Fields).To(HaveKey("template")) + key := spec.Fields["template"].(proto.Reference) + Expect(key).ToNot(BeNil()) + Expect(key.Reference()).To(Equal("io.k8s.api.core.v1.PodTemplateSpec")) + }) +}) + +var _ = Describe("Reading apps/v1beta1/Deployment from v1.11 openAPIData", func() { + var models proto.Models + BeforeEach(func() { + s, err := fakeSchemaNext.OpenAPISchema() + Expect(err).To(BeNil()) + models, err = proto.NewOpenAPIData(s) + Expect(err).To(BeNil()) + }) + + model := "io.k8s.api.apps.v1beta1.Deployment" + var schema proto.Schema + It("should lookup the Schema by its model name", func() { + schema = models.LookupModel(model) + Expect(schema).ToNot(BeNil()) + }) + + var deployment *proto.Kind + It("should be a Kind", func() { + deployment = schema.(*proto.Kind) + Expect(deployment).ToNot(BeNil()) + }) +}) + +var _ = Describe("Reading apps/v1beta1/ControllerRevision from v1.11 openAPIData", func() { + var models proto.Models + BeforeEach(func() { + s, err := fakeSchemaNext.OpenAPISchema() + Expect(err).To(BeNil()) + models, err = proto.NewOpenAPIData(s) + Expect(err).To(BeNil()) + }) + + model := "io.k8s.api.apps.v1beta1.ControllerRevision" + var schema proto.Schema + It("should lookup the Schema by its model name", func() { + schema = models.LookupModel(model) + Expect(schema).ToNot(BeNil()) + }) + + var cr *proto.Kind + It("data property should be map[string]Arbitrary", func() { + cr = schema.(*proto.Kind) + Expect(cr).ToNot(BeNil()) + Expect(cr.Fields).To(HaveKey("data")) + + data := cr.Fields["data"].(*proto.Map) + Expect(data).ToNot(BeNil()) + Expect(data.GetName()).To(Equal("Map of Arbitrary value (primitive, object or array)")) + Expect(data.GetPath().Get()).To(Equal([]string{"io.k8s.api.apps.v1beta1.ControllerRevision", ".data"})) + + arbitrary := data.SubType.(*proto.Arbitrary) + Expect(arbitrary).ToNot(BeNil()) + Expect(arbitrary.GetName()).To(Equal("Arbitrary value (primitive, object or array)")) + Expect(arbitrary.GetPath().Get()).To(Equal([]string{"io.k8s.api.apps.v1beta1.ControllerRevision", ".data"})) + }) +}) + +var _ = Describe("Reading authorization.k8s.io/v1/SubjectAccessReview from openAPIData", func() { + var models proto.Models + BeforeEach(func() { + s, err := fakeSchema.OpenAPISchema() + Expect(err).To(BeNil()) + models, err = proto.NewOpenAPIData(s) + Expect(err).To(BeNil()) + }) + + model := "io.k8s.api.authorization.v1.LocalSubjectAccessReview" + var schema proto.Schema + It("should lookup the Schema by its model", func() { + schema = models.LookupModel(model) + Expect(schema).ToNot(BeNil()) + }) + + var sarspec *proto.Kind + It("should be a Kind and have a spec", func() { + sar := schema.(*proto.Kind) + Expect(sar).ToNot(BeNil()) + Expect(sar.Fields).To(HaveKey("spec")) + specRef := sar.Fields["spec"].(proto.Reference) + Expect(specRef).ToNot(BeNil()) + Expect(specRef.Reference()).To(Equal("io.k8s.api.authorization.v1.SubjectAccessReviewSpec")) + sarspec = specRef.SubSchema().(*proto.Kind) + Expect(sarspec).ToNot(BeNil()) + }) + + It("should have a valid SubjectAccessReviewSpec", func() { + Expect(sarspec.Fields).To(HaveKey("extra")) + extra := sarspec.Fields["extra"].(*proto.Map) + Expect(extra).ToNot(BeNil()) + Expect(extra.GetName()).To(Equal("Map of Array of string")) + Expect(extra.GetPath().Get()).To(Equal([]string{"io.k8s.api.authorization.v1.SubjectAccessReviewSpec", ".extra"})) + array := extra.SubType.(*proto.Array) + Expect(array).ToNot(BeNil()) + Expect(array.GetName()).To(Equal("Array of string")) + Expect(array.GetPath().Get()).To(Equal([]string{"io.k8s.api.authorization.v1.SubjectAccessReviewSpec", ".extra"})) + str := array.SubType.(*proto.Primitive) + Expect(str).ToNot(BeNil()) + Expect(str.Type).To(Equal("string")) + Expect(str.GetName()).To(Equal("string")) + Expect(str.GetPath().Get()).To(Equal([]string{"io.k8s.api.authorization.v1.SubjectAccessReviewSpec", ".extra"})) + }) +}) + +var _ = Describe("Path", func() { + It("can be created by NewPath", func() { + path := proto.NewPath("key") + Expect(path.String()).To(Equal("key")) + }) + It("can create and print complex paths", func() { + key := proto.NewPath("key") + array := key.ArrayPath(12) + field := array.FieldPath("subKey") + + Expect(field.String()).To(Equal("key[12].subKey")) + }) + It("has a length", func() { + key := proto.NewPath("key") + array := key.ArrayPath(12) + field := array.FieldPath("subKey") + + Expect(field.Len()).To(Equal(3)) + }) + It("can look like an array", func() { + key := proto.NewPath("key") + array := key.ArrayPath(12) + field := array.FieldPath("subKey") + + Expect(field.Get()).To(Equal([]string{"key", "[12]", ".subKey"})) + }) +}) diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/testdata/swagger.json b/vendor/k8s.io/kube-openapi/pkg/util/proto/testdata/swagger.json new file mode 100644 index 000000000..0e15f86b8 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/testdata/swagger.json @@ -0,0 +1,6375 @@ +{ + "swagger": "2.0", + "info": { + "title": "Kubernetes", + "version": "v1.8.0" + }, + "paths": {}, + "definitions": { + "io.k8s.api.apps.v1beta1.ControllerRevision": { + "description": "ControllerRevision implements an immutable snapshot of state data. Clients are responsible for serializing and deserializing the objects that contain their internal state. Once a ControllerRevision has been successfully created, it can not be updated. The API Server will fail validation of all requests that attempt to mutate the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, it may be subject to name and representation changes in future releases, and clients should not depend on its stability. It is primarily for internal use by controllers.", + "required": [ + "revision" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "data": { + "description": "Data is the serialized representation of the state.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.runtime.RawExtension" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "revision": { + "description": "Revision indicates the revision of the state represented by Data.", + "type": "integer", + "format": "int64" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "ControllerRevision", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.ControllerRevisionList": { + "description": "ControllerRevisionList is a resource containing a list of ControllerRevision objects.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of ControllerRevisions", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.ControllerRevision" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "ControllerRevisionList", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.Deployment": { + "description": "Deployment enables declarative updates for Pods and ReplicaSets.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object metadata.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired behavior of the Deployment.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentSpec" + }, + "status": { + "description": "Most recently observed status of the Deployment.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "Deployment", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.DeploymentCondition": { + "description": "DeploymentCondition describes the state of a deployment at a certain point.", + "required": [ + "type", + "status" + ], + "properties": { + "lastTransitionTime": { + "description": "Last time the condition transitioned from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "lastUpdateTime": { + "description": "The last time this condition was updated.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of deployment condition.", + "type": "string" + } + } + }, + "io.k8s.api.apps.v1beta1.DeploymentList": { + "description": "DeploymentList is a list of Deployments.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of Deployments.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.Deployment" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "DeploymentList", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.DeploymentRollback": { + "description": "DEPRECATED. DeploymentRollback stores the information required to rollback a deployment.", + "required": [ + "name", + "rollbackTo" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "Required: This must match the Name of a deployment.", + "type": "string" + }, + "rollbackTo": { + "description": "The config of this deployment rollback.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollbackConfig" + }, + "updatedAnnotations": { + "description": "The annotations to be updated to a deployment", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "DeploymentRollback", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.DeploymentSpec": { + "description": "DeploymentSpec is the specification of the desired behavior of the Deployment.", + "required": [ + "template" + ], + "properties": { + "minReadySeconds": { + "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + "type": "integer", + "format": "int32" + }, + "paused": { + "description": "Indicates that the deployment is paused.", + "type": "boolean" + }, + "progressDeadlineSeconds": { + "description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.", + "type": "integer", + "format": "int32" + }, + "revisionHistoryLimit": { + "description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 2.", + "type": "integer", + "format": "int32" + }, + "rollbackTo": { + "description": "DEPRECATED. The config this deployment is rolling back to. Will be cleared after rollback is done.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollbackConfig" + }, + "selector": { + "description": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "strategy": { + "description": "The deployment strategy to use to replace existing pods with new ones.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentStrategy" + }, + "template": { + "description": "Template describes the pods that will be created.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + } + } + }, + "io.k8s.api.apps.v1beta1.DeploymentStatus": { + "description": "DeploymentStatus is the most recently observed status of the Deployment.", + "properties": { + "availableReplicas": { + "description": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.", + "type": "integer", + "format": "int32" + }, + "collisionCount": { + "description": "Count of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet.", + "type": "integer", + "format": "int32" + }, + "conditions": { + "description": "Represents the latest available observations of a deployment's current state.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "observedGeneration": { + "description": "The generation observed by the deployment controller.", + "type": "integer", + "format": "int64" + }, + "readyReplicas": { + "description": "Total number of ready pods targeted by this deployment.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).", + "type": "integer", + "format": "int32" + }, + "unavailableReplicas": { + "description": "Total number of unavailable pods targeted by this deployment.", + "type": "integer", + "format": "int32" + }, + "updatedReplicas": { + "description": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.DeploymentStrategy": { + "description": "DeploymentStrategy describes how to replace existing pods with new ones.", + "properties": { + "rollingUpdate": { + "description": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollingUpdateDeployment" + }, + "type": { + "description": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.", + "type": "string" + } + } + }, + "io.k8s.api.apps.v1beta1.RollbackConfig": { + "description": "DEPRECATED.", + "properties": { + "revision": { + "description": "The revision to rollback to. If set to 0, rollback to the last revision.", + "type": "integer", + "format": "int64" + } + } + }, + "io.k8s.api.apps.v1beta1.RollingUpdateDeployment": { + "description": "Spec to control the desired behavior of rolling update.", + "properties": { + "maxSurge": { + "description": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new RC can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new RC can be scaled up further, ensuring that total number of pods running at any time during the update is atmost 130% of desired pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + }, + "maxUnavailable": { + "description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old RC can be scaled down further, followed by scaling up the new RC, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + } + } + }, + "io.k8s.api.apps.v1beta1.RollingUpdateStatefulSetStrategy": { + "description": "RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType.", + "properties": { + "partition": { + "description": "Partition indicates the ordinal at which the StatefulSet should be partitioned.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.Scale": { + "description": "Scale represents a scaling request for a resource.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.ScaleSpec" + }, + "status": { + "description": "current status of the scale. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status. Read-only.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.ScaleStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "Scale", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.ScaleSpec": { + "description": "ScaleSpec describes the attributes of a scale subresource", + "properties": { + "replicas": { + "description": "desired number of instances for the scaled object.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.ScaleStatus": { + "description": "ScaleStatus represents the current status of a scale subresource.", + "required": [ + "replicas" + ], + "properties": { + "replicas": { + "description": "actual number of observed instances of the scaled object.", + "type": "integer", + "format": "int32" + }, + "selector": { + "description": "label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "targetSelector": { + "description": "label selector for pods that should match the replicas count. This is a serializated version of both map-based and more expressive set-based selectors. This is done to avoid introspection in the clients. The string will be in the same format as the query-param syntax. If the target type only supports map-based selectors, both this field and map-based selector field are populated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + "type": "string" + } + } + }, + "io.k8s.api.apps.v1beta1.StatefulSet": { + "description": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the desired identities of pods in this set.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSetSpec" + }, + "status": { + "description": "Status is the current status of Pods in this StatefulSet. This data may be out of date by some window of time.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSetStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "StatefulSet", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.StatefulSetList": { + "description": "StatefulSetList is a collection of StatefulSets.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSet" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "StatefulSetList", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.StatefulSetSpec": { + "description": "A StatefulSetSpec is the specification of a StatefulSet.", + "required": [ + "template", + "serviceName" + ], + "properties": { + "podManagementPolicy": { + "description": "podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is `OrderedReady`, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order. The alternative policy is `Parallel` which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.", + "type": "string" + }, + "replicas": { + "description": "replicas is the desired number of replicas of the given Template. These are replicas in the sense that they are instantiations of the same Template, but individual replicas also have a consistent identity. If unspecified, defaults to 1.", + "type": "integer", + "format": "int32" + }, + "revisionHistoryLimit": { + "description": "revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet's revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.", + "type": "integer", + "format": "int32" + }, + "selector": { + "description": "selector is a label query over pods that should match the replica count. If empty, defaulted to labels on the pod template. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "serviceName": { + "description": "serviceName is the name of the service that governs this StatefulSet. This service must exist before the StatefulSet, and is responsible for the network identity of the set. Pods get DNS/hostnames that follow the pattern: pod-specific-string.serviceName.default.svc.cluster.local where \"pod-specific-string\" is managed by the StatefulSet controller.", + "type": "string" + }, + "template": { + "description": "template is the object that describes the pod that will be created if insufficient replicas are detected. Each pod stamped out by the StatefulSet will fulfill this Template, but have a unique identity from the rest of the StatefulSet.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + }, + "updateStrategy": { + "description": "updateStrategy indicates the StatefulSetUpdateStrategy that will be employed to update Pods in the StatefulSet when a revision is made to Template.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSetUpdateStrategy" + }, + "volumeClaimTemplates": { + "description": "volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. A claim in this list takes precedence over any volumes in the template, with the same name.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaim" + } + } + } + }, + "io.k8s.api.apps.v1beta1.StatefulSetStatus": { + "description": "StatefulSetStatus represents the current state of a StatefulSet.", + "required": [ + "replicas" + ], + "properties": { + "collisionCount": { + "description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.", + "type": "integer", + "format": "int32" + }, + "currentReplicas": { + "description": "currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.", + "type": "integer", + "format": "int32" + }, + "currentRevision": { + "description": "currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).", + "type": "string" + }, + "observedGeneration": { + "description": "observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.", + "type": "integer", + "format": "int64" + }, + "readyReplicas": { + "description": "readyReplicas is the number of Pods created by the StatefulSet controller that have a Ready Condition.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "replicas is the number of Pods created by the StatefulSet controller.", + "type": "integer", + "format": "int32" + }, + "updateRevision": { + "description": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)", + "type": "string" + }, + "updatedReplicas": { + "description": "updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.StatefulSetUpdateStrategy": { + "description": "StatefulSetUpdateStrategy indicates the strategy that the StatefulSet controller will use to perform updates. It includes any additional parameters necessary to perform the update for the indicated strategy.", + "properties": { + "rollingUpdate": { + "description": "RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollingUpdateStatefulSetStrategy" + }, + "type": { + "description": "Type indicates the type of the StatefulSetUpdateStrategy.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.LocalSubjectAccessReview": { + "description": "LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace you made the request against. If empty, it is defaulted.", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "LocalSubjectAccessReview", + "version": "v1" + } + ] + }, + "io.k8s.api.authorization.v1.NonResourceAttributes": { + "description": "NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface", + "properties": { + "path": { + "description": "Path is the URL path of the request", + "type": "string" + }, + "verb": { + "description": "Verb is the standard HTTP verb", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.ResourceAttributes": { + "description": "ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface", + "properties": { + "group": { + "description": "Group is the API Group of the Resource. \"*\" means all.", + "type": "string" + }, + "name": { + "description": "Name is the name of the resource being requested for a \"get\" or deleted for a \"delete\". \"\" (empty) means all.", + "type": "string" + }, + "namespace": { + "description": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces \"\" (empty) is defaulted for LocalSubjectAccessReviews \"\" (empty) is empty for cluster-scoped resources \"\" (empty) means \"all\" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview", + "type": "string" + }, + "resource": { + "description": "Resource is one of the existing resource types. \"*\" means all.", + "type": "string" + }, + "subresource": { + "description": "Subresource is one of the existing resource types. \"\" means none.", + "type": "string" + }, + "verb": { + "description": "Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", + "type": "string" + }, + "version": { + "description": "Version is the API Version of the Resource. \"*\" means all.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.SelfSubjectAccessReview": { + "description": "SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means \"in all namespaces\". Self is a special case, because users should always be able to check whether they can perform an action", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. user and groups must be empty", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SelfSubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SelfSubjectAccessReview", + "version": "v1" + } + ] + }, + "io.k8s.api.authorization.v1.SelfSubjectAccessReviewSpec": { + "description": "SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "properties": { + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.ResourceAttributes" + } + } + }, + "io.k8s.api.authorization.v1.SubjectAccessReview": { + "description": "SubjectAccessReview checks whether or not a user or group can perform an action.", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SubjectAccessReview", + "version": "v1" + } + ] + }, + "io.k8s.api.authorization.v1.SubjectAccessReviewSpec": { + "description": "SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "properties": { + "extra": { + "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "groups": { + "description": "Groups is the groups you're testing for.", + "type": "array", + "items": { + "type": "string" + } + }, + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.ResourceAttributes" + }, + "uid": { + "description": "UID information about the requesting user.", + "type": "string" + }, + "user": { + "description": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.SubjectAccessReviewStatus": { + "description": "SubjectAccessReviewStatus", + "required": [ + "allowed" + ], + "properties": { + "allowed": { + "description": "Allowed is required. True if the action would be allowed, false otherwise.", + "type": "boolean" + }, + "evaluationError": { + "description": "EvaluationError is an indication that some error occurred during the authorization check. It is entirely possible to get an error and be able to continue determine authorization status in spite of it. For instance, RBAC can be missing a role, but enough roles are still present and bound to reason about the request.", + "type": "string" + }, + "reason": { + "description": "Reason is optional. It indicates why a request was allowed or denied.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.LocalSubjectAccessReview": { + "description": "LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace you made the request against. If empty, it is defaulted.", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "LocalSubjectAccessReview", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.authorization.v1beta1.NonResourceAttributes": { + "description": "NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface", + "properties": { + "path": { + "description": "Path is the URL path of the request", + "type": "string" + }, + "verb": { + "description": "Verb is the standard HTTP verb", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.ResourceAttributes": { + "description": "ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface", + "properties": { + "group": { + "description": "Group is the API Group of the Resource. \"*\" means all.", + "type": "string" + }, + "name": { + "description": "Name is the name of the resource being requested for a \"get\" or deleted for a \"delete\". \"\" (empty) means all.", + "type": "string" + }, + "namespace": { + "description": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces \"\" (empty) is defaulted for LocalSubjectAccessReviews \"\" (empty) is empty for cluster-scoped resources \"\" (empty) means \"all\" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview", + "type": "string" + }, + "resource": { + "description": "Resource is one of the existing resource types. \"*\" means all.", + "type": "string" + }, + "subresource": { + "description": "Subresource is one of the existing resource types. \"\" means none.", + "type": "string" + }, + "verb": { + "description": "Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", + "type": "string" + }, + "version": { + "description": "Version is the API Version of the Resource. \"*\" means all.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.SelfSubjectAccessReview": { + "description": "SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means \"in all namespaces\". Self is a special case, because users should always be able to check whether they can perform an action", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. user and groups must be empty", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SelfSubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SelfSubjectAccessReview", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.authorization.v1beta1.SelfSubjectAccessReviewSpec": { + "description": "SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "properties": { + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.ResourceAttributes" + } + } + }, + "io.k8s.api.authorization.v1beta1.SubjectAccessReview": { + "description": "SubjectAccessReview checks whether or not a user or group can perform an action.", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SubjectAccessReview", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.authorization.v1beta1.SubjectAccessReviewSpec": { + "description": "SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "properties": { + "extra": { + "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "group": { + "description": "Groups is the groups you're testing for.", + "type": "array", + "items": { + "type": "string" + } + }, + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.ResourceAttributes" + }, + "uid": { + "description": "UID information about the requesting user.", + "type": "string" + }, + "user": { + "description": "User is the user you're testing for. If you specify \"User\" but not \"Group\", then is it interpreted as \"What if User were not a member of any groups", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus": { + "description": "SubjectAccessReviewStatus", + "required": [ + "allowed" + ], + "properties": { + "allowed": { + "description": "Allowed is required. True if the action would be allowed, false otherwise.", + "type": "boolean" + }, + "evaluationError": { + "description": "EvaluationError is an indication that some error occurred during the authorization check. It is entirely possible to get an error and be able to continue determine authorization status in spite of it. For instance, RBAC can be missing a role, but enough roles are still present and bound to reason about the request.", + "type": "string" + }, + "reason": { + "description": "Reason is optional. It indicates why a request was allowed or denied.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.AWSElasticBlockStoreVolumeSource": { + "description": "Represents a Persistent Disk resource in AWS.\n\nAn AWS EBS disk must exist before mounting to a container. The disk must also be in the same AWS zone as the kubelet. An AWS EBS disk can only be mounted as read/write once. AWS EBS volumes support ownership management and SELinux relabeling.", + "required": [ + "volumeID" + ], + "properties": { + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "type": "string" + }, + "partition": { + "description": "The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty).", + "type": "integer", + "format": "int32" + }, + "readOnly": { + "description": "Specify \"true\" to force and set the ReadOnly property in VolumeMounts to \"true\". If omitted, the default is \"false\". More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "type": "boolean" + }, + "volumeID": { + "description": "Unique ID of the persistent disk resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Affinity": { + "description": "Affinity is a group of affinity scheduling rules.", + "properties": { + "nodeAffinity": { + "description": "Describes node affinity scheduling rules for the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeAffinity" + }, + "podAffinity": { + "description": "Describes pod affinity scheduling rules (e.g. co-locate this pod in the same node, zone, etc. as some other pod(s)).", + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinity" + }, + "podAntiAffinity": { + "description": "Describes pod anti-affinity scheduling rules (e.g. avoid putting this pod in the same node, zone, etc. as some other pod(s)).", + "$ref": "#/definitions/io.k8s.api.core.v1.PodAntiAffinity" + } + } + }, + "io.k8s.api.core.v1.AttachedVolume": { + "description": "AttachedVolume describes a volume attached to a node", + "required": [ + "name", + "devicePath" + ], + "properties": { + "devicePath": { + "description": "DevicePath represents the device path where the volume should be available", + "type": "string" + }, + "name": { + "description": "Name of the attached volume", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.AzureDiskVolumeSource": { + "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + "required": [ + "diskName", + "diskURI" + ], + "properties": { + "cachingMode": { + "description": "Host Caching mode: None, Read Only, Read Write.", + "type": "string" + }, + "diskName": { + "description": "The Name of the data disk in the blob storage", + "type": "string" + }, + "diskURI": { + "description": "The URI the data disk in the blob storage", + "type": "string" + }, + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "kind": { + "description": "Expected values Shared: multiple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.AzureFilePersistentVolumeSource": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "required": [ + "secretName", + "shareName" + ], + "properties": { + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretName": { + "description": "the name of secret that contains Azure Storage Account Name and Key", + "type": "string" + }, + "secretNamespace": { + "description": "the namespace of the secret that contains Azure Storage Account Name and Key default is the same as the Pod", + "type": "string" + }, + "shareName": { + "description": "Share Name", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.AzureFileVolumeSource": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "required": [ + "secretName", + "shareName" + ], + "properties": { + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretName": { + "description": "the name of secret that contains Azure Storage Account Name and Key", + "type": "string" + }, + "shareName": { + "description": "Share Name", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Binding": { + "description": "Binding ties one object to another; for example, a pod is bound to a node by a scheduler. Deprecated in 1.7, please use the bindings subresource of pods instead.", + "required": [ + "target" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "target": { + "description": "The target object that you want to bind to the standard object.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Binding", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.Capabilities": { + "description": "Adds and removes POSIX capabilities from running containers.", + "properties": { + "add": { + "description": "Added capabilities", + "type": "array", + "items": { + "type": "string" + } + }, + "drop": { + "description": "Removed capabilities", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.CephFSPersistentVolumeSource": { + "description": "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.", + "required": [ + "monitors" + ], + "properties": { + "monitors": { + "description": "Required: Monitors is a collection of Ceph monitors More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "array", + "items": { + "type": "string" + } + }, + "path": { + "description": "Optional: Used as the mounted root, rather than the full Ceph tree, default is /", + "type": "string" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "boolean" + }, + "secretFile": { + "description": "Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + }, + "secretRef": { + "description": "Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretReference" + }, + "user": { + "description": "Optional: User is the rados user name, default is admin More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.CephFSVolumeSource": { + "description": "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.", + "required": [ + "monitors" + ], + "properties": { + "monitors": { + "description": "Required: Monitors is a collection of Ceph monitors More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "array", + "items": { + "type": "string" + } + }, + "path": { + "description": "Optional: Used as the mounted root, rather than the full Ceph tree, default is /", + "type": "string" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "boolean" + }, + "secretFile": { + "description": "Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + }, + "secretRef": { + "description": "Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "user": { + "description": "Optional: User is the rados user name, default is admin More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.CinderVolumeSource": { + "description": "Represents a cinder volume resource in Openstack. A Cinder volume must exist before mounting to a container. The volume must also be in the same region as the kubelet. Cinder volumes support ownership management and SELinux relabeling.", + "required": [ + "volumeID" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "type": "string" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "type": "boolean" + }, + "volumeID": { + "description": "volume id used to identify the volume in cinder More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ClientIPConfig": { + "description": "ClientIPConfig represents the configurations of Client IP based session affinity.", + "properties": { + "timeoutSeconds": { + "description": "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be \u003e0 \u0026\u0026 \u003c=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours).", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.ComponentCondition": { + "description": "Information about the condition of a component.", + "required": [ + "type", + "status" + ], + "properties": { + "error": { + "description": "Condition error code for a component. For example, a health check error code.", + "type": "string" + }, + "message": { + "description": "Message about the condition for a component. For example, information about a health check.", + "type": "string" + }, + "status": { + "description": "Status of the condition for a component. Valid values for \"Healthy\": \"True\", \"False\", or \"Unknown\".", + "type": "string" + }, + "type": { + "description": "Type of condition for a component. Valid value: \"Healthy\"", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ComponentStatus": { + "description": "ComponentStatus (and ComponentStatusList) holds the cluster validation info.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "conditions": { + "description": "List of component conditions observed", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ComponentCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ComponentStatus", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ComponentStatusList": { + "description": "Status of all the conditions for the component as a list of ComponentStatus objects.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of ComponentStatus objects.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ComponentStatus" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ComponentStatusList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ConfigMap": { + "description": "ConfigMap holds configuration data for pods to consume.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "data": { + "description": "Data contains the configuration data. Each key must consist of alphanumeric characters, '-', '_' or '.'.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ConfigMap", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ConfigMapEnvSource": { + "description": "ConfigMapEnvSource selects a ConfigMap to populate the environment variables with.\n\nThe contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables.", + "properties": { + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.ConfigMapKeySelector": { + "description": "Selects a key from a ConfigMap.", + "required": [ + "key" + ], + "properties": { + "key": { + "description": "The key to select.", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap or it's key must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.ConfigMapList": { + "description": "ConfigMapList is a resource containing a list of ConfigMap objects.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of ConfigMaps.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMap" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ConfigMapList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ConfigMapProjection": { + "description": "Adapts a ConfigMap into a projected volume.\n\nThe contents of the target ConfigMap's Data field will be presented in a projected volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. Note that this is identical to a configmap volume source without the default mode.", + "properties": { + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap or it's keys must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.ConfigMapVolumeSource": { + "description": "Adapts a ConfigMap into a volume.\n\nThe contents of the target ConfigMap's Data field will be presented in a volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. ConfigMap volumes support ownership management and SELinux relabeling.", + "properties": { + "defaultMode": { + "description": "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap or it's keys must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.Container": { + "description": "A single application container that you want to run within a pod.", + "required": [ + "name", + "image" + ], + "properties": { + "args": { + "description": "Arguments to the entrypoint. The docker image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + "type": "array", + "items": { + "type": "string" + } + }, + "command": { + "description": "Entrypoint array. Not executed within a shell. The docker image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + "type": "array", + "items": { + "type": "string" + } + }, + "env": { + "description": "List of environment variables to set in the container. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EnvVar" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "envFrom": { + "description": "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EnvFromSource" + } + }, + "image": { + "description": "Docker image name. More info: https://kubernetes.io/docs/concepts/containers/images", + "type": "string" + }, + "imagePullPolicy": { + "description": "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images", + "type": "string" + }, + "lifecycle": { + "description": "Actions that the management system should take in response to container lifecycle events. Cannot be updated.", + "$ref": "#/definitions/io.k8s.api.core.v1.Lifecycle" + }, + "livenessProbe": { + "description": "Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "$ref": "#/definitions/io.k8s.api.core.v1.Probe" + }, + "name": { + "description": "Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.", + "type": "string" + }, + "ports": { + "description": "List of ports to expose from the container. Exposing a port here gives the system additional information about the network connections a container uses, but is primarily informational. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default \"0.0.0.0\" address inside a container will be accessible from the network. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerPort" + }, + "x-kubernetes-patch-merge-key": "containerPort", + "x-kubernetes-patch-strategy": "merge" + }, + "readinessProbe": { + "description": "Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "$ref": "#/definitions/io.k8s.api.core.v1.Probe" + }, + "resources": { + "description": "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements" + }, + "securityContext": { + "description": "Security options the pod should run with. More info: https://kubernetes.io/docs/concepts/policy/security-context/ More info: https://git.k8s.io/community/contributors/design-proposals/security_context.md", + "$ref": "#/definitions/io.k8s.api.core.v1.SecurityContext" + }, + "stdin": { + "description": "Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.", + "type": "boolean" + }, + "stdinOnce": { + "description": "Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false", + "type": "boolean" + }, + "terminationMessagePath": { + "description": "Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.", + "type": "string" + }, + "terminationMessagePolicy": { + "description": "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.", + "type": "string" + }, + "tty": { + "description": "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.", + "type": "boolean" + }, + "volumeMounts": { + "description": "Pod volumes to mount into the container's filesystem. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.VolumeMount" + }, + "x-kubernetes-patch-merge-key": "mountPath", + "x-kubernetes-patch-strategy": "merge" + }, + "workingDir": { + "description": "Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ContainerImage": { + "description": "Describe a container image", + "required": [ + "names" + ], + "properties": { + "names": { + "description": "Names by which this image is known. e.g. [\"k8s.gcr.io/hyperkube:v1.0.7\", \"dockerhub.io/google_containers/hyperkube:v1.0.7\"]", + "type": "array", + "items": { + "type": "string" + } + }, + "sizeBytes": { + "description": "The size of the image in bytes.", + "type": "integer", + "format": "int64" + } + } + }, + "io.k8s.api.core.v1.ContainerPort": { + "description": "ContainerPort represents a network port in a single container.", + "required": [ + "containerPort" + ], + "properties": { + "containerPort": { + "description": "Number of port to expose on the pod's IP address. This must be a valid port number, 0 \u003c x \u003c 65536.", + "type": "integer", + "format": "int32" + }, + "hostIP": { + "description": "What host IP to bind the external port to.", + "type": "string" + }, + "hostPort": { + "description": "Number of port to expose on the host. If specified, this must be a valid port number, 0 \u003c x \u003c 65536. If HostNetwork is specified, this must match ContainerPort. Most containers do not need this.", + "type": "integer", + "format": "int32" + }, + "name": { + "description": "If specified, this must be an IANA_SVC_NAME and unique within the pod. Each named port in a pod must have a unique name. Name for the port that can be referred to by services.", + "type": "string" + }, + "protocol": { + "description": "Protocol for port. Must be UDP or TCP. Defaults to \"TCP\".", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ContainerState": { + "description": "ContainerState holds a possible state of container. Only one of its members may be specified. If none of them is specified, the default one is ContainerStateWaiting.", + "properties": { + "running": { + "description": "Details about a running container", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStateRunning" + }, + "terminated": { + "description": "Details about a terminated container", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStateTerminated" + }, + "waiting": { + "description": "Details about a waiting container", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStateWaiting" + } + } + }, + "io.k8s.api.core.v1.ContainerStateRunning": { + "description": "ContainerStateRunning is a running state of a container.", + "properties": { + "startedAt": { + "description": "Time at which the container was last (re-)started", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + } + } + }, + "io.k8s.api.core.v1.ContainerStateTerminated": { + "description": "ContainerStateTerminated is a terminated state of a container.", + "required": [ + "exitCode" + ], + "properties": { + "containerID": { + "description": "Container's ID in the format 'docker://\u003ccontainer_id\u003e'", + "type": "string" + }, + "exitCode": { + "description": "Exit status from the last termination of the container", + "type": "integer", + "format": "int32" + }, + "finishedAt": { + "description": "Time at which the container last terminated", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "Message regarding the last termination of the container", + "type": "string" + }, + "reason": { + "description": "(brief) reason from the last termination of the container", + "type": "string" + }, + "signal": { + "description": "Signal from the last termination of the container", + "type": "integer", + "format": "int32" + }, + "startedAt": { + "description": "Time at which previous execution of the container started", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + } + } + }, + "io.k8s.api.core.v1.ContainerStateWaiting": { + "description": "ContainerStateWaiting is a waiting state of a container.", + "properties": { + "message": { + "description": "Message regarding why the container is not yet running.", + "type": "string" + }, + "reason": { + "description": "(brief) reason the container is not yet running.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ContainerStatus": { + "description": "ContainerStatus contains details for the current status of this container.", + "required": [ + "name", + "ready", + "restartCount", + "image", + "imageID" + ], + "properties": { + "containerID": { + "description": "Container's ID in the format 'docker://\u003ccontainer_id\u003e'.", + "type": "string" + }, + "image": { + "description": "The image the container is running. More info: https://kubernetes.io/docs/concepts/containers/images", + "type": "string" + }, + "imageID": { + "description": "ImageID of the container's image.", + "type": "string" + }, + "lastState": { + "description": "Details about the container's last termination condition.", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerState" + }, + "name": { + "description": "This must be a DNS_LABEL. Each container in a pod must have a unique name. Cannot be updated.", + "type": "string" + }, + "ready": { + "description": "Specifies whether the container has passed its readiness probe.", + "type": "boolean" + }, + "restartCount": { + "description": "The number of times the container has been restarted, currently based on the number of dead containers that have not yet been removed. Note that this is calculated from dead containers. But those containers are subject to garbage collection. This value will get capped at 5 by GC.", + "type": "integer", + "format": "int32" + }, + "state": { + "description": "Details about the container's current condition.", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerState" + } + } + }, + "io.k8s.api.core.v1.DaemonEndpoint": { + "description": "DaemonEndpoint contains information about a single Daemon endpoint.", + "required": [ + "Port" + ], + "properties": { + "Port": { + "description": "Port number of the given endpoint.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.DownwardAPIProjection": { + "description": "Represents downward API info for projecting into a projected volume. Note that this is identical to a downwardAPI volume source without the default mode.", + "properties": { + "items": { + "description": "Items is a list of DownwardAPIVolume file", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIVolumeFile" + } + } + } + }, + "io.k8s.api.core.v1.DownwardAPIVolumeFile": { + "description": "DownwardAPIVolumeFile represents information to create the file containing the pod field", + "required": [ + "path" + ], + "properties": { + "fieldRef": { + "description": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectFieldSelector" + }, + "mode": { + "description": "Optional: mode bits to use on this file, must be a value between 0 and 0777. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "path": { + "description": "Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..'", + "type": "string" + }, + "resourceFieldRef": { + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceFieldSelector" + } + } + }, + "io.k8s.api.core.v1.DownwardAPIVolumeSource": { + "description": "DownwardAPIVolumeSource represents a volume containing downward API info. Downward API volumes support ownership management and SELinux relabeling.", + "properties": { + "defaultMode": { + "description": "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "items": { + "description": "Items is a list of downward API volume file", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIVolumeFile" + } + } + } + }, + "io.k8s.api.core.v1.EmptyDirVolumeSource": { + "description": "Represents an empty directory for a pod. Empty directory volumes support ownership management and SELinux relabeling.", + "properties": { + "medium": { + "description": "What type of storage medium should back this directory. The default is \"\" which means to use the node's default medium. Must be an empty string (default) or Memory. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + "type": "string" + }, + "sizeLimit": { + "description": "Total amount of local storage required for this EmptyDir volume. The size limit is also applicable for memory medium. The maximum usage on memory medium EmptyDir would be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. More info: http://kubernetes.io/docs/user-guide/volumes#emptydir", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + } + }, + "io.k8s.api.core.v1.EndpointAddress": { + "description": "EndpointAddress is a tuple that describes single IP address.", + "required": [ + "ip" + ], + "properties": { + "hostname": { + "description": "The Hostname of this endpoint", + "type": "string" + }, + "ip": { + "description": "The IP of this endpoint. May not be loopback (127.0.0.0/8), link-local (169.254.0.0/16), or link-local multicast ((224.0.0.0/24). IPv6 is also accepted but not fully supported on all platforms. Also, certain kubernetes components, like kube-proxy, are not IPv6 ready.", + "type": "string" + }, + "nodeName": { + "description": "Optional: Node hosting this endpoint. This can be used to determine endpoints local to a node.", + "type": "string" + }, + "targetRef": { + "description": "Reference to object providing the endpoint.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + } + } + }, + "io.k8s.api.core.v1.EndpointPort": { + "description": "EndpointPort is a tuple that describes a single port.", + "required": [ + "port" + ], + "properties": { + "name": { + "description": "The name of this port (corresponds to ServicePort.Name). Must be a DNS_LABEL. Optional only if one port is defined.", + "type": "string" + }, + "port": { + "description": "The port number of the endpoint.", + "type": "integer", + "format": "int32" + }, + "protocol": { + "description": "The IP protocol for this port. Must be UDP or TCP. Default is TCP.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.EndpointSubset": { + "description": "EndpointSubset is a group of addresses with a common set of ports. The expanded set of endpoints is the Cartesian product of Addresses x Ports. For example, given:\n {\n Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n }\nThe resulting set of endpoints can be viewed as:\n a: [ 10.10.1.1:8675, 10.10.2.2:8675 ],\n b: [ 10.10.1.1:309, 10.10.2.2:309 ]", + "properties": { + "addresses": { + "description": "IP addresses which offer the related ports that are marked as ready. These endpoints should be considered safe for load balancers and clients to utilize.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointAddress" + } + }, + "notReadyAddresses": { + "description": "IP addresses which offer the related ports but are not currently marked as ready because they have not yet finished starting, have recently failed a readiness check, or have recently failed a liveness check.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointAddress" + } + }, + "ports": { + "description": "Port numbers available on the related IP addresses.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointPort" + } + } + } + }, + "io.k8s.api.core.v1.Endpoints": { + "description": "Endpoints is a collection of endpoints that implement the actual service. Example:\n Name: \"mysvc\",\n Subsets: [\n {\n Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n },\n {\n Addresses: [{\"ip\": \"10.10.3.3\"}],\n Ports: [{\"name\": \"a\", \"port\": 93}, {\"name\": \"b\", \"port\": 76}]\n },\n ]", + "required": [ + "subsets" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "subsets": { + "description": "The set of all endpoints is the union of all subsets. Addresses are placed into subsets according to the IPs they share. A single address with multiple ports, some of which are ready and some of which are not (because they come from different containers) will result in the address being displayed in different subsets for the different ports. No address will appear in both Addresses and NotReadyAddresses in the same subset. Sets of addresses and ports that comprise a service.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointSubset" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Endpoints", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EndpointsList": { + "description": "EndpointsList is a list of endpoints.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of endpoints.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Endpoints" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "EndpointsList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EnvFromSource": { + "description": "EnvFromSource represents the source of a set of ConfigMaps", + "properties": { + "configMapRef": { + "description": "The ConfigMap to select from", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapEnvSource" + }, + "prefix": { + "description": "An optional identifer to prepend to each key in the ConfigMap. Must be a C_IDENTIFIER.", + "type": "string" + }, + "secretRef": { + "description": "The Secret to select from", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretEnvSource" + } + } + }, + "io.k8s.api.core.v1.EnvVar": { + "description": "EnvVar represents an environment variable present in a Container.", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "Name of the environment variable. Must be a C_IDENTIFIER.", + "type": "string" + }, + "value": { + "description": "Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to \"\".", + "type": "string" + }, + "valueFrom": { + "description": "Source for the environment variable's value. Cannot be used if value is not empty.", + "$ref": "#/definitions/io.k8s.api.core.v1.EnvVarSource" + } + } + }, + "io.k8s.api.core.v1.EnvVarSource": { + "description": "EnvVarSource represents a source for the value of an EnvVar.", + "properties": { + "configMapKeyRef": { + "description": "Selects a key of a ConfigMap.", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapKeySelector" + }, + "fieldRef": { + "description": "Selects a field of the pod: supports metadata.name, metadata.namespace, metadata.labels, metadata.annotations, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectFieldSelector" + }, + "resourceFieldRef": { + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceFieldSelector" + }, + "secretKeyRef": { + "description": "Selects a key of a secret in the pod's namespace", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretKeySelector" + } + } + }, + "io.k8s.api.core.v1.Event": { + "description": "Event is a report of an event somewhere in the cluster.", + "required": [ + "metadata", + "involvedObject" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "count": { + "description": "The number of times this event has occurred.", + "type": "integer", + "format": "int32" + }, + "firstTimestamp": { + "description": "The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "involvedObject": { + "description": "The object that this event is about.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "lastTimestamp": { + "description": "The time at which the most recent occurrence of this event was recorded.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "A human-readable description of the status of this operation.", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "reason": { + "description": "This should be a short, machine understandable string that gives the reason for the transition into the object's current status.", + "type": "string" + }, + "source": { + "description": "The component reporting this event. Should be a short machine understandable string.", + "$ref": "#/definitions/io.k8s.api.core.v1.EventSource" + }, + "type": { + "description": "Type of this event (Normal, Warning), new types could be added in the future", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Event", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EventList": { + "description": "EventList is a list of events.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of events", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Event" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "EventList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EventSource": { + "description": "EventSource contains information for an event.", + "properties": { + "component": { + "description": "Component from which the event is generated.", + "type": "string" + }, + "host": { + "description": "Node name on which the event is generated.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ExecAction": { + "description": "ExecAction describes a \"run in container\" action.", + "properties": { + "command": { + "description": "Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.FCVolumeSource": { + "description": "Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.", + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "lun": { + "description": "Optional: FC target lun number", + "type": "integer", + "format": "int32" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "targetWWNs": { + "description": "Optional: FC target worldwide names (WWNs)", + "type": "array", + "items": { + "type": "string" + } + }, + "wwids": { + "description": "Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.FlexVolumeSource": { + "description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.", + "required": [ + "driver" + ], + "properties": { + "driver": { + "description": "Driver is the name of the driver to use for this volume.", + "type": "string" + }, + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script.", + "type": "string" + }, + "options": { + "description": "Optional: Extra command options if any.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + } + } + }, + "io.k8s.api.core.v1.FlockerVolumeSource": { + "description": "Represents a Flocker volume mounted by the Flocker agent. One and only one of datasetName and datasetUUID should be set. Flocker volumes do not support ownership management or SELinux relabeling.", + "properties": { + "datasetName": { + "description": "Name of the dataset stored as metadata -\u003e name on the dataset for Flocker should be considered as deprecated", + "type": "string" + }, + "datasetUUID": { + "description": "UUID of the dataset. This is unique identifier of a Flocker dataset", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.GCEPersistentDiskVolumeSource": { + "description": "Represents a Persistent Disk resource in Google Compute Engine.\n\nA GCE PD must exist before mounting to a container. The disk must also be in the same GCE project and zone as the kubelet. A GCE PD can only be mounted as read/write once or read-only many times. GCE PDs support ownership management and SELinux relabeling.", + "required": [ + "pdName" + ], + "properties": { + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "string" + }, + "partition": { + "description": "The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "integer", + "format": "int32" + }, + "pdName": { + "description": "Unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.GitRepoVolumeSource": { + "description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.", + "required": [ + "repository" + ], + "properties": { + "directory": { + "description": "Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.", + "type": "string" + }, + "repository": { + "description": "Repository URL", + "type": "string" + }, + "revision": { + "description": "Commit hash for the specified revision.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.GlusterfsVolumeSource": { + "description": "Represents a Glusterfs mount that lasts the lifetime of a pod. Glusterfs volumes do not support ownership management or SELinux relabeling.", + "required": [ + "endpoints", + "path" + ], + "properties": { + "endpoints": { + "description": "EndpointsName is the endpoint name that details Glusterfs topology. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md#create-a-pod", + "type": "string" + }, + "path": { + "description": "Path is the Glusterfs volume path. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md#create-a-pod", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the Glusterfs volume to be mounted with read-only permissions. Defaults to false. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md#create-a-pod", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.HTTPGetAction": { + "description": "HTTPGetAction describes an action based on HTTP Get requests.", + "required": [ + "port" + ], + "properties": { + "host": { + "description": "Host name to connect to, defaults to the pod IP. You probably want to set \"Host\" in httpHeaders instead.", + "type": "string" + }, + "httpHeaders": { + "description": "Custom headers to set in the request. HTTP allows repeated headers.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.HTTPHeader" + } + }, + "path": { + "description": "Path to access on the HTTP server.", + "type": "string" + }, + "port": { + "description": "Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + }, + "scheme": { + "description": "Scheme to use for connecting to the host. Defaults to HTTP.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.HTTPHeader": { + "description": "HTTPHeader describes a custom header to be used in HTTP probes", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "description": "The header field name", + "type": "string" + }, + "value": { + "description": "The header field value", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Handler": { + "description": "Handler defines a specific action that should be taken", + "properties": { + "exec": { + "description": "One and only one of the following should be specified. Exec specifies the action to take.", + "$ref": "#/definitions/io.k8s.api.core.v1.ExecAction" + }, + "httpGet": { + "description": "HTTPGet specifies the http request to perform.", + "$ref": "#/definitions/io.k8s.api.core.v1.HTTPGetAction" + }, + "tcpSocket": { + "description": "TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported", + "$ref": "#/definitions/io.k8s.api.core.v1.TCPSocketAction" + } + } + }, + "io.k8s.api.core.v1.HostAlias": { + "description": "HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.", + "properties": { + "hostnames": { + "description": "Hostnames for the above IP address.", + "type": "array", + "items": { + "type": "string" + } + }, + "ip": { + "description": "IP address of the host file entry.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.HostPathVolumeSource": { + "description": "Represents a host path mapped into a pod. Host path volumes do not support ownership management or SELinux relabeling.", + "required": [ + "path" + ], + "properties": { + "path": { + "description": "Path of the directory on the host. If the path is a symlink, it will follow the link to the real path. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "type": "string" + }, + "type": { + "description": "Type for HostPath Volume Defaults to \"\" More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ISCSIVolumeSource": { + "description": "Represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.", + "required": [ + "targetPortal", + "iqn", + "lun" + ], + "properties": { + "chapAuthDiscovery": { + "description": "whether support iSCSI Discovery CHAP authentication", + "type": "boolean" + }, + "chapAuthSession": { + "description": "whether support iSCSI Session CHAP authentication", + "type": "boolean" + }, + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#iscsi", + "type": "string" + }, + "initiatorName": { + "description": "Custom iSCSI initiator name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface \u003ctarget portal\u003e:\u003cvolume name\u003e will be created for the connection.", + "type": "string" + }, + "iqn": { + "description": "Target iSCSI Qualified Name.", + "type": "string" + }, + "iscsiInterface": { + "description": "Optional: Defaults to 'default' (tcp). iSCSI interface name that uses an iSCSI transport.", + "type": "string" + }, + "lun": { + "description": "iSCSI target lun number.", + "type": "integer", + "format": "int32" + }, + "portals": { + "description": "iSCSI target portal List. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + "type": "array", + "items": { + "type": "string" + } + }, + "readOnly": { + "description": "ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.", + "type": "boolean" + }, + "secretRef": { + "description": "CHAP secret for iSCSI target and initiator authentication", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "targetPortal": { + "description": "iSCSI target portal. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.KeyToPath": { + "description": "Maps a string key to a path within a volume.", + "required": [ + "key", + "path" + ], + "properties": { + "key": { + "description": "The key to project.", + "type": "string" + }, + "mode": { + "description": "Optional: mode bits to use on this file, must be a value between 0 and 0777. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "path": { + "description": "The relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Lifecycle": { + "description": "Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted.", + "properties": { + "postStart": { + "description": "PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks", + "$ref": "#/definitions/io.k8s.api.core.v1.Handler" + }, + "preStop": { + "description": "PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks", + "$ref": "#/definitions/io.k8s.api.core.v1.Handler" + } + } + }, + "io.k8s.api.core.v1.LimitRange": { + "description": "LimitRange sets resource usage limits for each kind of resource in a Namespace.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the limits enforced. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.LimitRangeSpec" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "LimitRange", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.LimitRangeItem": { + "description": "LimitRangeItem defines a min/max usage limit for any resource that matches on kind.", + "properties": { + "default": { + "description": "Default resource requirement limit value by resource name if resource limit is omitted.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "defaultRequest": { + "description": "DefaultRequest is the default resource requirement request value by resource name if resource request is omitted.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "max": { + "description": "Max usage constraints on this kind by resource name.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "maxLimitRequestRatio": { + "description": "MaxLimitRequestRatio if specified, the named resource must have a request and limit that are both non-zero where limit divided by request is less than or equal to the enumerated value; this represents the max burst for the named resource.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "min": { + "description": "Min usage constraints on this kind by resource name.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "type": { + "description": "Type of resource that this limit applies to.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.LimitRangeList": { + "description": "LimitRangeList is a list of LimitRange items.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is a list of LimitRange objects. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_limit_range.md", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LimitRange" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "LimitRangeList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.LimitRangeSpec": { + "description": "LimitRangeSpec defines a min/max usage limit for resources that match on kind.", + "required": [ + "limits" + ], + "properties": { + "limits": { + "description": "Limits is the list of LimitRangeItem objects that are enforced.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LimitRangeItem" + } + } + } + }, + "io.k8s.api.core.v1.LoadBalancerIngress": { + "description": "LoadBalancerIngress represents the status of a load-balancer ingress point: traffic intended for the service should be sent to an ingress point.", + "properties": { + "hostname": { + "description": "Hostname is set for load-balancer ingress points that are DNS based (typically AWS load-balancers)", + "type": "string" + }, + "ip": { + "description": "IP is set for load-balancer ingress points that are IP based (typically GCE or OpenStack load-balancers)", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.LoadBalancerStatus": { + "description": "LoadBalancerStatus represents the status of a load-balancer.", + "properties": { + "ingress": { + "description": "Ingress is a list containing ingress points for the load-balancer. Traffic intended for the service should be sent to these ingress points.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LoadBalancerIngress" + } + } + } + }, + "io.k8s.api.core.v1.LocalObjectReference": { + "description": "LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.", + "properties": { + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.LocalVolumeSource": { + "description": "Local represents directly-attached storage with node affinity", + "required": [ + "path" + ], + "properties": { + "path": { + "description": "The full path to the volume on the node For alpha, this path must be a directory Once block as a source is supported, then this path can point to a block device", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.NFSVolumeSource": { + "description": "Represents an NFS mount that lasts the lifetime of a pod. NFS volumes do not support ownership management or SELinux relabeling.", + "required": [ + "server", + "path" + ], + "properties": { + "path": { + "description": "Path that is exported by the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the NFS export to be mounted with read-only permissions. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "type": "boolean" + }, + "server": { + "description": "Server is the hostname or IP address of the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Namespace": { + "description": "Namespace provides a scope for Names. Use of multiple namespaces is optional.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the behavior of the Namespace. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NamespaceSpec" + }, + "status": { + "description": "Status describes the current status of a Namespace. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NamespaceStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Namespace", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NamespaceList": { + "description": "NamespaceList is a list of Namespaces.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of Namespace objects in the list. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Namespace" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "NamespaceList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NamespaceSpec": { + "description": "NamespaceSpec describes the attributes on a Namespace.", + "properties": { + "finalizers": { + "description": "Finalizers is an opaque list of values that must be empty to permanently remove object from storage. More info: https://git.k8s.io/community/contributors/design-proposals/namespaces.md#finalizers", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.NamespaceStatus": { + "description": "NamespaceStatus is information about the current status of a Namespace.", + "properties": { + "phase": { + "description": "Phase is the current lifecycle phase of the namespace. More info: https://git.k8s.io/community/contributors/design-proposals/namespaces.md#phases", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Node": { + "description": "Node is a worker node in Kubernetes. Each node will have a unique identifier in the cache (i.e. in etcd).", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the behavior of a node. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSpec" + }, + "status": { + "description": "Most recently observed status of the node. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Node", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NodeAddress": { + "description": "NodeAddress contains information for the node's address.", + "required": [ + "type", + "address" + ], + "properties": { + "address": { + "description": "The node address.", + "type": "string" + }, + "type": { + "description": "Node address type, one of Hostname, ExternalIP or InternalIP.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.NodeAffinity": { + "description": "Node affinity is a group of node affinity scheduling rules.", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "description": "The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node matches the corresponding matchExpressions; the node(s) with the highest sum are the most preferred.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PreferredSchedulingTerm" + } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "description": "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to an update), the system may or may not try to eventually evict the pod from its node.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector" + } + } + }, + "io.k8s.api.core.v1.NodeCondition": { + "description": "NodeCondition contains condition information for a node.", + "required": [ + "type", + "status" + ], + "properties": { + "lastHeartbeatTime": { + "description": "Last time we got an update on a given condition.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "lastTransitionTime": { + "description": "Last time the condition transit from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "Human readable message indicating details about last transition.", + "type": "string" + }, + "reason": { + "description": "(brief) reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of node condition.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.NodeConfigSource": { + "description": "NodeConfigSource specifies a source of node configuration. Exactly one subfield (excluding metadata) must be non-nil.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "configMapRef": { + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "NodeConfigSource", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NodeDaemonEndpoints": { + "description": "NodeDaemonEndpoints lists ports opened by daemons running on the Node.", + "properties": { + "kubeletEndpoint": { + "description": "Endpoint on which Kubelet is listening.", + "$ref": "#/definitions/io.k8s.api.core.v1.DaemonEndpoint" + } + } + }, + "io.k8s.api.core.v1.NodeList": { + "description": "NodeList is the whole list of all Nodes which have been registered with master.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of nodes", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Node" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "NodeList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NodeSelector": { + "description": "A node selector represents the union of the results of one or more label queries over a set of nodes; that is, it represents the OR of the selectors represented by the node selector terms.", + "required": [ + "nodeSelectorTerms" + ], + "properties": { + "nodeSelectorTerms": { + "description": "Required. A list of node selector terms. The terms are ORed.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorTerm" + } + } + } + }, + "io.k8s.api.core.v1.NodeSelectorRequirement": { + "description": "A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + "required": [ + "key", + "operator" + ], + "properties": { + "key": { + "description": "The label key that the selector applies to.", + "type": "string" + }, + "operator": { + "description": "Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.", + "type": "string" + }, + "values": { + "description": "An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. If the operator is Gt or Lt, the values array must have a single element, which will be interpreted as an integer. This array is replaced during a strategic merge patch.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.NodeSelectorTerm": { + "description": "A null or empty node selector term matches no objects.", + "required": [ + "matchExpressions" + ], + "properties": { + "matchExpressions": { + "description": "Required. A list of node selector requirements. The requirements are ANDed.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorRequirement" + } + } + } + }, + "io.k8s.api.core.v1.NodeSpec": { + "description": "NodeSpec describes the attributes that a node is created with.", + "properties": { + "configSource": { + "description": "If specified, the source to get node configuration from The DynamicKubeletConfig feature gate must be enabled for the Kubelet to use this field", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeConfigSource" + }, + "externalID": { + "description": "External ID of the node assigned by some machine database (e.g. a cloud provider). Deprecated.", + "type": "string" + }, + "podCIDR": { + "description": "PodCIDR represents the pod IP range assigned to the node.", + "type": "string" + }, + "providerID": { + "description": "ID of the node assigned by the cloud provider in the format: \u003cProviderName\u003e://\u003cProviderSpecificNodeID\u003e", + "type": "string" + }, + "taints": { + "description": "If specified, the node's taints.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Taint" + } + }, + "unschedulable": { + "description": "Unschedulable controls node schedulability of new pods. By default, node is schedulable. More info: https://kubernetes.io/docs/concepts/nodes/node/#manual-node-administration", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.NodeStatus": { + "description": "NodeStatus is information about the current status of a node.", + "properties": { + "addresses": { + "description": "List of addresses reachable to the node. Queried from cloud provider, if available. More info: https://kubernetes.io/docs/concepts/nodes/node/#addresses", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeAddress" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "allocatable": { + "description": "Allocatable represents the resources of a node that are available for scheduling. Defaults to Capacity.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "capacity": { + "description": "Capacity represents the total resources of a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "conditions": { + "description": "Conditions is an array of current observed node conditions. More info: https://kubernetes.io/docs/concepts/nodes/node/#condition", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "daemonEndpoints": { + "description": "Endpoints of daemons running on the Node.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeDaemonEndpoints" + }, + "images": { + "description": "List of container images on this node", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerImage" + } + }, + "nodeInfo": { + "description": "Set of ids/uuids to uniquely identify the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#info", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSystemInfo" + }, + "phase": { + "description": "NodePhase is the recently observed lifecycle phase of the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#phase The field is never populated, and now is deprecated.", + "type": "string" + }, + "volumesAttached": { + "description": "List of volumes that are attached to the node.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.AttachedVolume" + } + }, + "volumesInUse": { + "description": "List of attachable volumes in use (mounted) by the node.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.NodeSystemInfo": { + "description": "NodeSystemInfo is a set of ids/uuids to uniquely identify the node.", + "required": [ + "machineID", + "systemUUID", + "bootID", + "kernelVersion", + "osImage", + "containerRuntimeVersion", + "kubeletVersion", + "kubeProxyVersion", + "operatingSystem", + "architecture" + ], + "properties": { + "architecture": { + "description": "The Architecture reported by the node", + "type": "string" + }, + "bootID": { + "description": "Boot ID reported by the node.", + "type": "string" + }, + "containerRuntimeVersion": { + "description": "ContainerRuntime Version reported by the node through runtime remote API (e.g. docker://1.5.0).", + "type": "string" + }, + "kernelVersion": { + "description": "Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).", + "type": "string" + }, + "kubeProxyVersion": { + "description": "KubeProxy Version reported by the node.", + "type": "string" + }, + "kubeletVersion": { + "description": "Kubelet Version reported by the node.", + "type": "string" + }, + "machineID": { + "description": "MachineID reported by the node. For unique machine identification in the cluster this field is preferred. Learn more from man(5) machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html", + "type": "string" + }, + "operatingSystem": { + "description": "The Operating System reported by the node", + "type": "string" + }, + "osImage": { + "description": "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).", + "type": "string" + }, + "systemUUID": { + "description": "SystemUUID reported by the node. For unique machine identification MachineID is preferred. This field is specific to Red Hat hosts https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/getting-system-uuid.html", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ObjectFieldSelector": { + "description": "ObjectFieldSelector selects an APIVersioned field of an object.", + "required": [ + "fieldPath" + ], + "properties": { + "apiVersion": { + "description": "Version of the schema the FieldPath is written in terms of, defaults to \"v1\".", + "type": "string" + }, + "fieldPath": { + "description": "Path of the field to select in the specified API version.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ObjectReference": { + "description": "ObjectReference contains enough information to let you inspect or modify the referred object.", + "properties": { + "apiVersion": { + "description": "API version of the referent.", + "type": "string" + }, + "fieldPath": { + "description": "If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: \"spec.containers{name}\" (where \"name\" refers to the name of the container that triggered the event) or if no container name is specified \"spec.containers[2]\" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.", + "type": "string" + }, + "kind": { + "description": "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "namespace": { + "description": "Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + "type": "string" + }, + "resourceVersion": { + "description": "Specific resourceVersion to which this reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency", + "type": "string" + }, + "uid": { + "description": "UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PersistentVolume": { + "description": "PersistentVolume (PV) is a storage resource provisioned by an administrator. It is analogous to a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines a specification of a persistent volume owned by the cluster. Provisioned by an administrator. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistent-volumes", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeSpec" + }, + "status": { + "description": "Status represents the current information/status for the persistent volume. Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistent-volumes", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolume", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeClaim": { + "description": "PersistentVolumeClaim is a user's request for and claim to a persistent volume", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaimSpec" + }, + "status": { + "description": "Status represents the current information/status of a persistent volume claim. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaimStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolumeClaim", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeClaimList": { + "description": "PersistentVolumeClaimList is a list of PersistentVolumeClaim items.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "A list of persistent volume claims. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaim" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolumeClaimList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeClaimSpec": { + "description": "PersistentVolumeClaimSpec describes the common attributes of storage devices and allows a Source for provider-specific attributes", + "properties": { + "accessModes": { + "description": "AccessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1", + "type": "array", + "items": { + "type": "string" + } + }, + "resources": { + "description": "Resources represents the minimum resources the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements" + }, + "selector": { + "description": "A label query over volumes to consider for binding.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "storageClassName": { + "description": "Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1", + "type": "string" + }, + "volumeName": { + "description": "VolumeName is the binding reference to the PersistentVolume backing this claim.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeClaimStatus": { + "description": "PersistentVolumeClaimStatus is the current status of a persistent volume claim.", + "properties": { + "accessModes": { + "description": "AccessModes contains the actual access modes the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1", + "type": "array", + "items": { + "type": "string" + } + }, + "capacity": { + "description": "Represents the actual resources of the underlying volume.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "phase": { + "description": "Phase represents the current phase of PersistentVolumeClaim.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeClaimVolumeSource": { + "description": "PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace. This volume finds the bound PV and mounts that volume for the pod. A PersistentVolumeClaimVolumeSource is, essentially, a wrapper around another type of volume that is owned by someone else (the system).", + "required": [ + "claimName" + ], + "properties": { + "claimName": { + "description": "ClaimName is the name of a PersistentVolumeClaim in the same namespace as the pod using this volume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "type": "string" + }, + "readOnly": { + "description": "Will force the ReadOnly setting in VolumeMounts. Default false.", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeList": { + "description": "PersistentVolumeList is a list of PersistentVolume items.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of persistent volumes. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolume" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolumeList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeSpec": { + "description": "PersistentVolumeSpec is the specification of a persistent volume.", + "properties": { + "accessModes": { + "description": "AccessModes contains all ways the volume can be mounted. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes", + "type": "array", + "items": { + "type": "string" + } + }, + "awsElasticBlockStore": { + "description": "AWSElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "$ref": "#/definitions/io.k8s.api.core.v1.AWSElasticBlockStoreVolumeSource" + }, + "azureDisk": { + "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureDiskVolumeSource" + }, + "azureFile": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureFilePersistentVolumeSource" + }, + "capacity": { + "description": "A description of the persistent volume's resources and capacity. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "cephfs": { + "description": "CephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.CephFSPersistentVolumeSource" + }, + "cinder": { + "description": "Cinder represents a cinder volume attached and mounted on kubelets host machine More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.CinderVolumeSource" + }, + "claimRef": { + "description": "ClaimRef is part of a bi-directional binding between PersistentVolume and PersistentVolumeClaim. Expected to be non-nil when bound. claim.VolumeName is the authoritative bind between PV and PVC. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#binding", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "fc": { + "description": "FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.FCVolumeSource" + }, + "flexVolume": { + "description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.", + "$ref": "#/definitions/io.k8s.api.core.v1.FlexVolumeSource" + }, + "flocker": { + "description": "Flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running", + "$ref": "#/definitions/io.k8s.api.core.v1.FlockerVolumeSource" + }, + "gcePersistentDisk": { + "description": "GCEPersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "$ref": "#/definitions/io.k8s.api.core.v1.GCEPersistentDiskVolumeSource" + }, + "glusterfs": { + "description": "Glusterfs represents a Glusterfs volume that is attached to a host and exposed to the pod. Provisioned by an admin. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.GlusterfsVolumeSource" + }, + "hostPath": { + "description": "HostPath represents a directory on the host. Provisioned by a developer or tester. This is useful for single-node development and testing only! On-host storage is not supported in any way and WILL NOT WORK in a multi-node cluster. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "$ref": "#/definitions/io.k8s.api.core.v1.HostPathVolumeSource" + }, + "iscsi": { + "description": "ISCSI represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin.", + "$ref": "#/definitions/io.k8s.api.core.v1.ISCSIVolumeSource" + }, + "local": { + "description": "Local represents directly-attached storage with node affinity", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalVolumeSource" + }, + "mountOptions": { + "description": "A list of mount options, e.g. [\"ro\", \"soft\"]. Not validated - mount will simply fail if one is invalid. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#mount-options", + "type": "array", + "items": { + "type": "string" + } + }, + "nfs": { + "description": "NFS represents an NFS mount on the host. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "$ref": "#/definitions/io.k8s.api.core.v1.NFSVolumeSource" + }, + "persistentVolumeReclaimPolicy": { + "description": "What happens to a persistent volume when released from its claim. Valid options are Retain (default) and Recycle. Recycling must be supported by the volume plugin underlying this persistent volume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#reclaiming", + "type": "string" + }, + "photonPersistentDisk": { + "description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource" + }, + "portworxVolume": { + "description": "PortworxVolume represents a portworx volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PortworxVolumeSource" + }, + "quobyte": { + "description": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.QuobyteVolumeSource" + }, + "rbd": { + "description": "RBD represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.RBDVolumeSource" + }, + "scaleIO": { + "description": "ScaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + "$ref": "#/definitions/io.k8s.api.core.v1.ScaleIOVolumeSource" + }, + "storageClassName": { + "description": "Name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.", + "type": "string" + }, + "storageos": { + "description": "StorageOS represents a StorageOS volume that is attached to the kubelet's host machine and mounted into the pod More info: https://releases.k8s.io/HEAD/examples/volumes/storageos/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.StorageOSPersistentVolumeSource" + }, + "vsphereVolume": { + "description": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeStatus": { + "description": "PersistentVolumeStatus is the current status of a persistent volume.", + "properties": { + "message": { + "description": "A human-readable message indicating details about why the volume is in this state.", + "type": "string" + }, + "phase": { + "description": "Phase indicates if a volume is available, bound to a claim, or released by a claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#phase", + "type": "string" + }, + "reason": { + "description": "Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource": { + "description": "Represents a Photon Controller persistent disk resource.", + "required": [ + "pdID" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "pdID": { + "description": "ID that identifies Photon Controller persistent disk", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Pod": { + "description": "Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodSpec" + }, + "status": { + "description": "Most recently observed status of the pod. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Pod", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodAffinity": { + "description": "Pod affinity is a group of inter pod affinity scheduling rules.", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "description": "The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.WeightedPodAffinityTerm" + } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "description": "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinityTerm" + } + } + } + }, + "io.k8s.api.core.v1.PodAffinityTerm": { + "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", + "properties": { + "labelSelector": { + "description": "A label query over a set of resources, in this case pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "namespaces": { + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"", + "type": "array", + "items": { + "type": "string" + } + }, + "topologyKey": { + "description": "This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. For PreferredDuringScheduling pod anti-affinity, empty topologyKey is interpreted as \"all topologies\" (\"all topologies\" here means all the topologyKeys indicated by scheduler command-line argument --failure-domains); for affinity and for RequiredDuringScheduling pod anti-affinity, empty topologyKey is not allowed.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PodAntiAffinity": { + "description": "Pod anti affinity is a group of inter pod anti affinity scheduling rules.", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "description": "The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.WeightedPodAffinityTerm" + } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "description": "If the anti-affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the anti-affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinityTerm" + } + } + } + }, + "io.k8s.api.core.v1.PodCondition": { + "description": "PodCondition contains details for the current condition of this pod.", + "required": [ + "type", + "status" + ], + "properties": { + "lastProbeTime": { + "description": "Last time we probed the condition.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "lastTransitionTime": { + "description": "Last time the condition transitioned from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "Human-readable message indicating details about last transition.", + "type": "string" + }, + "reason": { + "description": "Unique, one-word, CamelCase reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status is the status of the condition. Can be True, False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + "type": "string" + }, + "type": { + "description": "Type is the type of the condition. Currently only Ready. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PodList": { + "description": "PodList is a list of Pods.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of pods. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Pod" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PodList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodSecurityContext": { + "description": "PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.", + "properties": { + "fsGroup": { + "description": "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod:\n\n1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw----\n\nIf unset, the Kubelet will not modify the ownership and permissions of any volume.", + "type": "integer", + "format": "int64" + }, + "runAsNonRoot": { + "description": "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "type": "boolean" + }, + "runAsUser": { + "description": "The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container.", + "type": "integer", + "format": "int64" + }, + "seLinuxOptions": { + "description": "The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container.", + "$ref": "#/definitions/io.k8s.api.core.v1.SELinuxOptions" + }, + "supplementalGroups": { + "description": "A list of groups applied to the first process run in each container, in addition to the container's primary GID. If unspecified, no groups will be added to any container.", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + }, + "io.k8s.api.core.v1.PodSpec": { + "description": "PodSpec is a description of a pod.", + "required": [ + "containers" + ], + "properties": { + "activeDeadlineSeconds": { + "description": "Optional duration in seconds the pod may be active on the node relative to StartTime before the system will actively try to mark it failed and kill associated containers. Value must be a positive integer.", + "type": "integer", + "format": "int64" + }, + "affinity": { + "description": "If specified, the pod's scheduling constraints", + "$ref": "#/definitions/io.k8s.api.core.v1.Affinity" + }, + "automountServiceAccountToken": { + "description": "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.", + "type": "boolean" + }, + "containers": { + "description": "List of containers belonging to the pod. Containers cannot currently be added or removed. There must be at least one container in a Pod. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Container" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "dnsPolicy": { + "description": "Set DNS policy for containers within the pod. One of 'ClusterFirstWithHostNet', 'ClusterFirst' or 'Default'. Defaults to \"ClusterFirst\". To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.", + "type": "string" + }, + "hostAliases": { + "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.HostAlias" + }, + "x-kubernetes-patch-merge-key": "ip", + "x-kubernetes-patch-strategy": "merge" + }, + "hostIPC": { + "description": "Use the host's ipc namespace. Optional: Default to false.", + "type": "boolean" + }, + "hostNetwork": { + "description": "Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false.", + "type": "boolean" + }, + "hostPID": { + "description": "Use the host's pid namespace. Optional: Default to false.", + "type": "boolean" + }, + "hostname": { + "description": "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.", + "type": "string" + }, + "imagePullSecrets": { + "description": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "initContainers": { + "description": "List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, or Liveness probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Container" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "nodeName": { + "description": "NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.", + "type": "string" + }, + "nodeSelector": { + "description": "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "priority": { + "description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.", + "type": "integer", + "format": "int32" + }, + "priorityClassName": { + "description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.", + "type": "string" + }, + "restartPolicy": { + "description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy", + "type": "string" + }, + "schedulerName": { + "description": "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.", + "type": "string" + }, + "securityContext": { + "description": "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodSecurityContext" + }, + "serviceAccount": { + "description": "DeprecatedServiceAccount is a depreciated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.", + "type": "string" + }, + "serviceAccountName": { + "description": "ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/", + "type": "string" + }, + "subdomain": { + "description": "If specified, the fully qualified Pod hostname will be \"\u003chostname\u003e.\u003csubdomain\u003e.\u003cpod namespace\u003e.svc.\u003ccluster domain\u003e\". If not specified, the pod will not have a domainname at all.", + "type": "string" + }, + "terminationGracePeriodSeconds": { + "description": "Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.", + "type": "integer", + "format": "int64" + }, + "tolerations": { + "description": "If specified, the pod's tolerations.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" + } + }, + "volumes": { + "description": "List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Volume" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys" + } + } + }, + "io.k8s.api.core.v1.PodStatus": { + "description": "PodStatus represents information about the status of a pod. Status may trail the actual state of a system.", + "properties": { + "conditions": { + "description": "Current service state of pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "containerStatuses": { + "description": "The list has one entry per container in the manifest. Each entry is currently the output of `docker inspect`. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStatus" + } + }, + "hostIP": { + "description": "IP address of the host to which the pod is assigned. Empty if not yet scheduled.", + "type": "string" + }, + "initContainerStatuses": { + "description": "The list has one entry per init container in the manifest. The most recent successful init container will have ready = true, the most recently started container will have startTime set. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStatus" + } + }, + "message": { + "description": "A human readable message indicating details about why the pod is in this condition.", + "type": "string" + }, + "phase": { + "description": "Current condition of the pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase", + "type": "string" + }, + "podIP": { + "description": "IP address allocated to the pod. Routable at least within the cluster. Empty if not yet allocated.", + "type": "string" + }, + "qosClass": { + "description": "The Quality of Service (QOS) classification assigned to the pod based on resource requirements See PodQOSClass type for available QOS classes More info: https://github.com/kubernetes/kubernetes/blob/master/docs/design/resource-qos.md", + "type": "string" + }, + "reason": { + "description": "A brief CamelCase message indicating details about why the pod is in this state. e.g. 'Evicted'", + "type": "string" + }, + "startTime": { + "description": "RFC 3339 date and time at which the object was acknowledged by the Kubelet. This is before the Kubelet pulled the container image(s) for the pod.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + } + } + }, + "io.k8s.api.core.v1.PodTemplate": { + "description": "PodTemplate describes a template for creating copies of a predefined pod.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "template": { + "description": "Template defines the pods that will be created from this pod template. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PodTemplate", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodTemplateList": { + "description": "PodTemplateList is a list of PodTemplates.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of pod templates", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplate" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PodTemplateList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodTemplateSpec": { + "description": "PodTemplateSpec describes the data a pod should have when created from a template", + "properties": { + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodSpec" + } + } + }, + "io.k8s.api.core.v1.PortworxVolumeSource": { + "description": "PortworxVolumeSource represents a Portworx volume resource.", + "required": [ + "volumeID" + ], + "properties": { + "fsType": { + "description": "FSType represents the filesystem type to mount Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "volumeID": { + "description": "VolumeID uniquely identifies a Portworx volume", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PreferredSchedulingTerm": { + "description": "An empty preferred scheduling term matches all objects with implicit weight 0 (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).", + "required": [ + "weight", + "preference" + ], + "properties": { + "preference": { + "description": "A node selector term, associated with the corresponding weight.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorTerm" + }, + "weight": { + "description": "Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.Probe": { + "description": "Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic.", + "properties": { + "exec": { + "description": "One and only one of the following should be specified. Exec specifies the action to take.", + "$ref": "#/definitions/io.k8s.api.core.v1.ExecAction" + }, + "failureThreshold": { + "description": "Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1.", + "type": "integer", + "format": "int32" + }, + "httpGet": { + "description": "HTTPGet specifies the http request to perform.", + "$ref": "#/definitions/io.k8s.api.core.v1.HTTPGetAction" + }, + "initialDelaySeconds": { + "description": "Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "type": "integer", + "format": "int32" + }, + "periodSeconds": { + "description": "How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.", + "type": "integer", + "format": "int32" + }, + "successThreshold": { + "description": "Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness. Minimum value is 1.", + "type": "integer", + "format": "int32" + }, + "tcpSocket": { + "description": "TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported", + "$ref": "#/definitions/io.k8s.api.core.v1.TCPSocketAction" + }, + "timeoutSeconds": { + "description": "Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.ProjectedVolumeSource": { + "description": "Represents a projected volume source", + "required": [ + "sources" + ], + "properties": { + "defaultMode": { + "description": "Mode bits to use on created files by default. Must be a value between 0 and 0777. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "sources": { + "description": "list of volume projections", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.VolumeProjection" + } + } + } + }, + "io.k8s.api.core.v1.QuobyteVolumeSource": { + "description": "Represents a Quobyte mount that lasts the lifetime of a pod. Quobyte volumes do not support ownership management or SELinux relabeling.", + "required": [ + "registry", + "volume" + ], + "properties": { + "group": { + "description": "Group to map volume access to Default is no group", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the Quobyte volume to be mounted with read-only permissions. Defaults to false.", + "type": "boolean" + }, + "registry": { + "description": "Registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes", + "type": "string" + }, + "user": { + "description": "User to map volume access to Defaults to serivceaccount user", + "type": "string" + }, + "volume": { + "description": "Volume is a string that references an already created Quobyte volume by name.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.RBDVolumeSource": { + "description": "Represents a Rados Block Device mount that lasts the lifetime of a pod. RBD volumes support ownership management and SELinux relabeling.", + "required": [ + "monitors", + "image" + ], + "properties": { + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd", + "type": "string" + }, + "image": { + "description": "The rados image name. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + }, + "keyring": { + "description": "Keyring is the path to key ring for RBDUser. Default is /etc/ceph/keyring. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + }, + "monitors": { + "description": "A collection of Ceph monitors. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "array", + "items": { + "type": "string" + } + }, + "pool": { + "description": "The rados pool name. Default is rbd. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef is name of the authentication secret for RBDUser. If provided overrides keyring. Default is nil. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "user": { + "description": "The rados user name. Default is admin. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ReplicationController": { + "description": "ReplicationController represents the configuration of a replication controller.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "If the Labels of a ReplicationController are empty, they are defaulted to be the same as the Pod(s) that the replication controller manages. Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the specification of the desired behavior of the replication controller. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationControllerSpec" + }, + "status": { + "description": "Status is the most recently observed status of the replication controller. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationControllerStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ReplicationController", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ReplicationControllerCondition": { + "description": "ReplicationControllerCondition describes the state of a replication controller at a certain point.", + "required": [ + "type", + "status" + ], + "properties": { + "lastTransitionTime": { + "description": "The last time the condition transitioned from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of replication controller condition.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ReplicationControllerList": { + "description": "ReplicationControllerList is a collection of replication controllers.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of replication controllers. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationController" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ReplicationControllerList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ReplicationControllerSpec": { + "description": "ReplicationControllerSpec is the specification of a replication controller.", + "properties": { + "minReadySeconds": { + "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Replicas is the number of desired replicas. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", + "type": "integer", + "format": "int32" + }, + "selector": { + "description": "Selector is a label query over pods that should match the Replicas count. If Selector is empty, it is defaulted to the labels present on the Pod template. Label keys and values that must match in order to be controlled by this replication controller, if empty defaulted to labels on Pod template. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "template": { + "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. This takes precedence over a TemplateRef. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + } + } + }, + "io.k8s.api.core.v1.ReplicationControllerStatus": { + "description": "ReplicationControllerStatus represents the current status of a replication controller.", + "required": [ + "replicas" + ], + "properties": { + "availableReplicas": { + "description": "The number of available replicas (ready for at least minReadySeconds) for this replication controller.", + "type": "integer", + "format": "int32" + }, + "conditions": { + "description": "Represents the latest available observations of a replication controller's current state.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationControllerCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "fullyLabeledReplicas": { + "description": "The number of pods that have labels matching the labels of the pod template of the replication controller.", + "type": "integer", + "format": "int32" + }, + "observedGeneration": { + "description": "ObservedGeneration reflects the generation of the most recently observed replication controller.", + "type": "integer", + "format": "int64" + }, + "readyReplicas": { + "description": "The number of ready replicas for this replication controller.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Replicas is the most recently oberved number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.ResourceFieldSelector": { + "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "required": [ + "resource" + ], + "properties": { + "containerName": { + "description": "Container name: required for volumes, optional for env vars", + "type": "string" + }, + "divisor": { + "description": "Specifies the output format of the exposed resources, defaults to \"1\"", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + }, + "resource": { + "description": "Required: resource to select", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ResourceQuota": { + "description": "ResourceQuota sets aggregate quota restrictions enforced per namespace", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the desired quota. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceQuotaSpec" + }, + "status": { + "description": "Status defines the actual enforced quota and its current usage. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceQuotaStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ResourceQuota", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ResourceQuotaList": { + "description": "ResourceQuotaList is a list of ResourceQuota items.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is a list of ResourceQuota objects. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_resource_quota.md", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceQuota" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ResourceQuotaList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ResourceQuotaSpec": { + "description": "ResourceQuotaSpec defines the desired hard limits to enforce for Quota.", + "properties": { + "hard": { + "description": "Hard is the set of desired hard limits for each named resource. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_resource_quota.md", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "scopes": { + "description": "A collection of filters that must match each object tracked by a quota. If not specified, the quota matches all objects.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.ResourceQuotaStatus": { + "description": "ResourceQuotaStatus defines the enforced hard limits and observed use.", + "properties": { + "hard": { + "description": "Hard is the set of enforced hard limits for each named resource. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_resource_quota.md", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "used": { + "description": "Used is the current observed total usage of the resource in the namespace.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + } + } + }, + "io.k8s.api.core.v1.ResourceRequirements": { + "description": "ResourceRequirements describes the compute resource requirements.", + "properties": { + "limits": { + "description": "Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "requests": { + "description": "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + } + } + }, + "io.k8s.api.core.v1.SELinuxOptions": { + "description": "SELinuxOptions are the labels to be applied to the container", + "properties": { + "level": { + "description": "Level is SELinux level label that applies to the container.", + "type": "string" + }, + "role": { + "description": "Role is a SELinux role label that applies to the container.", + "type": "string" + }, + "type": { + "description": "Type is a SELinux type label that applies to the container.", + "type": "string" + }, + "user": { + "description": "User is a SELinux user label that applies to the container.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ScaleIOVolumeSource": { + "description": "ScaleIOVolumeSource represents a persistent ScaleIO volume", + "required": [ + "gateway", + "system", + "secretRef" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "gateway": { + "description": "The host address of the ScaleIO API Gateway.", + "type": "string" + }, + "protectionDomain": { + "description": "The name of the Protection Domain for the configured storage (defaults to \"default\").", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail.", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "sslEnabled": { + "description": "Flag to enable/disable SSL communication with Gateway, default false", + "type": "boolean" + }, + "storageMode": { + "description": "Indicates whether the storage for a volume should be thick or thin (defaults to \"thin\").", + "type": "string" + }, + "storagePool": { + "description": "The Storage Pool associated with the protection domain (defaults to \"default\").", + "type": "string" + }, + "system": { + "description": "The name of the storage system as configured in ScaleIO.", + "type": "string" + }, + "volumeName": { + "description": "The name of a volume already created in the ScaleIO system that is associated with this volume source.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Secret": { + "description": "Secret holds secret data of a certain type. The total bytes of the values in the Data field must be less than MaxSecretSize bytes.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "data": { + "description": "Data contains the secret data. Each key must consist of alphanumeric characters, '-', '_' or '.'. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4", + "type": "object", + "additionalProperties": { + "type": "string", + "format": "byte" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "stringData": { + "description": "stringData allows specifying non-binary secret data in string form. It is provided as a write-only convenience method. All keys and values are merged into the data field on write, overwriting any existing values. It is never output when reading from the API.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "type": { + "description": "Used to facilitate programmatic handling of secret data.", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Secret", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.SecretEnvSource": { + "description": "SecretEnvSource selects a Secret to populate the environment variables with.\n\nThe contents of the target Secret's Data field will represent the key-value pairs as environment variables.", + "properties": { + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the Secret must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.SecretKeySelector": { + "description": "SecretKeySelector selects a key of a Secret.", + "required": [ + "key" + ], + "properties": { + "key": { + "description": "The key of the secret to select from. Must be a valid secret key.", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the Secret or it's key must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.SecretList": { + "description": "SecretList is a list of Secret.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is a list of secret objects. More info: https://kubernetes.io/docs/concepts/configuration/secret", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Secret" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "SecretList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.SecretProjection": { + "description": "Adapts a secret into a projected volume.\n\nThe contents of the target Secret's Data field will be presented in a projected volume as files using the keys in the Data field as the file names. Note that this is identical to a secret volume source without the default mode.", + "properties": { + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the Secret or its key must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.SecretReference": { + "description": "SecretReference represents a Secret Reference. It has enough information to retrieve secret in any namespace", + "properties": { + "name": { + "description": "Name is unique within a namespace to reference a secret resource.", + "type": "string" + }, + "namespace": { + "description": "Namespace defines the space within which the secret name must be unique.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.SecretVolumeSource": { + "description": "Adapts a Secret into a volume.\n\nThe contents of the target Secret's Data field will be presented in a volume as files using the keys in the Data field as the file names. Secret volumes support ownership management and SELinux relabeling.", + "properties": { + "defaultMode": { + "description": "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "optional": { + "description": "Specify whether the Secret or it's keys must be defined", + "type": "boolean" + }, + "secretName": { + "description": "Name of the secret in the pod's namespace to use. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.SecurityContext": { + "description": "SecurityContext holds security configuration that will be applied to a container. Some fields are present in both SecurityContext and PodSecurityContext. When both are set, the values in SecurityContext take precedence.", + "properties": { + "allowPrivilegeEscalation": { + "description": "AllowPrivilegeEscalation controls whether a process can gain more privileges than it's parent process. This bool directly controls if the no_new_privs flag will be set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged 2) has CAP_SYS_ADMIN", + "type": "boolean" + }, + "capabilities": { + "description": "The capabilities to add/drop when running containers. Defaults to the default set of capabilities granted by the container runtime.", + "$ref": "#/definitions/io.k8s.api.core.v1.Capabilities" + }, + "privileged": { + "description": "Run container in privileged mode. Processes in privileged containers are essentially equivalent to root on the host. Defaults to false.", + "type": "boolean" + }, + "readOnlyRootFilesystem": { + "description": "Whether this container has a read-only root filesystem. Default is false.", + "type": "boolean" + }, + "runAsNonRoot": { + "description": "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "type": "boolean" + }, + "runAsUser": { + "description": "The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "type": "integer", + "format": "int64" + }, + "seLinuxOptions": { + "description": "The SELinux context to be applied to the container. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "$ref": "#/definitions/io.k8s.api.core.v1.SELinuxOptions" + } + } + }, + "io.k8s.api.core.v1.Service": { + "description": "Service is a named abstraction of software service (for example, mysql) consisting of local port (for example 3306) that the proxy listens on, and the selector that determines which pods will answer requests sent through the proxy.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the behavior of a service. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ServiceSpec" + }, + "status": { + "description": "Most recently observed status of the service. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ServiceStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Service", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServiceAccount": { + "description": "ServiceAccount binds together: * a name, understood by users, and perhaps by peripheral systems, for an identity * a principal that can be authenticated and authorized * a set of secrets", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "automountServiceAccountToken": { + "description": "AutomountServiceAccountToken indicates whether pods running as this service account should have an API token automatically mounted. Can be overridden at the pod level.", + "type": "boolean" + }, + "imagePullSecrets": { + "description": "ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling any images in pods that reference this ServiceAccount. ImagePullSecrets are distinct from Secrets because Secrets can be mounted in the pod, but ImagePullSecrets are only accessed by the kubelet. More info: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "secrets": { + "description": "Secrets is the list of secrets allowed to be used by pods running using this ServiceAccount. More info: https://kubernetes.io/docs/concepts/configuration/secret", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ServiceAccount", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServiceAccountList": { + "description": "ServiceAccountList is a list of ServiceAccount objects", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of ServiceAccounts. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ServiceAccount" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ServiceAccountList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServiceList": { + "description": "ServiceList holds a list of services.", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of services", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Service" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ServiceList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServicePort": { + "description": "ServicePort contains information on service's port.", + "required": [ + "port" + ], + "properties": { + "name": { + "description": "The name of this port within the service. This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. This maps to the 'Name' field in EndpointPort objects. Optional if only one ServicePort is defined on this service.", + "type": "string" + }, + "nodePort": { + "description": "The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one. More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport", + "type": "integer", + "format": "int32" + }, + "port": { + "description": "The port that will be exposed by this service.", + "type": "integer", + "format": "int32" + }, + "protocol": { + "description": "The IP protocol for this port. Supports \"TCP\" and \"UDP\". Default is TCP.", + "type": "string" + }, + "targetPort": { + "description": "Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + } + } + }, + "io.k8s.api.core.v1.ServiceSpec": { + "description": "ServiceSpec describes the attributes that a user creates on a service.", + "properties": { + "clusterIP": { + "description": "clusterIP is the IP address of the service and is usually assigned randomly by the master. If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are \"None\", empty string (\"\"), or a valid IP address. \"None\" can be specified for headless services when proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + "type": "string" + }, + "externalIPs": { + "description": "externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.", + "type": "array", + "items": { + "type": "string" + } + }, + "externalName": { + "description": "externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid DNS name and requires Type to be ExternalName.", + "type": "string" + }, + "externalTrafficPolicy": { + "description": "externalTrafficPolicy denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints. \"Local\" preserves the client source IP and avoids a second hop for LoadBalancer and Nodeport type services, but risks potentially imbalanced traffic spreading. \"Cluster\" obscures the client source IP and may cause a second hop to another node, but should have good overall load-spreading.", + "type": "string" + }, + "healthCheckNodePort": { + "description": "healthCheckNodePort specifies the healthcheck nodePort for the service. If not specified, HealthCheckNodePort is created by the service api backend with the allocated nodePort. Will use user-specified nodePort value if specified by the client. Only effects when Type is set to LoadBalancer and ExternalTrafficPolicy is set to Local.", + "type": "integer", + "format": "int32" + }, + "loadBalancerIP": { + "description": "Only applies to Service Type: LoadBalancer LoadBalancer will get created with the IP specified in this field. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature.", + "type": "string" + }, + "loadBalancerSourceRanges": { + "description": "If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.\" More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/", + "type": "array", + "items": { + "type": "string" + } + }, + "ports": { + "description": "The list of ports that are exposed by this service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ServicePort" + }, + "x-kubernetes-patch-merge-key": "port", + "x-kubernetes-patch-strategy": "merge" + }, + "publishNotReadyAddresses": { + "description": "publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service. The default value is false. The primary use case for setting this field is to use a StatefulSet's Headless Service to propagate SRV records for its Pods without respect to their readiness for purpose of peer discovery. This field will replace the service.alpha.kubernetes.io/tolerate-unready-endpoints when that annotation is deprecated and all clients have been converted to use this field.", + "type": "boolean" + }, + "selector": { + "description": "Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "sessionAffinity": { + "description": "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + "type": "string" + }, + "sessionAffinityConfig": { + "description": "sessionAffinityConfig contains the configurations of session affinity.", + "$ref": "#/definitions/io.k8s.api.core.v1.SessionAffinityConfig" + }, + "type": { + "description": "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ExternalName\" maps to the specified externalName. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ServiceStatus": { + "description": "ServiceStatus represents the current status of a service.", + "properties": { + "loadBalancer": { + "description": "LoadBalancer contains the current status of the load-balancer, if one is present.", + "$ref": "#/definitions/io.k8s.api.core.v1.LoadBalancerStatus" + } + } + }, + "io.k8s.api.core.v1.SessionAffinityConfig": { + "description": "SessionAffinityConfig represents the configurations of session affinity.", + "properties": { + "clientIP": { + "description": "clientIP contains the configurations of Client IP based session affinity.", + "$ref": "#/definitions/io.k8s.api.core.v1.ClientIPConfig" + } + } + }, + "io.k8s.api.core.v1.StorageOSPersistentVolumeSource": { + "description": "Represents a StorageOS persistent volume resource.", + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "volumeName": { + "description": "VolumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.", + "type": "string" + }, + "volumeNamespace": { + "description": "VolumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to \"default\" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.StorageOSVolumeSource": { + "description": "Represents a StorageOS persistent volume resource.", + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted.", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "volumeName": { + "description": "VolumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.", + "type": "string" + }, + "volumeNamespace": { + "description": "VolumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to \"default\" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.TCPSocketAction": { + "description": "TCPSocketAction describes an action based on opening a socket", + "required": [ + "port" + ], + "properties": { + "host": { + "description": "Optional: Host name to connect to, defaults to the pod IP.", + "type": "string" + }, + "port": { + "description": "Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + } + } + }, + "io.k8s.api.core.v1.Taint": { + "description": "The node this Taint is attached to has the \"effect\" on any pod that does not tolerate the Taint.", + "required": [ + "key", + "effect" + ], + "properties": { + "effect": { + "description": "Required. The effect of the taint on pods that do not tolerate the taint. Valid effects are NoSchedule, PreferNoSchedule and NoExecute.", + "type": "string" + }, + "key": { + "description": "Required. The taint key to be applied to a node.", + "type": "string" + }, + "timeAdded": { + "description": "TimeAdded represents the time at which the taint was added. It is only written for NoExecute taints.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "value": { + "description": "Required. The taint value corresponding to the taint key.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Toleration": { + "description": "The pod this Toleration is attached to tolerates any taint that matches the triple \u003ckey,value,effect\u003e using the matching operator \u003coperator\u003e.", + "properties": { + "effect": { + "description": "Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.", + "type": "string" + }, + "key": { + "description": "Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys.", + "type": "string" + }, + "operator": { + "description": "Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.", + "type": "string" + }, + "tolerationSeconds": { + "description": "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.", + "type": "integer", + "format": "int64" + }, + "value": { + "description": "Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Volume": { + "description": "Volume represents a named volume in a pod that may be accessed by any container in the pod.", + "required": [ + "name" + ], + "properties": { + "awsElasticBlockStore": { + "description": "AWSElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "$ref": "#/definitions/io.k8s.api.core.v1.AWSElasticBlockStoreVolumeSource" + }, + "azureDisk": { + "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureDiskVolumeSource" + }, + "azureFile": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureFileVolumeSource" + }, + "cephfs": { + "description": "CephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.CephFSVolumeSource" + }, + "cinder": { + "description": "Cinder represents a cinder volume attached and mounted on kubelets host machine More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.CinderVolumeSource" + }, + "configMap": { + "description": "ConfigMap represents a configMap that should populate this volume", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapVolumeSource" + }, + "downwardAPI": { + "description": "DownwardAPI represents downward API about the pod that should populate this volume", + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIVolumeSource" + }, + "emptyDir": { + "description": "EmptyDir represents a temporary directory that shares a pod's lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + "$ref": "#/definitions/io.k8s.api.core.v1.EmptyDirVolumeSource" + }, + "fc": { + "description": "FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.FCVolumeSource" + }, + "flexVolume": { + "description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.", + "$ref": "#/definitions/io.k8s.api.core.v1.FlexVolumeSource" + }, + "flocker": { + "description": "Flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running", + "$ref": "#/definitions/io.k8s.api.core.v1.FlockerVolumeSource" + }, + "gcePersistentDisk": { + "description": "GCEPersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "$ref": "#/definitions/io.k8s.api.core.v1.GCEPersistentDiskVolumeSource" + }, + "gitRepo": { + "description": "GitRepo represents a git repository at a particular revision.", + "$ref": "#/definitions/io.k8s.api.core.v1.GitRepoVolumeSource" + }, + "glusterfs": { + "description": "Glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.GlusterfsVolumeSource" + }, + "hostPath": { + "description": "HostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "$ref": "#/definitions/io.k8s.api.core.v1.HostPathVolumeSource" + }, + "iscsi": { + "description": "ISCSI represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://releases.k8s.io/HEAD/examples/volumes/iscsi/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.ISCSIVolumeSource" + }, + "name": { + "description": "Volume's name. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "nfs": { + "description": "NFS represents an NFS mount on the host that shares a pod's lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "$ref": "#/definitions/io.k8s.api.core.v1.NFSVolumeSource" + }, + "persistentVolumeClaim": { + "description": "PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaimVolumeSource" + }, + "photonPersistentDisk": { + "description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource" + }, + "portworxVolume": { + "description": "PortworxVolume represents a portworx volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PortworxVolumeSource" + }, + "projected": { + "description": "Items for all in one resources secrets, configmaps, and downward API", + "$ref": "#/definitions/io.k8s.api.core.v1.ProjectedVolumeSource" + }, + "quobyte": { + "description": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.QuobyteVolumeSource" + }, + "rbd": { + "description": "RBD represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.RBDVolumeSource" + }, + "scaleIO": { + "description": "ScaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + "$ref": "#/definitions/io.k8s.api.core.v1.ScaleIOVolumeSource" + }, + "secret": { + "description": "Secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretVolumeSource" + }, + "storageos": { + "description": "StorageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.", + "$ref": "#/definitions/io.k8s.api.core.v1.StorageOSVolumeSource" + }, + "vsphereVolume": { + "description": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource" + } + } + }, + "io.k8s.api.core.v1.VolumeMount": { + "description": "VolumeMount describes a mounting of a Volume within a container.", + "required": [ + "name", + "mountPath" + ], + "properties": { + "mountPath": { + "description": "Path within the container at which the volume should be mounted. Must not contain ':'.", + "type": "string" + }, + "name": { + "description": "This must match the Name of a Volume.", + "type": "string" + }, + "readOnly": { + "description": "Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.", + "type": "boolean" + }, + "subPath": { + "description": "Path within the volume from which the container's volume should be mounted. Defaults to \"\" (volume's root).", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.VolumeProjection": { + "description": "Projection that may be projected along with other supported volume types", + "properties": { + "configMap": { + "description": "information about the configMap data to project", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapProjection" + }, + "downwardAPI": { + "description": "information about the downwardAPI data to project", + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIProjection" + }, + "secret": { + "description": "information about the secret data to project", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretProjection" + } + } + }, + "io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource": { + "description": "Represents a vSphere volume resource.", + "required": [ + "volumePath" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "storagePolicyID": { + "description": "Storage Policy Based Management (SPBM) profile ID associated with the StoragePolicyName.", + "type": "string" + }, + "storagePolicyName": { + "description": "Storage Policy Based Management (SPBM) profile name.", + "type": "string" + }, + "volumePath": { + "description": "Path that identifies vSphere volume vmdk", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.WeightedPodAffinityTerm": { + "description": "The weights of all of the matched WeightedPodAffinityTerm fields are added per-node to find the most preferred node(s)", + "required": [ + "weight", + "podAffinityTerm" + ], + "properties": { + "podAffinityTerm": { + "description": "Required. A pod affinity term, associated with the corresponding weight.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinityTerm" + }, + "weight": { + "description": "weight associated with matching the corresponding podAffinityTerm, in the range 1-100.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.apimachinery.pkg.api.resource.Quantity": { + "type": "string" + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup": { + "description": "APIGroup contains the name, the supported versions, and the preferred version of a group.", + "required": [ + "name", + "versions", + "serverAddressByClientCIDRs" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "name is the name of the group.", + "type": "string" + }, + "preferredVersion": { + "description": "preferredVersion is the version preferred by the API server, which probably is the storage version.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery" + }, + "serverAddressByClientCIDRs": { + "description": "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR" + } + }, + "versions": { + "description": "versions are the versions supported in this group.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIGroup", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIGroupList": { + "description": "APIGroupList is a list of APIGroup, to allow clients to discover the API at /apis.", + "required": [ + "groups" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "groups": { + "description": "groups is a list of APIGroup.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIGroupList", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIResource": { + "description": "APIResource specifies the name of a resource and whether it is namespaced.", + "required": [ + "name", + "singularName", + "namespaced", + "kind", + "verbs" + ], + "properties": { + "categories": { + "description": "categories is a list of the grouped resources this resource belongs to (e.g. 'all')", + "type": "array", + "items": { + "type": "string" + } + }, + "kind": { + "description": "kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo')", + "type": "string" + }, + "name": { + "description": "name is the plural name of the resource.", + "type": "string" + }, + "namespaced": { + "description": "namespaced indicates if a resource is namespaced or not.", + "type": "boolean" + }, + "shortNames": { + "description": "shortNames is a list of suggested short names of the resource.", + "type": "array", + "items": { + "type": "string" + } + }, + "singularName": { + "description": "singularName is the singular name of the resource. This allows clients to handle plural and singular opaquely. The singularName is more correct for reporting status on a single item and both singular and plural are allowed from the kubectl CLI interface.", + "type": "string" + }, + "verbs": { + "description": "verbs is a list of supported kube verbs (this includes get, list, watch, create, update, patch, delete, deletecollection, and proxy)", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIResourceList": { + "description": "APIResourceList is a list of APIResource, it is used to expose the name of the resources supported in a specific group and version, and if the resource is namespaced.", + "required": [ + "groupVersion", + "resources" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "groupVersion": { + "description": "groupVersion is the group and version this APIResourceList is for.", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "resources": { + "description": "resources contains the name of the resources and if they are namespaced.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIResource" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIResourceList", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIVersions": { + "description": "APIVersions lists the versions that are available, to allow clients to discover the API at /api, which is the root path of the legacy v1 API.", + "required": [ + "versions", + "serverAddressByClientCIDRs" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "serverAddressByClientCIDRs": { + "description": "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR" + } + }, + "versions": { + "description": "versions are the api versions that are available.", + "type": "array", + "items": { + "type": "string" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIVersions", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions": { + "description": "DeleteOptions may be provided when deleting an API object.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "gracePeriodSeconds": { + "description": "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.", + "type": "integer", + "format": "int64" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "orphanDependents": { + "description": "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.", + "type": "boolean" + }, + "preconditions": { + "description": "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions" + }, + "propagationPolicy": { + "description": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy.", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "admission.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "admissionregistration.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "apps", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "apps", + "kind": "DeleteOptions", + "version": "v1beta2" + }, + { + "group": "authentication.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "authentication.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "autoscaling", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "autoscaling", + "kind": "DeleteOptions", + "version": "v2alpha1" + }, + { + "group": "batch", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "batch", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "batch", + "kind": "DeleteOptions", + "version": "v2alpha1" + }, + { + "group": "certificates.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "extensions", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "federation", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "imagepolicy.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "networking.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "policy", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "scheduling.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "settings.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "storage.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "storage.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery": { + "description": "GroupVersion contains the \"group/version\" and \"version\" string of a version. It is made a struct to keep extensibility.", + "required": [ + "groupVersion", + "version" + ], + "properties": { + "groupVersion": { + "description": "groupVersion specifies the API group and version in the form \"group/version\"", + "type": "string" + }, + "version": { + "description": "version specifies the version in the form of \"version\". This is to save the clients the trouble of splitting the GroupVersion.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Initializer": { + "description": "Initializer is information about an initializer that has not yet completed.", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "name of the process that is responsible for initializing this object.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Initializers": { + "description": "Initializers tracks the progress of initialization.", + "required": [ + "pending" + ], + "properties": { + "pending": { + "description": "Pending is a list of initializers that must execute in order before this object is visible. When the last pending initializer is removed, and no failing result is set, the initializers struct will be set to nil and the object is considered as initialized and visible to all clients.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Initializer" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "result": { + "description": "If result is set with the Failure field, the object will be persisted to storage and then deleted, ensuring that other clients can observe the deletion.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Status" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector": { + "description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.", + "properties": { + "matchExpressions": { + "description": "matchExpressions is a list of label selector requirements. The requirements are ANDed.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement" + } + }, + "matchLabels": { + "description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement": { + "description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + "required": [ + "key", + "operator" + ], + "properties": { + "key": { + "description": "key is the label key that the selector applies to.", + "type": "string", + "x-kubernetes-patch-merge-key": "key", + "x-kubernetes-patch-strategy": "merge" + }, + "operator": { + "description": "operator represents a key's relationship to a set of values. Valid operators ard In, NotIn, Exists and DoesNotExist.", + "type": "string" + }, + "values": { + "description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta": { + "description": "ListMeta describes metadata that synthetic resources must have, including lists and various status objects. A resource may have only one of {ObjectMeta, ListMeta}.", + "properties": { + "resourceVersion": { + "description": "String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency", + "type": "string" + }, + "selfLink": { + "description": "SelfLink is a URL representing this object. Populated by the system. Read-only.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": { + "description": "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.", + "properties": { + "annotations": { + "description": "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "clusterName": { + "description": "The name of the cluster which the object belongs to. This is used to distinguish resources with same name and namespace in different clusters. This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request.", + "type": "string" + }, + "creationTimestamp": { + "description": "CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "deletionGracePeriodSeconds": { + "description": "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.", + "type": "integer", + "format": "int64" + }, + "deletionTimestamp": { + "description": "DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field. Once set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested.\n\nPopulated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "finalizers": { + "description": "Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed.", + "type": "array", + "items": { + "type": "string" + }, + "x-kubernetes-patch-strategy": "merge" + }, + "generateName": { + "description": "GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.\n\nIf this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header).\n\nApplied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#idempotency", + "type": "string" + }, + "generation": { + "description": "A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.", + "type": "integer", + "format": "int64" + }, + "initializers": { + "description": "An initializer is a controller which enforces some system invariant at object creation time. This field is a list of initializers that have not yet acted on this object. If nil or empty, this object has been completely initialized. Otherwise, the object is considered uninitialized and is hidden (in list/watch and get calls) from clients that haven't explicitly asked to observe uninitialized objects.\n\nWhen an object is created, the system will populate this list with the current set of initializers. Only privileged users may set or modify this list. Once it is empty, it may not be modified further by any user.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Initializers" + }, + "labels": { + "description": "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "description": "Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names", + "type": "string" + }, + "namespace": { + "description": "Namespace defines the space within each name must be unique. An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.\n\nMust be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces", + "type": "string" + }, + "ownerReferences": { + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference" + }, + "x-kubernetes-patch-merge-key": "uid", + "x-kubernetes-patch-strategy": "merge" + }, + "resourceVersion": { + "description": "An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.\n\nPopulated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency", + "type": "string" + }, + "selfLink": { + "description": "SelfLink is a URL representing this object. Populated by the system. Read-only.", + "type": "string" + }, + "uid": { + "description": "UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.\n\nPopulated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference": { + "description": "OwnerReference contains enough information to let you identify an owning object. Currently, an owning object must be in the same namespace, so there is no namespace field.", + "required": [ + "apiVersion", + "kind", + "name", + "uid" + ], + "properties": { + "apiVersion": { + "description": "API version of the referent.", + "type": "string" + }, + "blockOwnerDeletion": { + "description": "If true, AND if the owner has the \"foregroundDeletion\" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs \"delete\" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.", + "type": "boolean" + }, + "controller": { + "description": "If true, this reference points to the managing controller.", + "type": "boolean" + }, + "kind": { + "description": "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names", + "type": "string" + }, + "uid": { + "description": "UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Patch": { + "description": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body." + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions": { + "description": "Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out.", + "properties": { + "uid": { + "description": "Specifies the target UID.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR": { + "description": "ServerAddressByClientCIDR helps the client to determine the server address that they should use, depending on the clientCIDR that they match.", + "required": [ + "clientCIDR", + "serverAddress" + ], + "properties": { + "clientCIDR": { + "description": "The CIDR with which clients can match their IP to figure out the server address that they should use.", + "type": "string" + }, + "serverAddress": { + "description": "Address of this server, suitable for a client that matches the above CIDR. This can be a hostname, hostname:port, IP or IP:port.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Status": { + "description": "Status is a return value for calls that don't return other objects.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "code": { + "description": "Suggested HTTP return code for this status, 0 if not set.", + "type": "integer", + "format": "int32" + }, + "details": { + "description": "Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "message": { + "description": "A human-readable description of the status of this operation.", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + }, + "reason": { + "description": "A machine-readable description of why this operation is in the \"Failure\" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.", + "type": "string" + }, + "status": { + "description": "Status of the operation. One of: \"Success\" or \"Failure\". More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Status", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause": { + "description": "StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.", + "properties": { + "field": { + "description": "The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.\n\nExamples:\n \"name\" - the field \"name\" on the current resource\n \"items[0].name\" - the field \"name\" on the first array entry in \"items\"", + "type": "string" + }, + "message": { + "description": "A human-readable description of the cause of the error. This field may be presented as-is to a reader.", + "type": "string" + }, + "reason": { + "description": "A machine-readable description of the cause of the error. If this value is empty there is no information available.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails": { + "description": "StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.", + "properties": { + "causes": { + "description": "The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause" + } + }, + "group": { + "description": "The group attribute of the resource associated with the status StatusReason.", + "type": "string" + }, + "kind": { + "description": "The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).", + "type": "string" + }, + "retryAfterSeconds": { + "description": "If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.", + "type": "integer", + "format": "int32" + }, + "uid": { + "description": "UID of the resource. (when there is a single resource which can be described). More info: http://kubernetes.io/docs/user-guide/identifiers#uids", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Time": { + "type": "string", + "format": "date-time" + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.WatchEvent": { + "description": "Event represents a single event to a watched resource.", + "required": [ + "type", + "object" + ], + "properties": { + "object": { + "description": "Object is:\n * If Type is Added or Modified: the new state of the object.\n * If Type is Deleted: the state of the object immediately before deletion.\n * If Type is Error: *Status is recommended; other types may make sense\n depending on context.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.runtime.RawExtension" + }, + "type": { + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "admission.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "admissionregistration.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "apps", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "apps", + "kind": "WatchEvent", + "version": "v1beta2" + }, + { + "group": "authentication.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "authentication.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "autoscaling", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "autoscaling", + "kind": "WatchEvent", + "version": "v2alpha1" + }, + { + "group": "batch", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "batch", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "batch", + "kind": "WatchEvent", + "version": "v2alpha1" + }, + { + "group": "certificates.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "extensions", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "federation", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "imagepolicy.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "networking.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "policy", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "scheduling.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "settings.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "storage.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "storage.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + } + ] + }, + "io.k8s.apimachinery.pkg.runtime.RawExtension": { + "description": "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.\n\n// Internal package: type MyAPIObject struct {\n\truntime.TypeMeta `json:\",inline\"`\n\tMyPlugin runtime.Object `json:\"myPlugin\"`\n} type PluginA struct {\n\tAOption string `json:\"aOption\"`\n}\n\n// External package: type MyAPIObject struct {\n\truntime.TypeMeta `json:\",inline\"`\n\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n} type PluginA struct {\n\tAOption string `json:\"aOption\"`\n}\n\n// On the wire, the JSON will look something like this: {\n\t\"kind\":\"MyAPIObject\",\n\t\"apiVersion\":\"v1\",\n\t\"myPlugin\": {\n\t\t\"kind\":\"PluginA\",\n\t\t\"aOption\":\"foo\",\n\t},\n}\n\nSo what happens? Decode first uses json or yaml to unmarshal the serialized data into your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's DefaultScheme has conversion functions installed which will unpack the JSON stored in RawExtension, turning it into the correct object type, and storing it in the Object. (TODO: In the case where the object is of an unknown type, a runtime.Unknown object will be created and stored.)", + "required": [ + "Raw" + ], + "properties": { + "Raw": { + "description": "Raw is the underlying serialization of this object.", + "type": "string", + "format": "byte" + } + } + }, + "io.k8s.apimachinery.pkg.util.intstr.IntOrString": { + "type": "string", + "format": "int-or-string" + }, + "io.k8s.apimachinery.pkg.version.Info": { + "description": "Info contains versioning information. how we'll want to distribute that information.", + "required": [ + "major", + "minor", + "gitVersion", + "gitCommit", + "gitTreeState", + "buildDate", + "goVersion", + "compiler", + "platform" + ], + "properties": { + "buildDate": { + "type": "string" + }, + "compiler": { + "type": "string" + }, + "gitCommit": { + "type": "string" + }, + "gitTreeState": { + "type": "string" + }, + "gitVersion": { + "type": "string" + }, + "goVersion": { + "type": "string" + }, + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "platform": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "BearerToken": { + "description": "Bearer Token authentication", + "type": "apiKey", + "name": "authorization", + "in": "header" + } + }, + "security": [ + { + "BearerToken": [] + } + ] + } diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/testdata/swagger_next.json b/vendor/k8s.io/kube-openapi/pkg/util/proto/testdata/swagger_next.json new file mode 100644 index 000000000..f2dc451f9 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/testdata/swagger_next.json @@ -0,0 +1,6574 @@ +{ + "swagger": "2.0", + "info": { + "title": "Kubernetes", + "version": "v1.8.0" + }, + "paths": {}, + "definitions": { + "io.k8s.api.apps.v1beta1.ControllerRevision": { + "description": "ControllerRevision implements an immutable snapshot of state data. Clients are responsible for serializing and deserializing the objects that contain their internal state. Once a ControllerRevision has been successfully created, it can not be updated. The API Server will fail validation of all requests that attempt to mutate the Data field. ControllerRevisions may, however, be deleted. Note that, due to its use by both the DaemonSet and StatefulSet controllers for update and rollback, this object is beta. However, it may be subject to name and representation changes in future releases, and clients should not depend on its stability. It is primarily for internal use by controllers.", + "type": "object", + "required": [ + "revision" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "data": { + "description": "Data is the serialized representation of the state.", + "type": "object" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "revision": { + "description": "Revision indicates the revision of the state represented by Data.", + "type": "integer", + "format": "int64" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "ControllerRevision", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.ControllerRevisionList": { + "description": "ControllerRevisionList is a resource containing a list of ControllerRevision objects.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of ControllerRevisions", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.ControllerRevision" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "ControllerRevisionList", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.Deployment": { + "description": "Deployment enables declarative updates for Pods and ReplicaSets.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object metadata.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired behavior of the Deployment.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentSpec" + }, + "status": { + "description": "Most recently observed status of the Deployment.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "Deployment", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.DeploymentCondition": { + "description": "DeploymentCondition describes the state of a deployment at a certain point.", + "type": "object", + "required": [ + "type", + "status" + ], + "properties": { + "lastTransitionTime": { + "description": "Last time the condition transitioned from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "lastUpdateTime": { + "description": "The last time this condition was updated.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of deployment condition.", + "type": "string" + } + } + }, + "io.k8s.api.apps.v1beta1.DeploymentList": { + "description": "DeploymentList is a list of Deployments.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of Deployments.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.Deployment" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "DeploymentList", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.DeploymentRollback": { + "description": "DEPRECATED. DeploymentRollback stores the information required to rollback a deployment.", + "type": "object", + "required": [ + "name", + "rollbackTo" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "Required: This must match the Name of a deployment.", + "type": "string" + }, + "rollbackTo": { + "description": "The config of this deployment rollback.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollbackConfig" + }, + "updatedAnnotations": { + "description": "The annotations to be updated to a deployment", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "DeploymentRollback", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.DeploymentSpec": { + "description": "DeploymentSpec is the specification of the desired behavior of the Deployment.", + "type": "object", + "required": [ + "template" + ], + "properties": { + "minReadySeconds": { + "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + "type": "integer", + "format": "int32" + }, + "paused": { + "description": "Indicates that the deployment is paused.", + "type": "boolean" + }, + "progressDeadlineSeconds": { + "description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.", + "type": "integer", + "format": "int32" + }, + "revisionHistoryLimit": { + "description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 2.", + "type": "integer", + "format": "int32" + }, + "rollbackTo": { + "description": "DEPRECATED. The config this deployment is rolling back to. Will be cleared after rollback is done.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollbackConfig" + }, + "selector": { + "description": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "strategy": { + "description": "The deployment strategy to use to replace existing pods with new ones.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentStrategy" + }, + "template": { + "description": "Template describes the pods that will be created.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + } + } + }, + "io.k8s.api.apps.v1beta1.DeploymentStatus": { + "description": "DeploymentStatus is the most recently observed status of the Deployment.", + "type": "object", + "properties": { + "availableReplicas": { + "description": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.", + "type": "integer", + "format": "int32" + }, + "collisionCount": { + "description": "Count of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet.", + "type": "integer", + "format": "int32" + }, + "conditions": { + "description": "Represents the latest available observations of a deployment's current state.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "observedGeneration": { + "description": "The generation observed by the deployment controller.", + "type": "integer", + "format": "int64" + }, + "readyReplicas": { + "description": "Total number of ready pods targeted by this deployment.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).", + "type": "integer", + "format": "int32" + }, + "unavailableReplicas": { + "description": "Total number of unavailable pods targeted by this deployment.", + "type": "integer", + "format": "int32" + }, + "updatedReplicas": { + "description": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.DeploymentStrategy": { + "description": "DeploymentStrategy describes how to replace existing pods with new ones.", + "type": "object", + "properties": { + "rollingUpdate": { + "description": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollingUpdateDeployment" + }, + "type": { + "description": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.", + "type": "string" + } + } + }, + "io.k8s.api.apps.v1beta1.RollbackConfig": { + "description": "DEPRECATED.", + "type": "object", + "properties": { + "revision": { + "description": "The revision to rollback to. If set to 0, rollback to the last revision.", + "type": "integer", + "format": "int64" + } + } + }, + "io.k8s.api.apps.v1beta1.RollingUpdateDeployment": { + "description": "Spec to control the desired behavior of rolling update.", + "type": "object", + "properties": { + "maxSurge": { + "description": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new RC can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new RC can be scaled up further, ensuring that total number of pods running at any time during the update is atmost 130% of desired pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + }, + "maxUnavailable": { + "description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old RC can be scaled down further, followed by scaling up the new RC, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + } + } + }, + "io.k8s.api.apps.v1beta1.RollingUpdateStatefulSetStrategy": { + "description": "RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType.", + "type": "object", + "properties": { + "partition": { + "description": "Partition indicates the ordinal at which the StatefulSet should be partitioned.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.Scale": { + "description": "Scale represents a scaling request for a resource.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.ScaleSpec" + }, + "status": { + "description": "current status of the scale. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status. Read-only.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.ScaleStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "Scale", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.ScaleSpec": { + "description": "ScaleSpec describes the attributes of a scale subresource", + "type": "object", + "properties": { + "replicas": { + "description": "desired number of instances for the scaled object.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.ScaleStatus": { + "description": "ScaleStatus represents the current status of a scale subresource.", + "type": "object", + "required": [ + "replicas" + ], + "properties": { + "replicas": { + "description": "actual number of observed instances of the scaled object.", + "type": "integer", + "format": "int32" + }, + "selector": { + "description": "label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "targetSelector": { + "description": "label selector for pods that should match the replicas count. This is a serializated version of both map-based and more expressive set-based selectors. This is done to avoid introspection in the clients. The string will be in the same format as the query-param syntax. If the target type only supports map-based selectors, both this field and map-based selector field are populated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + "type": "string" + } + } + }, + "io.k8s.api.apps.v1beta1.StatefulSet": { + "description": "StatefulSet represents a set of pods with consistent identities. Identities are defined as:\n - Network: A single stable DNS and hostname.\n - Storage: As many VolumeClaims as requested.\nThe StatefulSet guarantees that a given network identity will always map to the same storage identity.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the desired identities of pods in this set.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSetSpec" + }, + "status": { + "description": "Status is the current status of Pods in this StatefulSet. This data may be out of date by some window of time.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSetStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "StatefulSet", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.StatefulSetList": { + "description": "StatefulSetList is a collection of StatefulSets.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSet" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "apps", + "kind": "StatefulSetList", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.apps.v1beta1.StatefulSetSpec": { + "description": "A StatefulSetSpec is the specification of a StatefulSet.", + "type": "object", + "required": [ + "template", + "serviceName" + ], + "properties": { + "podManagementPolicy": { + "description": "podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is `OrderedReady`, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order. The alternative policy is `Parallel` which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.", + "type": "string" + }, + "replicas": { + "description": "replicas is the desired number of replicas of the given Template. These are replicas in the sense that they are instantiations of the same Template, but individual replicas also have a consistent identity. If unspecified, defaults to 1.", + "type": "integer", + "format": "int32" + }, + "revisionHistoryLimit": { + "description": "revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet's revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.", + "type": "integer", + "format": "int32" + }, + "selector": { + "description": "selector is a label query over pods that should match the replica count. If empty, defaulted to labels on the pod template. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "serviceName": { + "description": "serviceName is the name of the service that governs this StatefulSet. This service must exist before the StatefulSet, and is responsible for the network identity of the set. Pods get DNS/hostnames that follow the pattern: pod-specific-string.serviceName.default.svc.cluster.local where \"pod-specific-string\" is managed by the StatefulSet controller.", + "type": "string" + }, + "template": { + "description": "template is the object that describes the pod that will be created if insufficient replicas are detected. Each pod stamped out by the StatefulSet will fulfill this Template, but have a unique identity from the rest of the StatefulSet.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + }, + "updateStrategy": { + "description": "updateStrategy indicates the StatefulSetUpdateStrategy that will be employed to update Pods in the StatefulSet when a revision is made to Template.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.StatefulSetUpdateStrategy" + }, + "volumeClaimTemplates": { + "description": "volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. A claim in this list takes precedence over any volumes in the template, with the same name.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaim" + } + } + } + }, + "io.k8s.api.apps.v1beta1.StatefulSetStatus": { + "description": "StatefulSetStatus represents the current state of a StatefulSet.", + "type": "object", + "required": [ + "replicas" + ], + "properties": { + "collisionCount": { + "description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.", + "type": "integer", + "format": "int32" + }, + "currentReplicas": { + "description": "currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.", + "type": "integer", + "format": "int32" + }, + "currentRevision": { + "description": "currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).", + "type": "string" + }, + "observedGeneration": { + "description": "observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.", + "type": "integer", + "format": "int64" + }, + "readyReplicas": { + "description": "readyReplicas is the number of Pods created by the StatefulSet controller that have a Ready Condition.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "replicas is the number of Pods created by the StatefulSet controller.", + "type": "integer", + "format": "int32" + }, + "updateRevision": { + "description": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)", + "type": "string" + }, + "updatedReplicas": { + "description": "updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.apps.v1beta1.StatefulSetUpdateStrategy": { + "description": "StatefulSetUpdateStrategy indicates the strategy that the StatefulSet controller will use to perform updates. It includes any additional parameters necessary to perform the update for the indicated strategy.", + "type": "object", + "properties": { + "rollingUpdate": { + "description": "RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.", + "$ref": "#/definitions/io.k8s.api.apps.v1beta1.RollingUpdateStatefulSetStrategy" + }, + "type": { + "description": "Type indicates the type of the StatefulSetUpdateStrategy.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.LocalSubjectAccessReview": { + "description": "LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.", + "type": "object", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace you made the request against. If empty, it is defaulted.", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "LocalSubjectAccessReview", + "version": "v1" + } + ] + }, + "io.k8s.api.authorization.v1.NonResourceAttributes": { + "description": "NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface", + "type": "object", + "properties": { + "path": { + "description": "Path is the URL path of the request", + "type": "string" + }, + "verb": { + "description": "Verb is the standard HTTP verb", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.ResourceAttributes": { + "description": "ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface", + "type": "object", + "properties": { + "group": { + "description": "Group is the API Group of the Resource. \"*\" means all.", + "type": "string" + }, + "name": { + "description": "Name is the name of the resource being requested for a \"get\" or deleted for a \"delete\". \"\" (empty) means all.", + "type": "string" + }, + "namespace": { + "description": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces \"\" (empty) is defaulted for LocalSubjectAccessReviews \"\" (empty) is empty for cluster-scoped resources \"\" (empty) means \"all\" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview", + "type": "string" + }, + "resource": { + "description": "Resource is one of the existing resource types. \"*\" means all.", + "type": "string" + }, + "subresource": { + "description": "Subresource is one of the existing resource types. \"\" means none.", + "type": "string" + }, + "verb": { + "description": "Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", + "type": "string" + }, + "version": { + "description": "Version is the API Version of the Resource. \"*\" means all.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.SelfSubjectAccessReview": { + "description": "SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means \"in all namespaces\". Self is a special case, because users should always be able to check whether they can perform an action", + "type": "object", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. user and groups must be empty", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SelfSubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SelfSubjectAccessReview", + "version": "v1" + } + ] + }, + "io.k8s.api.authorization.v1.SelfSubjectAccessReviewSpec": { + "description": "SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "type": "object", + "properties": { + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.ResourceAttributes" + } + } + }, + "io.k8s.api.authorization.v1.SubjectAccessReview": { + "description": "SubjectAccessReview checks whether or not a user or group can perform an action.", + "type": "object", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SubjectAccessReview", + "version": "v1" + } + ] + }, + "io.k8s.api.authorization.v1.SubjectAccessReviewSpec": { + "description": "SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "type": "object", + "properties": { + "extra": { + "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "groups": { + "description": "Groups is the groups you're testing for.", + "type": "array", + "items": { + "type": "string" + } + }, + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1.ResourceAttributes" + }, + "uid": { + "description": "UID information about the requesting user.", + "type": "string" + }, + "user": { + "description": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1.SubjectAccessReviewStatus": { + "description": "SubjectAccessReviewStatus", + "type": "object", + "required": [ + "allowed" + ], + "properties": { + "allowed": { + "description": "Allowed is required. True if the action would be allowed, false otherwise.", + "type": "boolean" + }, + "evaluationError": { + "description": "EvaluationError is an indication that some error occurred during the authorization check. It is entirely possible to get an error and be able to continue determine authorization status in spite of it. For instance, RBAC can be missing a role, but enough roles are still present and bound to reason about the request.", + "type": "string" + }, + "reason": { + "description": "Reason is optional. It indicates why a request was allowed or denied.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.LocalSubjectAccessReview": { + "description": "LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.", + "type": "object", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace you made the request against. If empty, it is defaulted.", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "LocalSubjectAccessReview", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.authorization.v1beta1.NonResourceAttributes": { + "description": "NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface", + "type": "object", + "properties": { + "path": { + "description": "Path is the URL path of the request", + "type": "string" + }, + "verb": { + "description": "Verb is the standard HTTP verb", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.ResourceAttributes": { + "description": "ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface", + "type": "object", + "properties": { + "group": { + "description": "Group is the API Group of the Resource. \"*\" means all.", + "type": "string" + }, + "name": { + "description": "Name is the name of the resource being requested for a \"get\" or deleted for a \"delete\". \"\" (empty) means all.", + "type": "string" + }, + "namespace": { + "description": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces \"\" (empty) is defaulted for LocalSubjectAccessReviews \"\" (empty) is empty for cluster-scoped resources \"\" (empty) means \"all\" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview", + "type": "string" + }, + "resource": { + "description": "Resource is one of the existing resource types. \"*\" means all.", + "type": "string" + }, + "subresource": { + "description": "Subresource is one of the existing resource types. \"\" means none.", + "type": "string" + }, + "verb": { + "description": "Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", + "type": "string" + }, + "version": { + "description": "Version is the API Version of the Resource. \"*\" means all.", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.SelfSubjectAccessReview": { + "description": "SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means \"in all namespaces\". Self is a special case, because users should always be able to check whether they can perform an action", + "type": "object", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated. user and groups must be empty", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SelfSubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SelfSubjectAccessReview", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.authorization.v1beta1.SelfSubjectAccessReviewSpec": { + "description": "SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "type": "object", + "properties": { + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.ResourceAttributes" + } + } + }, + "io.k8s.api.authorization.v1beta1.SubjectAccessReview": { + "description": "SubjectAccessReview checks whether or not a user or group can perform an action.", + "type": "object", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec holds information about the request being evaluated", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewSpec" + }, + "status": { + "description": "Status is filled in by the server and indicates whether the request is allowed or not", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "authorization.k8s.io", + "kind": "SubjectAccessReview", + "version": "v1beta1" + } + ] + }, + "io.k8s.api.authorization.v1beta1.SubjectAccessReviewSpec": { + "description": "SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "type": "object", + "properties": { + "extra": { + "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "group": { + "description": "Groups is the groups you're testing for.", + "type": "array", + "items": { + "type": "string" + } + }, + "nonResourceAttributes": { + "description": "NonResourceAttributes describes information for a non-resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.NonResourceAttributes" + }, + "resourceAttributes": { + "description": "ResourceAuthorizationAttributes describes information for a resource access request", + "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.ResourceAttributes" + }, + "uid": { + "description": "UID information about the requesting user.", + "type": "string" + }, + "user": { + "description": "User is the user you're testing for. If you specify \"User\" but not \"Group\", then is it interpreted as \"What if User were not a member of any groups", + "type": "string" + } + } + }, + "io.k8s.api.authorization.v1beta1.SubjectAccessReviewStatus": { + "description": "SubjectAccessReviewStatus", + "type": "object", + "required": [ + "allowed" + ], + "properties": { + "allowed": { + "description": "Allowed is required. True if the action would be allowed, false otherwise.", + "type": "boolean" + }, + "evaluationError": { + "description": "EvaluationError is an indication that some error occurred during the authorization check. It is entirely possible to get an error and be able to continue determine authorization status in spite of it. For instance, RBAC can be missing a role, but enough roles are still present and bound to reason about the request.", + "type": "string" + }, + "reason": { + "description": "Reason is optional. It indicates why a request was allowed or denied.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.AWSElasticBlockStoreVolumeSource": { + "description": "Represents a Persistent Disk resource in AWS.\n\nAn AWS EBS disk must exist before mounting to a container. The disk must also be in the same AWS zone as the kubelet. An AWS EBS disk can only be mounted as read/write once. AWS EBS volumes support ownership management and SELinux relabeling.", + "type": "object", + "required": [ + "volumeID" + ], + "properties": { + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "type": "string" + }, + "partition": { + "description": "The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty).", + "type": "integer", + "format": "int32" + }, + "readOnly": { + "description": "Specify \"true\" to force and set the ReadOnly property in VolumeMounts to \"true\". If omitted, the default is \"false\". More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "type": "boolean" + }, + "volumeID": { + "description": "Unique ID of the persistent disk resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Affinity": { + "description": "Affinity is a group of affinity scheduling rules.", + "type": "object", + "properties": { + "nodeAffinity": { + "description": "Describes node affinity scheduling rules for the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeAffinity" + }, + "podAffinity": { + "description": "Describes pod affinity scheduling rules (e.g. co-locate this pod in the same node, zone, etc. as some other pod(s)).", + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinity" + }, + "podAntiAffinity": { + "description": "Describes pod anti-affinity scheduling rules (e.g. avoid putting this pod in the same node, zone, etc. as some other pod(s)).", + "$ref": "#/definitions/io.k8s.api.core.v1.PodAntiAffinity" + } + } + }, + "io.k8s.api.core.v1.AttachedVolume": { + "description": "AttachedVolume describes a volume attached to a node", + "type": "object", + "required": [ + "name", + "devicePath" + ], + "properties": { + "devicePath": { + "description": "DevicePath represents the device path where the volume should be available", + "type": "string" + }, + "name": { + "description": "Name of the attached volume", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.AzureDiskVolumeSource": { + "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + "type": "object", + "required": [ + "diskName", + "diskURI" + ], + "properties": { + "cachingMode": { + "description": "Host Caching mode: None, Read Only, Read Write.", + "type": "string" + }, + "diskName": { + "description": "The Name of the data disk in the blob storage", + "type": "string" + }, + "diskURI": { + "description": "The URI the data disk in the blob storage", + "type": "string" + }, + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "kind": { + "description": "Expected values Shared: mulitple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.AzureFilePersistentVolumeSource": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "type": "object", + "required": [ + "secretName", + "shareName" + ], + "properties": { + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretName": { + "description": "the name of secret that contains Azure Storage Account Name and Key", + "type": "string" + }, + "secretNamespace": { + "description": "the namespace of the secret that contains Azure Storage Account Name and Key default is the same as the Pod", + "type": "string" + }, + "shareName": { + "description": "Share Name", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.AzureFileVolumeSource": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "type": "object", + "required": [ + "secretName", + "shareName" + ], + "properties": { + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretName": { + "description": "the name of secret that contains Azure Storage Account Name and Key", + "type": "string" + }, + "shareName": { + "description": "Share Name", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Binding": { + "description": "Binding ties one object to another; for example, a pod is bound to a node by a scheduler. Deprecated in 1.7, please use the bindings subresource of pods instead.", + "type": "object", + "required": [ + "target" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "target": { + "description": "The target object that you want to bind to the standard object.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Binding", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.Capabilities": { + "description": "Adds and removes POSIX capabilities from running containers.", + "type": "object", + "properties": { + "add": { + "description": "Added capabilities", + "type": "array", + "items": { + "type": "string" + } + }, + "drop": { + "description": "Removed capabilities", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.CephFSPersistentVolumeSource": { + "description": "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.", + "type": "object", + "required": [ + "monitors" + ], + "properties": { + "monitors": { + "description": "Required: Monitors is a collection of Ceph monitors More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "array", + "items": { + "type": "string" + } + }, + "path": { + "description": "Optional: Used as the mounted root, rather than the full Ceph tree, default is /", + "type": "string" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "boolean" + }, + "secretFile": { + "description": "Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + }, + "secretRef": { + "description": "Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretReference" + }, + "user": { + "description": "Optional: User is the rados user name, default is admin More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.CephFSVolumeSource": { + "description": "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.", + "type": "object", + "required": [ + "monitors" + ], + "properties": { + "monitors": { + "description": "Required: Monitors is a collection of Ceph monitors More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "array", + "items": { + "type": "string" + } + }, + "path": { + "description": "Optional: Used as the mounted root, rather than the full Ceph tree, default is /", + "type": "string" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "boolean" + }, + "secretFile": { + "description": "Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + }, + "secretRef": { + "description": "Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "user": { + "description": "Optional: User is the rados user name, default is admin More info: https://releases.k8s.io/HEAD/examples/volumes/cephfs/README.md#how-to-use-it", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.CinderVolumeSource": { + "description": "Represents a cinder volume resource in Openstack. A Cinder volume must exist before mounting to a container. The volume must also be in the same region as the kubelet. Cinder volumes support ownership management and SELinux relabeling.", + "type": "object", + "required": [ + "volumeID" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "type": "string" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "type": "boolean" + }, + "volumeID": { + "description": "volume id used to identify the volume in cinder More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ClientIPConfig": { + "description": "ClientIPConfig represents the configurations of Client IP based session affinity.", + "type": "object", + "properties": { + "timeoutSeconds": { + "description": "timeoutSeconds specifies the seconds of ClientIP type session sticky time. The value must be \u003e0 \u0026\u0026 \u003c=86400(for 1 day) if ServiceAffinity == \"ClientIP\". Default value is 10800(for 3 hours).", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.ComponentCondition": { + "description": "Information about the condition of a component.", + "type": "object", + "required": [ + "type", + "status" + ], + "properties": { + "error": { + "description": "Condition error code for a component. For example, a health check error code.", + "type": "string" + }, + "message": { + "description": "Message about the condition for a component. For example, information about a health check.", + "type": "string" + }, + "status": { + "description": "Status of the condition for a component. Valid values for \"Healthy\": \"True\", \"False\", or \"Unknown\".", + "type": "string" + }, + "type": { + "description": "Type of condition for a component. Valid value: \"Healthy\"", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ComponentStatus": { + "description": "ComponentStatus (and ComponentStatusList) holds the cluster validation info.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "conditions": { + "description": "List of component conditions observed", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ComponentCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ComponentStatus", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ComponentStatusList": { + "description": "Status of all the conditions for the component as a list of ComponentStatus objects.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of ComponentStatus objects.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ComponentStatus" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ComponentStatusList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ConfigMap": { + "description": "ConfigMap holds configuration data for pods to consume.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "data": { + "description": "Data contains the configuration data. Each key must consist of alphanumeric characters, '-', '_' or '.'.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ConfigMap", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ConfigMapEnvSource": { + "description": "ConfigMapEnvSource selects a ConfigMap to populate the environment variables with.\n\nThe contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables.", + "type": "object", + "properties": { + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.ConfigMapKeySelector": { + "description": "Selects a key from a ConfigMap.", + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "description": "The key to select.", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap or it's key must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.ConfigMapList": { + "description": "ConfigMapList is a resource containing a list of ConfigMap objects.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of ConfigMaps.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMap" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ConfigMapList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ConfigMapProjection": { + "description": "Adapts a ConfigMap into a projected volume.\n\nThe contents of the target ConfigMap's Data field will be presented in a projected volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. Note that this is identical to a configmap volume source without the default mode.", + "type": "object", + "properties": { + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap or it's keys must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.ConfigMapVolumeSource": { + "description": "Adapts a ConfigMap into a volume.\n\nThe contents of the target ConfigMap's Data field will be presented in a volume as files using the keys in the Data field as the file names, unless the items element is populated with specific mappings of keys to paths. ConfigMap volumes support ownership management and SELinux relabeling.", + "type": "object", + "properties": { + "defaultMode": { + "description": "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the ConfigMap or it's keys must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.Container": { + "description": "A single application container that you want to run within a pod.", + "type": "object", + "required": [ + "name", + "image" + ], + "properties": { + "args": { + "description": "Arguments to the entrypoint. The docker image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + "type": "array", + "items": { + "type": "string" + } + }, + "command": { + "description": "Entrypoint array. Not executed within a shell. The docker image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", + "type": "array", + "items": { + "type": "string" + } + }, + "env": { + "description": "List of environment variables to set in the container. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EnvVar" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "envFrom": { + "description": "List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EnvFromSource" + } + }, + "image": { + "description": "Docker image name. More info: https://kubernetes.io/docs/concepts/containers/images", + "type": "string" + }, + "imagePullPolicy": { + "description": "Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images", + "type": "string" + }, + "lifecycle": { + "description": "Actions that the management system should take in response to container lifecycle events. Cannot be updated.", + "$ref": "#/definitions/io.k8s.api.core.v1.Lifecycle" + }, + "livenessProbe": { + "description": "Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "$ref": "#/definitions/io.k8s.api.core.v1.Probe" + }, + "name": { + "description": "Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.", + "type": "string" + }, + "ports": { + "description": "List of ports to expose from the container. Exposing a port here gives the system additional information about the network connections a container uses, but is primarily informational. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default \"0.0.0.0\" address inside a container will be accessible from the network. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerPort" + }, + "x-kubernetes-patch-merge-key": "containerPort", + "x-kubernetes-patch-strategy": "merge" + }, + "readinessProbe": { + "description": "Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "$ref": "#/definitions/io.k8s.api.core.v1.Probe" + }, + "resources": { + "description": "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements" + }, + "securityContext": { + "description": "Security options the pod should run with. More info: https://kubernetes.io/docs/concepts/policy/security-context/ More info: https://git.k8s.io/community/contributors/design-proposals/security_context.md", + "$ref": "#/definitions/io.k8s.api.core.v1.SecurityContext" + }, + "stdin": { + "description": "Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.", + "type": "boolean" + }, + "stdinOnce": { + "description": "Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false", + "type": "boolean" + }, + "terminationMessagePath": { + "description": "Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.", + "type": "string" + }, + "terminationMessagePolicy": { + "description": "Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.", + "type": "string" + }, + "tty": { + "description": "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.", + "type": "boolean" + }, + "volumeMounts": { + "description": "Pod volumes to mount into the container's filesystem. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.VolumeMount" + }, + "x-kubernetes-patch-merge-key": "mountPath", + "x-kubernetes-patch-strategy": "merge" + }, + "workingDir": { + "description": "Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ContainerImage": { + "description": "Describe a container image", + "type": "object", + "required": [ + "names" + ], + "properties": { + "names": { + "description": "Names by which this image is known. e.g. [\"gcr.io/google_containers/hyperkube:v1.0.7\", \"dockerhub.io/google_containers/hyperkube:v1.0.7\"]", + "type": "array", + "items": { + "type": "string" + } + }, + "sizeBytes": { + "description": "The size of the image in bytes.", + "type": "integer", + "format": "int64" + } + } + }, + "io.k8s.api.core.v1.ContainerPort": { + "description": "ContainerPort represents a network port in a single container.", + "type": "object", + "required": [ + "containerPort" + ], + "properties": { + "containerPort": { + "description": "Number of port to expose on the pod's IP address. This must be a valid port number, 0 \u003c x \u003c 65536.", + "type": "integer", + "format": "int32" + }, + "hostIP": { + "description": "What host IP to bind the external port to.", + "type": "string" + }, + "hostPort": { + "description": "Number of port to expose on the host. If specified, this must be a valid port number, 0 \u003c x \u003c 65536. If HostNetwork is specified, this must match ContainerPort. Most containers do not need this.", + "type": "integer", + "format": "int32" + }, + "name": { + "description": "If specified, this must be an IANA_SVC_NAME and unique within the pod. Each named port in a pod must have a unique name. Name for the port that can be referred to by services.", + "type": "string" + }, + "protocol": { + "description": "Protocol for port. Must be UDP or TCP. Defaults to \"TCP\".", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ContainerState": { + "description": "ContainerState holds a possible state of container. Only one of its members may be specified. If none of them is specified, the default one is ContainerStateWaiting.", + "type": "object", + "properties": { + "running": { + "description": "Details about a running container", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStateRunning" + }, + "terminated": { + "description": "Details about a terminated container", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStateTerminated" + }, + "waiting": { + "description": "Details about a waiting container", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStateWaiting" + } + } + }, + "io.k8s.api.core.v1.ContainerStateRunning": { + "description": "ContainerStateRunning is a running state of a container.", + "type": "object", + "properties": { + "startedAt": { + "description": "Time at which the container was last (re-)started", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + } + } + }, + "io.k8s.api.core.v1.ContainerStateTerminated": { + "description": "ContainerStateTerminated is a terminated state of a container.", + "type": "object", + "required": [ + "exitCode" + ], + "properties": { + "containerID": { + "description": "Container's ID in the format 'docker://\u003ccontainer_id\u003e'", + "type": "string" + }, + "exitCode": { + "description": "Exit status from the last termination of the container", + "type": "integer", + "format": "int32" + }, + "finishedAt": { + "description": "Time at which the container last terminated", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "Message regarding the last termination of the container", + "type": "string" + }, + "reason": { + "description": "(brief) reason from the last termination of the container", + "type": "string" + }, + "signal": { + "description": "Signal from the last termination of the container", + "type": "integer", + "format": "int32" + }, + "startedAt": { + "description": "Time at which previous execution of the container started", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + } + } + }, + "io.k8s.api.core.v1.ContainerStateWaiting": { + "description": "ContainerStateWaiting is a waiting state of a container.", + "type": "object", + "properties": { + "message": { + "description": "Message regarding why the container is not yet running.", + "type": "string" + }, + "reason": { + "description": "(brief) reason the container is not yet running.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ContainerStatus": { + "description": "ContainerStatus contains details for the current status of this container.", + "type": "object", + "required": [ + "name", + "ready", + "restartCount", + "image", + "imageID" + ], + "properties": { + "containerID": { + "description": "Container's ID in the format 'docker://\u003ccontainer_id\u003e'.", + "type": "string" + }, + "image": { + "description": "The image the container is running. More info: https://kubernetes.io/docs/concepts/containers/images", + "type": "string" + }, + "imageID": { + "description": "ImageID of the container's image.", + "type": "string" + }, + "lastState": { + "description": "Details about the container's last termination condition.", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerState" + }, + "name": { + "description": "This must be a DNS_LABEL. Each container in a pod must have a unique name. Cannot be updated.", + "type": "string" + }, + "ready": { + "description": "Specifies whether the container has passed its readiness probe.", + "type": "boolean" + }, + "restartCount": { + "description": "The number of times the container has been restarted, currently based on the number of dead containers that have not yet been removed. Note that this is calculated from dead containers. But those containers are subject to garbage collection. This value will get capped at 5 by GC.", + "type": "integer", + "format": "int32" + }, + "state": { + "description": "Details about the container's current condition.", + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerState" + } + } + }, + "io.k8s.api.core.v1.DaemonEndpoint": { + "description": "DaemonEndpoint contains information about a single Daemon endpoint.", + "type": "object", + "required": [ + "Port" + ], + "properties": { + "Port": { + "description": "Port number of the given endpoint.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.DownwardAPIProjection": { + "description": "Represents downward API info for projecting into a projected volume. Note that this is identical to a downwardAPI volume source without the default mode.", + "type": "object", + "properties": { + "items": { + "description": "Items is a list of DownwardAPIVolume file", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIVolumeFile" + } + } + } + }, + "io.k8s.api.core.v1.DownwardAPIVolumeFile": { + "description": "DownwardAPIVolumeFile represents information to create the file containing the pod field", + "type": "object", + "required": [ + "path" + ], + "properties": { + "fieldRef": { + "description": "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectFieldSelector" + }, + "mode": { + "description": "Optional: mode bits to use on this file, must be a value between 0 and 0777. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "path": { + "description": "Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..'", + "type": "string" + }, + "resourceFieldRef": { + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceFieldSelector" + } + } + }, + "io.k8s.api.core.v1.DownwardAPIVolumeSource": { + "description": "DownwardAPIVolumeSource represents a volume containing downward API info. Downward API volumes support ownership management and SELinux relabeling.", + "type": "object", + "properties": { + "defaultMode": { + "description": "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "items": { + "description": "Items is a list of downward API volume file", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIVolumeFile" + } + } + } + }, + "io.k8s.api.core.v1.EmptyDirVolumeSource": { + "description": "Represents an empty directory for a pod. Empty directory volumes support ownership management and SELinux relabeling.", + "type": "object", + "properties": { + "medium": { + "description": "What type of storage medium should back this directory. The default is \"\" which means to use the node's default medium. Must be an empty string (default) or Memory. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + "type": "string" + }, + "sizeLimit": { + "description": "Total amount of local storage required for this EmptyDir volume. The size limit is also applicable for memory medium. The maximum usage on memory medium EmptyDir would be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. More info: http://kubernetes.io/docs/user-guide/volumes#emptydir", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + } + }, + "io.k8s.api.core.v1.EndpointAddress": { + "description": "EndpointAddress is a tuple that describes single IP address.", + "type": "object", + "required": [ + "ip" + ], + "properties": { + "hostname": { + "description": "The Hostname of this endpoint", + "type": "string" + }, + "ip": { + "description": "The IP of this endpoint. May not be loopback (127.0.0.0/8), link-local (169.254.0.0/16), or link-local multicast ((224.0.0.0/24). IPv6 is also accepted but not fully supported on all platforms. Also, certain kubernetes components, like kube-proxy, are not IPv6 ready.", + "type": "string" + }, + "nodeName": { + "description": "Optional: Node hosting this endpoint. This can be used to determine endpoints local to a node.", + "type": "string" + }, + "targetRef": { + "description": "Reference to object providing the endpoint.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + } + } + }, + "io.k8s.api.core.v1.EndpointPort": { + "description": "EndpointPort is a tuple that describes a single port.", + "type": "object", + "required": [ + "port" + ], + "properties": { + "name": { + "description": "The name of this port (corresponds to ServicePort.Name). Must be a DNS_LABEL. Optional only if one port is defined.", + "type": "string" + }, + "port": { + "description": "The port number of the endpoint.", + "type": "integer", + "format": "int32" + }, + "protocol": { + "description": "The IP protocol for this port. Must be UDP or TCP. Default is TCP.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.EndpointSubset": { + "description": "EndpointSubset is a group of addresses with a common set of ports. The expanded set of endpoints is the Cartesian product of Addresses x Ports. For example, given:\n {\n Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n }\nThe resulting set of endpoints can be viewed as:\n a: [ 10.10.1.1:8675, 10.10.2.2:8675 ],\n b: [ 10.10.1.1:309, 10.10.2.2:309 ]", + "type": "object", + "properties": { + "addresses": { + "description": "IP addresses which offer the related ports that are marked as ready. These endpoints should be considered safe for load balancers and clients to utilize.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointAddress" + } + }, + "notReadyAddresses": { + "description": "IP addresses which offer the related ports but are not currently marked as ready because they have not yet finished starting, have recently failed a readiness check, or have recently failed a liveness check.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointAddress" + } + }, + "ports": { + "description": "Port numbers available on the related IP addresses.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointPort" + } + } + } + }, + "io.k8s.api.core.v1.Endpoints": { + "description": "Endpoints is a collection of endpoints that implement the actual service. Example:\n Name: \"mysvc\",\n Subsets: [\n {\n Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n Ports: [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n },\n {\n Addresses: [{\"ip\": \"10.10.3.3\"}],\n Ports: [{\"name\": \"a\", \"port\": 93}, {\"name\": \"b\", \"port\": 76}]\n },\n ]", + "type": "object", + "required": [ + "subsets" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "subsets": { + "description": "The set of all endpoints is the union of all subsets. Addresses are placed into subsets according to the IPs they share. A single address with multiple ports, some of which are ready and some of which are not (because they come from different containers) will result in the address being displayed in different subsets for the different ports. No address will appear in both Addresses and NotReadyAddresses in the same subset. Sets of addresses and ports that comprise a service.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.EndpointSubset" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Endpoints", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EndpointsList": { + "description": "EndpointsList is a list of endpoints.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of endpoints.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Endpoints" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "EndpointsList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EnvFromSource": { + "description": "EnvFromSource represents the source of a set of ConfigMaps", + "type": "object", + "properties": { + "configMapRef": { + "description": "The ConfigMap to select from", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapEnvSource" + }, + "prefix": { + "description": "An optional identifer to prepend to each key in the ConfigMap. Must be a C_IDENTIFIER.", + "type": "string" + }, + "secretRef": { + "description": "The Secret to select from", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretEnvSource" + } + } + }, + "io.k8s.api.core.v1.EnvVar": { + "description": "EnvVar represents an environment variable present in a Container.", + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "Name of the environment variable. Must be a C_IDENTIFIER.", + "type": "string" + }, + "value": { + "description": "Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to \"\".", + "type": "string" + }, + "valueFrom": { + "description": "Source for the environment variable's value. Cannot be used if value is not empty.", + "$ref": "#/definitions/io.k8s.api.core.v1.EnvVarSource" + } + } + }, + "io.k8s.api.core.v1.EnvVarSource": { + "description": "EnvVarSource represents a source for the value of an EnvVar.", + "type": "object", + "properties": { + "configMapKeyRef": { + "description": "Selects a key of a ConfigMap.", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapKeySelector" + }, + "fieldRef": { + "description": "Selects a field of the pod: supports metadata.name, metadata.namespace, metadata.labels, metadata.annotations, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectFieldSelector" + }, + "resourceFieldRef": { + "description": "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceFieldSelector" + }, + "secretKeyRef": { + "description": "Selects a key of a secret in the pod's namespace", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretKeySelector" + } + } + }, + "io.k8s.api.core.v1.Event": { + "description": "Event is a report of an event somewhere in the cluster.", + "type": "object", + "required": [ + "metadata", + "involvedObject" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "count": { + "description": "The number of times this event has occurred.", + "type": "integer", + "format": "int32" + }, + "firstTimestamp": { + "description": "The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "involvedObject": { + "description": "The object that this event is about.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "lastTimestamp": { + "description": "The time at which the most recent occurrence of this event was recorded.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "A human-readable description of the status of this operation.", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "reason": { + "description": "This should be a short, machine understandable string that gives the reason for the transition into the object's current status.", + "type": "string" + }, + "source": { + "description": "The component reporting this event. Should be a short machine understandable string.", + "$ref": "#/definitions/io.k8s.api.core.v1.EventSource" + }, + "type": { + "description": "Type of this event (Normal, Warning), new types could be added in the future", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Event", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EventList": { + "description": "EventList is a list of events.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of events", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Event" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "EventList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.EventSource": { + "description": "EventSource contains information for an event.", + "type": "object", + "properties": { + "component": { + "description": "Component from which the event is generated.", + "type": "string" + }, + "host": { + "description": "Node name on which the event is generated.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ExecAction": { + "description": "ExecAction describes a \"run in container\" action.", + "type": "object", + "properties": { + "command": { + "description": "Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.FCVolumeSource": { + "description": "Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.", + "type": "object", + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "lun": { + "description": "Optional: FC target lun number", + "type": "integer", + "format": "int32" + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "targetWWNs": { + "description": "Optional: FC target worldwide names (WWNs)", + "type": "array", + "items": { + "type": "string" + } + }, + "wwids": { + "description": "Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.FlexVolumeSource": { + "description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.", + "type": "object", + "required": [ + "driver" + ], + "properties": { + "driver": { + "description": "Driver is the name of the driver to use for this volume.", + "type": "string" + }, + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script.", + "type": "string" + }, + "options": { + "description": "Optional: Extra command options if any.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "readOnly": { + "description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + } + } + }, + "io.k8s.api.core.v1.FlockerVolumeSource": { + "description": "Represents a Flocker volume mounted by the Flocker agent. One and only one of datasetName and datasetUUID should be set. Flocker volumes do not support ownership management or SELinux relabeling.", + "type": "object", + "properties": { + "datasetName": { + "description": "Name of the dataset stored as metadata -\u003e name on the dataset for Flocker should be considered as deprecated", + "type": "string" + }, + "datasetUUID": { + "description": "UUID of the dataset. This is unique identifier of a Flocker dataset", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.GCEPersistentDiskVolumeSource": { + "description": "Represents a Persistent Disk resource in Google Compute Engine.\n\nA GCE PD must exist before mounting to a container. The disk must also be in the same GCE project and zone as the kubelet. A GCE PD can only be mounted as read/write once or read-only many times. GCE PDs support ownership management and SELinux relabeling.", + "type": "object", + "required": [ + "pdName" + ], + "properties": { + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "string" + }, + "partition": { + "description": "The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "integer", + "format": "int32" + }, + "pdName": { + "description": "Unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.GitRepoVolumeSource": { + "description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.", + "type": "object", + "required": [ + "repository" + ], + "properties": { + "directory": { + "description": "Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.", + "type": "string" + }, + "repository": { + "description": "Repository URL", + "type": "string" + }, + "revision": { + "description": "Commit hash for the specified revision.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.GlusterfsVolumeSource": { + "description": "Represents a Glusterfs mount that lasts the lifetime of a pod. Glusterfs volumes do not support ownership management or SELinux relabeling.", + "type": "object", + "required": [ + "endpoints", + "path" + ], + "properties": { + "endpoints": { + "description": "EndpointsName is the endpoint name that details Glusterfs topology. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md#create-a-pod", + "type": "string" + }, + "path": { + "description": "Path is the Glusterfs volume path. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md#create-a-pod", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the Glusterfs volume to be mounted with read-only permissions. Defaults to false. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md#create-a-pod", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.HTTPGetAction": { + "description": "HTTPGetAction describes an action based on HTTP Get requests.", + "type": "object", + "required": [ + "port" + ], + "properties": { + "host": { + "description": "Host name to connect to, defaults to the pod IP. You probably want to set \"Host\" in httpHeaders instead.", + "type": "string" + }, + "httpHeaders": { + "description": "Custom headers to set in the request. HTTP allows repeated headers.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.HTTPHeader" + } + }, + "path": { + "description": "Path to access on the HTTP server.", + "type": "string" + }, + "port": { + "description": "Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + }, + "scheme": { + "description": "Scheme to use for connecting to the host. Defaults to HTTP.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.HTTPHeader": { + "description": "HTTPHeader describes a custom header to be used in HTTP probes", + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "description": "The header field name", + "type": "string" + }, + "value": { + "description": "The header field value", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Handler": { + "description": "Handler defines a specific action that should be taken", + "type": "object", + "properties": { + "exec": { + "description": "One and only one of the following should be specified. Exec specifies the action to take.", + "$ref": "#/definitions/io.k8s.api.core.v1.ExecAction" + }, + "httpGet": { + "description": "HTTPGet specifies the http request to perform.", + "$ref": "#/definitions/io.k8s.api.core.v1.HTTPGetAction" + }, + "tcpSocket": { + "description": "TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported", + "$ref": "#/definitions/io.k8s.api.core.v1.TCPSocketAction" + } + } + }, + "io.k8s.api.core.v1.HostAlias": { + "description": "HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.", + "type": "object", + "properties": { + "hostnames": { + "description": "Hostnames for the above IP address.", + "type": "array", + "items": { + "type": "string" + } + }, + "ip": { + "description": "IP address of the host file entry.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.HostPathVolumeSource": { + "description": "Represents a host path mapped into a pod. Host path volumes do not support ownership management or SELinux relabeling.", + "type": "object", + "required": [ + "path" + ], + "properties": { + "path": { + "description": "Path of the directory on the host. If the path is a symlink, it will follow the link to the real path. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "type": "string" + }, + "type": { + "description": "Type for HostPath Volume Defaults to \"\" More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ISCSIVolumeSource": { + "description": "Represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.", + "type": "object", + "required": [ + "targetPortal", + "iqn", + "lun" + ], + "properties": { + "chapAuthDiscovery": { + "description": "whether support iSCSI Discovery CHAP authentication", + "type": "boolean" + }, + "chapAuthSession": { + "description": "whether support iSCSI Session CHAP authentication", + "type": "boolean" + }, + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#iscsi", + "type": "string" + }, + "initiatorName": { + "description": "Custom iSCSI initiator name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface \u003ctarget portal\u003e:\u003cvolume name\u003e will be created for the connection.", + "type": "string" + }, + "iqn": { + "description": "Target iSCSI Qualified Name.", + "type": "string" + }, + "iscsiInterface": { + "description": "Optional: Defaults to 'default' (tcp). iSCSI interface name that uses an iSCSI transport.", + "type": "string" + }, + "lun": { + "description": "iSCSI target lun number.", + "type": "integer", + "format": "int32" + }, + "portals": { + "description": "iSCSI target portal List. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + "type": "array", + "items": { + "type": "string" + } + }, + "readOnly": { + "description": "ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.", + "type": "boolean" + }, + "secretRef": { + "description": "CHAP secret for iSCSI target and initiator authentication", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "targetPortal": { + "description": "iSCSI target portal. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.KeyToPath": { + "description": "Maps a string key to a path within a volume.", + "type": "object", + "required": [ + "key", + "path" + ], + "properties": { + "key": { + "description": "The key to project.", + "type": "string" + }, + "mode": { + "description": "Optional: mode bits to use on this file, must be a value between 0 and 0777. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "path": { + "description": "The relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Lifecycle": { + "description": "Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted.", + "type": "object", + "properties": { + "postStart": { + "description": "PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks", + "$ref": "#/definitions/io.k8s.api.core.v1.Handler" + }, + "preStop": { + "description": "PreStop is called immediately before a container is terminated. The container is terminated after the handler completes. The reason for termination is passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks", + "$ref": "#/definitions/io.k8s.api.core.v1.Handler" + } + } + }, + "io.k8s.api.core.v1.LimitRange": { + "description": "LimitRange sets resource usage limits for each kind of resource in a Namespace.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the limits enforced. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.LimitRangeSpec" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "LimitRange", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.LimitRangeItem": { + "description": "LimitRangeItem defines a min/max usage limit for any resource that matches on kind.", + "type": "object", + "properties": { + "default": { + "description": "Default resource requirement limit value by resource name if resource limit is omitted.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "defaultRequest": { + "description": "DefaultRequest is the default resource requirement request value by resource name if resource request is omitted.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "max": { + "description": "Max usage constraints on this kind by resource name.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "maxLimitRequestRatio": { + "description": "MaxLimitRequestRatio if specified, the named resource must have a request and limit that are both non-zero where limit divided by request is less than or equal to the enumerated value; this represents the max burst for the named resource.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "min": { + "description": "Min usage constraints on this kind by resource name.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "type": { + "description": "Type of resource that this limit applies to.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.LimitRangeList": { + "description": "LimitRangeList is a list of LimitRange items.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is a list of LimitRange objects. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_limit_range.md", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LimitRange" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "LimitRangeList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.LimitRangeSpec": { + "description": "LimitRangeSpec defines a min/max usage limit for resources that match on kind.", + "type": "object", + "required": [ + "limits" + ], + "properties": { + "limits": { + "description": "Limits is the list of LimitRangeItem objects that are enforced.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LimitRangeItem" + } + } + } + }, + "io.k8s.api.core.v1.LoadBalancerIngress": { + "description": "LoadBalancerIngress represents the status of a load-balancer ingress point: traffic intended for the service should be sent to an ingress point.", + "type": "object", + "properties": { + "hostname": { + "description": "Hostname is set for load-balancer ingress points that are DNS based (typically AWS load-balancers)", + "type": "string" + }, + "ip": { + "description": "IP is set for load-balancer ingress points that are IP based (typically GCE or OpenStack load-balancers)", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.LoadBalancerStatus": { + "description": "LoadBalancerStatus represents the status of a load-balancer.", + "type": "object", + "properties": { + "ingress": { + "description": "Ingress is a list containing ingress points for the load-balancer. Traffic intended for the service should be sent to these ingress points.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LoadBalancerIngress" + } + } + } + }, + "io.k8s.api.core.v1.LocalObjectReference": { + "description": "LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.", + "type": "object", + "properties": { + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.LocalVolumeSource": { + "description": "Local represents directly-attached storage with node affinity", + "type": "object", + "required": [ + "path" + ], + "properties": { + "path": { + "description": "The full path to the volume on the node For alpha, this path must be a directory Once block as a source is supported, then this path can point to a block device", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.NFSVolumeSource": { + "description": "Represents an NFS mount that lasts the lifetime of a pod. NFS volumes do not support ownership management or SELinux relabeling.", + "type": "object", + "required": [ + "server", + "path" + ], + "properties": { + "path": { + "description": "Path that is exported by the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the NFS export to be mounted with read-only permissions. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "type": "boolean" + }, + "server": { + "description": "Server is the hostname or IP address of the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Namespace": { + "description": "Namespace provides a scope for Names. Use of multiple namespaces is optional.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the behavior of the Namespace. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NamespaceSpec" + }, + "status": { + "description": "Status describes the current status of a Namespace. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NamespaceStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Namespace", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NamespaceList": { + "description": "NamespaceList is a list of Namespaces.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is the list of Namespace objects in the list. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Namespace" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "NamespaceList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NamespaceSpec": { + "description": "NamespaceSpec describes the attributes on a Namespace.", + "type": "object", + "properties": { + "finalizers": { + "description": "Finalizers is an opaque list of values that must be empty to permanently remove object from storage. More info: https://git.k8s.io/community/contributors/design-proposals/namespaces.md#finalizers", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.NamespaceStatus": { + "description": "NamespaceStatus is information about the current status of a Namespace.", + "type": "object", + "properties": { + "phase": { + "description": "Phase is the current lifecycle phase of the namespace. More info: https://git.k8s.io/community/contributors/design-proposals/namespaces.md#phases", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Node": { + "description": "Node is a worker node in Kubernetes. Each node will have a unique identifier in the cache (i.e. in etcd).", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the behavior of a node. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSpec" + }, + "status": { + "description": "Most recently observed status of the node. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Node", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NodeAddress": { + "description": "NodeAddress contains information for the node's address.", + "type": "object", + "required": [ + "type", + "address" + ], + "properties": { + "address": { + "description": "The node address.", + "type": "string" + }, + "type": { + "description": "Node address type, one of Hostname, ExternalIP or InternalIP.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.NodeAffinity": { + "description": "Node affinity is a group of node affinity scheduling rules.", + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "description": "The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node matches the corresponding matchExpressions; the node(s) with the highest sum are the most preferred.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PreferredSchedulingTerm" + } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "description": "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to an update), the system may or may not try to eventually evict the pod from its node.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelector" + } + } + }, + "io.k8s.api.core.v1.NodeCondition": { + "description": "NodeCondition contains condition information for a node.", + "type": "object", + "required": [ + "type", + "status" + ], + "properties": { + "lastHeartbeatTime": { + "description": "Last time we got an update on a given condition.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "lastTransitionTime": { + "description": "Last time the condition transit from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "Human readable message indicating details about last transition.", + "type": "string" + }, + "reason": { + "description": "(brief) reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of node condition.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.NodeConfigSource": { + "description": "NodeConfigSource specifies a source of node configuration. Exactly one subfield (excluding metadata) must be non-nil.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "configMapRef": { + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "NodeConfigSource", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NodeDaemonEndpoints": { + "description": "NodeDaemonEndpoints lists ports opened by daemons running on the Node.", + "type": "object", + "properties": { + "kubeletEndpoint": { + "description": "Endpoint on which Kubelet is listening.", + "$ref": "#/definitions/io.k8s.api.core.v1.DaemonEndpoint" + } + } + }, + "io.k8s.api.core.v1.NodeList": { + "description": "NodeList is the whole list of all Nodes which have been registered with master.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of nodes", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Node" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "NodeList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.NodeSelector": { + "description": "A node selector represents the union of the results of one or more label queries over a set of nodes; that is, it represents the OR of the selectors represented by the node selector terms.", + "type": "object", + "required": [ + "nodeSelectorTerms" + ], + "properties": { + "nodeSelectorTerms": { + "description": "Required. A list of node selector terms. The terms are ORed.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorTerm" + } + } + } + }, + "io.k8s.api.core.v1.NodeSelectorRequirement": { + "description": "A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + "type": "object", + "required": [ + "key", + "operator" + ], + "properties": { + "key": { + "description": "The label key that the selector applies to.", + "type": "string" + }, + "operator": { + "description": "Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.", + "type": "string" + }, + "values": { + "description": "An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. If the operator is Gt or Lt, the values array must have a single element, which will be interpreted as an integer. This array is replaced during a strategic merge patch.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.NodeSelectorTerm": { + "description": "A null or empty node selector term matches no objects.", + "type": "object", + "required": [ + "matchExpressions" + ], + "properties": { + "matchExpressions": { + "description": "Required. A list of node selector requirements. The requirements are ANDed.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorRequirement" + } + } + } + }, + "io.k8s.api.core.v1.NodeSpec": { + "description": "NodeSpec describes the attributes that a node is created with.", + "type": "object", + "properties": { + "configSource": { + "description": "If specified, the source to get node configuration from The DynamicKubeletConfig feature gate must be enabled for the Kubelet to use this field", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeConfigSource" + }, + "externalID": { + "description": "External ID of the node assigned by some machine database (e.g. a cloud provider). Deprecated.", + "type": "string" + }, + "podCIDR": { + "description": "PodCIDR represents the pod IP range assigned to the node.", + "type": "string" + }, + "providerID": { + "description": "ID of the node assigned by the cloud provider in the format: \u003cProviderName\u003e://\u003cProviderSpecificNodeID\u003e", + "type": "string" + }, + "taints": { + "description": "If specified, the node's taints.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Taint" + } + }, + "unschedulable": { + "description": "Unschedulable controls node schedulability of new pods. By default, node is schedulable. More info: https://kubernetes.io/docs/concepts/nodes/node/#manual-node-administration", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.NodeStatus": { + "description": "NodeStatus is information about the current status of a node.", + "type": "object", + "properties": { + "addresses": { + "description": "List of addresses reachable to the node. Queried from cloud provider, if available. More info: https://kubernetes.io/docs/concepts/nodes/node/#addresses", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeAddress" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "allocatable": { + "description": "Allocatable represents the resources of a node that are available for scheduling. Defaults to Capacity.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "capacity": { + "description": "Capacity represents the total resources of a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "conditions": { + "description": "Conditions is an array of current observed node conditions. More info: https://kubernetes.io/docs/concepts/nodes/node/#condition", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.NodeCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "daemonEndpoints": { + "description": "Endpoints of daemons running on the Node.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeDaemonEndpoints" + }, + "images": { + "description": "List of container images on this node", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerImage" + } + }, + "nodeInfo": { + "description": "Set of ids/uuids to uniquely identify the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#info", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSystemInfo" + }, + "phase": { + "description": "NodePhase is the recently observed lifecycle phase of the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#phase The field is never populated, and now is deprecated.", + "type": "string" + }, + "volumesAttached": { + "description": "List of volumes that are attached to the node.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.AttachedVolume" + } + }, + "volumesInUse": { + "description": "List of attachable volumes in use (mounted) by the node.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.NodeSystemInfo": { + "description": "NodeSystemInfo is a set of ids/uuids to uniquely identify the node.", + "type": "object", + "required": [ + "machineID", + "systemUUID", + "bootID", + "kernelVersion", + "osImage", + "containerRuntimeVersion", + "kubeletVersion", + "kubeProxyVersion", + "operatingSystem", + "architecture" + ], + "properties": { + "architecture": { + "description": "The Architecture reported by the node", + "type": "string" + }, + "bootID": { + "description": "Boot ID reported by the node.", + "type": "string" + }, + "containerRuntimeVersion": { + "description": "ContainerRuntime Version reported by the node through runtime remote API (e.g. docker://1.5.0).", + "type": "string" + }, + "kernelVersion": { + "description": "Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).", + "type": "string" + }, + "kubeProxyVersion": { + "description": "KubeProxy Version reported by the node.", + "type": "string" + }, + "kubeletVersion": { + "description": "Kubelet Version reported by the node.", + "type": "string" + }, + "machineID": { + "description": "MachineID reported by the node. For unique machine identification in the cluster this field is preferred. Learn more from man(5) machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html", + "type": "string" + }, + "operatingSystem": { + "description": "The Operating System reported by the node", + "type": "string" + }, + "osImage": { + "description": "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).", + "type": "string" + }, + "systemUUID": { + "description": "SystemUUID reported by the node. For unique machine identification MachineID is preferred. This field is specific to Red Hat hosts https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/getting-system-uuid.html", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ObjectFieldSelector": { + "description": "ObjectFieldSelector selects an APIVersioned field of an object.", + "type": "object", + "required": [ + "fieldPath" + ], + "properties": { + "apiVersion": { + "description": "Version of the schema the FieldPath is written in terms of, defaults to \"v1\".", + "type": "string" + }, + "fieldPath": { + "description": "Path of the field to select in the specified API version.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ObjectReference": { + "description": "ObjectReference contains enough information to let you inspect or modify the referred object.", + "type": "object", + "properties": { + "apiVersion": { + "description": "API version of the referent.", + "type": "string" + }, + "fieldPath": { + "description": "If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: \"spec.containers{name}\" (where \"name\" refers to the name of the container that triggered the event) or if no container name is specified \"spec.containers[2]\" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.", + "type": "string" + }, + "kind": { + "description": "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "namespace": { + "description": "Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + "type": "string" + }, + "resourceVersion": { + "description": "Specific resourceVersion to which this reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency", + "type": "string" + }, + "uid": { + "description": "UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PersistentVolume": { + "description": "PersistentVolume (PV) is a storage resource provisioned by an administrator. It is analogous to a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines a specification of a persistent volume owned by the cluster. Provisioned by an administrator. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistent-volumes", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeSpec" + }, + "status": { + "description": "Status represents the current information/status for the persistent volume. Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistent-volumes", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolume", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeClaim": { + "description": "PersistentVolumeClaim is a user's request for and claim to a persistent volume", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaimSpec" + }, + "status": { + "description": "Status represents the current information/status of a persistent volume claim. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaimStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolumeClaim", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeClaimList": { + "description": "PersistentVolumeClaimList is a list of PersistentVolumeClaim items.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "A list of persistent volume claims. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaim" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolumeClaimList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeClaimSpec": { + "description": "PersistentVolumeClaimSpec describes the common attributes of storage devices and allows a Source for provider-specific attributes", + "type": "object", + "properties": { + "accessModes": { + "description": "AccessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1", + "type": "array", + "items": { + "type": "string" + } + }, + "resources": { + "description": "Resources represents the minimum resources the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements" + }, + "selector": { + "description": "A label query over volumes to consider for binding.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "storageClassName": { + "description": "Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1", + "type": "string" + }, + "volumeName": { + "description": "VolumeName is the binding reference to the PersistentVolume backing this claim.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeClaimStatus": { + "description": "PersistentVolumeClaimStatus is the current status of a persistent volume claim.", + "type": "object", + "properties": { + "accessModes": { + "description": "AccessModes contains the actual access modes the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1", + "type": "array", + "items": { + "type": "string" + } + }, + "capacity": { + "description": "Represents the actual resources of the underlying volume.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "phase": { + "description": "Phase represents the current phase of PersistentVolumeClaim.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeClaimVolumeSource": { + "description": "PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace. This volume finds the bound PV and mounts that volume for the pod. A PersistentVolumeClaimVolumeSource is, essentially, a wrapper around another type of volume that is owned by someone else (the system).", + "type": "object", + "required": [ + "claimName" + ], + "properties": { + "claimName": { + "description": "ClaimName is the name of a PersistentVolumeClaim in the same namespace as the pod using this volume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "type": "string" + }, + "readOnly": { + "description": "Will force the ReadOnly setting in VolumeMounts. Default false.", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeList": { + "description": "PersistentVolumeList is a list of PersistentVolume items.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of persistent volumes. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolume" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PersistentVolumeList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PersistentVolumeSpec": { + "description": "PersistentVolumeSpec is the specification of a persistent volume.", + "type": "object", + "properties": { + "accessModes": { + "description": "AccessModes contains all ways the volume can be mounted. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes", + "type": "array", + "items": { + "type": "string" + } + }, + "awsElasticBlockStore": { + "description": "AWSElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "$ref": "#/definitions/io.k8s.api.core.v1.AWSElasticBlockStoreVolumeSource" + }, + "azureDisk": { + "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureDiskVolumeSource" + }, + "azureFile": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureFilePersistentVolumeSource" + }, + "capacity": { + "description": "A description of the persistent volume's resources and capacity. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "cephfs": { + "description": "CephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.CephFSPersistentVolumeSource" + }, + "cinder": { + "description": "Cinder represents a cinder volume attached and mounted on kubelets host machine More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.CinderVolumeSource" + }, + "claimRef": { + "description": "ClaimRef is part of a bi-directional binding between PersistentVolume and PersistentVolumeClaim. Expected to be non-nil when bound. claim.VolumeName is the authoritative bind between PV and PVC. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#binding", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "fc": { + "description": "FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.FCVolumeSource" + }, + "flexVolume": { + "description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.", + "$ref": "#/definitions/io.k8s.api.core.v1.FlexVolumeSource" + }, + "flocker": { + "description": "Flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running", + "$ref": "#/definitions/io.k8s.api.core.v1.FlockerVolumeSource" + }, + "gcePersistentDisk": { + "description": "GCEPersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "$ref": "#/definitions/io.k8s.api.core.v1.GCEPersistentDiskVolumeSource" + }, + "glusterfs": { + "description": "Glusterfs represents a Glusterfs volume that is attached to a host and exposed to the pod. Provisioned by an admin. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.GlusterfsVolumeSource" + }, + "hostPath": { + "description": "HostPath represents a directory on the host. Provisioned by a developer or tester. This is useful for single-node development and testing only! On-host storage is not supported in any way and WILL NOT WORK in a multi-node cluster. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "$ref": "#/definitions/io.k8s.api.core.v1.HostPathVolumeSource" + }, + "iscsi": { + "description": "ISCSI represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. Provisioned by an admin.", + "$ref": "#/definitions/io.k8s.api.core.v1.ISCSIVolumeSource" + }, + "local": { + "description": "Local represents directly-attached storage with node affinity", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalVolumeSource" + }, + "mountOptions": { + "description": "A list of mount options, e.g. [\"ro\", \"soft\"]. Not validated - mount will simply fail if one is invalid. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#mount-options", + "type": "array", + "items": { + "type": "string" + } + }, + "nfs": { + "description": "NFS represents an NFS mount on the host. Provisioned by an admin. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "$ref": "#/definitions/io.k8s.api.core.v1.NFSVolumeSource" + }, + "persistentVolumeReclaimPolicy": { + "description": "What happens to a persistent volume when released from its claim. Valid options are Retain (default) and Recycle. Recycling must be supported by the volume plugin underlying this persistent volume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#reclaiming", + "type": "string" + }, + "photonPersistentDisk": { + "description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource" + }, + "portworxVolume": { + "description": "PortworxVolume represents a portworx volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PortworxVolumeSource" + }, + "quobyte": { + "description": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.QuobyteVolumeSource" + }, + "rbd": { + "description": "RBD represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.RBDVolumeSource" + }, + "scaleIO": { + "description": "ScaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + "$ref": "#/definitions/io.k8s.api.core.v1.ScaleIOVolumeSource" + }, + "storageClassName": { + "description": "Name of StorageClass to which this persistent volume belongs. Empty value means that this volume does not belong to any StorageClass.", + "type": "string" + }, + "storageos": { + "description": "StorageOS represents a StorageOS volume that is attached to the kubelet's host machine and mounted into the pod More info: https://releases.k8s.io/HEAD/examples/volumes/storageos/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.StorageOSPersistentVolumeSource" + }, + "vsphereVolume": { + "description": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource" + } + } + }, + "io.k8s.api.core.v1.PersistentVolumeStatus": { + "description": "PersistentVolumeStatus is the current status of a persistent volume.", + "type": "object", + "properties": { + "message": { + "description": "A human-readable message indicating details about why the volume is in this state.", + "type": "string" + }, + "phase": { + "description": "Phase indicates if a volume is available, bound to a claim, or released by a claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#phase", + "type": "string" + }, + "reason": { + "description": "Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource": { + "description": "Represents a Photon Controller persistent disk resource.", + "type": "object", + "required": [ + "pdID" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "pdID": { + "description": "ID that identifies Photon Controller persistent disk", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Pod": { + "description": "Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodSpec" + }, + "status": { + "description": "Most recently observed status of the pod. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Pod", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodAffinity": { + "description": "Pod affinity is a group of inter pod affinity scheduling rules.", + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "description": "The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.WeightedPodAffinityTerm" + } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "description": "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinityTerm" + } + } + } + }, + "io.k8s.api.core.v1.PodAffinityTerm": { + "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", + "type": "object", + "properties": { + "labelSelector": { + "description": "A label query over a set of resources, in this case pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "namespaces": { + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"", + "type": "array", + "items": { + "type": "string" + } + }, + "topologyKey": { + "description": "This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. For PreferredDuringScheduling pod anti-affinity, empty topologyKey is interpreted as \"all topologies\" (\"all topologies\" here means all the topologyKeys indicated by scheduler command-line argument --failure-domains); for affinity and for RequiredDuringScheduling pod anti-affinity, empty topologyKey is not allowed.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PodAntiAffinity": { + "description": "Pod anti affinity is a group of inter pod anti affinity scheduling rules.", + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "description": "The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.WeightedPodAffinityTerm" + } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "description": "If the anti-affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the anti-affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinityTerm" + } + } + } + }, + "io.k8s.api.core.v1.PodCondition": { + "description": "PodCondition contains details for the current condition of this pod.", + "type": "object", + "required": [ + "type", + "status" + ], + "properties": { + "lastProbeTime": { + "description": "Last time we probed the condition.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "lastTransitionTime": { + "description": "Last time the condition transitioned from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "Human-readable message indicating details about last transition.", + "type": "string" + }, + "reason": { + "description": "Unique, one-word, CamelCase reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status is the status of the condition. Can be True, False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + "type": "string" + }, + "type": { + "description": "Type is the type of the condition. Currently only Ready. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PodList": { + "description": "PodList is a list of Pods.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of pods. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Pod" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PodList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodSecurityContext": { + "description": "PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.", + "type": "object", + "properties": { + "fsGroup": { + "description": "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod:\n\n1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw----\n\nIf unset, the Kubelet will not modify the ownership and permissions of any volume.", + "type": "integer", + "format": "int64" + }, + "runAsNonRoot": { + "description": "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "type": "boolean" + }, + "runAsUser": { + "description": "The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container.", + "type": "integer", + "format": "int64" + }, + "seLinuxOptions": { + "description": "The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container.", + "$ref": "#/definitions/io.k8s.api.core.v1.SELinuxOptions" + }, + "supplementalGroups": { + "description": "A list of groups applied to the first process run in each container, in addition to the container's primary GID. If unspecified, no groups will be added to any container.", + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + }, + "io.k8s.api.core.v1.PodSpec": { + "description": "PodSpec is a description of a pod.", + "type": "object", + "required": [ + "containers" + ], + "properties": { + "activeDeadlineSeconds": { + "description": "Optional duration in seconds the pod may be active on the node relative to StartTime before the system will actively try to mark it failed and kill associated containers. Value must be a positive integer.", + "type": "integer", + "format": "int64" + }, + "affinity": { + "description": "If specified, the pod's scheduling constraints", + "$ref": "#/definitions/io.k8s.api.core.v1.Affinity" + }, + "automountServiceAccountToken": { + "description": "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.", + "type": "boolean" + }, + "containers": { + "description": "List of containers belonging to the pod. Containers cannot currently be added or removed. There must be at least one container in a Pod. Cannot be updated.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Container" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "dnsPolicy": { + "description": "Set DNS policy for containers within the pod. One of 'ClusterFirstWithHostNet', 'ClusterFirst' or 'Default'. Defaults to \"ClusterFirst\". To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.", + "type": "string" + }, + "hostAliases": { + "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.HostAlias" + }, + "x-kubernetes-patch-merge-key": "ip", + "x-kubernetes-patch-strategy": "merge" + }, + "hostIPC": { + "description": "Use the host's ipc namespace. Optional: Default to false.", + "type": "boolean" + }, + "hostNetwork": { + "description": "Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false.", + "type": "boolean" + }, + "hostPID": { + "description": "Use the host's pid namespace. Optional: Default to false.", + "type": "boolean" + }, + "hostname": { + "description": "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.", + "type": "string" + }, + "imagePullSecrets": { + "description": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "initContainers": { + "description": "List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, or Liveness probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Container" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "nodeName": { + "description": "NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.", + "type": "string" + }, + "nodeSelector": { + "description": "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "priority": { + "description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.", + "type": "integer", + "format": "int32" + }, + "priorityClassName": { + "description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.", + "type": "string" + }, + "restartPolicy": { + "description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy", + "type": "string" + }, + "schedulerName": { + "description": "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.", + "type": "string" + }, + "securityContext": { + "description": "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodSecurityContext" + }, + "serviceAccount": { + "description": "DeprecatedServiceAccount is a depreciated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.", + "type": "string" + }, + "serviceAccountName": { + "description": "ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/", + "type": "string" + }, + "subdomain": { + "description": "If specified, the fully qualified Pod hostname will be \"\u003chostname\u003e.\u003csubdomain\u003e.\u003cpod namespace\u003e.svc.\u003ccluster domain\u003e\". If not specified, the pod will not have a domainname at all.", + "type": "string" + }, + "terminationGracePeriodSeconds": { + "description": "Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.", + "type": "integer", + "format": "int64" + }, + "tolerations": { + "description": "If specified, the pod's tolerations.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" + } + }, + "volumes": { + "description": "List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Volume" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys" + } + } + }, + "io.k8s.api.core.v1.PodStatus": { + "description": "PodStatus represents information about the status of a pod. Status may trail the actual state of a system.", + "type": "object", + "properties": { + "conditions": { + "description": "Current service state of pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "containerStatuses": { + "description": "The list has one entry per container in the manifest. Each entry is currently the output of `docker inspect`. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStatus" + } + }, + "hostIP": { + "description": "IP address of the host to which the pod is assigned. Empty if not yet scheduled.", + "type": "string" + }, + "initContainerStatuses": { + "description": "The list has one entry per init container in the manifest. The most recent successful init container will have ready = true, the most recently started container will have startTime set. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ContainerStatus" + } + }, + "message": { + "description": "A human readable message indicating details about why the pod is in this condition.", + "type": "string" + }, + "phase": { + "description": "Current condition of the pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase", + "type": "string" + }, + "podIP": { + "description": "IP address allocated to the pod. Routable at least within the cluster. Empty if not yet allocated.", + "type": "string" + }, + "qosClass": { + "description": "The Quality of Service (QOS) classification assigned to the pod based on resource requirements See PodQOSClass type for available QOS classes More info: https://github.com/kubernetes/kubernetes/blob/master/docs/design/resource-qos.md", + "type": "string" + }, + "reason": { + "description": "A brief CamelCase message indicating details about why the pod is in this state. e.g. 'Evicted'", + "type": "string" + }, + "startTime": { + "description": "RFC 3339 date and time at which the object was acknowledged by the Kubelet. This is before the Kubelet pulled the container image(s) for the pod.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + } + } + }, + "io.k8s.api.core.v1.PodTemplate": { + "description": "PodTemplate describes a template for creating copies of a predefined pod.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "template": { + "description": "Template defines the pods that will be created from this pod template. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PodTemplate", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodTemplateList": { + "description": "PodTemplateList is a list of PodTemplates.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of pod templates", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplate" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "PodTemplateList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.PodTemplateSpec": { + "description": "PodTemplateSpec describes the data a pod should have when created from a template", + "type": "object", + "properties": { + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.PodSpec" + } + } + }, + "io.k8s.api.core.v1.PortworxVolumeSource": { + "description": "PortworxVolumeSource represents a Portworx volume resource.", + "type": "object", + "required": [ + "volumeID" + ], + "properties": { + "fsType": { + "description": "FSType represents the filesystem type to mount Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "volumeID": { + "description": "VolumeID uniquely identifies a Portworx volume", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.PreferredSchedulingTerm": { + "description": "An empty preferred scheduling term matches all objects with implicit weight 0 (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).", + "type": "object", + "required": [ + "weight", + "preference" + ], + "properties": { + "preference": { + "description": "A node selector term, associated with the corresponding weight.", + "$ref": "#/definitions/io.k8s.api.core.v1.NodeSelectorTerm" + }, + "weight": { + "description": "Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.Probe": { + "description": "Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic.", + "type": "object", + "properties": { + "exec": { + "description": "One and only one of the following should be specified. Exec specifies the action to take.", + "$ref": "#/definitions/io.k8s.api.core.v1.ExecAction" + }, + "failureThreshold": { + "description": "Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1.", + "type": "integer", + "format": "int32" + }, + "httpGet": { + "description": "HTTPGet specifies the http request to perform.", + "$ref": "#/definitions/io.k8s.api.core.v1.HTTPGetAction" + }, + "initialDelaySeconds": { + "description": "Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "type": "integer", + "format": "int32" + }, + "periodSeconds": { + "description": "How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.", + "type": "integer", + "format": "int32" + }, + "successThreshold": { + "description": "Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness. Minimum value is 1.", + "type": "integer", + "format": "int32" + }, + "tcpSocket": { + "description": "TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported", + "$ref": "#/definitions/io.k8s.api.core.v1.TCPSocketAction" + }, + "timeoutSeconds": { + "description": "Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.ProjectedVolumeSource": { + "description": "Represents a projected volume source", + "type": "object", + "required": [ + "sources" + ], + "properties": { + "defaultMode": { + "description": "Mode bits to use on created files by default. Must be a value between 0 and 0777. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "sources": { + "description": "list of volume projections", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.VolumeProjection" + } + } + } + }, + "io.k8s.api.core.v1.QuobyteVolumeSource": { + "description": "Represents a Quobyte mount that lasts the lifetime of a pod. Quobyte volumes do not support ownership management or SELinux relabeling.", + "type": "object", + "required": [ + "registry", + "volume" + ], + "properties": { + "group": { + "description": "Group to map volume access to Default is no group", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the Quobyte volume to be mounted with read-only permissions. Defaults to false.", + "type": "boolean" + }, + "registry": { + "description": "Registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes", + "type": "string" + }, + "user": { + "description": "User to map volume access to Defaults to serivceaccount user", + "type": "string" + }, + "volume": { + "description": "Volume is a string that references an already created Quobyte volume by name.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.RBDVolumeSource": { + "description": "Represents a Rados Block Device mount that lasts the lifetime of a pod. RBD volumes support ownership management and SELinux relabeling.", + "type": "object", + "required": [ + "monitors", + "image" + ], + "properties": { + "fsType": { + "description": "Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd", + "type": "string" + }, + "image": { + "description": "The rados image name. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + }, + "keyring": { + "description": "Keyring is the path to key ring for RBDUser. Default is /etc/ceph/keyring. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + }, + "monitors": { + "description": "A collection of Ceph monitors. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "array", + "items": { + "type": "string" + } + }, + "pool": { + "description": "The rados pool name. Default is rbd. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + }, + "readOnly": { + "description": "ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef is name of the authentication secret for RBDUser. If provided overrides keyring. Default is nil. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "user": { + "description": "The rados user name. Default is admin. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md#how-to-use-it", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ReplicationController": { + "description": "ReplicationController represents the configuration of a replication controller.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "If the Labels of a ReplicationController are empty, they are defaulted to be the same as the Pod(s) that the replication controller manages. Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the specification of the desired behavior of the replication controller. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationControllerSpec" + }, + "status": { + "description": "Status is the most recently observed status of the replication controller. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationControllerStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ReplicationController", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ReplicationControllerCondition": { + "description": "ReplicationControllerCondition describes the state of a replication controller at a certain point.", + "type": "object", + "required": [ + "type", + "status" + ], + "properties": { + "lastTransitionTime": { + "description": "The last time the condition transitioned from one status to another.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "message": { + "description": "A human readable message indicating details about the transition.", + "type": "string" + }, + "reason": { + "description": "The reason for the condition's last transition.", + "type": "string" + }, + "status": { + "description": "Status of the condition, one of True, False, Unknown.", + "type": "string" + }, + "type": { + "description": "Type of replication controller condition.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ReplicationControllerList": { + "description": "ReplicationControllerList is a collection of replication controllers.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of replication controllers. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationController" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ReplicationControllerList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ReplicationControllerSpec": { + "description": "ReplicationControllerSpec is the specification of a replication controller.", + "type": "object", + "properties": { + "minReadySeconds": { + "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Replicas is the number of desired replicas. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", + "type": "integer", + "format": "int32" + }, + "selector": { + "description": "Selector is a label query over pods that should match the Replicas count. If Selector is empty, it is defaulted to the labels present on the Pod template. Label keys and values that must match in order to be controlled by this replication controller, if empty defaulted to labels on Pod template. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "template": { + "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. This takes precedence over a TemplateRef. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template", + "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" + } + } + }, + "io.k8s.api.core.v1.ReplicationControllerStatus": { + "description": "ReplicationControllerStatus represents the current status of a replication controller.", + "type": "object", + "required": [ + "replicas" + ], + "properties": { + "availableReplicas": { + "description": "The number of available replicas (ready for at least minReadySeconds) for this replication controller.", + "type": "integer", + "format": "int32" + }, + "conditions": { + "description": "Represents the latest available observations of a replication controller's current state.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ReplicationControllerCondition" + }, + "x-kubernetes-patch-merge-key": "type", + "x-kubernetes-patch-strategy": "merge" + }, + "fullyLabeledReplicas": { + "description": "The number of pods that have labels matching the labels of the pod template of the replication controller.", + "type": "integer", + "format": "int32" + }, + "observedGeneration": { + "description": "ObservedGeneration reflects the generation of the most recently observed replication controller.", + "type": "integer", + "format": "int64" + }, + "readyReplicas": { + "description": "The number of ready replicas for this replication controller.", + "type": "integer", + "format": "int32" + }, + "replicas": { + "description": "Replicas is the most recently oberved number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.api.core.v1.ResourceFieldSelector": { + "description": "ResourceFieldSelector represents container resources (cpu, memory) and their output format", + "type": "object", + "required": [ + "resource" + ], + "properties": { + "containerName": { + "description": "Container name: required for volumes, optional for env vars", + "type": "string" + }, + "divisor": { + "description": "Specifies the output format of the exposed resources, defaults to \"1\"", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + }, + "resource": { + "description": "Required: resource to select", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ResourceQuota": { + "description": "ResourceQuota sets aggregate quota restrictions enforced per namespace", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the desired quota. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceQuotaSpec" + }, + "status": { + "description": "Status defines the actual enforced quota and its current usage. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceQuotaStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ResourceQuota", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ResourceQuotaList": { + "description": "ResourceQuotaList is a list of ResourceQuota items.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is a list of ResourceQuota objects. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_resource_quota.md", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ResourceQuota" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ResourceQuotaList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ResourceQuotaSpec": { + "description": "ResourceQuotaSpec defines the desired hard limits to enforce for Quota.", + "type": "object", + "properties": { + "hard": { + "description": "Hard is the set of desired hard limits for each named resource. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_resource_quota.md", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "scopes": { + "description": "A collection of filters that must match each object tracked by a quota. If not specified, the quota matches all objects.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.api.core.v1.ResourceQuotaStatus": { + "description": "ResourceQuotaStatus defines the enforced hard limits and observed use.", + "type": "object", + "properties": { + "hard": { + "description": "Hard is the set of enforced hard limits for each named resource. More info: https://git.k8s.io/community/contributors/design-proposals/admission_control_resource_quota.md", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "used": { + "description": "Used is the current observed total usage of the resource in the namespace.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + } + } + }, + "io.k8s.api.core.v1.ResourceRequirements": { + "description": "ResourceRequirements describes the compute resource requirements.", + "type": "object", + "properties": { + "limits": { + "description": "Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + }, + "requests": { + "description": "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" + } + } + } + }, + "io.k8s.api.core.v1.SELinuxOptions": { + "description": "SELinuxOptions are the labels to be applied to the container", + "type": "object", + "properties": { + "level": { + "description": "Level is SELinux level label that applies to the container.", + "type": "string" + }, + "role": { + "description": "Role is a SELinux role label that applies to the container.", + "type": "string" + }, + "type": { + "description": "Type is a SELinux type label that applies to the container.", + "type": "string" + }, + "user": { + "description": "User is a SELinux user label that applies to the container.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ScaleIOVolumeSource": { + "description": "ScaleIOVolumeSource represents a persistent ScaleIO volume", + "type": "object", + "required": [ + "gateway", + "system", + "secretRef" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "gateway": { + "description": "The host address of the ScaleIO API Gateway.", + "type": "string" + }, + "protectionDomain": { + "description": "The name of the Protection Domain for the configured storage (defaults to \"default\").", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail.", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "sslEnabled": { + "description": "Flag to enable/disable SSL communication with Gateway, default false", + "type": "boolean" + }, + "storageMode": { + "description": "Indicates whether the storage for a volume should be thick or thin (defaults to \"thin\").", + "type": "string" + }, + "storagePool": { + "description": "The Storage Pool associated with the protection domain (defaults to \"default\").", + "type": "string" + }, + "system": { + "description": "The name of the storage system as configured in ScaleIO.", + "type": "string" + }, + "volumeName": { + "description": "The name of a volume already created in the ScaleIO system that is associated with this volume source.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Secret": { + "description": "Secret holds secret data of a certain type. The total bytes of the values in the Data field must be less than MaxSecretSize bytes.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "data": { + "description": "Data contains the secret data. Each key must consist of alphanumeric characters, '-', '_' or '.'. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4", + "type": "object", + "additionalProperties": { + "type": "string", + "format": "byte" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "stringData": { + "description": "stringData allows specifying non-binary secret data in string form. It is provided as a write-only convenience method. All keys and values are merged into the data field on write, overwriting any existing values. It is never output when reading from the API.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "type": { + "description": "Used to facilitate programmatic handling of secret data.", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Secret", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.SecretEnvSource": { + "description": "SecretEnvSource selects a Secret to populate the environment variables with.\n\nThe contents of the target Secret's Data field will represent the key-value pairs as environment variables.", + "type": "object", + "properties": { + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the Secret must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.SecretKeySelector": { + "description": "SecretKeySelector selects a key of a Secret.", + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "description": "The key of the secret to select from. Must be a valid secret key.", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the Secret or it's key must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.SecretList": { + "description": "SecretList is a list of Secret.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "Items is a list of secret objects. More info: https://kubernetes.io/docs/concepts/configuration/secret", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Secret" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "SecretList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.SecretProjection": { + "description": "Adapts a secret into a projected volume.\n\nThe contents of the target Secret's Data field will be presented in a projected volume as files using the keys in the Data field as the file names. Note that this is identical to a secret volume source without the default mode.", + "type": "object", + "properties": { + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "name": { + "description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "optional": { + "description": "Specify whether the Secret or its key must be defined", + "type": "boolean" + } + } + }, + "io.k8s.api.core.v1.SecretReference": { + "description": "SecretReference represents a Secret Reference. It has enough information to retrieve secret in any namespace", + "type": "object", + "properties": { + "name": { + "description": "Name is unique within a namespace to reference a secret resource.", + "type": "string" + }, + "namespace": { + "description": "Namespace defines the space within which the secret name must be unique.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.SecretVolumeSource": { + "description": "Adapts a Secret into a volume.\n\nThe contents of the target Secret's Data field will be presented in a volume as files using the keys in the Data field as the file names. Secret volumes support ownership management and SELinux relabeling.", + "type": "object", + "properties": { + "defaultMode": { + "description": "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.", + "type": "integer", + "format": "int32" + }, + "items": { + "description": "If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.KeyToPath" + } + }, + "optional": { + "description": "Specify whether the Secret or it's keys must be defined", + "type": "boolean" + }, + "secretName": { + "description": "Name of the secret in the pod's namespace to use. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.SecurityContext": { + "description": "SecurityContext holds security configuration that will be applied to a container. Some fields are present in both SecurityContext and PodSecurityContext. When both are set, the values in SecurityContext take precedence.", + "type": "object", + "properties": { + "allowPrivilegeEscalation": { + "description": "AllowPrivilegeEscalation controls whether a process can gain more privileges than it's parent process. This bool directly controls if the no_new_privs flag will be set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged 2) has CAP_SYS_ADMIN", + "type": "boolean" + }, + "capabilities": { + "description": "The capabilities to add/drop when running containers. Defaults to the default set of capabilities granted by the container runtime.", + "$ref": "#/definitions/io.k8s.api.core.v1.Capabilities" + }, + "privileged": { + "description": "Run container in privileged mode. Processes in privileged containers are essentially equivalent to root on the host. Defaults to false.", + "type": "boolean" + }, + "readOnlyRootFilesystem": { + "description": "Whether this container has a read-only root filesystem. Default is false.", + "type": "boolean" + }, + "runAsNonRoot": { + "description": "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "type": "boolean" + }, + "runAsUser": { + "description": "The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "type": "integer", + "format": "int64" + }, + "seLinuxOptions": { + "description": "The SELinux context to be applied to the container. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence.", + "$ref": "#/definitions/io.k8s.api.core.v1.SELinuxOptions" + } + } + }, + "io.k8s.api.core.v1.Service": { + "description": "Service is a named abstraction of software service (for example, mysql) consisting of local port (for example 3306) that the proxy listens on, and the selector that determines which pods will answer requests sent through the proxy.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "description": "Spec defines the behavior of a service. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ServiceSpec" + }, + "status": { + "description": "Most recently observed status of the service. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "$ref": "#/definitions/io.k8s.api.core.v1.ServiceStatus" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Service", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServiceAccount": { + "description": "ServiceAccount binds together: * a name, understood by users, and perhaps by peripheral systems, for an identity * a principal that can be authenticated and authorized * a set of secrets", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "automountServiceAccountToken": { + "description": "AutomountServiceAccountToken indicates whether pods running as this service account should have an API token automatically mounted. Can be overridden at the pod level.", + "type": "boolean" + }, + "imagePullSecrets": { + "description": "ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling any images in pods that reference this ServiceAccount. ImagePullSecrets are distinct from Secrets because Secrets can be mounted in the pod, but ImagePullSecrets are only accessed by the kubelet. More info: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "secrets": { + "description": "Secrets is the list of secrets allowed to be used by pods running using this ServiceAccount. More info: https://kubernetes.io/docs/concepts/configuration/secret", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ServiceAccount", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServiceAccountList": { + "description": "ServiceAccountList is a list of ServiceAccount objects", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of ServiceAccounts. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ServiceAccount" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ServiceAccountList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServiceList": { + "description": "ServiceList holds a list of services.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of services", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Service" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "ServiceList", + "version": "v1" + } + ] + }, + "io.k8s.api.core.v1.ServicePort": { + "description": "ServicePort contains information on service's port.", + "type": "object", + "required": [ + "port" + ], + "properties": { + "name": { + "description": "The name of this port within the service. This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. This maps to the 'Name' field in EndpointPort objects. Optional if only one ServicePort is defined on this service.", + "type": "string" + }, + "nodePort": { + "description": "The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one. More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport", + "type": "integer", + "format": "int32" + }, + "port": { + "description": "The port that will be exposed by this service.", + "type": "integer", + "format": "int32" + }, + "protocol": { + "description": "The IP protocol for this port. Supports \"TCP\" and \"UDP\". Default is TCP.", + "type": "string" + }, + "targetPort": { + "description": "Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + } + } + }, + "io.k8s.api.core.v1.ServiceSpec": { + "description": "ServiceSpec describes the attributes that a user creates on a service.", + "type": "object", + "properties": { + "clusterIP": { + "description": "clusterIP is the IP address of the service and is usually assigned randomly by the master. If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are \"None\", empty string (\"\"), or a valid IP address. \"None\" can be specified for headless services when proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + "type": "string" + }, + "externalIPs": { + "description": "externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.", + "type": "array", + "items": { + "type": "string" + } + }, + "externalName": { + "description": "externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid DNS name and requires Type to be ExternalName.", + "type": "string" + }, + "externalTrafficPolicy": { + "description": "externalTrafficPolicy denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints. \"Local\" preserves the client source IP and avoids a second hop for LoadBalancer and Nodeport type services, but risks potentially imbalanced traffic spreading. \"Cluster\" obscures the client source IP and may cause a second hop to another node, but should have good overall load-spreading.", + "type": "string" + }, + "healthCheckNodePort": { + "description": "healthCheckNodePort specifies the healthcheck nodePort for the service. If not specified, HealthCheckNodePort is created by the service api backend with the allocated nodePort. Will use user-specified nodePort value if specified by the client. Only effects when Type is set to LoadBalancer and ExternalTrafficPolicy is set to Local.", + "type": "integer", + "format": "int32" + }, + "loadBalancerIP": { + "description": "Only applies to Service Type: LoadBalancer LoadBalancer will get created with the IP specified in this field. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature.", + "type": "string" + }, + "loadBalancerSourceRanges": { + "description": "If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.\" More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/", + "type": "array", + "items": { + "type": "string" + } + }, + "ports": { + "description": "The list of ports that are exposed by this service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.ServicePort" + }, + "x-kubernetes-patch-merge-key": "port", + "x-kubernetes-patch-strategy": "merge" + }, + "publishNotReadyAddresses": { + "description": "publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service. The default value is false. The primary use case for setting this field is to use a StatefulSet's Headless Service to propagate SRV records for its Pods without respect to their readiness for purpose of peer discovery. This field will replace the service.alpha.kubernetes.io/tolerate-unready-endpoints when that annotation is deprecated and all clients have been converted to use this field.", + "type": "boolean" + }, + "selector": { + "description": "Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "sessionAffinity": { + "description": "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies", + "type": "string" + }, + "sessionAffinityConfig": { + "description": "sessionAffinityConfig contains the configurations of session affinity.", + "$ref": "#/definitions/io.k8s.api.core.v1.SessionAffinityConfig" + }, + "type": { + "description": "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ExternalName\" maps to the specified externalName. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.ServiceStatus": { + "description": "ServiceStatus represents the current status of a service.", + "type": "object", + "properties": { + "loadBalancer": { + "description": "LoadBalancer contains the current status of the load-balancer, if one is present.", + "$ref": "#/definitions/io.k8s.api.core.v1.LoadBalancerStatus" + } + } + }, + "io.k8s.api.core.v1.SessionAffinityConfig": { + "description": "SessionAffinityConfig represents the configurations of session affinity.", + "type": "object", + "properties": { + "clientIP": { + "description": "clientIP contains the configurations of Client IP based session affinity.", + "$ref": "#/definitions/io.k8s.api.core.v1.ClientIPConfig" + } + } + }, + "io.k8s.api.core.v1.StorageOSPersistentVolumeSource": { + "description": "Represents a StorageOS persistent volume resource.", + "type": "object", + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted.", + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + }, + "volumeName": { + "description": "VolumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.", + "type": "string" + }, + "volumeNamespace": { + "description": "VolumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to \"default\" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.StorageOSVolumeSource": { + "description": "Represents a StorageOS persistent volume resource.", + "type": "object", + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "readOnly": { + "description": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", + "type": "boolean" + }, + "secretRef": { + "description": "SecretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted.", + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "volumeName": { + "description": "VolumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.", + "type": "string" + }, + "volumeNamespace": { + "description": "VolumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to \"default\" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.TCPSocketAction": { + "description": "TCPSocketAction describes an action based on opening a socket", + "type": "object", + "required": [ + "port" + ], + "properties": { + "host": { + "description": "Optional: Host name to connect to, defaults to the pod IP.", + "type": "string" + }, + "port": { + "description": "Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + } + } + }, + "io.k8s.api.core.v1.Taint": { + "description": "The node this Taint is attached to has the \"effect\" on any pod that does not tolerate the Taint.", + "type": "object", + "required": [ + "key", + "effect" + ], + "properties": { + "effect": { + "description": "Required. The effect of the taint on pods that do not tolerate the taint. Valid effects are NoSchedule, PreferNoSchedule and NoExecute.", + "type": "string" + }, + "key": { + "description": "Required. The taint key to be applied to a node.", + "type": "string" + }, + "timeAdded": { + "description": "TimeAdded represents the time at which the taint was added. It is only written for NoExecute taints.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "value": { + "description": "Required. The taint value corresponding to the taint key.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Toleration": { + "description": "The pod this Toleration is attached to tolerates any taint that matches the triple \u003ckey,value,effect\u003e using the matching operator \u003coperator\u003e.", + "type": "object", + "properties": { + "effect": { + "description": "Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.", + "type": "string" + }, + "key": { + "description": "Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys.", + "type": "string" + }, + "operator": { + "description": "Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.", + "type": "string" + }, + "tolerationSeconds": { + "description": "TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.", + "type": "integer", + "format": "int64" + }, + "value": { + "description": "Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.Volume": { + "description": "Volume represents a named volume in a pod that may be accessed by any container in the pod.", + "type": "object", + "required": [ + "name" + ], + "properties": { + "awsElasticBlockStore": { + "description": "AWSElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore", + "$ref": "#/definitions/io.k8s.api.core.v1.AWSElasticBlockStoreVolumeSource" + }, + "azureDisk": { + "description": "AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureDiskVolumeSource" + }, + "azureFile": { + "description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.AzureFileVolumeSource" + }, + "cephfs": { + "description": "CephFS represents a Ceph FS mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.CephFSVolumeSource" + }, + "cinder": { + "description": "Cinder represents a cinder volume attached and mounted on kubelets host machine More info: https://releases.k8s.io/HEAD/examples/mysql-cinder-pd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.CinderVolumeSource" + }, + "configMap": { + "description": "ConfigMap represents a configMap that should populate this volume", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapVolumeSource" + }, + "downwardAPI": { + "description": "DownwardAPI represents downward API about the pod that should populate this volume", + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIVolumeSource" + }, + "emptyDir": { + "description": "EmptyDir represents a temporary directory that shares a pod's lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir", + "$ref": "#/definitions/io.k8s.api.core.v1.EmptyDirVolumeSource" + }, + "fc": { + "description": "FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.", + "$ref": "#/definitions/io.k8s.api.core.v1.FCVolumeSource" + }, + "flexVolume": { + "description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. This is an alpha feature and may change in future.", + "$ref": "#/definitions/io.k8s.api.core.v1.FlexVolumeSource" + }, + "flocker": { + "description": "Flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running", + "$ref": "#/definitions/io.k8s.api.core.v1.FlockerVolumeSource" + }, + "gcePersistentDisk": { + "description": "GCEPersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk", + "$ref": "#/definitions/io.k8s.api.core.v1.GCEPersistentDiskVolumeSource" + }, + "gitRepo": { + "description": "GitRepo represents a git repository at a particular revision.", + "$ref": "#/definitions/io.k8s.api.core.v1.GitRepoVolumeSource" + }, + "glusterfs": { + "description": "Glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: https://releases.k8s.io/HEAD/examples/volumes/glusterfs/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.GlusterfsVolumeSource" + }, + "hostPath": { + "description": "HostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath", + "$ref": "#/definitions/io.k8s.api.core.v1.HostPathVolumeSource" + }, + "iscsi": { + "description": "ISCSI represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://releases.k8s.io/HEAD/examples/volumes/iscsi/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.ISCSIVolumeSource" + }, + "name": { + "description": "Volume's name. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + "type": "string" + }, + "nfs": { + "description": "NFS represents an NFS mount on the host that shares a pod's lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs", + "$ref": "#/definitions/io.k8s.api.core.v1.NFSVolumeSource" + }, + "persistentVolumeClaim": { + "description": "PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims", + "$ref": "#/definitions/io.k8s.api.core.v1.PersistentVolumeClaimVolumeSource" + }, + "photonPersistentDisk": { + "description": "PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource" + }, + "portworxVolume": { + "description": "PortworxVolume represents a portworx volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.PortworxVolumeSource" + }, + "projected": { + "description": "Items for all in one resources secrets, configmaps, and downward API", + "$ref": "#/definitions/io.k8s.api.core.v1.ProjectedVolumeSource" + }, + "quobyte": { + "description": "Quobyte represents a Quobyte mount on the host that shares a pod's lifetime", + "$ref": "#/definitions/io.k8s.api.core.v1.QuobyteVolumeSource" + }, + "rbd": { + "description": "RBD represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://releases.k8s.io/HEAD/examples/volumes/rbd/README.md", + "$ref": "#/definitions/io.k8s.api.core.v1.RBDVolumeSource" + }, + "scaleIO": { + "description": "ScaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.", + "$ref": "#/definitions/io.k8s.api.core.v1.ScaleIOVolumeSource" + }, + "secret": { + "description": "Secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretVolumeSource" + }, + "storageos": { + "description": "StorageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.", + "$ref": "#/definitions/io.k8s.api.core.v1.StorageOSVolumeSource" + }, + "vsphereVolume": { + "description": "VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine", + "$ref": "#/definitions/io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource" + } + } + }, + "io.k8s.api.core.v1.VolumeMount": { + "description": "VolumeMount describes a mounting of a Volume within a container.", + "required": [ + "name", + "mountPath" + ], + "properties": { + "mountPath": { + "description": "Path within the container at which the volume should be mounted. Must not contain ':'.", + "type": "string" + }, + "name": { + "description": "This must match the Name of a Volume.", + "type": "string" + }, + "readOnly": { + "description": "Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.", + "type": "boolean" + }, + "subPath": { + "description": "Path within the volume from which the container's volume should be mounted. Defaults to \"\" (volume's root).", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.VolumeProjection": { + "description": "Projection that may be projected along with other supported volume types", + "type": "object", + "properties": { + "configMap": { + "description": "information about the configMap data to project", + "$ref": "#/definitions/io.k8s.api.core.v1.ConfigMapProjection" + }, + "downwardAPI": { + "description": "information about the downwardAPI data to project", + "$ref": "#/definitions/io.k8s.api.core.v1.DownwardAPIProjection" + }, + "secret": { + "description": "information about the secret data to project", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretProjection" + } + } + }, + "io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource": { + "description": "Represents a vSphere volume resource.", + "type": "object", + "required": [ + "volumePath" + ], + "properties": { + "fsType": { + "description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", + "type": "string" + }, + "storagePolicyID": { + "description": "Storage Policy Based Management (SPBM) profile ID associated with the StoragePolicyName.", + "type": "string" + }, + "storagePolicyName": { + "description": "Storage Policy Based Management (SPBM) profile name.", + "type": "string" + }, + "volumePath": { + "description": "Path that identifies vSphere volume vmdk", + "type": "string" + } + } + }, + "io.k8s.api.core.v1.WeightedPodAffinityTerm": { + "description": "The weights of all of the matched WeightedPodAffinityTerm fields are added per-node to find the most preferred node(s)", + "type": "object", + "required": [ + "weight", + "podAffinityTerm" + ], + "properties": { + "podAffinityTerm": { + "description": "Required. A pod affinity term, associated with the corresponding weight.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodAffinityTerm" + }, + "weight": { + "description": "weight associated with matching the corresponding podAffinityTerm, in the range 1-100.", + "type": "integer", + "format": "int32" + } + } + }, + "io.k8s.apimachinery.pkg.api.resource.Quantity": { + "type": "string" + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup": { + "description": "APIGroup contains the name, the supported versions, and the preferred version of a group.", + "type": "object", + "required": [ + "name", + "versions", + "serverAddressByClientCIDRs" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "name is the name of the group.", + "type": "string" + }, + "preferredVersion": { + "description": "preferredVersion is the version preferred by the API server, which probably is the storage version.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery" + }, + "serverAddressByClientCIDRs": { + "description": "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR" + } + }, + "versions": { + "description": "versions are the versions supported in this group.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIGroup", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIGroupList": { + "description": "APIGroupList is a list of APIGroup, to allow clients to discover the API at /apis.", + "type": "object", + "required": [ + "groups" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "groups": { + "description": "groups is a list of APIGroup.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIGroupList", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIResource": { + "description": "APIResource specifies the name of a resource and whether it is namespaced.", + "type": "object", + "required": [ + "name", + "singularName", + "namespaced", + "kind", + "verbs" + ], + "properties": { + "categories": { + "description": "categories is a list of the grouped resources this resource belongs to (e.g. 'all')", + "type": "array", + "items": { + "type": "string" + } + }, + "kind": { + "description": "kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo')", + "type": "string" + }, + "name": { + "description": "name is the plural name of the resource.", + "type": "string" + }, + "namespaced": { + "description": "namespaced indicates if a resource is namespaced or not.", + "type": "boolean" + }, + "shortNames": { + "description": "shortNames is a list of suggested short names of the resource.", + "type": "array", + "items": { + "type": "string" + } + }, + "singularName": { + "description": "singularName is the singular name of the resource. This allows clients to handle plural and singular opaquely. The singularName is more correct for reporting status on a single item and both singular and plural are allowed from the kubectl CLI interface.", + "type": "string" + }, + "verbs": { + "description": "verbs is a list of supported kube verbs (this includes get, list, watch, create, update, patch, delete, deletecollection, and proxy)", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIResourceList": { + "description": "APIResourceList is a list of APIResource, it is used to expose the name of the resources supported in a specific group and version, and if the resource is namespaced.", + "type": "object", + "required": [ + "groupVersion", + "resources" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "groupVersion": { + "description": "groupVersion is the group and version this APIResourceList is for.", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "resources": { + "description": "resources contains the name of the resources and if they are namespaced.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIResource" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIResourceList", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.APIVersions": { + "description": "APIVersions lists the versions that are available, to allow clients to discover the API at /api, which is the root path of the legacy v1 API.", + "type": "object", + "required": [ + "versions", + "serverAddressByClientCIDRs" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "serverAddressByClientCIDRs": { + "description": "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR" + } + }, + "versions": { + "description": "versions are the api versions that are available.", + "type": "array", + "items": { + "type": "string" + } + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "APIVersions", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions": { + "description": "DeleteOptions may be provided when deleting an API object.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "gracePeriodSeconds": { + "description": "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.", + "type": "integer", + "format": "int64" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "orphanDependents": { + "description": "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.", + "type": "boolean" + }, + "preconditions": { + "description": "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions" + }, + "propagationPolicy": { + "description": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy.", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "admission.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "admissionregistration.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "apps", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "apps", + "kind": "DeleteOptions", + "version": "v1beta2" + }, + { + "group": "authentication.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "authentication.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "autoscaling", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "autoscaling", + "kind": "DeleteOptions", + "version": "v2alpha1" + }, + { + "group": "batch", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "batch", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "batch", + "kind": "DeleteOptions", + "version": "v2alpha1" + }, + { + "group": "certificates.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "extensions", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "federation", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "imagepolicy.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "networking.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "policy", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + }, + { + "group": "scheduling.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "settings.k8s.io", + "kind": "DeleteOptions", + "version": "v1alpha1" + }, + { + "group": "storage.k8s.io", + "kind": "DeleteOptions", + "version": "v1" + }, + { + "group": "storage.k8s.io", + "kind": "DeleteOptions", + "version": "v1beta1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery": { + "description": "GroupVersion contains the \"group/version\" and \"version\" string of a version. It is made a struct to keep extensibility.", + "type": "object", + "required": [ + "groupVersion", + "version" + ], + "properties": { + "groupVersion": { + "description": "groupVersion specifies the API group and version in the form \"group/version\"", + "type": "string" + }, + "version": { + "description": "version specifies the version in the form of \"version\". This is to save the clients the trouble of splitting the GroupVersion.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Initializer": { + "description": "Initializer is information about an initializer that has not yet completed.", + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "name of the process that is responsible for initializing this object.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Initializers": { + "description": "Initializers tracks the progress of initialization.", + "type": "object", + "required": [ + "pending" + ], + "properties": { + "pending": { + "description": "Pending is a list of initializers that must execute in order before this object is visible. When the last pending initializer is removed, and no failing result is set, the initializers struct will be set to nil and the object is considered as initialized and visible to all clients.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Initializer" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "result": { + "description": "If result is set with the Failure field, the object will be persisted to storage and then deleted, ensuring that other clients can observe the deletion.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Status" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector": { + "description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.", + "type": "object", + "properties": { + "matchExpressions": { + "description": "matchExpressions is a list of label selector requirements. The requirements are ANDed.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement" + } + }, + "matchLabels": { + "description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement": { + "description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + "type": "object", + "required": [ + "key", + "operator" + ], + "properties": { + "key": { + "description": "key is the label key that the selector applies to.", + "type": "string", + "x-kubernetes-patch-merge-key": "key", + "x-kubernetes-patch-strategy": "merge" + }, + "operator": { + "description": "operator represents a key's relationship to a set of values. Valid operators ard In, NotIn, Exists and DoesNotExist.", + "type": "string" + }, + "values": { + "description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta": { + "description": "ListMeta describes metadata that synthetic resources must have, including lists and various status objects. A resource may have only one of {ObjectMeta, ListMeta}.", + "type": "object", + "properties": { + "resourceVersion": { + "description": "String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency", + "type": "string" + }, + "selfLink": { + "description": "SelfLink is a URL representing this object. Populated by the system. Read-only.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": { + "description": "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.", + "type": "object", + "properties": { + "annotations": { + "description": "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "clusterName": { + "description": "The name of the cluster which the object belongs to. This is used to distinguish resources with same name and namespace in different clusters. This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request.", + "type": "string" + }, + "creationTimestamp": { + "description": "CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "deletionGracePeriodSeconds": { + "description": "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.", + "type": "integer", + "format": "int64" + }, + "deletionTimestamp": { + "description": "DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field. Once set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested.\n\nPopulated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time" + }, + "finalizers": { + "description": "Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed.", + "type": "array", + "items": { + "type": "string" + }, + "x-kubernetes-patch-strategy": "merge" + }, + "generateName": { + "description": "GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.\n\nIf this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header).\n\nApplied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#idempotency", + "type": "string" + }, + "generation": { + "description": "A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.", + "type": "integer", + "format": "int64" + }, + "initializers": { + "description": "An initializer is a controller which enforces some system invariant at object creation time. This field is a list of initializers that have not yet acted on this object. If nil or empty, this object has been completely initialized. Otherwise, the object is considered uninitialized and is hidden (in list/watch and get calls) from clients that haven't explicitly asked to observe uninitialized objects.\n\nWhen an object is created, the system will populate this list with the current set of initializers. Only privileged users may set or modify this list. Once it is empty, it may not be modified further by any user.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Initializers" + }, + "labels": { + "description": "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "description": "Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names", + "type": "string" + }, + "namespace": { + "description": "Namespace defines the space within each name must be unique. An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.\n\nMust be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces", + "type": "string" + }, + "ownerReferences": { + "description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference" + }, + "x-kubernetes-patch-merge-key": "uid", + "x-kubernetes-patch-strategy": "merge" + }, + "resourceVersion": { + "description": "An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.\n\nPopulated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency", + "type": "string" + }, + "selfLink": { + "description": "SelfLink is a URL representing this object. Populated by the system. Read-only.", + "type": "string" + }, + "uid": { + "description": "UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.\n\nPopulated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference": { + "description": "OwnerReference contains enough information to let you identify an owning object. Currently, an owning object must be in the same namespace, so there is no namespace field.", + "type": "object", + "required": [ + "apiVersion", + "kind", + "name", + "uid" + ], + "properties": { + "apiVersion": { + "description": "API version of the referent.", + "type": "string" + }, + "blockOwnerDeletion": { + "description": "If true, AND if the owner has the \"foregroundDeletion\" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs \"delete\" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.", + "type": "boolean" + }, + "controller": { + "description": "If true, this reference points to the managing controller.", + "type": "boolean" + }, + "kind": { + "description": "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names", + "type": "string" + }, + "uid": { + "description": "UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Patch": { + "description": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.", + "type": "object" + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions": { + "description": "Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out.", + "type": "object", + "properties": { + "uid": { + "description": "Specifies the target UID.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR": { + "description": "ServerAddressByClientCIDR helps the client to determine the server address that they should use, depending on the clientCIDR that they match.", + "type": "object", + "required": [ + "clientCIDR", + "serverAddress" + ], + "properties": { + "clientCIDR": { + "description": "The CIDR with which clients can match their IP to figure out the server address that they should use.", + "type": "string" + }, + "serverAddress": { + "description": "Address of this server, suitable for a client that matches the above CIDR. This can be a hostname, hostname:port, IP or IP:port.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Status": { + "description": "Status is a return value for calls that don't return other objects.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "code": { + "description": "Suggested HTTP return code for this status, 0 if not set.", + "type": "integer", + "format": "int32" + }, + "details": { + "description": "Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "message": { + "description": "A human-readable description of the status of this operation.", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta" + }, + "reason": { + "description": "A machine-readable description of why this operation is in the \"Failure\" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.", + "type": "string" + }, + "status": { + "description": "Status of the operation. One of: \"Success\" or \"Failure\". More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "Status", + "version": "v1" + } + ] + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause": { + "description": "StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.", + "type": "object", + "properties": { + "field": { + "description": "The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.\n\nExamples:\n \"name\" - the field \"name\" on the current resource\n \"items[0].name\" - the field \"name\" on the first array entry in \"items\"", + "type": "string" + }, + "message": { + "description": "A human-readable description of the cause of the error. This field may be presented as-is to a reader.", + "type": "string" + }, + "reason": { + "description": "A machine-readable description of the cause of the error. If this value is empty there is no information available.", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails": { + "description": "StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.", + "type": "object", + "properties": { + "causes": { + "description": "The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause" + } + }, + "group": { + "description": "The group attribute of the resource associated with the status StatusReason.", + "type": "string" + }, + "kind": { + "description": "The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "name": { + "description": "The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).", + "type": "string" + }, + "retryAfterSeconds": { + "description": "If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.", + "type": "integer", + "format": "int32" + }, + "uid": { + "description": "UID of the resource. (when there is a single resource which can be described). More info: http://kubernetes.io/docs/user-guide/identifiers#uids", + "type": "string" + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.Time": { + "type": "string", + "format": "date-time" + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.WatchEvent": { + "description": "Event represents a single event to a watched resource.", + "type": "object", + "required": [ + "type", + "object" + ], + "properties": { + "object": { + "description": "Object is:\n * If Type is Added or Modified: the new state of the object.\n * If Type is Deleted: the state of the object immediately before deletion.\n * If Type is Error: *Status is recommended; other types may make sense\n depending on context.", + "type": "object" + }, + "type": { + "type": "string" + } + }, + "x-kubernetes-group-version-kind": [ + { + "group": "", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "admission.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "admissionregistration.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "apps", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "apps", + "kind": "WatchEvent", + "version": "v1beta2" + }, + { + "group": "authentication.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "authentication.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "autoscaling", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "autoscaling", + "kind": "WatchEvent", + "version": "v2alpha1" + }, + { + "group": "batch", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "batch", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "batch", + "kind": "WatchEvent", + "version": "v2alpha1" + }, + { + "group": "certificates.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "extensions", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "federation", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "imagepolicy.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "networking.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "policy", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "rbac.authorization.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + }, + { + "group": "scheduling.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "settings.k8s.io", + "kind": "WatchEvent", + "version": "v1alpha1" + }, + { + "group": "storage.k8s.io", + "kind": "WatchEvent", + "version": "v1" + }, + { + "group": "storage.k8s.io", + "kind": "WatchEvent", + "version": "v1beta1" + } + ] + }, + "io.k8s.apimachinery.pkg.util.intstr.IntOrString": { + "type": "string", + "format": "int-or-string" + }, + "io.k8s.apimachinery.pkg.version.Info": { + "description": "Info contains versioning information. how we'll want to distribute that information.", + "type": "object", + "required": [ + "major", + "minor", + "gitVersion", + "gitCommit", + "gitTreeState", + "buildDate", + "goVersion", + "compiler", + "platform" + ], + "properties": { + "buildDate": { + "type": "string" + }, + "compiler": { + "type": "string" + }, + "gitCommit": { + "type": "string" + }, + "gitTreeState": { + "type": "string" + }, + "gitVersion": { + "type": "string" + }, + "goVersion": { + "type": "string" + }, + "major": { + "type": "string" + }, + "minor": { + "type": "string" + }, + "platform": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "BearerToken": { + "description": "Bearer Token authentication", + "type": "apiKey", + "name": "authorization", + "in": "header" + } + }, + "security": [ + { + "BearerToken": [] + } + ] +} diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/testing/openapi.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/testing/openapi.go new file mode 100644 index 000000000..bc280a198 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/testing/openapi.go @@ -0,0 +1,68 @@ +/* +Copyright 2017 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 testing + +import ( + "io/ioutil" + "os" + "sync" + + yaml "gopkg.in/yaml.v2" + + "github.com/googleapis/gnostic/OpenAPIv2" + "github.com/googleapis/gnostic/compiler" +) + +// Fake opens and returns a openapi swagger from a file Path. It will +// parse only once and then return the same copy everytime. +type Fake struct { + Path string + + once sync.Once + document *openapi_v2.Document + err error +} + +// OpenAPISchema returns the openapi document and a potential error. +func (f *Fake) OpenAPISchema() (*openapi_v2.Document, error) { + f.once.Do(func() { + _, err := os.Stat(f.Path) + if err != nil { + f.err = err + return + } + spec, err := ioutil.ReadFile(f.Path) + if err != nil { + f.err = err + return + } + var info yaml.MapSlice + err = yaml.Unmarshal(spec, &info) + if err != nil { + f.err = err + return + } + f.document, f.err = openapi_v2.NewDocument(info, compiler.NewContext("$root", nil)) + }) + return f.document, f.err +} + +type Empty struct{} + +func (Empty) OpenAPISchema() (*openapi_v2.Document, error) { + return nil, nil +} diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/errors.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/errors.go new file mode 100644 index 000000000..b1aa8c008 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/errors.go @@ -0,0 +1,79 @@ +/* +Copyright 2017 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 validation + +import ( + "fmt" +) + +type errors struct { + errors []error +} + +func (e *errors) Errors() []error { + return e.errors +} + +func (e *errors) AppendErrors(err ...error) { + e.errors = append(e.errors, err...) +} + +type ValidationError struct { + Path string + Err error +} + +func (e ValidationError) Error() string { + return fmt.Sprintf("ValidationError(%s): %v", e.Path, e.Err) +} + +type InvalidTypeError struct { + Path string + Expected string + Actual string +} + +func (e InvalidTypeError) Error() string { + return fmt.Sprintf("invalid type for %s: got %q, expected %q", e.Path, e.Actual, e.Expected) +} + +type MissingRequiredFieldError struct { + Path string + Field string +} + +func (e MissingRequiredFieldError) Error() string { + return fmt.Sprintf("missing required field %q in %s", e.Field, e.Path) +} + +type UnknownFieldError struct { + Path string + Field string +} + +func (e UnknownFieldError) Error() string { + return fmt.Sprintf("unknown field %q in %s", e.Field, e.Path) +} + +type InvalidObjectTypeError struct { + Path string + Type string +} + +func (e InvalidObjectTypeError) Error() string { + return fmt.Sprintf("unknown object type %q in %s", e.Type, e.Path) +} diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/types.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/types.go new file mode 100644 index 000000000..bbbdd4f61 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/types.go @@ -0,0 +1,298 @@ +/* +Copyright 2017 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 validation + +import ( + "reflect" + "sort" + + "k8s.io/kube-openapi/pkg/util/proto" +) + +type validationItem interface { + proto.SchemaVisitor + + Errors() []error + Path() *proto.Path +} + +type baseItem struct { + errors errors + path proto.Path +} + +// Errors returns the list of errors found for this item. +func (item *baseItem) Errors() []error { + return item.errors.Errors() +} + +// AddValidationError wraps the given error into a ValidationError and +// attaches it to this item. +func (item *baseItem) AddValidationError(err error) { + item.errors.AppendErrors(ValidationError{Path: item.path.String(), Err: err}) +} + +// AddError adds a regular (non-validation related) error to the list. +func (item *baseItem) AddError(err error) { + item.errors.AppendErrors(err) +} + +// CopyErrors adds a list of errors to this item. This is useful to copy +// errors from subitems. +func (item *baseItem) CopyErrors(errs []error) { + item.errors.AppendErrors(errs...) +} + +// Path returns the path of this item, helps print useful errors. +func (item *baseItem) Path() *proto.Path { + return &item.path +} + +// mapItem represents a map entry in the yaml. +type mapItem struct { + baseItem + + Map map[string]interface{} +} + +func (item *mapItem) sortedKeys() []string { + sortedKeys := []string{} + for key := range item.Map { + sortedKeys = append(sortedKeys, key) + } + sort.Strings(sortedKeys) + return sortedKeys +} + +var _ validationItem = &mapItem{} + +func (item *mapItem) VisitPrimitive(schema *proto.Primitive) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: schema.Type, Actual: "map"}) +} + +func (item *mapItem) VisitArray(schema *proto.Array) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: "array", Actual: "map"}) +} + +func (item *mapItem) VisitMap(schema *proto.Map) { + for _, key := range item.sortedKeys() { + subItem, err := itemFactory(item.Path().FieldPath(key), item.Map[key]) + if err != nil { + item.AddError(err) + continue + } + schema.SubType.Accept(subItem) + item.CopyErrors(subItem.Errors()) + } +} + +func (item *mapItem) VisitKind(schema *proto.Kind) { + // Verify each sub-field. + for _, key := range item.sortedKeys() { + if item.Map[key] == nil { + continue + } + subItem, err := itemFactory(item.Path().FieldPath(key), item.Map[key]) + if err != nil { + item.AddError(err) + continue + } + if _, ok := schema.Fields[key]; !ok { + item.AddValidationError(UnknownFieldError{Path: schema.GetPath().String(), Field: key}) + continue + } + schema.Fields[key].Accept(subItem) + item.CopyErrors(subItem.Errors()) + } + + // Verify that all required fields are present. + for _, required := range schema.RequiredFields { + if v, ok := item.Map[required]; !ok || v == nil { + item.AddValidationError(MissingRequiredFieldError{Path: schema.GetPath().String(), Field: required}) + } + } +} + +func (item *mapItem) VisitArbitrary(schema *proto.Arbitrary) { +} + +func (item *mapItem) VisitReference(schema proto.Reference) { + // passthrough + schema.SubSchema().Accept(item) +} + +// arrayItem represents a yaml array. +type arrayItem struct { + baseItem + + Array []interface{} +} + +var _ validationItem = &arrayItem{} + +func (item *arrayItem) VisitPrimitive(schema *proto.Primitive) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: schema.Type, Actual: "array"}) +} + +func (item *arrayItem) VisitArray(schema *proto.Array) { + for i, v := range item.Array { + path := item.Path().ArrayPath(i) + if v == nil { + item.AddValidationError(InvalidObjectTypeError{Type: "nil", Path: path.String()}) + continue + } + subItem, err := itemFactory(path, v) + if err != nil { + item.AddError(err) + continue + } + schema.SubType.Accept(subItem) + item.CopyErrors(subItem.Errors()) + } +} + +func (item *arrayItem) VisitMap(schema *proto.Map) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: "map", Actual: "array"}) +} + +func (item *arrayItem) VisitKind(schema *proto.Kind) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: "map", Actual: "array"}) +} + +func (item *arrayItem) VisitArbitrary(schema *proto.Arbitrary) { +} + +func (item *arrayItem) VisitReference(schema proto.Reference) { + // passthrough + schema.SubSchema().Accept(item) +} + +// primitiveItem represents a yaml value. +type primitiveItem struct { + baseItem + + Value interface{} + Kind string +} + +var _ validationItem = &primitiveItem{} + +func (item *primitiveItem) VisitPrimitive(schema *proto.Primitive) { + // Some types of primitives can match more than one (a number + // can be a string, but not the other way around). Return from + // the switch if we have a valid possible type conversion + // NOTE(apelisse): This logic is blindly copied from the + // existing swagger logic, and I'm not sure I agree with it. + switch schema.Type { + case proto.Boolean: + switch item.Kind { + case proto.Boolean: + return + } + case proto.Integer: + switch item.Kind { + case proto.Integer, proto.Number: + return + } + case proto.Number: + switch item.Kind { + case proto.Number: + return + } + case proto.String: + return + } + + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: schema.Type, Actual: item.Kind}) +} + +func (item *primitiveItem) VisitArray(schema *proto.Array) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: "array", Actual: item.Kind}) +} + +func (item *primitiveItem) VisitMap(schema *proto.Map) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: "map", Actual: item.Kind}) +} + +func (item *primitiveItem) VisitKind(schema *proto.Kind) { + item.AddValidationError(InvalidTypeError{Path: schema.GetPath().String(), Expected: "map", Actual: item.Kind}) +} + +func (item *primitiveItem) VisitArbitrary(schema *proto.Arbitrary) { +} + +func (item *primitiveItem) VisitReference(schema proto.Reference) { + // passthrough + schema.SubSchema().Accept(item) +} + +// itemFactory creates the relevant item type/visitor based on the current yaml type. +func itemFactory(path proto.Path, v interface{}) (validationItem, error) { + // We need to special case for no-type fields in yaml (e.g. empty item in list) + if v == nil { + return nil, InvalidObjectTypeError{Type: "nil", Path: path.String()} + } + kind := reflect.TypeOf(v).Kind() + switch kind { + case reflect.Bool: + return &primitiveItem{ + baseItem: baseItem{path: path}, + Value: v, + Kind: proto.Boolean, + }, nil + case reflect.Int, + reflect.Int8, + reflect.Int16, + reflect.Int32, + reflect.Int64, + reflect.Uint, + reflect.Uint8, + reflect.Uint16, + reflect.Uint32, + reflect.Uint64: + return &primitiveItem{ + baseItem: baseItem{path: path}, + Value: v, + Kind: proto.Integer, + }, nil + case reflect.Float32, + reflect.Float64: + return &primitiveItem{ + baseItem: baseItem{path: path}, + Value: v, + Kind: proto.Number, + }, nil + case reflect.String: + return &primitiveItem{ + baseItem: baseItem{path: path}, + Value: v, + Kind: proto.String, + }, nil + case reflect.Array, + reflect.Slice: + return &arrayItem{ + baseItem: baseItem{path: path}, + Array: v.([]interface{}), + }, nil + case reflect.Map: + return &mapItem{ + baseItem: baseItem{path: path}, + Map: v.(map[string]interface{}), + }, nil + } + return nil, InvalidObjectTypeError{Type: kind.String(), Path: path.String()} +} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/roundtrip_test.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation.go similarity index 65% rename from vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/roundtrip_test.go rename to vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation.go index 353e81287..35310f637 100644 --- a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/roundtrip_test.go +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation.go @@ -14,15 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. */ -package install +package validation import ( - "testing" - - apiextensionsfuzzer "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer" - "k8s.io/apimachinery/pkg/api/testing/roundtrip" + "k8s.io/kube-openapi/pkg/util/proto" ) -func TestRoundTrip(t *testing.T) { - roundtrip.RoundTripTestForAPIGroup(t, Install, apiextensionsfuzzer.Funcs) +func ValidateModel(obj interface{}, schema proto.Schema, name string) []error { + rootValidation, err := itemFactory(proto.NewPath(name), obj) + if err != nil { + return []error{err} + } + schema.Accept(rootValidation) + return rootValidation.Errors() } diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation_suite_test.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation_suite_test.go new file mode 100644 index 000000000..30e4381f9 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation_suite_test.go @@ -0,0 +1,49 @@ +/* +Copyright 2017 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 validation + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/config" + . "github.com/onsi/ginkgo/types" + . "github.com/onsi/gomega" + + "fmt" + "testing" +) + +func TestOpenapi(t *testing.T) { + RegisterFailHandler(Fail) + 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") } diff --git a/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation_test.go b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation_test.go new file mode 100644 index 000000000..dee2eb701 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/proto/validation/validation_test.go @@ -0,0 +1,369 @@ +/* +Copyright 2017 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 validation_test + +import ( + "fmt" + "path/filepath" + + "github.com/ghodss/yaml" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "k8s.io/kube-openapi/pkg/util/proto" + "k8s.io/kube-openapi/pkg/util/proto/testing" + "k8s.io/kube-openapi/pkg/util/proto/validation" +) + +var fakeSchema = testing.Fake{Path: filepath.Join("..", "testdata", "swagger.json")} + +func Validate(models proto.Models, model string, data string) []error { + var obj interface{} + if err := yaml.Unmarshal([]byte(data), &obj); err != nil { + return []error{fmt.Errorf("pre-validation: failed to parse yaml: %v", err)} + } + schema := models.LookupModel(model) + if schema == nil { + return []error{fmt.Errorf("pre-validation: couldn't find model %s", model)} + } + + return validation.ValidateModel(obj, schema, model) +} + +var _ = Describe("resource validation using OpenAPI Schema", func() { + var models proto.Models + BeforeEach(func() { + s, err := fakeSchema.OpenAPISchema() + Expect(err).To(BeNil()) + models, err = proto.NewOpenAPIData(s) + Expect(err).To(BeNil()) + }) + + It("finds Deployment in Schema and validates it", func() { + err := Validate(models, "io.k8s.api.apps.v1beta1.Deployment", ` +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + labels: + name: redis-master + name: name +spec: + replicas: 1 + template: + metadata: + labels: + app: redis + spec: + containers: + - image: redis + name: redis +`) + Expect(err).To(BeNil()) + }) + + It("validates a valid pod", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +apiVersion: v1 +kind: Pod +metadata: + labels: + name: redis-master + name: name +spec: + containers: + - args: + - this + - is + - an + - ok + - command + image: gcr.io/fake_project/fake_image:fake_tag + name: master +`) + Expect(err).To(BeNil()) + }) + + It("finds invalid command (string instead of []string) in Json Pod", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +{ + "kind": "Pod", + "apiVersion": "v1", + "metadata": { + "name": "name", + "labels": { + "name": "redis-master" + } + }, + "spec": { + "containers": [ + { + "name": "master", + "image": "gcr.io/fake_project/fake_image:fake_tag", + "args": "this is a bad command" + } + ] + } +} +`) + Expect(err).To(Equal([]error{ + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0].args", + Err: validation.InvalidTypeError{ + Path: "io.k8s.api.core.v1.Container.args", + Expected: "array", + Actual: "string", + }, + }, + })) + }) + + It("fails because hostPort is string instead of int", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +{ + "kind": "Pod", + "apiVersion": "v1", + "metadata": { + "name": "apache-php", + "labels": { + "name": "apache-php" + } + }, + "spec": { + "volumes": [{ + "name": "shared-disk" + }], + "containers": [ + { + "name": "apache-php", + "image": "gcr.io/fake_project/fake_image:fake_tag", + "ports": [ + { + "name": "apache", + "hostPort": "13380", + "containerPort": 80, + "protocol": "TCP" + } + ], + "volumeMounts": [ + { + "name": "shared-disk", + "mountPath": "/var/www/html" + } + ] + } + ] + } +} +`) + + Expect(err).To(Equal([]error{ + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0].ports[0].hostPort", + Err: validation.InvalidTypeError{ + Path: "io.k8s.api.core.v1.ContainerPort.hostPort", + Expected: "integer", + Actual: "string", + }, + }, + })) + + }) + + It("fails because volume is not an array of object", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +{ + "kind": "Pod", + "apiVersion": "v1", + "metadata": { + "name": "apache-php", + "labels": { + "name": "apache-php" + } + }, + "spec": { + "volumes": [ + "name": "shared-disk" + ], + "containers": [ + { + "name": "apache-php", + "image": "gcr.io/fake_project/fake_image:fake_tag", + "ports": [ + { + "name": "apache", + "hostPort": 13380, + "containerPort": 80, + "protocol": "TCP" + } + ], + "volumeMounts": [ + { + "name": "shared-disk", + "mountPath": "/var/www/html" + } + ] + } + ] + } +} +`) + Expect(err).To(BeNil()) + }) + + It("fails because some string lists have empty strings", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +apiVersion: v1 +kind: Pod +metadata: + labels: + name: redis-master + name: name +spec: + containers: + - image: gcr.io/fake_project/fake_image:fake_tag + name: master + args: + - + command: + - +`) + + Expect(err).To(Equal([]error{ + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0].args", + Err: validation.InvalidObjectTypeError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0].args[0]", + Type: "nil", + }, + }, + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0].command", + Err: validation.InvalidObjectTypeError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0].command[0]", + Type: "nil", + }, + }, + })) + }) + + It("fails if required fields are missing", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +apiVersion: v1 +kind: Pod +metadata: + labels: + name: redis-master + name: name +spec: + containers: + - command: ["my", "command"] +`) + + Expect(err).To(Equal([]error{ + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0]", + Err: validation.MissingRequiredFieldError{ + Path: "io.k8s.api.core.v1.Container", + Field: "name", + }, + }, + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0]", + Err: validation.MissingRequiredFieldError{ + Path: "io.k8s.api.core.v1.Container", + Field: "image", + }, + }, + })) + }) + + It("fails if required fields are empty", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +apiVersion: v1 +kind: Pod +metadata: + labels: + name: redis-master + name: name +spec: + containers: + - image: + name: +`) + + Expect(err).To(Equal([]error{ + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0]", + Err: validation.MissingRequiredFieldError{ + Path: "io.k8s.api.core.v1.Container", + Field: "name", + }, + }, + validation.ValidationError{ + Path: "io.k8s.api.core.v1.Pod.spec.containers[0]", + Err: validation.MissingRequiredFieldError{ + Path: "io.k8s.api.core.v1.Container", + Field: "image", + }, + }, + })) + }) + + It("is fine with empty non-mandatory fields", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +apiVersion: v1 +kind: Pod +metadata: + labels: + name: redis-master + name: name +spec: + containers: + - image: image + name: name + command: +`) + + Expect(err).To(BeNil()) + }) + + It("fails because apiVersion is not provided", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +kind: Pod +metadata: + name: name +spec: + containers: + - name: name + image: image +`) + Expect(err).To(BeNil()) + }) + + It("fails because apiVersion type is not string and kind is not provided", func() { + err := Validate(models, "io.k8s.api.core.v1.Pod", ` +apiVersion: 1 +metadata: + name: name +spec: + containers: + - name: name + image: image +`) + Expect(err).To(BeNil()) + }) +}) diff --git a/vendor/k8s.io/kube-openapi/pkg/util/trie.go b/vendor/k8s.io/kube-openapi/pkg/util/trie.go new file mode 100644 index 000000000..a9a76c179 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/trie.go @@ -0,0 +1,79 @@ +/* +Copyright 2016 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 util + +// A simple trie implementation with Add and HasPrefix methods only. +type Trie struct { + children map[byte]*Trie + wordTail bool + word string +} + +// NewTrie creates a Trie and add all strings in the provided list to it. +func NewTrie(list []string) Trie { + ret := Trie{ + children: make(map[byte]*Trie), + wordTail: false, + } + for _, v := range list { + ret.Add(v) + } + return ret +} + +// Add adds a word to this trie +func (t *Trie) Add(v string) { + root := t + for _, b := range []byte(v) { + child, exists := root.children[b] + if !exists { + child = &Trie{ + children: make(map[byte]*Trie), + wordTail: false, + } + root.children[b] = child + } + root = child + } + root.wordTail = true + root.word = v +} + +// HasPrefix returns true of v has any of the prefixes stored in this trie. +func (t *Trie) HasPrefix(v string) bool { + _, has := t.GetPrefix(v) + return has +} + +// GetPrefix is like HasPrefix but return the prefix in case of match or empty string otherwise. +func (t *Trie) GetPrefix(v string) (string, bool) { + root := t + if root.wordTail { + return root.word, true + } + for _, b := range []byte(v) { + child, exists := root.children[b] + if !exists { + return "", false + } + if child.wordTail { + return child.word, true + } + root = child + } + return "", false +} diff --git a/vendor/k8s.io/kube-openapi/pkg/util/util.go b/vendor/k8s.io/kube-openapi/pkg/util/util.go new file mode 100644 index 000000000..bcc0c4d4b --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/util.go @@ -0,0 +1,39 @@ +/* +Copyright 2017 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 util + +import "strings" + +// ToCanonicalName converts Golang package/type name into canonical OpenAPI name. +// Examples: +// Input: k8s.io/api/core/v1.Pod +// Output: io.k8s.api.core.v1.Pod +// +// Input: k8s.io/api/core/v1 +// Output: io.k8s.api.core.v1 +func ToCanonicalName(name string) string { + nameParts := strings.Split(name, "/") + // Reverse first part. e.g., io.k8s... instead of k8s.io... + if len(nameParts) > 0 && strings.Contains(nameParts[0], ".") { + parts := strings.Split(nameParts[0], ".") + for i, j := 0, len(parts)-1; i < j; i, j = i+1, j-1 { + parts[i], parts[j] = parts[j], parts[i] + } + nameParts[0] = strings.Join(parts, ".") + } + return strings.Join(nameParts, ".") +} diff --git a/vendor/k8s.io/kube-openapi/pkg/util/util_test.go b/vendor/k8s.io/kube-openapi/pkg/util/util_test.go new file mode 100644 index 000000000..f3a1b91a4 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/pkg/util/util_test.go @@ -0,0 +1,37 @@ +/* +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 util + +import "testing" + +func TestCanonicalName(t *testing.T) { + + var tests = []struct { + input string + expected string + }{ + {"k8s.io/api/core/v1.Pod", "io.k8s.api.core.v1.Pod"}, + {"k8s.io/api/networking/v1/NetworkPolicy", "io.k8s.api.networking.v1.NetworkPolicy"}, + {"k8s.io/api/apps/v1beta2.Scale", "io.k8s.api.apps.v1beta2.Scale"}, + {"servicecatalog.k8s.io/foo/bar/v1alpha1.Baz", "io.k8s.servicecatalog.foo.bar.v1alpha1.Baz"}, + } + for _, test := range tests { + if got := ToCanonicalName(test.input); got != test.expected { + t.Errorf("ToCanonicalName(%q) = %v", test.input, got) + } + } +} diff --git a/vendor/k8s.io/kube-openapi/test/integration/README.md b/vendor/k8s.io/kube-openapi/test/integration/README.md new file mode 100644 index 000000000..5ddff91a3 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/test/integration/README.md @@ -0,0 +1,28 @@ +# Kube OpenAPI Integration Tests + +## Running the integration tests + +Within the current directory: + +```bash +$ go test -v . +``` + +## Generating the golden Swagger definition file + +First, run the generator to create `openapi_generated.go` file which specifies +the `OpenAPIDefinition` for each type. + +```bash +$ go run ../../cmd/openapi-gen/openapi-gen.go "./testdata/listtype" +``` +The generated file `pkg/generaged/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 golden.json +``` + diff --git a/vendor/k8s.io/kube-openapi/test/integration/builder/main.go b/vendor/k8s.io/kube-openapi/test/integration/builder/main.go new file mode 100644 index 000000000..7008c574c --- /dev/null +++ b/vendor/k8s.io/kube-openapi/test/integration/builder/main.go @@ -0,0 +1,85 @@ +/* +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" + "fmt" + "io/ioutil" + "log" + "os" + + "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 + swagger, serr := builder.BuildOpenAPIDefinitionsForResources(config, defNames...) + if serr != nil { + log.Fatalf("ERROR: %s", serr.Error()) + } + + // Marshal the swagger spec into JSON, then write it out. + specBytes, err := json.MarshalIndent(swagger, " ", " ") + if err != nil { + panic(fmt.Sprintf("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", + }, + }, + } +} diff --git a/vendor/k8s.io/kube-openapi/test/integration/integration_suite_test.go b/vendor/k8s.io/kube-openapi/test/integration/integration_suite_test.go new file mode 100644 index 000000000..4496de142 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/test/integration/integration_suite_test.go @@ -0,0 +1,93 @@ +/* +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" + generatedSwaggerFile = "generated.json" + goldenSwaggerFile = "golden.json" + timeoutSeconds = 5.0 +) + +func TestGenerators(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Integration Test Suite") +} + +var _ = Describe("Open API Definitions Generation", func() { + + var ( + tempDir string + terr error + generatedSwaggerDef string + ) + + BeforeSuite(func() { + // Create a temporary directory for generated swagger files. + tempDir, terr = ioutil.TempDir("", "openapi") + Expect(terr).ShouldNot(HaveOccurred()) + // Build the OpenAPI code generator. + binary_path, berr := gexec.Build("../../cmd/openapi-gen/openapi-gen.go") + Expect(berr).ShouldNot(HaveOccurred()) + // Run the OpenAPI code generator, creating OpenAPIDefinition code + // to be compiled into builder. + command := exec.Command(binary_path, inputDir) + session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) + Expect(err).ShouldNot(HaveOccurred()) + Eventually(session, timeoutSeconds).Should(gexec.Exit(0)) + + // 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. + generatedSwaggerDef = filepath.Join(tempDir, generatedSwaggerFile) + command = exec.Command(binary_path, generatedSwaggerDef) + command.Dir = testdataDir + 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("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", goldenSwaggerFile, generatedSwaggerDef) + command.Dir = testdataDir + session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) + Expect(err).ShouldNot(HaveOccurred()) + Eventually(session, timeoutSeconds).Should(gexec.Exit(0)) + }) + }) +}) diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/generated_expansion.go b/vendor/k8s.io/kube-openapi/test/integration/pkg/generated/openapi_generated.go similarity index 72% rename from vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/generated_expansion.go rename to vendor/k8s.io/kube-openapi/test/integration/pkg/generated/openapi_generated.go index 755021ec4..43705ccec 100644 --- a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/generated_expansion.go +++ b/vendor/k8s.io/kube-openapi/test/integration/pkg/generated/openapi_generated.go @@ -14,8 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by client-gen. DO NOT EDIT. +package generated -package v1 +import ( + common "k8s.io/kube-openapi/pkg/common" +) -type ExampleExpansion interface{} +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{} +} diff --git a/vendor/k8s.io/kube-openapi/test/integration/testdata/golden.json b/vendor/k8s.io/kube-openapi/test/integration/testdata/golden.json new file mode 100644 index 000000000..0eb907804 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/test/integration/testdata/golden.json @@ -0,0 +1,68 @@ +{ + "swagger": "2.0", + "info": { + "title": "Integration Test", + "version": "1.0" + }, + "paths": {}, + "definitions": { + "listtype.AtomicList": { + "required": [ + "Field" + ], + "properties": { + "Field": { + "type": "array", + "items": { + "type": "string" + }, + "x-kubernetes-list-type": "atomic" + } + } + }, + "listtype.Item": { + "required": [ + "Port", + "Protocol" + ], + "properties": { + "Port": { + "type": "integer", + "format": "int32" + }, + "Protocol": { + "type": "string" + } + } + }, + "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" + } + } + } + } + } \ No newline at end of file diff --git a/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/atomic-list.go b/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/atomic-list.go new file mode 100644 index 000000000..9029ece01 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/atomic-list.go @@ -0,0 +1,7 @@ +package listtype + +// +k8s:openapi-gen=true +type AtomicList struct { + // +listType=atomic + Field []string +} diff --git a/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/map-list.go b/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/map-list.go new file mode 100644 index 000000000..bb1f693d1 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/map-list.go @@ -0,0 +1,14 @@ +package listtype + +// +k8s:openapi-gen=true +type Item struct { + Port int + Protocol string +} + +// +k8s:openapi-gen=true +type MapList struct { + // +listType=map + // +listMapKey=port + Field []Item +} diff --git a/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/set-list.go b/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/set-list.go new file mode 100644 index 000000000..bf7b27c53 --- /dev/null +++ b/vendor/k8s.io/kube-openapi/test/integration/testdata/listtype/set-list.go @@ -0,0 +1,7 @@ +package listtype + +// +k8s:openapi-gen=true +type SetList struct { + // +listType=set + Field []string +}