From d02ed1d7411433ea4a0dcf189689ea0b36434457 Mon Sep 17 00:00:00 2001 From: Michael Henriksen Date: Wed, 9 Jan 2019 10:58:46 -0500 Subject: [PATCH 1/2] generate cdi-controller.yaml from resources defined in code --- glide.lock | 11 +- glide.yaml | 2 + hack/build/build-manifests.sh | 30 +- manifests/templates/cdi-controller.yaml.in | 451 -- pkg/operator/resources/cluster/apiserver.go | 87 + pkg/operator/resources/cluster/controller.go | 152 + pkg/operator/resources/cluster/datavolume.go | 160 + pkg/operator/resources/cluster/factory.go | 61 + pkg/operator/resources/cluster/rbac.go | 64 + .../resources/namespaced/apiserver.go | 127 + pkg/operator/resources/namespaced/common.go | 153 + .../resources/namespaced/controller.go | 108 + pkg/operator/resources/namespaced/factory.go | 66 + .../resources/namespaced/uploadproxy.go | 124 + .../manifest-generator/manifest-generator.go | 143 +- tools/manifest-generator/marshaller.go | 78 + vendor/github.com/pkg/errors/format_test.go | 25 + vendor/github.com/pkg/errors/stack.go | 137 +- vendor/github.com/pkg/errors/stack_test.go | 18 +- .../.github/PULL_REQUEST_TEMPLATE.md | 2 + .../apiextensions-apiserver/CONTRIBUTING.md | 7 + .../Godeps/Godeps.json | 2186 ++++++ .../apiextensions-apiserver/Godeps/OWNERS | 2 + .../apiextensions-apiserver/Godeps/Readme | 5 + vendor/k8s.io/apiextensions-apiserver/LICENSE | 202 + vendor/k8s.io/apiextensions-apiserver/OWNERS | 11 + .../k8s.io/apiextensions-apiserver/README.md | 20 + .../apiextensions-apiserver/SECURITY_CONTACTS | 17 + .../customresource-01/noxu-apiservice.yaml | 12 + .../noxu-resource-definition.yaml | 13 + .../artifacts/customresource-01/noxu.yaml | 6 + .../artifacts/example/apiservice.yaml | 12 + .../artifacts/example/auth-delegator.yaml | 12 + .../artifacts/example/auth-reader.yaml | 13 + .../artifacts/example/rc.yaml | 26 + .../artifacts/example/sa.yaml | 5 + .../artifacts/example/service.yaml | 12 + .../artifacts/simple-image/Dockerfile | 17 + .../code-of-conduct.md | 3 + .../examples/client-go/README.md | 57 + .../examples/client-go/hack/update-codegen.sh | 34 + .../examples/client-go/hack/verify-codegen.sh | 48 + .../client-go/pkg/apis/cr/register.go | 21 + .../examples/client-go/pkg/apis/cr/v1/doc.go | 21 + .../client-go/pkg/apis/cr/v1/register.go | 53 + .../client-go/pkg/apis/cr/v1/types.go | 63 + .../pkg/apis/cr/v1/zz_generated.deepcopy.go | 118 + .../client/clientset/versioned/clientset.go | 98 + .../pkg/client/clientset/versioned/doc.go | 20 + .../versioned/fake/clientset_generated.go | 82 + .../client/clientset/versioned/fake/doc.go | 20 + .../clientset/versioned/fake/register.go | 56 + .../client/clientset/versioned/scheme/doc.go | 20 + .../clientset/versioned/scheme/register.go | 56 + .../versioned/typed/cr/v1/cr_client.go | 90 + .../clientset/versioned/typed/cr/v1/doc.go | 20 + .../versioned/typed/cr/v1/example.go | 157 + .../versioned/typed/cr/v1/fake/doc.go | 20 + .../typed/cr/v1/fake/fake_cr_client.go | 40 + .../typed/cr/v1/fake/fake_example.go | 128 + .../typed/cr/v1/generated_expansion.go | 21 + .../externalversions/cr/interface.go | 46 + .../externalversions/cr/v1/example.go | 89 + .../externalversions/cr/v1/interface.go | 45 + .../informers/externalversions/factory.go | 180 + .../informers/externalversions/generic.go | 62 + .../internalinterfaces/factory_interfaces.go | 38 + .../pkg/client/listers/cr/v1/example.go | 94 + .../listers/cr/v1/expansion_generated.go | 27 + .../hack/boilerplate.go.txt | 16 + .../hack/build-image.sh | 30 + .../hack/update-codegen.sh | 34 + .../hack/verify-codegen.sh | 49 + vendor/k8s.io/apiextensions-apiserver/main.go | 40 + .../pkg/apis/apiextensions/deepcopy.go | 262 + .../pkg/apis/apiextensions/doc.go | 21 + .../pkg/apis/apiextensions/fuzzer/fuzzer.go | 142 + .../pkg/apis/apiextensions/helpers.go | 149 + .../pkg/apis/apiextensions/helpers_test.go | 421 ++ .../pkg/apis/apiextensions/install/install.go | 31 + .../apiextensions/install/roundtrip_test.go | 28 + .../pkg/apis/apiextensions/register.go | 51 + .../pkg/apis/apiextensions/types.go | 250 + .../apis/apiextensions/types_jsonschema.go | 96 + .../apis/apiextensions/v1beta1/conversion.go | 73 + .../apiextensions/v1beta1/conversion_test.go | 113 + .../apis/apiextensions/v1beta1/deepcopy.go | 238 + .../apis/apiextensions/v1beta1/defaults.go | 74 + .../pkg/apis/apiextensions/v1beta1/doc.go | 24 + .../apiextensions/v1beta1/generated.pb.go | 6022 +++++++++++++++++ .../apiextensions/v1beta1/generated.proto | 365 + .../pkg/apis/apiextensions/v1beta1/marshal.go | 135 + .../apiextensions/v1beta1/marshal_test.go | 150 + .../apis/apiextensions/v1beta1/register.go | 61 + .../pkg/apis/apiextensions/v1beta1/types.go | 265 + .../apiextensions/v1beta1/types_jsonschema.go | 150 + .../v1beta1/zz_generated.conversion.go | 1125 +++ .../v1beta1/zz_generated.deepcopy.go | 470 ++ .../v1beta1/zz_generated.defaults.go | 48 + .../apiextensions/validation/validation.go | 546 ++ .../validation/validation_test.go | 926 +++ .../apiextensions/zz_generated.deepcopy.go | 449 ++ .../pkg/apiserver/apiserver.go | 214 + .../pkg/apiserver/conversion/converter.go | 117 + .../pkg/apiserver/conversion/nop_converter.go | 79 + .../pkg/apiserver/customresource_discovery.go | 127 + .../customresource_discovery_controller.go | 275 + .../pkg/apiserver/customresource_handler.go | 895 +++ .../apiserver/customresource_handler_test.go | 309 + .../pkg/apiserver/jsonpath_test.go | 235 + .../pkg/apiserver/validation/validation.go | 249 + .../apiserver/validation/validation_test.go | 87 + .../client/clientset/clientset/clientset.go | 98 + .../pkg/client/clientset/clientset/doc.go | 20 + .../clientset/fake/clientset_generated.go | 82 + .../client/clientset/clientset/fake/doc.go | 20 + .../clientset/clientset/fake/register.go | 56 + .../client/clientset/clientset/scheme/doc.go | 20 + .../clientset/clientset/scheme/register.go | 56 + .../v1beta1/apiextensions_client.go | 90 + .../v1beta1/customresourcedefinition.go | 163 + .../typed/apiextensions/v1beta1/doc.go | 20 + .../typed/apiextensions/v1beta1/fake/doc.go | 20 + .../v1beta1/fake/fake_apiextensions_client.go | 40 + .../fake/fake_customresourcedefinition.go | 131 + .../v1beta1/generated_expansion.go | 21 + .../clientset/internalclientset/clientset.go | 90 + .../client/clientset/internalclientset/doc.go | 20 + .../fake/clientset_generated.go | 77 + .../clientset/internalclientset/fake/doc.go | 20 + .../internalclientset/fake/register.go | 56 + .../clientset/internalclientset/scheme/doc.go | 20 + .../internalclientset/scheme/register.go | 41 + .../internalversion/apiextensions_client.go | 96 + .../customresourcedefinition.go | 163 + .../apiextensions/internalversion/doc.go | 20 + .../apiextensions/internalversion/fake/doc.go | 20 + .../fake/fake_apiextensions_client.go | 40 + .../fake/fake_customresourcedefinition.go | 131 + .../internalversion/generated_expansion.go | 21 + .../apiextensions/interface.go | 46 + .../v1beta1/customresourcedefinition.go | 88 + .../apiextensions/v1beta1/interface.go | 45 + .../informers/externalversions/factory.go | 180 + .../informers/externalversions/generic.go | 62 + .../internalinterfaces/factory_interfaces.go | 38 + .../apiextensions/interface.go | 46 + .../customresourcedefinition.go | 88 + .../internalversion/interface.go | 45 + .../informers/internalversion/factory.go | 180 + .../informers/internalversion/generic.go | 62 + .../internalinterfaces/factory_interfaces.go | 38 + .../customresourcedefinition.go | 65 + .../internalversion/expansion_generated.go | 23 + .../v1beta1/customresourcedefinition.go | 65 + .../v1beta1/expansion_generated.go | 23 + .../pkg/cmd/server/options/options.go | 116 + .../pkg/cmd/server/server.go | 64 + .../localhost_127.0.0.1_localhost.crt | 37 + .../localhost_127.0.0.1_localhost.key | 27 + .../pkg/cmd/server/testing/testserver.go | 211 + .../establish/establishing_controller.go | 143 + .../pkg/controller/finalizer/crd_finalizer.go | 327 + .../controller/status/naming_controller.go | 374 + .../status/naming_controller_test.go | 344 + .../pkg/crdserverscheme/unstructured.go | 67 + .../pkg/features/OWNERS | 2 + .../pkg/features/kube_features.go | 55 + .../pkg/registry/customresource/etcd.go | 325 + .../pkg/registry/customresource/etcd_test.go | 575 ++ .../customresource/status_strategy.go | 59 + .../customresource/status_strategy_test.go | 138 + .../pkg/registry/customresource/strategy.go | 185 + .../tableconvertor/tableconvertor.go | 172 + .../tableconvertor/tableconvertor_test.go | 68 + .../pkg/registry/customresource/validator.go | 195 + .../registry/customresourcedefinition/etcd.go | 181 + .../customresourcedefinition/strategy.go | 202 + .../certificates/apiserver.crt | 19 + .../certificates/apiserver.key | 27 + .../test/integration/basic_test.go | 982 +++ .../test/integration/finalization_test.go | 165 + .../test/integration/fixtures/resources.go | 403 ++ .../test/integration/fixtures/server.go | 108 + .../test/integration/helpers.go | 94 + .../test/integration/objectmeta_test.go | 164 + .../test/integration/registration_test.go | 456 ++ .../test/integration/subresources_test.go | 770 +++ .../test/integration/table_test.go | 218 + .../test/integration/validation_test.go | 431 ++ .../test/integration/versioning_test.go | 138 + .../test/integration/yaml_test.go | 541 ++ 192 files changed, 32422 insertions(+), 552 deletions(-) delete mode 100644 manifests/templates/cdi-controller.yaml.in create mode 100644 pkg/operator/resources/cluster/apiserver.go create mode 100644 pkg/operator/resources/cluster/controller.go create mode 100644 pkg/operator/resources/cluster/datavolume.go create mode 100644 pkg/operator/resources/cluster/factory.go create mode 100644 pkg/operator/resources/cluster/rbac.go create mode 100644 pkg/operator/resources/namespaced/apiserver.go create mode 100644 pkg/operator/resources/namespaced/common.go create mode 100644 pkg/operator/resources/namespaced/controller.go create mode 100644 pkg/operator/resources/namespaced/factory.go create mode 100644 pkg/operator/resources/namespaced/uploadproxy.go create mode 100644 tools/manifest-generator/marshaller.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 vendor/k8s.io/apiextensions-apiserver/CONTRIBUTING.md create mode 100644 vendor/k8s.io/apiextensions-apiserver/Godeps/Godeps.json create mode 100644 vendor/k8s.io/apiextensions-apiserver/Godeps/OWNERS create mode 100644 vendor/k8s.io/apiextensions-apiserver/Godeps/Readme create mode 100644 vendor/k8s.io/apiextensions-apiserver/LICENSE create mode 100644 vendor/k8s.io/apiextensions-apiserver/OWNERS create mode 100644 vendor/k8s.io/apiextensions-apiserver/README.md create mode 100644 vendor/k8s.io/apiextensions-apiserver/SECURITY_CONTACTS create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-apiservice.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-resource-definition.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/example/apiservice.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-delegator.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-reader.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/example/rc.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/example/sa.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/example/service.yaml create mode 100644 vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile create mode 100644 vendor/k8s.io/apiextensions-apiserver/code-of-conduct.md create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/README.md create mode 100755 vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh create mode 100755 vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/verify-codegen.sh create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/types.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/clientset.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/clientset_generated.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/cr_client.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/generated_expansion.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/interface.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/example.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/interface.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/factory.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/generic.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/example.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/expansion_generated.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt create mode 100755 vendor/k8s.io/apiextensions-apiserver/hack/build-image.sh create mode 100755 vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh create mode 100755 vendor/k8s.io/apiextensions-apiserver/hack/verify-codegen.sh create mode 100644 vendor/k8s.io/apiextensions-apiserver/main.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/deepcopy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/roundtrip_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types_jsonschema.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/deepcopy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/defaults.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.pb.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types_jsonschema.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.conversion.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.defaults.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/converter.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/nop_converter.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery_controller.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/jsonpath_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/clientset.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/clientset_generated.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/apiextensions_client.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/generated_expansion.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/clientset.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/clientset_generated.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/register.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/apiextensions_client.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/doc.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_apiextensions_client.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/generated_expansion.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/interface.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/interface.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/factory.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/generic.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/interface.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/interface.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/factory.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/generic.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/expansion_generated.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/customresourcedefinition.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/expansion_generated.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/server.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.crt create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.key create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testserver.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/controller/establish/establishing_controller.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/crdserverscheme/unstructured.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/features/OWNERS create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/features/kube_features.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.crt create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.key create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/basic_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/fixtures/resources.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/fixtures/server.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/helpers.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/objectmeta_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/registration_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/subresources_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/table_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/validation_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/versioning_test.go create mode 100644 vendor/k8s.io/apiextensions-apiserver/test/integration/yaml_test.go diff --git a/glide.lock b/glide.lock index aecb8f00c3..d27467e2d3 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 79d152fb584cb4e17e24b60927398c6ae580fce5625a80a6e284aeba8cb9e461 -updated: 2019-01-08T21:10:02.533518921Z +hash: e0155c8be846dca64d527ca4805bdf6ea796ea8ccc7c19802f408995a7113cab +updated: 2019-01-09T16:19:14.466534746Z imports: - name: github.com/beorn7/perks version: 3ac7bf7a47d159a033b107610db8a1b6575507a4 @@ -145,7 +145,7 @@ imports: - name: github.com/peterbourgon/diskv version: 5f041e8faa004a95c88a202771f4cc3e991971e6 - name: github.com/pkg/errors - version: c38ea53d8c3f78ac85b9b0f1247abeb6d38f6988 + version: ffb6e22f01932bf7ac35e0bad9be11f01d1c8685 - name: github.com/prometheus/client_golang version: 505eaef017263e299324067d40ca2c48f6a2cf50 subpackages: @@ -307,6 +307,11 @@ imports: - storage/v1 - storage/v1alpha1 - storage/v1beta1 +- name: k8s.io/apiextensions-apiserver + version: 853f76028711219c2fc251fd5184f23fd44a7aa0 + subpackages: + - pkg/apis/apiextensions + - pkg/apis/apiextensions/v1beta1 - name: k8s.io/apimachinery version: 49ce2735e5074ffc3f8190c8406cf51a96302dad subpackages: diff --git a/glide.yaml b/glide.yaml index bbe02a63a3..c17e7cb6fa 100644 --- a/glide.yaml +++ b/glide.yaml @@ -30,3 +30,5 @@ import: version: ^1.0.0 - package: sigs.k8s.io/controller-runtime version: v0.1.9 +- package: k8s.io/apiextensions-apiserver + version: kubernetes-1.12.4 diff --git a/hack/build/build-manifests.sh b/hack/build/build-manifests.sh index b8cf2c0b3f..a778cf7665 100755 --- a/hack/build/build-manifests.sh +++ b/hack/build/build-manifests.sh @@ -18,7 +18,7 @@ script_dir="$(readlink -f $(dirname $0))" source "${script_dir}"/common.sh source "${script_dir}"/config.sh -templates="$(find "${MANIFEST_TEMPLATE_DIR}" -name *.in -type f)" +templates="$(find "${MANIFEST_TEMPLATE_DIR}" -name "*.in" -type f)" generator="${BIN_DIR}/manifest-generator" (cd "${CDI_DIR}/tools/manifest-generator/" && go build -o "${generator}" ./...) @@ -60,5 +60,33 @@ for tmpl in ${templates}; do ) 1>"${MANIFEST_GENERATED_DIR}/${outFile}.j2" done +(${generator} -code-group=everything \ + -docker-repo="${DOCKER_REPO}" \ + -docker-tag="${DOCKER_TAG}" \ + -controller-image="${CONTROLLER_IMAGE_NAME}" \ + -importer-image="${IMPORTER_IMAGE_NAME}" \ + -cloner-image="${CLONER_IMAGE_NAME}" \ + -apiserver-image=${APISERVER_IMAGE_NAME} \ + -uploadproxy-image=${UPLOADPROXY_IMAGE_NAME} \ + -uploadserver-image=${UPLOADSERVER_IMAGE_NAME} \ + -verbosity="${VERBOSITY}" \ + -pull-policy="${PULL_POLICY}" \ + -namespace="${NAMESPACE}" +) 1>"${MANIFEST_GENERATED_DIR}/cdi-controller.yaml" + +(${generator} -code-group=everything \ + -docker-repo="{{ docker_prefix }}" \ + -docker-tag="{{ docker_tag }}" \ + -controller-image="{{ controller_image }}" \ + -importer-image="{{ importer_image }}" \ + -cloner-image="{{ cloner_image }}" \ + -apiserver-image="{{ apiserver_image }}" \ + -uploadproxy-image="{{ uploadproxy_image }}" \ + -uploadserver-image="{{ uploadserver_image }}" \ + -verbosity="{{ verbosity }}" \ + -pull-policy="{{ pull_policy }}" \ + -namespace="{{ cdi_namespace }}" +) 1>"${MANIFEST_GENERATED_DIR}/cdi-controller.yaml.j2" + # Remove empty lines at the end of files which are added by go templating find ${MANIFEST_GENERATED_DIR}/ -type f -exec sed -i {} -e '${/^$/d;}' \; diff --git a/manifests/templates/cdi-controller.yaml.in b/manifests/templates/cdi-controller.yaml.in deleted file mode 100644 index 661ca10597..0000000000 --- a/manifests/templates/cdi-controller.yaml.in +++ /dev/null @@ -1,451 +0,0 @@ -kind: ServiceAccount -apiVersion: v1 -metadata: - name: cdi-sa - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "" ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: cdi - labels: - cdi.kubevirt.io: "" -rules: -- apiGroups: [""] - resources: ["events"] - verbs: ["create", "update", "patch"] -- apiGroups: [""] - resources: ["persistentvolumeclaims"] - verbs: ["get", "list", "watch", "create", "update", "patch"] -- apiGroups: [""] - resources: ["persistentvolumeclaims/finalizers"] - verbs: ["update"] -- apiGroups: [""] - resources: ["pods"] - verbs: ["get", "list", "watch", "create", "delete"] -- apiGroups: [""] - resources: ["pods/finalizers"] - verbs: ["update"] -- apiGroups: [""] - resources: ["services"] - verbs: ["get", "list", "watch", "create", "delete"] -- apiGroups: [""] - resources: ["secrets"] - verbs: ["get", "list", "watch", "create"] -- apiGroups: ["storage.k8s.io"] - resources: ["storageclasses"] - verbs: ["get"] -- apiGroups: [""] - resources: ["configmaps"] - verbs: ["get", "list", "watch", "create", "update"] -- apiGroups: ["cdi.kubevirt.io"] - resources: - - '*' - verbs: - - '*' ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: cdi-sa - labels: - cdi.kubevirt.io: "" -roleRef: - kind: ClusterRole - name: cdi - apiGroup: rbac.authorization.k8s.io -subjects: - - kind: ServiceAccount - name: cdi-sa - namespace: {{ .Namespace }} ---- -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: cdi-deployment - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "" - app: containerized-data-importer -spec: - selector: - matchLabels: - app: containerized-data-importer - replicas: 1 - template: - metadata: - labels: - app: containerized-data-importer - cdi.kubevirt.io: "" - spec: - serviceAccountName: cdi-sa - containers: - - name: cdi-controller - image: {{ .DockerRepo }}/{{ .ControllerImage }}:{{ .DockerTag }} - imagePullPolicy: {{ .PullPolicy }} - args: ["-v={{ .Verbosity }}"] # default verbosity; change to 2 or 3 for more detailed logging - env: - - name: IMPORTER_IMAGE - value: {{ .DockerRepo }}/{{ .ImporterImage }}:{{ .DockerTag }} - - name: CLONER_IMAGE - value: {{ .DockerRepo }}/{{ .ClonerImage }}:{{ .DockerTag }} - - name: UPLOADSERVER_IMAGE - value: {{ .DockerRepo }}/{{ .UploadServerImage }}:{{ .DockerTag }} - - name: PULL_POLICY - value: {{ .PullPolicy }} - - name: UPLOADPROXY_SERVICE - value: cdi-uploadproxy ---- -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - labels: - cdi.kubevirt.io: "" - name: datavolumes.cdi.kubevirt.io -spec: - group: cdi.kubevirt.io - names: - kind: DataVolume - plural: datavolumes - shortNames: - - dv - - dvs - singular: datavolume - scope: Namespaced - validation: - openAPIV3Schema: - properties: - apiVersion: - type: string - kind: - type: string - metadata: {} - spec: - properties: - source: - properties: - http: - properties: - url: - type: string - secretRef: - type: string - required: - - url - s3: - properties: - url: - type: string - secretRef: - type: string - required: - - url - registry: - properties: - url: - type: string - secretRef: - type: string - required: - - url - pvc: - properties: - namespace: - type: string - name: - type: string - required: - - namespace - - name - upload: {} - blank: {} - pvc: - properties: - resources: - properties: - requests: - properties: - storage: - type: string - required: - - storage - required: - - requests - storageClassName: - type: string - accessModes: - type: array - required: - - resources - - version: v1alpha1 ---- -kind: ServiceAccount -apiVersion: v1 -metadata: - name: cdi-apiserver - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "" ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding -metadata: - name: cdi-apiserver - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "" -roleRef: - kind: Role - name: cdi-apiserver - apiGroup: rbac.authorization.k8s.io -subjects: - - kind: ServiceAccount - name: cdi-apiserver - namespace: {{ .Namespace }} ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role -metadata: - name: cdi-apiserver - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "" -rules: - - apiGroups: - - '' - resources: - - secrets - verbs: - - get - - create - - apiGroups: - - '' - resources: - - configmaps - verbs: - - get - - create ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding -metadata: - name: cdi-extension-apiserver-authentication - namespace: kube-system - labels: - cdi.kubevirt.io: "" -roleRef: - kind: Role - name: cdi-extension-apiserver-authentication - apiGroup: rbac.authorization.k8s.io -subjects: - - kind: ServiceAccount - name: cdi-apiserver - namespace: {{ .Namespace }} ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role -metadata: - name: cdi-extension-apiserver-authentication - namespace: kube-system - labels: - cdi.kubevirt.io: "" -rules: - - apiGroups: - - '' - resources: - - configmaps - resourceNames: - - extension-apiserver-authentication - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: cdi-apiserver - labels: - cdi.kubevirt.io: "" -roleRef: - kind: ClusterRole - name: cdi-apiserver - apiGroup: rbac.authorization.k8s.io -subjects: - - kind: ServiceAccount - name: cdi-apiserver - namespace: {{ .Namespace }} ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRole -metadata: - name: cdi-apiserver - labels: - cdi.kubevirt.io: "" -rules: - - apiGroups: - - admissionregistration.k8s.io - resources: - - validatingwebhookconfigurations - verbs: - - get - - create - - update - - apiGroups: - - apiregistration.k8s.io - resources: - - apiservices - verbs: - - get - - create - - update - - apiGroups: - - '' - resources: - - pods - - persistentvolumeclaims - verbs: - - get - - list ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: cdi-apiserver-auth-delegator - labels: - cdi.kubevirt.io: "" -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:auth-delegator -subjects: -- kind: ServiceAccount - name: cdi-apiserver - namespace: {{ .Namespace }} ---- -apiVersion: v1 -kind: Service -metadata: - name: cdi-api - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "cdi-api" -spec: - ports: - - port: 443 - targetPort: 8443 - protocol: TCP - selector: - cdi.kubevirt.io: cdi-api ---- -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: cdi-api - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "cdi-api" -spec: - selector: - matchLabels: - cdi.kubevirt.io: "cdi-api" - replicas: 1 - template: - metadata: - labels: - cdi.kubevirt.io: "cdi-api" - spec: - serviceAccountName: cdi-apiserver - containers: - - name: cdi-apiserver-api - image: {{ .DockerRepo }}/{{ .APIServerImage }}:{{ .DockerTag }} - imagePullPolicy: {{ .PullPolicy }} - args: ["-v={{ .Verbosity }}"] # default verbosity; change to 2 or 3 for more detailed logging ---- -apiVersion: v1 -kind: Service -metadata: - name: cdi-uploadproxy - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "cdi-uploadproxy" -spec: - ports: - - port: 443 - targetPort: 8443 - protocol: TCP - selector: - cdi.kubevirt.io: cdi-uploadproxy ---- -apiVersion: apps/v1beta2 -kind: Deployment -metadata: - name: cdi-uploadproxy - namespace: {{ .Namespace }} - labels: - cdi.kubevirt.io: "cdi-uploadproxy" -spec: - selector: - matchLabels: - cdi.kubevirt.io: "cdi-uploadproxy" - replicas: 1 - template: - metadata: - labels: - cdi.kubevirt.io: "cdi-uploadproxy" - spec: - containers: - - name: cdi-uploadproxy - image: {{ .DockerRepo }}/{{ .UploadProxyImage }}:{{ .DockerTag }} - imagePullPolicy: {{ .PullPolicy }} - args: ["-v={{ .Verbosity }}"] # default verbosity; change to 2 or 3 for more detailed logging - env: - - name: APISERVER_PUBLIC_KEY - valueFrom: - secretKeyRef: - name: cdi-api-signing-key - key: id_rsa.pub - - name: UPLOAD_SERVER_CLIENT_KEY - valueFrom: - secretKeyRef: - name: cdi-upload-server-client-key - key: tls.key - - name: UPLOAD_SERVER_CLIENT_CERT - valueFrom: - secretKeyRef: - name: cdi-upload-server-client-key - key: tls.crt - - name: UPLOAD_SERVER_CA_CERT - valueFrom: - secretKeyRef: - name: cdi-upload-server-client-key - key: ca.crt - - name: SERVICE_TLS_KEY - valueFrom: - secretKeyRef: - name: cdi-upload-proxy-server-key - key: tls.key - - name: SERVICE_TLS_CERT - valueFrom: - secretKeyRef: - name: cdi-upload-proxy-server-key - key: tls.crt ---- -apiVersion: v1 -kind: Service -metadata: - name: kubevirt-prometheus-metrics - namespace: {{.Namespace}} - labels: - prometheus.kubevirt.io: "" - kubevirt.io: "" -spec: - ports: - - name: metrics - port: 443 - targetPort: metrics - protocol: TCP - selector: - prometheus.kubevirt.io: "" - diff --git a/pkg/operator/resources/cluster/apiserver.go b/pkg/operator/resources/cluster/apiserver.go new file mode 100644 index 0000000000..e75d3e8c05 --- /dev/null +++ b/pkg/operator/resources/cluster/apiserver.go @@ -0,0 +1,87 @@ +/* +Copyright 2018 The CDI 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 cluster + +import ( + rbacv1beta1 "k8s.io/api/rbac/v1beta1" +) + +const ( + apiServerResourceName = "cdi-apiserver" +) + +func createAPIServerResources(args *FactoryArgs) []Resource { + return []Resource{ + createAPIServerClusterRoleBinding(args.Namespace), + createAPIServerClusterRole(), + createAPIServerAuthClusterRoleBinding(args.Namespace), + } +} + +func createAPIServerClusterRoleBinding(namespace string) *rbacv1beta1.ClusterRoleBinding { + return createClusterRoleBinding(apiServerResourceName, apiServerResourceName, apiServerResourceName, namespace) +} + +func createAPIServerClusterRole() *rbacv1beta1.ClusterRole { + clusterRole := createClusterRole(apiServerResourceName) + clusterRole.Rules = []rbacv1beta1.PolicyRule{ + { + APIGroups: []string{ + "admissionregistration.k8s.io", + }, + Resources: []string{ + "validatingwebhookconfigurations", + }, + Verbs: []string{ + "get", + "create", + "update", + }, + }, + { + APIGroups: []string{ + "apiregistration.k8s.io", + }, + Resources: []string{ + "apiservices", + }, + Verbs: []string{ + "get", + "create", + "update", + }, + }, + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "pods", + "persistentvolumeclaims", + }, + Verbs: []string{ + "get", + "list", + }, + }, + } + return clusterRole +} + +func createAPIServerAuthClusterRoleBinding(namespace string) *rbacv1beta1.ClusterRoleBinding { + return createClusterRoleBinding("cdi-apiserver-auth-delegator", "system:auth-delegator", apiServerResourceName, namespace) +} diff --git a/pkg/operator/resources/cluster/controller.go b/pkg/operator/resources/cluster/controller.go new file mode 100644 index 0000000000..b409d2d789 --- /dev/null +++ b/pkg/operator/resources/cluster/controller.go @@ -0,0 +1,152 @@ +/* +Copyright 2018 The CDI 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 cluster + +import ( + rbacv1beta1 "k8s.io/api/rbac/v1beta1" +) + +const ( + controllerServiceAccountName = "cdi-sa" + controlerClusterRoleName = "cdi" +) + +func createControllerResources(args *FactoryArgs) []Resource { + return []Resource{ + createControllerClusterRoleBinding(args.Namespace), + createControllerClusterRole(), + } +} + +func createControllerClusterRoleBinding(namespace string) *rbacv1beta1.ClusterRoleBinding { + return createClusterRoleBinding(controllerServiceAccountName, controlerClusterRoleName, controllerServiceAccountName, namespace) +} + +func createControllerClusterRole() *rbacv1beta1.ClusterRole { + clusterRole := createClusterRole(controlerClusterRoleName) + clusterRole.Rules = []rbacv1beta1.PolicyRule{ + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "events", + }, + Verbs: []string{ + "create", + "update", + "patch", + }, + }, + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "persistentvolumeclaims", + }, + Verbs: []string{ + "get", + "list", + "watch", + "create", + "update", + "patch", + }, + }, + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "persistentvolumeclaims/finalizers", + "pods/finalizers", + }, + Verbs: []string{ + "update", + }, + }, + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "pods", + "services", + }, + Verbs: []string{ + "get", + "list", + "watch", + "create", + "delete", + }, + }, + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "secrets", + }, + Verbs: []string{ + "get", + "list", + "watch", + "create", + }, + }, + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "configmaps", + }, + Verbs: []string{ + "get", + "list", + "watch", + "create", + "update", + }, + }, + { + APIGroups: []string{ + "storage.k8s.io", + }, + Resources: []string{ + "storageclasses", + }, + Verbs: []string{ + "get", + }, + }, + { + APIGroups: []string{ + "cdi.kubevirt.io", + }, + Resources: []string{ + "*", + }, + Verbs: []string{ + "*", + }, + }, + } + return clusterRole +} diff --git a/pkg/operator/resources/cluster/datavolume.go b/pkg/operator/resources/cluster/datavolume.go new file mode 100644 index 0000000000..c6c7aff51f --- /dev/null +++ b/pkg/operator/resources/cluster/datavolume.go @@ -0,0 +1,160 @@ +/* +Copyright 2018 The CDI 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 cluster + +import ( + extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func createCRDResources(args *FactoryArgs) []Resource { + return []Resource{ + createDataVolumeCRD(), + } +} + +func createDataVolumeCRD() *extv1beta1.CustomResourceDefinition { + return &extv1beta1.CustomResourceDefinition{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "apiextensions.k8s.io/v1beta1", + Kind: "CustomResourceDefinition", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "datavolumes.cdi.kubevirt.io", + Labels: map[string]string{ + "cdikubevirt.io": "", + }, + }, + Spec: extv1beta1.CustomResourceDefinitionSpec{ + Group: "cdi.kubevirt.io", + Names: extv1beta1.CustomResourceDefinitionNames{ + Kind: "DataVolume", + Plural: "datavolumes", + ShortNames: []string{ + "dv", + "dvs", + }, + Singular: "datavolume", + }, + Version: "v1alpha1", + Scope: "Namespaced", + Validation: &extv1beta1.CustomResourceValidation{ + OpenAPIV3Schema: &extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "apiVersion": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + "kind": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + "metadata": extv1beta1.JSONSchemaProps{}, + "spec": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "source": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "http": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "url": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + "secretRef": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + }, + Required: []string{ + "url", + }, + }, + "s3": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "url": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + "secretRef": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + }, + Required: []string{ + "url", + }, + }, + "registry": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "url": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + "secretRef": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + }, + Required: []string{ + "url", + }, + }, + "pvc": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "namespace": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + "name": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + }, + Required: []string{ + "namespace", + "name", + }, + }, + "upload": extv1beta1.JSONSchemaProps{}, + "blank": extv1beta1.JSONSchemaProps{}, + }, + }, + "pvc": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "resources": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "requests": extv1beta1.JSONSchemaProps{ + Properties: map[string]extv1beta1.JSONSchemaProps{ + "storage": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + }, + }, + }, + Required: []string{ + "requests", + }, + }, + "storageClassName": extv1beta1.JSONSchemaProps{ + Type: "string", + }, + "accessModes": extv1beta1.JSONSchemaProps{ + Type: "array", + }, + }, + Required: []string{ + "resources", + }, + }, + }, + }, + }, + }, + }, + }, + } +} diff --git a/pkg/operator/resources/cluster/factory.go b/pkg/operator/resources/cluster/factory.go new file mode 100644 index 0000000000..b62c979f68 --- /dev/null +++ b/pkg/operator/resources/cluster/factory.go @@ -0,0 +1,61 @@ +/* +Copyright 2018 The CDI 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 cluster + +import ( + "fmt" + + "k8s.io/apimachinery/pkg/runtime" +) + +// FactoryArgs contains the required parameters to generate all cluster-scoped resources +type FactoryArgs struct { + Namespace string +} + +// Resource defines the interface of all cluster-wide components +type Resource runtime.Object + +type factoryFunc func(*FactoryArgs) []Resource + +var factoryFunctions = map[string]factoryFunc{ + "crd": createCRDResources, + "controller": createControllerResources, + "apiserver": createAPIServerResources, +} + +// CreateAllResources creates all cluster-wide resources +func CreateAllResources(args *FactoryArgs) ([]Resource, error) { + resources := []Resource{} + for group := range factoryFunctions { + rs, err := CreateResourceGroup(group, args) + if err != nil { + return nil, err + } + resources = append(resources, rs...) + } + return resources, nil +} + +// CreateResourceGroup creates all cluster resources fr a specific group/component +func CreateResourceGroup(group string, args *FactoryArgs) ([]Resource, error) { + f, ok := factoryFunctions[group] + if !ok { + return nil, fmt.Errorf("Group %s does not exist", group) + } + return f(args), nil +} diff --git a/pkg/operator/resources/cluster/rbac.go b/pkg/operator/resources/cluster/rbac.go new file mode 100644 index 0000000000..074447b2ac --- /dev/null +++ b/pkg/operator/resources/cluster/rbac.go @@ -0,0 +1,64 @@ +/* +Copyright 2018 The CDI 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 cluster + +import ( + rbacv1beta1 "k8s.io/api/rbac/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func createClusterRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace string) *rbacv1beta1.ClusterRoleBinding { + return &rbacv1beta1.ClusterRoleBinding{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "rbac.authorization.k8s.io/v1beta1", + Kind: "ClusterRoleBinding", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: map[string]string{ + "cdi.kubevirt.io": "", + }, + }, + RoleRef: rbacv1beta1.RoleRef{ + Kind: "ClusterRole", + Name: roleRef, + APIGroup: "rbac.authorization.k8s.io", + }, + Subjects: []rbacv1beta1.Subject{ + { + Kind: "ServiceAccount", + Name: serviceAccount, + Namespace: serviceAccountNamespace, + }, + }, + } +} + +func createClusterRole(name string) *rbacv1beta1.ClusterRole { + return &rbacv1beta1.ClusterRole{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "rbac.authorization.k8s.io/v1beta1", + Kind: "ClusterRole", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: map[string]string{ + "cdi.kubevirt.io": "", + }, + }, + } +} diff --git a/pkg/operator/resources/namespaced/apiserver.go b/pkg/operator/resources/namespaced/apiserver.go new file mode 100644 index 0000000000..a3847342a5 --- /dev/null +++ b/pkg/operator/resources/namespaced/apiserver.go @@ -0,0 +1,127 @@ +/* +Copyright 2018 The CDI 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 namespaced + +import ( + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + rbacv1beta1 "k8s.io/api/rbac/v1beta1" + "k8s.io/apimachinery/pkg/util/intstr" + + "kubevirt.io/containerized-data-importer/pkg/common" +) + +const ( + cdiLabel = common.CDIComponentLabel + apiServerRessouceName = "cdi-apiserver" + extensionAPIResourceName = "cdi-extension-apiserver-authentication" + extensionAPIConfigMapName = "extension-apiserver-authentication" +) + +func createAPIServerResources(args *FactoryArgs) []Resource { + return []Resource{ + createAPIServerServiceAccount(), + createAPIServerRoleBinding(args.Namespace), + createAPIServerRole(), + createExtensionAPIServerRoleBinding(args.Namespace), + createExtensionAPIServerRole(), + createAPIServerService(), + createAPIServerDeployment(args.DockerRepo, args.APIServerImage, args.DockerTag, args.Verbosity, args.PullPolicy), + } +} + +func createAPIServerServiceAccount() *corev1.ServiceAccount { + return createServiceAccount(apiServerRessouceName) +} + +func createAPIServerRoleBinding(serviceAccountNamespace string) *rbacv1beta1.RoleBinding { + return createRoleBinding(apiServerRessouceName, apiServerRessouceName, apiServerRessouceName, serviceAccountNamespace) +} + +func createAPIServerRole() *rbacv1beta1.Role { + role := createRole(apiServerRessouceName) + role.Rules = []rbacv1beta1.PolicyRule{ + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "secrets", + "configmaps", + }, + Verbs: []string{ + "get", + "create", + }, + }, + } + return role +} + +func createExtensionAPIServerRoleBinding(serviceAccountNamespace string) *rbacv1beta1.RoleBinding { + roleBinding := createRoleBinding( + extensionAPIResourceName, + extensionAPIResourceName, + apiServerRessouceName, + serviceAccountNamespace, + ) + roleBinding.Namespace = "kube-system" + return roleBinding +} + +func createExtensionAPIServerRole() *rbacv1beta1.Role { + role := createRole(extensionAPIResourceName) + role.Rules = []rbacv1beta1.PolicyRule{ + { + APIGroups: []string{ + "", + }, + Resources: []string{ + "configmaps", + }, + Verbs: []string{ + "get", + }, + ResourceNames: []string{ + extensionAPIConfigMapName, + }, + }, + } + return role +} + +func createAPIServerService() *corev1.Service { + service := createService("cdi-api", cdiLabel, apiServerRessouceName) + service.Spec.Ports = []corev1.ServicePort{ + { + Port: 443, + TargetPort: intstr.IntOrString{ + Type: intstr.Int, + IntVal: 8443, + }, + Protocol: corev1.ProtocolTCP, + }, + } + return service +} + +func createAPIServerDeployment(repo, image, tag, verbosity, pullPolicy string) *appsv1.Deployment { + deployment := createDeployment(apiServerRessouceName, cdiLabel, apiServerRessouceName, apiServerRessouceName, 1) + container := createContainer(apiServerRessouceName, repo, image, tag, verbosity, corev1.PullPolicy(pullPolicy)) + deployment.Spec.Template.Spec.Containers = []corev1.Container{container} + return deployment +} diff --git a/pkg/operator/resources/namespaced/common.go b/pkg/operator/resources/namespaced/common.go new file mode 100644 index 0000000000..16fe2a125b --- /dev/null +++ b/pkg/operator/resources/namespaced/common.go @@ -0,0 +1,153 @@ +/* +Copyright 2018 The CDI 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 namespaced + +import ( + "fmt" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + rbacv1beta1 "k8s.io/api/rbac/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var commonLabels = map[string]string{ + "cdi.kubevirt.io": "", +} + +func withCommonLabels(labels map[string]string) map[string]string { + if labels == nil { + labels = make(map[string]string) + } + + for k, v := range commonLabels { + _, ok := labels[k] + if !ok { + labels[k] = v + } + } + + return labels +} + +func createServiceAccount(name string) *corev1.ServiceAccount { + return &corev1.ServiceAccount{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "ServiceAccount", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: withCommonLabels(nil), + }, + } +} + +func createRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace string) *rbacv1beta1.RoleBinding { + return &rbacv1beta1.RoleBinding{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "rbac.authorization.k8s.io/v1beta1", + Kind: "RoleBinding", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: withCommonLabels(nil), + }, + RoleRef: rbacv1beta1.RoleRef{ + Kind: "Role", + Name: roleRef, + APIGroup: "rbac.authorization.k8s.io", + }, + Subjects: []rbacv1beta1.Subject{ + { + Kind: "ServiceAccount", + Name: serviceAccount, + Namespace: serviceAccountNamespace, + }, + }, + } +} + +func createRole(name string) *rbacv1beta1.Role { + return &rbacv1beta1.Role{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "rbac.authorization.k8s.io/v1beta1", + Kind: "Role", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: withCommonLabels(nil), + }, + } +} + +func createDeployment(name, matchKey, matchValue, serviceAccount string, numReplicas int32) *appsv1.Deployment { + matchMap := map[string]string{matchKey: matchValue} + deployment := &appsv1.Deployment{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "apps/v1", + Kind: "Deployment", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: withCommonLabels(matchMap), + }, + Spec: appsv1.DeploymentSpec{ + Replicas: &numReplicas, + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + matchKey: matchValue, + }, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: withCommonLabels(matchMap), + }, + }, + }, + } + if serviceAccount != "" { + deployment.Spec.Template.Spec.ServiceAccountName = serviceAccount + } + return deployment +} + +func createContainer(name, repo, image, tag, verbosity string, pullPolicy corev1.PullPolicy) corev1.Container { + return corev1.Container{ + Name: name, + Image: fmt.Sprintf("%s/%s:%s", repo, image, tag), + ImagePullPolicy: pullPolicy, + Args: []string{"-v=" + verbosity}, + } +} + +func createService(name, matchKey, matchValue string) *corev1.Service { + matchMap := map[string]string{matchKey: matchValue} + return &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "Service", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: withCommonLabels(matchMap), + }, + Spec: corev1.ServiceSpec{ + Selector: matchMap, + }, + } +} diff --git a/pkg/operator/resources/namespaced/controller.go b/pkg/operator/resources/namespaced/controller.go new file mode 100644 index 0000000000..a3277a05aa --- /dev/null +++ b/pkg/operator/resources/namespaced/controller.go @@ -0,0 +1,108 @@ +/* +Copyright 2018 The CDI 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 namespaced + +import ( + "fmt" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + + "kubevirt.io/containerized-data-importer/pkg/common" +) + +const ( + controllerServiceAccount = "cdi-sa" + prometheusLabel = common.PrometheusLabel +) + +func createControllerResources(args *FactoryArgs) []Resource { + return []Resource{ + createControllerServiceAccount(), + createControllerDeployment(args.DockerRepo, + args.ControllerImage, + args.ImporterImage, + args.ClonerImage, + args.UploadServerImage, + args.DockerTag, + args.Verbosity, + args.PullPolicy), + } +} + +func createControllerServiceAccount() *corev1.ServiceAccount { + return createServiceAccount(controllerServiceAccount) +} + +func createControllerDeployment(repo, controllerImage, importerImage, clonerImage, uploadServerImage, tag, verbosity, pullPolicy string) *appsv1.Deployment { + deployment := createDeployment("cdi-deployment", "app", "containerized-data-importer", controllerServiceAccount, int32(1)) + container := createContainer("cdi-controller", repo, controllerImage, tag, verbosity, corev1.PullPolicy(pullPolicy)) + container.Env = []corev1.EnvVar{ + { + Name: "IMPORTER_IMAGE", + Value: fmt.Sprintf("%s/%s:%s", repo, importerImage, tag), + }, + { + Name: "CLONER_IMAGE", + Value: fmt.Sprintf("%s/%s:%s", repo, clonerImage, tag), + }, + { + Name: "UPLOADSERVER_IMAGE", + Value: fmt.Sprintf("%s/%s:%s", repo, uploadServerImage, tag), + }, + { + Name: "UPLOADPROXY_SERVICE", + Value: uploadProxyResourceName, + }, + } + deployment.Spec.Template.Spec.Containers = []corev1.Container{container} + return deployment +} + +func createPrometheusService() *corev1.Service { + return &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "Service", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "kubevirt-prometheus-metrics", + Labels: map[string]string{ + prometheusLabel: "", + "kubevirt.io": "", + }, + }, + Spec: corev1.ServiceSpec{ + Selector: map[string]string{ + prometheusLabel: "", + }, + Ports: []corev1.ServicePort{ + { + Name: "metrics", + Port: 443, + TargetPort: intstr.IntOrString{ + Type: intstr.String, + StrVal: "metrics", + }, + Protocol: corev1.ProtocolTCP, + }, + }, + }, + } +} diff --git a/pkg/operator/resources/namespaced/factory.go b/pkg/operator/resources/namespaced/factory.go new file mode 100644 index 0000000000..68e976ea7e --- /dev/null +++ b/pkg/operator/resources/namespaced/factory.go @@ -0,0 +1,66 @@ +package namespaced + +import ( + "fmt" + + "k8s.io/apimachinery/pkg/runtime" +) + +// FactoryArgs contains the required parameters to generate all namespaced resources +type FactoryArgs struct { + DockerRepo string + DockerTag string + ControllerImage string + ImporterImage string + ClonerImage string + APIServerImage string + UploadProxyImage string + UploadServerImage string + Verbosity string + PullPolicy string + Namespace string +} + +type factoryFunc func(*FactoryArgs) []Resource + +// Resource defines the interface for namespaced resources +type Resource interface { + runtime.Object + SetNamespace(string) + GetNamespace() string +} + +var factoryFunctions = map[string]factoryFunc{ + "apiserver": createAPIServerResources, + "controller": createControllerResources, + "uploadproxy": createUploadProxyResources, +} + +// CreateAllResources creates all namespaced resources +func CreateAllResources(args *FactoryArgs) ([]Resource, error) { + resources := []Resource{} + for group := range factoryFunctions { + rs, err := CreateResourceGroup(group, args) + if err != nil { + return nil, err + } + resources = append(resources, rs...) + } + return resources, nil +} + +// CreateResourceGroup creates namespaced resources for a specific group/component +func CreateResourceGroup(group string, args *FactoryArgs) ([]Resource, error) { + f, ok := factoryFunctions[group] + if !ok { + return nil, fmt.Errorf("Group %s does not exist", group) + } + resources := []Resource{} + for _, o := range f(args) { + if o.GetNamespace() == "" { + o.SetNamespace(args.Namespace) + } + resources = append(resources, o) + } + return resources, nil +} diff --git a/pkg/operator/resources/namespaced/uploadproxy.go b/pkg/operator/resources/namespaced/uploadproxy.go new file mode 100644 index 0000000000..ba837e2fc9 --- /dev/null +++ b/pkg/operator/resources/namespaced/uploadproxy.go @@ -0,0 +1,124 @@ +/* +Copyright 2018 The CDI 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 namespaced + +import ( + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/util/intstr" +) + +const ( + uploadProxyResourceName = "cdi-uploadproxy" +) + +func createUploadProxyResources(args *FactoryArgs) []Resource { + return []Resource{ + createUploadProxyService(), + createUploadProxyDeployment(args.DockerRepo, args.UploadProxyImage, args.DockerTag, args.Verbosity, args.PullPolicy), + } +} + +func createUploadProxyService() *corev1.Service { + service := createService(uploadProxyResourceName, "cdi.kubevirt.io", uploadProxyResourceName) + service.Spec.Ports = []corev1.ServicePort{ + { + Port: 443, + TargetPort: intstr.IntOrString{ + Type: intstr.Int, + IntVal: 8443, + }, + Protocol: corev1.ProtocolTCP, + }, + } + return service +} + +func createUploadProxyDeployment(repo, image, tag, verbosity, pullPolicy string) *appsv1.Deployment { + deployment := createDeployment(uploadProxyResourceName, "cdi.kubevirt.io", uploadProxyResourceName, "", int32(1)) + container := createContainer(uploadProxyResourceName, repo, image, tag, verbosity, corev1.PullPolicy(pullPolicy)) + container.Env = []corev1.EnvVar{ + { + Name: "APISERVER_PUBLIC_KEY", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "cdi-api-signing-key", + }, + Key: "id_rsa.pub", + }, + }, + }, + { + Name: "UPLOAD_SERVER_CLIENT_KEY", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "cdi-upload-server-client-key", + }, + Key: "tls.key", + }, + }, + }, + { + Name: "UPLOAD_SERVER_CLIENT_CERT", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "cdi-upload-server-client-key", + }, + Key: "tls.crt", + }, + }, + }, + { + Name: "UPLOAD_SERVER_CA_CERT", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "cdi-upload-server-client-key", + }, + Key: "ca.crt", + }, + }, + }, + { + Name: "SERVICE_TLS_KEY", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "cdi-upload-proxy-server-key", + }, + Key: "tls.key", + }, + }, + }, + { + Name: "SERVICE_TLS_CERT", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "cdi-upload-proxy-server-key", + }, + Key: "tls.crt", + }, + }, + }, + } + deployment.Spec.Template.Spec.Containers = []corev1.Container{container} + return deployment +} diff --git a/tools/manifest-generator/manifest-generator.go b/tools/manifest-generator/manifest-generator.go index 1ba2d0685c..22bc94a2ed 100644 --- a/tools/manifest-generator/manifest-generator.go +++ b/tools/manifest-generator/manifest-generator.go @@ -18,9 +18,12 @@ import ( "text/template" "github.com/golang/glog" + + cdicluster "kubevirt.io/containerized-data-importer/pkg/operator/resources/cluster" + cdinamespaced "kubevirt.io/containerized-data-importer/pkg/operator/resources/namespaced" ) -type data struct { +type templateData struct { DockerRepo string DockerTag string ControllerImage string @@ -35,23 +38,36 @@ type data struct { Namespace string } +var ( + dockerRepo = flag.String("docker-repo", "", "") + dockertag = flag.String("docker-tag", "", "") + controllerImage = flag.String("controller-image", "", "") + importerImage = flag.String("importer-image", "", "") + clonerImage = flag.String("cloner-image", "", "") + apiServerImage = flag.String("apiserver-image", "", "") + uploadProxyImage = flag.String("uploadproxy-image", "", "") + uploadServerImage = flag.String("uploadserver-image", "", "") + operatorImage = flag.String("operator-image", "", "") + verbosity = flag.String("verbosity", "1", "") + pullPolicy = flag.String("pull-policy", "", "") + namespace = flag.String("namespace", "", "") +) + func main() { - dockerRepo := flag.String("docker-repo", "", "") - dockertag := flag.String("docker-tag", "", "") - controllerImage := flag.String("controller-image", "", "") - importerImage := flag.String("importer-image", "", "") - clonerImage := flag.String("cloner-image", "", "") - apiServerImage := flag.String("apiserver-image", "", "") - uploadProxyImage := flag.String("uploadproxy-image", "", "") - uploadServerImage := flag.String("uploadserver-image", "", "") - operatorImage := flag.String("operator-image", "", "") templFile := flag.String("template", "", "") - verbosity := flag.String("verbosity", "1", "") - pullPolicy := flag.String("pull-policy", "", "") - namespace := flag.String("namespace", "", "") + codeGroup := flag.String("code-group", "everything", "") flag.Parse() - data := &data{ + if *templFile != "" { + generateFromFile(*templFile) + return + } + + generateFromCode(*codeGroup) +} + +func generateFromFile(templFile string) { + data := &templateData{ Verbosity: *verbosity, DockerRepo: *dockerRepo, DockerTag: *dockertag, @@ -66,15 +82,108 @@ func main() { Namespace: *namespace, } - file, err := os.OpenFile(*templFile, os.O_RDONLY, 0) + file, err := os.OpenFile(templFile, os.O_RDONLY, 0) if err != nil { - glog.Fatalf("Failed to open file %s: %v\n", *templFile, err) + glog.Fatalf("Failed to open file %s: %v\n", templFile, err) } defer file.Close() - tmpl := template.Must(template.ParseFiles(*templFile)) + tmpl := template.Must(template.ParseFiles(templFile)) err = tmpl.Execute(os.Stdout, data) if err != nil { glog.Fatalf("Error executing template: %v\n", err) } } + +func generateFromCode(codeGroup string) { + var resources []interface{} + + crs, err := getClusterResources(codeGroup) + if err != nil { + glog.Fatalf("Error getting cluster resources: %v\n", err) + } + + resources = append(resources, crs...) + + nsrs, err := getNamespacedResources(codeGroup) + if err != nil { + glog.Fatalf("Error getting namespaced resources: %v\n", err) + } + + resources = append(resources, nsrs...) + + for _, resource := range resources { + err = MarshallObject(resource, os.Stdout) + if err != nil { + glog.Fatalf("Error marshalling resource: %v\n", err) + } + } +} + +// getClusterResources creates cluster-scoped resources for a specific group/component +// returning interface{} because caller is only interested in marshalling to json +// and is stuffing cluster-scomed and namespaced resources in the same slice +func getClusterResources(codeGroup string) ([]interface{}, error) { + var result []interface{} + var resources []cdicluster.Resource + var err error + + args := &cdicluster.FactoryArgs{ + Namespace: *namespace, + } + + if codeGroup == "everything" { + resources, err = cdicluster.CreateAllResources(args) + } else { + resources, err = cdicluster.CreateResourceGroup(codeGroup, args) + } + + if err != nil { + return nil, err + } + + for _, resource := range resources { + result = append(result, resource.(interface{})) + } + + return result, nil +} + +// getNamespacedResources creates namespace-scoped resources for a specific group/component +// returning interface{} because caller is only interested in marshalling to json +// and is stuffing cluster-scomed and namespaced resources in the same slice +func getNamespacedResources(codeGroup string) ([]interface{}, error) { + var result []interface{} + var resources []cdinamespaced.Resource + var err error + + args := &cdinamespaced.FactoryArgs{ + Verbosity: *verbosity, + DockerRepo: *dockerRepo, + DockerTag: *dockertag, + ControllerImage: *controllerImage, + ImporterImage: *importerImage, + ClonerImage: *clonerImage, + APIServerImage: *apiServerImage, + UploadProxyImage: *uploadProxyImage, + UploadServerImage: *uploadServerImage, + PullPolicy: *pullPolicy, + Namespace: *namespace, + } + + if codeGroup == "everything" { + resources, err = cdinamespaced.CreateAllResources(args) + } else { + resources, err = cdinamespaced.CreateResourceGroup(codeGroup, args) + } + + if err != nil { + return nil, err + } + + for _, resource := range resources { + result = append(result, resource.(interface{})) + } + + return result, nil +} diff --git a/tools/manifest-generator/marshaller.go b/tools/manifest-generator/marshaller.go new file mode 100644 index 0000000000..469d970648 --- /dev/null +++ b/tools/manifest-generator/marshaller.go @@ -0,0 +1,78 @@ +/* + * This file is part of the KubeVirt project + * + * 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. + * + * Copyright 2018 Red Hat, Inc. + * + */ + +// this file directly copy/pasted from KubeVirt project here: +// https://github.com/kubevirt/kubevirt/blob/master/tools/util/marshaller.go + +package main + +import ( + "encoding/json" + "io" + "strings" + + "github.com/ghodss/yaml" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" +) + +// MarshallObject marshalls an object to yaml appropriate for kubectl +func MarshallObject(obj interface{}, writer io.Writer) error { + jsonBytes, err := json.Marshal(obj) + if err != nil { + return err + } + + var r unstructured.Unstructured + if err := json.Unmarshal(jsonBytes, &r.Object); err != nil { + return err + } + + // remove status and metadata.creationTimestamp + unstructured.RemoveNestedField(r.Object, "metadata", "creationTimestamp") + unstructured.RemoveNestedField(r.Object, "spec", "template", "metadata", "creationTimestamp") + unstructured.RemoveNestedField(r.Object, "status") + + jsonBytes, err = json.Marshal(r.Object) + if err != nil { + return err + } + + yamlBytes, err := yaml.JSONToYAML(jsonBytes) + if err != nil { + return err + } + + // fix templates by removing quotes... + s := string(yamlBytes) + s = strings.Replace(s, "'{{", "{{", -1) + s = strings.Replace(s, "}}'", "}}", -1) + yamlBytes = []byte(s) + + _, err = writer.Write([]byte("---\n")) + if err != nil { + return err + } + + _, err = writer.Write(yamlBytes) + if err != nil { + return err + } + + return nil +} diff --git a/vendor/github.com/pkg/errors/format_test.go b/vendor/github.com/pkg/errors/format_test.go index c2eef5f045..cb1df821fc 100644 --- a/vendor/github.com/pkg/errors/format_test.go +++ b/vendor/github.com/pkg/errors/format_test.go @@ -360,7 +360,32 @@ func TestFormatGeneric(t *testing.T) { } } +func wrappedNew(message string) error { // This function will be mid-stack inlined in go 1.12+ + return New(message) +} + +func TestFormatWrappedNew(t *testing.T) { + tests := []struct { + error + format string + want string + }{{ + wrappedNew("error"), + "%+v", + "error\n" + + "github.com/pkg/errors.wrappedNew\n" + + "\t.+/github.com/pkg/errors/format_test.go:364\n" + + "github.com/pkg/errors.TestFormatWrappedNew\n" + + "\t.+/github.com/pkg/errors/format_test.go:373", + }} + + for i, tt := range tests { + testFormatRegexp(t, i, tt.error, tt.format, tt.want) + } +} + func testFormatRegexp(t *testing.T, n int, arg interface{}, format, want string) { + t.Helper() got := fmt.Sprintf(format, arg) gotLines := strings.SplitN(got, "\n", -1) wantLines := strings.SplitN(want, "\n", -1) diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go index 3b582c2578..81f8856416 100644 --- a/vendor/github.com/pkg/errors/stack.go +++ b/vendor/github.com/pkg/errors/stack.go @@ -1,7 +1,6 @@ package errors import ( - "bytes" "fmt" "io" "path" @@ -11,7 +10,44 @@ import ( ) // Frame represents a program counter inside a stack frame. -type Frame runtime.Frame +// For historical reasons if Frame is interpreted as a uintptr +// its value represents the program counter + 1. +type Frame uintptr + +// pc returns the program counter for this frame; +// multiple frames may have the same PC value. +func (f Frame) pc() uintptr { return uintptr(f) - 1 } + +// file returns the full path to the file that contains the +// function for this Frame's pc. +func (f Frame) file() string { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return "unknown" + } + file, _ := fn.FileLine(f.pc()) + return file +} + +// line returns the line number of source code of the +// function for this Frame's pc. +func (f Frame) line() int { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return 0 + } + _, line := fn.FileLine(f.pc()) + return line +} + +// name returns the name of this function, if known. +func (f Frame) name() string { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return "unknown" + } + return fn.Name() +} // Format formats the frame according to the fmt.Formatter interface. // @@ -26,39 +62,24 @@ type Frame runtime.Frame // GOPATH separated by \n\t (\n\t) // %+v equivalent to %+s:%d func (f Frame) Format(s fmt.State, verb rune) { - f.format(s, s, verb) -} - -// format allows stack trace printing calls to be made with a bytes.Buffer. -func (f Frame) format(w io.Writer, s fmt.State, verb rune) { switch verb { case 's': switch { case s.Flag('+'): - fn := f.Func - if fn == nil { - io.WriteString(w, "unknown") - } else { - io.WriteString(w, fn.Name()) - io.WriteString(w, "\n\t") - io.WriteString(w, f.File) - } + io.WriteString(s, f.name()) + io.WriteString(s, "\n\t") + io.WriteString(s, f.file()) default: - file := f.File - if file == "" { - file = "unknown" - } - io.WriteString(w, path.Base(file)) + io.WriteString(s, path.Base(f.file())) } case 'd': - io.WriteString(w, strconv.Itoa(f.Line)) + io.WriteString(s, strconv.Itoa(f.line())) case 'n': - name := f.Function - io.WriteString(s, funcname(name)) + io.WriteString(s, funcname(f.name())) case 'v': - f.format(w, s, 's') - io.WriteString(w, ":") - f.format(w, s, 'd') + f.Format(s, 's') + io.WriteString(s, ":") + f.Format(s, 'd') } } @@ -74,50 +95,37 @@ type StackTrace []Frame // // %+v Prints filename, function, and line number for each Frame in the stack. func (st StackTrace) Format(s fmt.State, verb rune) { - var b bytes.Buffer switch verb { case 'v': switch { case s.Flag('+'): - b.Grow(len(st) * stackMinLen) - for _, fr := range st { - b.WriteByte('\n') - fr.format(&b, s, verb) + for _, f := range st { + io.WriteString(s, "\n") + f.Format(s, verb) } case s.Flag('#'): - fmt.Fprintf(&b, "%#v", []Frame(st)) + fmt.Fprintf(s, "%#v", []Frame(st)) default: - st.formatSlice(&b, s, verb) + st.formatSlice(s, verb) } case 's': - st.formatSlice(&b, s, verb) + st.formatSlice(s, verb) } - io.Copy(s, &b) } // formatSlice will format this StackTrace into the given buffer as a slice of // Frame, only valid when called with '%s' or '%v'. -func (st StackTrace) formatSlice(b *bytes.Buffer, s fmt.State, verb rune) { - b.WriteByte('[') - if len(st) == 0 { - b.WriteByte(']') - return - } - - b.Grow(len(st) * (stackMinLen / 4)) - st[0].format(b, s, verb) - for _, fr := range st[1:] { - b.WriteByte(' ') - fr.format(b, s, verb) +func (st StackTrace) formatSlice(s fmt.State, verb rune) { + io.WriteString(s, "[") + for i, f := range st { + if i > 0 { + io.WriteString(s, " ") + } + f.Format(s, verb) } - b.WriteByte(']') + io.WriteString(s, "]") } -// stackMinLen is a best-guess at the minimum length of a stack trace. It -// doesn't need to be exact, just give a good enough head start for the buffer -// to avoid the expensive early growth. -const stackMinLen = 96 - // stack represents a stack of program counters. type stack []uintptr @@ -126,29 +134,20 @@ func (s *stack) Format(st fmt.State, verb rune) { case 'v': switch { case st.Flag('+'): - frames := runtime.CallersFrames(*s) - for { - frame, more := frames.Next() - fmt.Fprintf(st, "\n%+v", Frame(frame)) - if !more { - break - } + for _, pc := range *s { + f := Frame(pc) + fmt.Fprintf(st, "\n%+v", f) } } } } func (s *stack) StackTrace() StackTrace { - var st []Frame - frames := runtime.CallersFrames(*s) - for { - frame, more := frames.Next() - st = append(st, Frame(frame)) - if !more { - break - } + f := make([]Frame, len(*s)) + for i := 0; i < len(f); i++ { + f[i] = Frame((*s)[i]) } - return st + return f } func callers() *stack { diff --git a/vendor/github.com/pkg/errors/stack_test.go b/vendor/github.com/pkg/errors/stack_test.go index 7f7669432c..1acd719bcc 100644 --- a/vendor/github.com/pkg/errors/stack_test.go +++ b/vendor/github.com/pkg/errors/stack_test.go @@ -35,11 +35,11 @@ func TestFrameFormat(t *testing.T) { "github.com/pkg/errors.init\n" + "\t.+/github.com/pkg/errors/stack_test.go", }, { - Frame{}, + 0, "%s", "unknown", }, { - Frame{}, + 0, "%+s", "unknown", }, { @@ -47,7 +47,7 @@ func TestFrameFormat(t *testing.T) { "%d", "9", }, { - Frame{}, + 0, "%d", "0", }, { @@ -69,7 +69,7 @@ func TestFrameFormat(t *testing.T) { "%n", "X.val", }, { - Frame{}, + 0, "%n", "", }, { @@ -82,7 +82,7 @@ func TestFrameFormat(t *testing.T) { "github.com/pkg/errors.init\n" + "\t.+/github.com/pkg/errors/stack_test.go:9", }, { - Frame{}, + 0, "%v", "unknown:0", }} @@ -133,7 +133,7 @@ func TestStackTrace(t *testing.T) { "\t.+/github.com/pkg/errors/stack_test.go:131", // this is the stack of New }, }, { - func() error { noinline(); return New("ooh") }(), []string{ + func() error { return New("ooh") }(), []string{ `github.com/pkg/errors.TestStackTrace.func1` + "\n\t.+/github.com/pkg/errors/stack_test.go:136", // this is the stack of New "github.com/pkg/errors.TestStackTrace\n" + @@ -246,9 +246,5 @@ func caller() Frame { n := runtime.Callers(2, pcs[:]) frames := runtime.CallersFrames(pcs[:n]) frame, _ := frames.Next() - return Frame(frame) + return Frame(frame.PC) } - -//go:noinline -// noinline prevents the caller being inlined -func noinline() {} diff --git a/vendor/k8s.io/apiextensions-apiserver/.github/PULL_REQUEST_TEMPLATE.md b/vendor/k8s.io/apiextensions-apiserver/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..e559c074bb --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000000..d8ad4d2d34 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# 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 new file mode 100644 index 0000000000..f9478cdbe7 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/Godeps/Godeps.json @@ -0,0 +1,2186 @@ +{ + "ImportPath": "k8s.io/apiextensions-apiserver", + "GoVersion": "go1.10", + "GodepVersion": "v80", + "Packages": [ + "./..." + ], + "Deps": [ + { + "ImportPath": "bitbucket.org/ww/goautoneg", + "Rev": "75cd24fc2f2c2a2088577d12123ddee5f54e0675" + }, + { + "ImportPath": "github.com/Azure/go-ansiterm", + "Rev": "d6e3b3328b783f23731bc4d058875b0371ff8109" + }, + { + "ImportPath": "github.com/Azure/go-ansiterm/winterm", + "Rev": "d6e3b3328b783f23731bc4d058875b0371ff8109" + }, + { + "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": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/auth", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/auth/authpb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/client", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/clientv3", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/clientv3/concurrency", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/clientv3/namespace", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/clientv3/naming", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/compactor", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/discovery", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/embed", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/error", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/etcdhttp", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v2http", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v2http/httptypes", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3client", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3election", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb/gw", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3lock", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb/gw", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3rpc", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/auth", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/etcdserverpb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/etcdserverpb/gw", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/membership", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/etcdserver/stats", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/integration", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/lease", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/lease/leasehttp", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/lease/leasepb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/mvcc", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/mvcc/backend", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/mvcc/mvccpb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/adt", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/contention", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/cors", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/cpuutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/crc", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/debugutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/fileutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/httputil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/idutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/ioutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/logutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/monotime", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/netutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/pathutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/pbutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/runtime", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/schedule", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/srv", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/testutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/tlsutil", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/transport", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/types", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/pkg/wait", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/proxy/grpcproxy", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/proxy/grpcproxy/adapter", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/proxy/grpcproxy/cache", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/raft", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/raft/raftpb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/rafthttp", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/snap", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/snap/snappb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/store", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/version", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/wal", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "ImportPath": "github.com/coreos/etcd/wal/walpb", + "Rev": "420a452267a7ce45b3fcbed04d54030d69964fc1" + }, + { + "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/docker/docker/pkg/term", + "Rev": "a9fbbdc8dd8794b20af358382ab780559bca589d" + }, + { + "ImportPath": "github.com/docker/docker/pkg/term/windows", + "Rev": "a9fbbdc8dd8794b20af358382ab780559bca589d" + }, + { + "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": "36442dbdb585210f8d5a1b45e67aa323c197d5c4" + }, + { + "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": "9316a62528ac99aaecb4e47eadd6dc8aa6533d58" + }, + { + "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": "c12348ce28de40eed0136aa2b644d0ee0650e56c" + }, + { + "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/sirupsen/logrus", + "Rev": "89742aefa4b206dcf400792f3bd35b542998eb3b" + }, + { + "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": "de0752318171da717af4ce24d0a2e8626afaeb11" + }, + { + "ImportPath": "golang.org/x/crypto/blowfish", + "Rev": "de0752318171da717af4ce24d0a2e8626afaeb11" + }, + { + "ImportPath": "golang.org/x/crypto/ssh/terminal", + "Rev": "de0752318171da717af4ce24d0a2e8626afaeb11" + }, + { + "ImportPath": "golang.org/x/net/context", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/net/http2", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/net/http2/hpack", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/net/idna", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/net/internal/timeseries", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/net/lex/httplex", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/net/trace", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/net/websocket", + "Rev": "0ed95abb35c445290478a5348a7b38bb154135fd" + }, + { + "ImportPath": "golang.org/x/oauth2", + "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" + }, + { + "ImportPath": "golang.org/x/oauth2/internal", + "Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4" + }, + { + "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": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/admissionregistration/v1alpha1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/admissionregistration/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/apps/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/apps/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/apps/v1beta2", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/authentication/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/authentication/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/authorization/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/authorization/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/autoscaling/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/autoscaling/v2beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/autoscaling/v2beta2", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/batch/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/batch/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/batch/v2alpha1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/certificates/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/coordination/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/core/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/events/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/extensions/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/networking/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/policy/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/rbac/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/rbac/v1alpha1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/rbac/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/scheduling/v1alpha1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/scheduling/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/settings/v1alpha1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/storage/v1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/storage/v1alpha1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/api/storage/v1beta1", + "Rev": "6db15a15d2d3874a6c3ddb2140ac9f3bc7058428" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/equality", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/errors", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/meta", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/meta/table", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/resource", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/validation", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/api/validation/path", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/validation", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/conversion", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/fields", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/labels", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/selection", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/types", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/cache", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/clock", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/diff", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/duration", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/errors", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/framer", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/intstr", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/json", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/naming", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/net", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/rand", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/runtime", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/sets", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/uuid", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/validation", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/wait", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/waitgroup", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/util/yaml", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/version", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/pkg/watch", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", + "Rev": "49ce2735e5074ffc3f8190c8406cf51a96302dad" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/configuration", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/initializer", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/metrics", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/initialization", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/config", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/v1alpha1", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/errors", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/generic", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/namespace", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/request", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/rules", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/util", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/admission/plugin/webhook/validating", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/apiserver", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/apiserver/install", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/audit", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/audit/install", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/audit/v1", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/audit/v1alpha1", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/audit/v1beta1", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/apis/audit/validation", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/audit", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/audit/policy", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/authenticator", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/authenticatorfactory", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/group", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/request/anonymous", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/request/bearertoken", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/request/headerrequest", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/request/union", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/request/websocket", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/request/x509", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/serviceaccount", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/token/tokenfile", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authentication/user", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authorization/authorizer", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authorization/authorizerfactory", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authorization/path", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/authorization/union", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/discovery", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/filters", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/handlers", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/handlers/negotiation", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/metrics", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/openapi", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/endpoints/request", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/features", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/registry/generic", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/registry/generic/registry", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/registry/generic/testing", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/registry/rest", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/registry/rest/resttest", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/filters", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/healthz", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/httplog", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/mux", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/options", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/resourceconfig", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/routes", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/routes/data/swagger", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/server/storage", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/cacher", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/errors", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/etcd", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/etcdtest", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/metrics", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/testing", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/testing/testingcert", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/etcd/util", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/etcd3", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/names", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/storagebackend", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/storagebackend/factory", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/testing", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/storage/value", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/dryrun", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/feature", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/flag", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/flushwriter", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/logs", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/openapi", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/trace", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/webhook", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/pkg/util/wsstream", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/buffered", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/log", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/truncate", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/plugin/pkg/audit/webhook", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/plugin/pkg/authenticator/token/webhook", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/apiserver/plugin/pkg/authorizer/webhook", + "Rev": "9601a7bf41efece7e12a8f9f74d2c3b10cdd998e" + }, + { + "ImportPath": "k8s.io/client-go/discovery", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/discovery/fake", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/dynamic", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/admissionregistration", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/admissionregistration/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/admissionregistration/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/apps", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/apps/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/apps/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/apps/v1beta2", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/autoscaling", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/autoscaling/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/autoscaling/v2beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/autoscaling/v2beta2", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/batch", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/batch/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/batch/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/batch/v2alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/certificates", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/certificates/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/coordination", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/coordination/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/core", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/core/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/events", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/events/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/extensions", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/extensions/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/internalinterfaces", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/networking", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/networking/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/policy", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/policy/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/rbac", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/rbac/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/rbac/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/rbac/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/scheduling", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/scheduling/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/scheduling/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/settings", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/settings/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/storage", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/storage/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/storage/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/informers/storage/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/scheme", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/apps/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/apps/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/apps/v1beta2", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/authentication/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/authentication/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/authorization/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/authorization/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/batch/v2alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/certificates/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/coordination/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/core/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/events/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/extensions/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/networking/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/policy/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/rbac/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/rbac/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/settings/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/storage/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/storage/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/kubernetes/typed/storage/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/admissionregistration/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/admissionregistration/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/apps/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/apps/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/apps/v1beta2", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/autoscaling/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/autoscaling/v2beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/autoscaling/v2beta2", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/batch/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/batch/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/batch/v2alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/certificates/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/coordination/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/core/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/events/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/extensions/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/networking/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/policy/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/rbac/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/rbac/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/rbac/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/scheduling/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/scheduling/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/settings/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/storage/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/storage/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/listers/storage/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/pkg/apis/clientauthentication", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/pkg/version", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/plugin/pkg/client/auth/exec", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/rest", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/rest/watch", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/restmapper", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale/scheme", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale/scheme/appsint", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale/scheme/appsv1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale/scheme/appsv1beta2", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale/scheme/autoscalingv1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale/scheme/extensionsint", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/scale/scheme/extensionsv1beta1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/testing", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/third_party/forked/golang/template", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/auth", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/cache", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/clientcmd", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/clientcmd/api", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/clientcmd/api/latest", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/clientcmd/api/v1", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/metrics", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/pager", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/tools/reference", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/transport", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/buffer", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/cert", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/connrotation", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/flowcontrol", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/homedir", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/integer", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/jsonpath", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/retry", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/client-go/util/workqueue", + "Rev": "5e6a3d4e34f694e895b13ae728111e726a5b69df" + }, + { + "ImportPath": "k8s.io/kube-openapi/pkg/builder", + "Rev": "0cf8f7e6ed1d2e3d47d02e3b6e559369af24d803" + }, + { + "ImportPath": "k8s.io/kube-openapi/pkg/common", + "Rev": "0cf8f7e6ed1d2e3d47d02e3b6e559369af24d803" + }, + { + "ImportPath": "k8s.io/kube-openapi/pkg/handler", + "Rev": "0cf8f7e6ed1d2e3d47d02e3b6e559369af24d803" + }, + { + "ImportPath": "k8s.io/kube-openapi/pkg/util", + "Rev": "0cf8f7e6ed1d2e3d47d02e3b6e559369af24d803" + }, + { + "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", + "Rev": "0cf8f7e6ed1d2e3d47d02e3b6e559369af24d803" + } + ] +} diff --git a/vendor/k8s.io/apiextensions-apiserver/Godeps/OWNERS b/vendor/k8s.io/apiextensions-apiserver/Godeps/OWNERS new file mode 100644 index 0000000000..3d49f30605 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/Godeps/OWNERS @@ -0,0 +1,2 @@ +approvers: +- dep-approvers diff --git a/vendor/k8s.io/apiextensions-apiserver/Godeps/Readme b/vendor/k8s.io/apiextensions-apiserver/Godeps/Readme new file mode 100644 index 0000000000..4cdaa53d56 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/Godeps/Readme @@ -0,0 +1,5 @@ +This directory tree is generated automatically by godep. + +Please do not edit. + +See https://github.com/tools/godep for more information. diff --git a/vendor/k8s.io/apiextensions-apiserver/LICENSE b/vendor/k8s.io/apiextensions-apiserver/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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/OWNERS b/vendor/k8s.io/apiextensions-apiserver/OWNERS new file mode 100644 index 0000000000..f76281ad3b --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/OWNERS @@ -0,0 +1,11 @@ +reviewers: +- deads2k +- sttts +- enisoc +- mbohlool +approvers: +- deads2k +- lavalamp +- sttts +labels: +- sig/api-machinery diff --git a/vendor/k8s.io/apiextensions-apiserver/README.md b/vendor/k8s.io/apiextensions-apiserver/README.md new file mode 100644 index 0000000000..be75b9ba49 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/README.md @@ -0,0 +1,20 @@ +# 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 new file mode 100644 index 0000000000..0648a8ebff --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/SECURITY_CONTACTS @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 0000000000..44d07f6413 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-apiservice.yaml @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000000..86205f9dbf --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu-resource-definition.yaml @@ -0,0 +1,13 @@ +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 new file mode 100644 index 0000000000..3cdda5efe6 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/customresource-01/noxu.yaml @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000000..332bb120ae --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/apiservice.yaml @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000000..ef608eced0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-delegator.yaml @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000000..4f0f0e2b64 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/auth-reader.yaml @@ -0,0 +1,13 @@ +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 new file mode 100644 index 0000000000..b42d850829 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/rc.yaml @@ -0,0 +1,26 @@ +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.24 diff --git a/vendor/k8s.io/apiextensions-apiserver/artifacts/example/sa.yaml b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/sa.yaml new file mode 100644 index 0000000000..0f2e17f6a4 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/sa.yaml @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000000..2b66f1d8af --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/example/service.yaml @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000000..c41affec9a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile @@ -0,0 +1,17 @@ +# 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/code-of-conduct.md b/vendor/k8s.io/apiextensions-apiserver/code-of-conduct.md new file mode 100644 index 0000000000..0d15c00cf3 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/code-of-conduct.md @@ -0,0 +1,3 @@ +# Kubernetes Community Code of Conduct + +Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/README.md b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/README.md new file mode 100644 index 0000000000..1949e5d47f --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/README.md @@ -0,0 +1,57 @@ +# 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 new file mode 100755 index 0000000000..ea26ad63cc --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh @@ -0,0 +1,34 @@ +#!/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 new file mode 100755 index 0000000000..d02a6fa395 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/verify-codegen.sh @@ -0,0 +1,48 @@ +#!/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/register.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/register.go new file mode 100644 index 0000000000..6eb299ecae --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/register.go @@ -0,0 +1,21 @@ +/* +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 cr + +const ( + GroupName = "cr.example.apiextensions.k8s.io" +) diff --git a/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/doc.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/doc.go new file mode 100644 index 0000000000..73d79a45d5 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/doc.go @@ -0,0 +1,21 @@ +/* +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 v1 is the v1 version of the API. +// +groupName=cr.example.apiextensions.k8s.io +package v1 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 new file mode 100644 index 0000000000..65b65fb32a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/register.go @@ -0,0 +1,53 @@ +/* +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" + "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{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + 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 new file mode 100644 index 0000000000..274b30f61a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/types.go @@ -0,0 +1,63 @@ +/* +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 new file mode 100644 index 0000000000..50828809de --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1/zz_generated.deepcopy.go @@ -0,0 +1,118 @@ +// +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 new file mode 100644 index 0000000000..92ff158191 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,98 @@ +/* +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/doc.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/doc.go new file mode 100644 index 0000000000..41721ca52d --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +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 versioned 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 new file mode 100644 index 0000000000..28089890db --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,82 @@ +/* +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 new file mode 100644 index 0000000000..9b99e71670 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..1260d0d3a5 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +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" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + crv1.AddToScheme, +} + +// 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. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(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 new file mode 100644 index 0000000000..7dc3756168 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..5743937a95 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +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" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + crv1.AddToScheme, +} + +// 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. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(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 new file mode 100644 index 0000000000..04e3930e14 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/cr_client.go @@ -0,0 +1,90 @@ +/* +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 new file mode 100644 index 0000000000..3af5d054f1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..b9408f1c5a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go @@ -0,0 +1,157 @@ +/* +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" + metav1 "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 *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.Example, error) + List(opts metav1.ListOptions) (*v1.ExampleList, error) + Watch(opts metav1.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 metav1.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 metav1.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 metav1.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 *metav1.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 *metav1.DeleteOptions, listOptions metav1.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/doc.go b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/doc.go new file mode 100644 index 0000000000..16f4439906 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +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/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 new file mode 100644 index 0000000000..5ce9023133 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go @@ -0,0 +1,40 @@ +/* +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 new file mode 100644 index 0000000000..f7f5691ee1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go @@ -0,0 +1,128 @@ +/* +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" + 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 *crv1.Example, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(examplesResource, c.ns, name), &crv1.Example{}) + + if obj == nil { + return nil, err + } + return obj.(*crv1.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 *crv1.ExampleList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(examplesResource, examplesKind, c.ns, opts), &crv1.ExampleList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &crv1.ExampleList{ListMeta: obj.(*crv1.ExampleList).ListMeta} + for _, item := range obj.(*crv1.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 *crv1.Example) (result *crv1.Example, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(examplesResource, c.ns, example), &crv1.Example{}) + + if obj == nil { + return nil, err + } + return obj.(*crv1.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 *crv1.Example) (result *crv1.Example, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(examplesResource, c.ns, example), &crv1.Example{}) + + if obj == nil { + return nil, err + } + return obj.(*crv1.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), &crv1.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, &crv1.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 *crv1.Example, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(examplesResource, c.ns, name, data, subresources...), &crv1.Example{}) + + if obj == nil { + return nil, err + } + return obj.(*crv1.Example), err +} 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/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/generated_expansion.go new file mode 100644 index 0000000000..755021ec40 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +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 + +type ExampleExpansion interface{} 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 new file mode 100644 index 0000000000..0c633e3efe --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/interface.go @@ -0,0 +1,46 @@ +/* +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 new file mode 100644 index 0000000000..2496cd2ce0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/example.go @@ -0,0 +1,89 @@ +/* +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" + + crv1 "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" + metav1 "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 metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CrV1().Examples(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CrV1().Examples(namespace).Watch(options) + }, + }, + &crv1.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(&crv1.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 new file mode 100644 index 0000000000..96ee1514c7 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/interface.go @@ -0,0 +1,45 @@ +/* +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 new file mode 100644 index 0000000000..67c55af392 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,180 @@ +/* +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 new file mode 100644 index 0000000000..2bf6c5a47e --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +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 new file mode 100644 index 0000000000..5b81f037b6 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,38 @@ +/* +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 new file mode 100644 index 0000000000..8a64d09ccb --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/example.go @@ -0,0 +1,94 @@ +/* +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 new file mode 100644 index 0000000000..5291ebaec3 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/listers/cr/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +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 new file mode 100644 index 0000000000..b7c650da47 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/hack/boilerplate.go.txt @@ -0,0 +1,16 @@ +/* +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 new file mode 100755 index 0000000000..d0d129078f --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/hack/build-image.sh @@ -0,0 +1,30 @@ +#!/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 new file mode 100755 index 0000000000..0dc83d07f2 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh @@ -0,0 +1,34 @@ +#!/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. +CLIENTSET_NAME_VERSIONED=clientset \ +CLIENTSET_NAME_INTERNAL=internalclientset \ +${CODEGEN_PKG}/generate-internal-groups.sh all \ + k8s.io/apiextensions-apiserver/pkg/client k8s.io/apiextensions-apiserver/pkg/apis k8s.io/apiextensions-apiserver/pkg/apis \ + "apiextensions:v1beta1" \ + --output-base "$(dirname ${BASH_SOURCE})/../../.." \ + --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 new file mode 100755 index 0000000000..ab43ba23d0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/hack/verify-codegen.sh @@ -0,0 +1,49 @@ +#!/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 new file mode 100644 index 0000000000..888a04b1a4 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/main.go @@ -0,0 +1,40 @@ +/* +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.NewServerCommand(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 new file mode 100644 index 0000000000..37b4d1df9f --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/deepcopy.go @@ -0,0 +1,262 @@ +/* +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 new file mode 100644 index 0000000000..0517ec6a84 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/doc.go @@ -0,0 +1,21 @@ +/* +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 new file mode 100644 index 0000000000..ff8cc03346 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer/fuzzer.go @@ -0,0 +1,142 @@ +/* +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 new file mode 100644 index 0000000000..92cad7d9b7 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers.go @@ -0,0 +1,149 @@ +/* +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 new file mode 100644 index 0000000000..df58a7cbf8 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/helpers_test.go @@ -0,0 +1,421 @@ +/* +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 new file mode 100644 index 0000000000..2fd04b77d3 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/install.go @@ -0,0 +1,31 @@ +/* +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/install/roundtrip_test.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/roundtrip_test.go new file mode 100644 index 0000000000..f199dd5e54 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install/roundtrip_test.go @@ -0,0 +1,28 @@ +/* +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 ( + "testing" + + apiextensionsfuzzer "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer" + "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" +) + +func TestRoundTrip(t *testing.T) { + roundtrip.RoundTripTestForAPIGroup(t, Install, apiextensionsfuzzer.Funcs) +} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/register.go b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/register.go new file mode 100644 index 0000000000..273f7f123b --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/register.go @@ -0,0 +1,51 @@ +/* +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 new file mode 100644 index 0000000000..6fc75154fa --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types.go @@ -0,0 +1,250 @@ +/* +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 new file mode 100644 index 0000000000..79f34e8bf6 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types_jsonschema.go @@ -0,0 +1,96 @@ +/* +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 new file mode 100644 index 0000000000..f9951009dc --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion.go @@ -0,0 +1,73 @@ +/* +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 new file mode 100644 index 0000000000..a697dd9e3a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/conversion_test.go @@ -0,0 +1,113 @@ +/* +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 new file mode 100644 index 0000000000..f6a114e2b3 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/deepcopy.go @@ -0,0 +1,238 @@ +/* +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 new file mode 100644 index 0000000000..e3235e8702 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/defaults.go @@ -0,0 +1,74 @@ +/* +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 new file mode 100644 index 0000000000..50ab2b54c6 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/doc.go @@ -0,0 +1,24 @@ +/* +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 new file mode 100644 index 0000000000..c771e61cb5 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.pb.go @@ -0,0 +1,6022 @@ +/* +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{ + // 2292 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0xdd, 0x6f, 0x5b, 0x49, + 0x15, 0xef, 0xd8, 0x71, 0xe2, 0x8c, 0x93, 0x26, 0x99, 0x6d, 0xca, 0x6d, 0x68, 0xed, 0xd4, 0x65, + 0x57, 0x01, 0xb6, 0x0e, 0x2d, 0xbb, 0xec, 0xb2, 0x12, 0x0f, 0x71, 0x52, 0x50, 0x97, 0xa6, 0x89, + 0xc6, 0x6d, 0x11, 0xec, 0xe7, 0xc4, 0x9e, 0x38, 0xb7, 0xb9, 0x5f, 0xbd, 0x33, 0xd7, 0x4d, 0x24, + 0x40, 0x7c, 0x68, 0x85, 0x84, 0x80, 0x05, 0xb6, 0x42, 0x42, 0xe2, 0x05, 0x24, 0x5e, 0x10, 0x82, + 0x07, 0x78, 0x83, 0x3f, 0xa0, 0x8f, 0xfb, 0xb8, 0x4f, 0x16, 0x35, 0xff, 0x02, 0x12, 0x52, 0x9e, + 0xd0, 0x7c, 0xdc, 0xb9, 0x1f, 0x4e, 0xb6, 0x11, 0x6b, 0x6f, 0xdf, 0x7c, 0xcf, 0x39, 0x73, 0x7e, + 0xbf, 0x39, 0x73, 0xe6, 0xcc, 0x39, 0x09, 0xdc, 0xdd, 0x7f, 0x95, 0x35, 0x6c, 0x7f, 0x75, 0x3f, + 0xda, 0xa1, 0xa1, 0x47, 0x39, 0x65, 0xab, 0x3d, 0xea, 0x75, 0xfc, 0x70, 0x55, 0x2b, 0x48, 0x60, + 0xd3, 0x03, 0x4e, 0x3d, 0x66, 0xfb, 0x1e, 0xbb, 0x4a, 0x02, 0x9b, 0xd1, 0xb0, 0x47, 0xc3, 0xd5, + 0x60, 0xbf, 0x2b, 0x74, 0x2c, 0x6b, 0xb0, 0xda, 0xbb, 0xb6, 0x43, 0x39, 0xb9, 0xb6, 0xda, 0xa5, + 0x1e, 0x0d, 0x09, 0xa7, 0x9d, 0x46, 0x10, 0xfa, 0xdc, 0x47, 0x5f, 0x53, 0xee, 0x1a, 0x19, 0xeb, + 0x77, 0x8c, 0xbb, 0x46, 0xb0, 0xdf, 0x15, 0x3a, 0x96, 0x35, 0x68, 0x68, 0x77, 0x4b, 0x57, 0xbb, + 0x36, 0xdf, 0x8b, 0x76, 0x1a, 0x6d, 0xdf, 0x5d, 0xed, 0xfa, 0x5d, 0x7f, 0x55, 0x7a, 0xdd, 0x89, + 0x76, 0xe5, 0x97, 0xfc, 0x90, 0xbf, 0x14, 0xda, 0xd2, 0x4b, 0x09, 0x79, 0x97, 0xb4, 0xf7, 0x6c, + 0x8f, 0x86, 0x87, 0x09, 0x63, 0x97, 0x72, 0xb2, 0xda, 0x1b, 0xe2, 0xb8, 0xb4, 0x7a, 0xd2, 0xaa, + 0x30, 0xf2, 0xb8, 0xed, 0xd2, 0xa1, 0x05, 0x5f, 0x79, 0xda, 0x02, 0xd6, 0xde, 0xa3, 0x2e, 0xc9, + 0xaf, 0xab, 0x7f, 0x50, 0x80, 0xd5, 0xf5, 0x88, 0x71, 0xdf, 0xc5, 0x94, 0xf9, 0x51, 0xd8, 0xa6, + 0xeb, 0xbe, 0x13, 0xb9, 0xde, 0x06, 0xdd, 0xb5, 0x3d, 0x9b, 0xdb, 0xbe, 0x87, 0x96, 0xe1, 0x84, + 0x47, 0x5c, 0x6a, 0x81, 0x65, 0xb0, 0x32, 0xdd, 0x9c, 0x79, 0xdc, 0xaf, 0x9d, 0x19, 0xf4, 0x6b, + 0x13, 0xb7, 0x89, 0x4b, 0xb1, 0xd4, 0x08, 0x0b, 0x7e, 0x18, 0x50, 0xab, 0x90, 0xb5, 0xb8, 0x73, + 0x18, 0x50, 0x2c, 0x35, 0xe8, 0x05, 0x38, 0xb9, 0xeb, 0x87, 0x2e, 0xe1, 0x56, 0x51, 0xda, 0x9c, + 0xd5, 0x36, 0x93, 0x5f, 0x97, 0x52, 0xac, 0xb5, 0xe8, 0x65, 0x58, 0xe9, 0x50, 0xd6, 0x0e, 0xed, + 0x40, 0x40, 0x5b, 0x13, 0xd2, 0xf8, 0x39, 0x6d, 0x5c, 0xd9, 0x48, 0x54, 0x38, 0x6d, 0x87, 0x5e, + 0x84, 0xe5, 0x20, 0xb4, 0xfd, 0xd0, 0xe6, 0x87, 0x56, 0x69, 0x19, 0xac, 0x94, 0x9a, 0xf3, 0x7a, + 0x4d, 0x79, 0x5b, 0xcb, 0xb1, 0xb1, 0x40, 0xcb, 0xb0, 0xfc, 0x7a, 0x6b, 0xeb, 0xf6, 0x36, 0xe1, + 0x7b, 0xd6, 0xa4, 0x44, 0x98, 0x10, 0xd6, 0xb8, 0x7c, 0x5f, 0x4b, 0xeb, 0x3f, 0x2e, 0x42, 0x2b, + 0x1b, 0x95, 0x54, 0x3c, 0xde, 0x85, 0x65, 0x71, 0x6c, 0x1d, 0xc2, 0x89, 0x8c, 0x49, 0xe5, 0xfa, + 0x97, 0x1a, 0x49, 0x4a, 0x99, 0xe8, 0x27, 0x79, 0x24, 0xac, 0x1b, 0xbd, 0x6b, 0x8d, 0xad, 0x9d, + 0xfb, 0xb4, 0xcd, 0x37, 0x29, 0x27, 0x4d, 0xa4, 0xe9, 0xc1, 0x44, 0x86, 0x8d, 0x57, 0xf4, 0x3d, + 0x38, 0xc1, 0x02, 0xda, 0x96, 0xf1, 0xac, 0x5c, 0x7f, 0xa3, 0xf1, 0x89, 0x12, 0xb6, 0x71, 0xd2, + 0x46, 0x5a, 0x01, 0x6d, 0x27, 0x87, 0x25, 0xbe, 0xb0, 0x84, 0x45, 0xef, 0x01, 0x38, 0xc9, 0x38, + 0xe1, 0x11, 0x93, 0xa7, 0x55, 0xb9, 0xfe, 0xd6, 0xb8, 0x18, 0x48, 0x90, 0x24, 0x19, 0xd4, 0x37, + 0xd6, 0xe0, 0xf5, 0xff, 0x14, 0xe0, 0xe5, 0x93, 0x96, 0xae, 0xfb, 0x5e, 0x47, 0x1d, 0xc7, 0x4d, + 0x9d, 0x7c, 0x2a, 0x3d, 0x5f, 0x4e, 0x27, 0xdf, 0x51, 0xbf, 0xf6, 0xfc, 0x53, 0x1d, 0xa4, 0xb2, + 0xf4, 0xab, 0x66, 0xdf, 0x2a, 0x93, 0x2f, 0x67, 0x89, 0x1d, 0xf5, 0x6b, 0x73, 0x66, 0x59, 0x96, + 0x2b, 0xea, 0x41, 0xe4, 0x10, 0xc6, 0xef, 0x84, 0xc4, 0x63, 0xca, 0xad, 0xed, 0x52, 0x1d, 0xbe, + 0x2f, 0x9c, 0x2e, 0x3d, 0xc4, 0x8a, 0xe6, 0x92, 0x86, 0x44, 0xb7, 0x86, 0xbc, 0xe1, 0x63, 0x10, + 0xc4, 0xc5, 0x0a, 0x29, 0x61, 0xe6, 0xae, 0x98, 0x58, 0x62, 0x29, 0xc5, 0x5a, 0x8b, 0x3e, 0x0f, + 0xa7, 0x5c, 0xca, 0x18, 0xe9, 0x52, 0x79, 0x41, 0xa6, 0x9b, 0x73, 0xda, 0x70, 0x6a, 0x53, 0x89, + 0x71, 0xac, 0xaf, 0x1f, 0x01, 0x78, 0xf1, 0xa4, 0xa8, 0xdd, 0xb2, 0x19, 0x47, 0x6f, 0x0e, 0x5d, + 0x80, 0xc6, 0xe9, 0x76, 0x28, 0x56, 0xcb, 0xf4, 0x37, 0xb7, 0x33, 0x96, 0xa4, 0x92, 0xff, 0xbb, + 0xb0, 0x64, 0x73, 0xea, 0x8a, 0x33, 0x28, 0xae, 0x54, 0xae, 0x7f, 0x6b, 0x4c, 0xb9, 0xd7, 0x9c, + 0xd5, 0x1c, 0x4a, 0x37, 0x05, 0x1a, 0x56, 0xa0, 0xf5, 0x3f, 0x16, 0xe0, 0xa5, 0x93, 0x96, 0x88, + 0x8a, 0xc7, 0x44, 0xc4, 0x03, 0x27, 0x0a, 0x89, 0xa3, 0x33, 0xce, 0x44, 0x7c, 0x5b, 0x4a, 0xb1, + 0xd6, 0x8a, 0x9a, 0xc4, 0x6c, 0xaf, 0x1b, 0x39, 0x24, 0xd4, 0xe9, 0x64, 0x76, 0xdd, 0xd2, 0x72, + 0x6c, 0x2c, 0x50, 0x03, 0x42, 0xb6, 0xe7, 0x87, 0x5c, 0x62, 0x58, 0xc5, 0xe5, 0xa2, 0xf0, 0x2c, + 0x0a, 0x44, 0xcb, 0x48, 0x71, 0xca, 0x42, 0x94, 0xdc, 0x7d, 0xdb, 0xeb, 0xe8, 0x53, 0x37, 0xb7, + 0xf8, 0x9b, 0xb6, 0xd7, 0xc1, 0x52, 0x23, 0xf0, 0x1d, 0x9b, 0x71, 0x21, 0xd1, 0x47, 0x9e, 0x89, + 0xba, 0xb4, 0x34, 0x16, 0x02, 0xbf, 0x4d, 0x38, 0xed, 0xfa, 0xa1, 0x4d, 0x99, 0x35, 0x99, 0xe0, + 0xaf, 0x1b, 0x29, 0x4e, 0x59, 0xd4, 0x7f, 0x35, 0x75, 0x72, 0x92, 0x88, 0x52, 0x82, 0xae, 0xc0, + 0x52, 0x37, 0xf4, 0xa3, 0x40, 0x47, 0xc9, 0x44, 0xfb, 0x1b, 0x42, 0x88, 0x95, 0x4e, 0x64, 0x65, + 0x8f, 0x86, 0xe2, 0xc0, 0x74, 0x88, 0x4c, 0x56, 0xde, 0x53, 0x62, 0x1c, 0xeb, 0xd1, 0x0f, 0x01, + 0x2c, 0x79, 0x3a, 0x38, 0x22, 0xe5, 0xde, 0x1c, 0x53, 0x5e, 0xc8, 0xf0, 0x26, 0x74, 0x55, 0xe4, + 0x15, 0x32, 0x7a, 0x09, 0x96, 0x58, 0xdb, 0x0f, 0xa8, 0x8e, 0x7a, 0x35, 0x36, 0x6a, 0x09, 0xe1, + 0x51, 0xbf, 0x36, 0x1b, 0xbb, 0x93, 0x02, 0xac, 0x8c, 0xd1, 0x4f, 0x00, 0x84, 0x3d, 0xe2, 0xd8, + 0x1d, 0x22, 0xdf, 0xb4, 0x92, 0xa4, 0x3f, 0xda, 0xb4, 0xbe, 0x67, 0xdc, 0xab, 0x43, 0x4b, 0xbe, + 0x71, 0x0a, 0x1a, 0xbd, 0x0f, 0xe0, 0x0c, 0x8b, 0x76, 0x42, 0xbd, 0x8a, 0xc9, 0xd7, 0xaf, 0x72, + 0xfd, 0xdb, 0x23, 0xe5, 0xd2, 0x4a, 0x01, 0x34, 0xe7, 0x07, 0xfd, 0xda, 0x4c, 0x5a, 0x82, 0x33, + 0x04, 0xd0, 0xcf, 0x00, 0x2c, 0xeb, 0x13, 0x66, 0xd6, 0x94, 0xbc, 0xf0, 0x6f, 0x8f, 0xe9, 0x60, + 0x75, 0x46, 0x25, 0xb7, 0x40, 0x0b, 0x18, 0x36, 0x0c, 0xd0, 0x3f, 0x00, 0xb4, 0x48, 0x47, 0x15, + 0x78, 0xe2, 0x6c, 0x87, 0xb6, 0xc7, 0x69, 0xa8, 0x1a, 0x22, 0x66, 0x95, 0x25, 0xbd, 0xd1, 0xbe, + 0x85, 0xf9, 0x66, 0xab, 0xb9, 0xac, 0xd9, 0x59, 0x6b, 0x27, 0xd0, 0xc0, 0x27, 0x12, 0xac, 0xbf, + 0x5f, 0xcc, 0xf7, 0x72, 0xf9, 0xa7, 0x16, 0x3d, 0x02, 0x10, 0xb6, 0xe3, 0x27, 0x8c, 0x59, 0x40, + 0x6e, 0xe9, 0xdd, 0x31, 0x45, 0xdc, 0xbc, 0x95, 0x49, 0xbb, 0x63, 0x44, 0xa2, 0x9a, 0x98, 0xdf, + 0xe8, 0xb7, 0x00, 0xce, 0x92, 0x76, 0x9b, 0x06, 0x9c, 0x76, 0x54, 0x05, 0x2c, 0x7c, 0x0a, 0x97, + 0x7c, 0x51, 0xb3, 0x9a, 0x5d, 0x4b, 0x43, 0xe3, 0x2c, 0x13, 0xf4, 0x1a, 0x3c, 0xcb, 0xb8, 0x1f, + 0xd2, 0x4e, 0x9c, 0x2f, 0xba, 0x3a, 0xa3, 0x41, 0xbf, 0x76, 0xb6, 0x95, 0xd1, 0xe0, 0x9c, 0x65, + 0xfd, 0x37, 0x00, 0xd6, 0x9e, 0x92, 0x8f, 0xa7, 0x68, 0xaf, 0x5f, 0x80, 0x93, 0x72, 0xbb, 0x1d, + 0x19, 0x95, 0x72, 0xaa, 0x5f, 0x92, 0x52, 0xac, 0xb5, 0xa2, 0x9a, 0x0a, 0x7c, 0xf1, 0xc6, 0x17, + 0xa5, 0xa1, 0xa9, 0xa6, 0x2d, 0x25, 0xc6, 0xb1, 0xbe, 0xfe, 0x5f, 0x90, 0x4f, 0x95, 0xd4, 0x25, + 0x6d, 0xb5, 0x89, 0x43, 0xd1, 0x06, 0x9c, 0x17, 0xdd, 0x20, 0xa6, 0x81, 0x63, 0xb7, 0x09, 0x93, + 0xdd, 0xb2, 0xe2, 0x68, 0x69, 0xb7, 0xf3, 0xad, 0x9c, 0x1e, 0x0f, 0xad, 0x40, 0xaf, 0x43, 0xa4, + 0x3a, 0xa4, 0x8c, 0x1f, 0x55, 0xec, 0x4d, 0xaf, 0xd3, 0x1a, 0xb2, 0xc0, 0xc7, 0xac, 0x42, 0xeb, + 0x70, 0xc1, 0x21, 0x3b, 0xd4, 0x69, 0x51, 0x87, 0xb6, 0xb9, 0x1f, 0x4a, 0x57, 0x6a, 0x9e, 0x58, + 0x1c, 0xf4, 0x6b, 0x0b, 0xb7, 0xf2, 0x4a, 0x3c, 0x6c, 0x5f, 0xbf, 0x9c, 0x3f, 0x91, 0xf4, 0xc6, + 0x55, 0xdf, 0xf9, 0xfb, 0x02, 0x5c, 0x3a, 0xb9, 0xa6, 0xa1, 0x1f, 0x25, 0xed, 0xb1, 0xea, 0x7e, + 0xde, 0x1e, 0x57, 0xfd, 0xd4, 0xfd, 0x31, 0x1c, 0xee, 0x8d, 0xd1, 0xf7, 0xc5, 0x53, 0x44, 0x1c, + 0xaa, 0x2f, 0xca, 0x5b, 0x63, 0xa3, 0x20, 0x40, 0x9a, 0xd3, 0xea, 0x95, 0x23, 0x8e, 0x7c, 0xd4, + 0x88, 0x43, 0xeb, 0x7f, 0x02, 0xf9, 0x09, 0x29, 0x79, 0x73, 0xd0, 0xcf, 0x01, 0x9c, 0xf3, 0x03, + 0xea, 0xad, 0x6d, 0xdf, 0xbc, 0xf7, 0xe5, 0x96, 0x1c, 0x3c, 0x75, 0xa8, 0x6e, 0x7f, 0x42, 0x9e, + 0x62, 0x6e, 0x53, 0x0e, 0xb7, 0x43, 0x3f, 0x60, 0xcd, 0xe7, 0x06, 0xfd, 0xda, 0xdc, 0x56, 0x16, + 0x0a, 0xe7, 0xb1, 0xeb, 0x2e, 0x5c, 0xbc, 0x71, 0xc0, 0x69, 0xe8, 0x11, 0x67, 0xc3, 0x6f, 0x47, + 0x2e, 0xf5, 0xb8, 0x22, 0x9a, 0x1b, 0x37, 0xc1, 0x29, 0xc7, 0xcd, 0x4b, 0xb0, 0x18, 0x85, 0x8e, + 0xce, 0xe2, 0x8a, 0x36, 0x2f, 0xde, 0xc5, 0xb7, 0xb0, 0x90, 0xd7, 0x2f, 0xc3, 0x09, 0xc1, 0x13, + 0x5d, 0x80, 0xc5, 0x90, 0x3c, 0x94, 0x5e, 0x67, 0x9a, 0x53, 0xc2, 0x04, 0x93, 0x87, 0x58, 0xc8, + 0xea, 0x7f, 0xbe, 0x08, 0xe7, 0x72, 0x7b, 0x41, 0x4b, 0xb0, 0x60, 0x77, 0x34, 0x07, 0xa8, 0x9d, + 0x16, 0x6e, 0x6e, 0xe0, 0x82, 0xdd, 0x41, 0xaf, 0xc0, 0x49, 0x35, 0xc0, 0x6b, 0xd0, 0x9a, 0x29, + 0x01, 0x52, 0x2a, 0x7a, 0x8f, 0xc4, 0x9d, 0x20, 0xa2, 0xcd, 0x25, 0x07, 0xba, 0xab, 0x6f, 0x89, + 0xe2, 0x40, 0x77, 0xb1, 0x90, 0xfd, 0xbf, 0xb3, 0x76, 0x3c, 0xec, 0x97, 0x4e, 0x31, 0xec, 0x4f, + 0x7e, 0xec, 0xb0, 0x7f, 0x05, 0x96, 0xb8, 0xcd, 0x1d, 0x6a, 0x4d, 0x65, 0x5b, 0xc4, 0x3b, 0x42, + 0x88, 0x95, 0x0e, 0xdd, 0x87, 0x53, 0x1d, 0xba, 0x4b, 0x22, 0x87, 0x5b, 0x65, 0x99, 0x42, 0xeb, + 0x23, 0x48, 0xa1, 0x66, 0x45, 0x54, 0xc5, 0x0d, 0xe5, 0x17, 0xc7, 0x00, 0xe8, 0x79, 0x38, 0xe5, + 0x92, 0x03, 0xdb, 0x8d, 0x5c, 0x6b, 0x7a, 0x19, 0xac, 0x00, 0x65, 0xb6, 0xa9, 0x44, 0x38, 0xd6, + 0x89, 0xca, 0x48, 0x0f, 0xda, 0x4e, 0xc4, 0xec, 0x1e, 0xd5, 0x4a, 0x0b, 0xca, 0x82, 0x6b, 0x2a, + 0xe3, 0x8d, 0x9c, 0x1e, 0x0f, 0xad, 0x90, 0x60, 0xb6, 0x27, 0x17, 0x57, 0x52, 0x60, 0x4a, 0x84, + 0x63, 0x5d, 0x16, 0x4c, 0xdb, 0xcf, 0x9c, 0x04, 0xa6, 0x17, 0x0f, 0xad, 0x40, 0x5f, 0x84, 0xd3, + 0x2e, 0x39, 0xb8, 0x45, 0xbd, 0x2e, 0xdf, 0xb3, 0x66, 0x97, 0xc1, 0x4a, 0xb1, 0x39, 0x3b, 0xe8, + 0xd7, 0xa6, 0x37, 0x63, 0x21, 0x4e, 0xf4, 0xd2, 0xd8, 0xf6, 0xb4, 0xf1, 0xd9, 0x94, 0x71, 0x2c, + 0xc4, 0x89, 0x5e, 0x3c, 0x3a, 0x01, 0xe1, 0xe2, 0x72, 0x59, 0x73, 0xd9, 0x16, 0x7e, 0x5b, 0x89, + 0x71, 0xac, 0x47, 0x2b, 0xb0, 0xec, 0x92, 0x03, 0x39, 0x6e, 0x59, 0xf3, 0xd2, 0xed, 0x8c, 0xe8, + 0xc3, 0x36, 0xb5, 0x0c, 0x1b, 0xad, 0xb4, 0xb4, 0x3d, 0x65, 0xb9, 0x90, 0xb2, 0xd4, 0x32, 0x6c, + 0xb4, 0x22, 0x89, 0x23, 0xcf, 0x7e, 0x10, 0x51, 0x65, 0x8c, 0x64, 0x64, 0x4c, 0x12, 0xdf, 0x4d, + 0x54, 0x38, 0x6d, 0x27, 0xc6, 0x1d, 0x37, 0x72, 0xb8, 0x1d, 0x38, 0x74, 0x6b, 0xd7, 0x7a, 0x4e, + 0xc6, 0x5f, 0x76, 0xce, 0x9b, 0x46, 0x8a, 0x53, 0x16, 0x88, 0xc2, 0x09, 0xea, 0x45, 0xae, 0x75, + 0x4e, 0x36, 0x4c, 0x23, 0x49, 0x41, 0x73, 0x73, 0x6e, 0x78, 0x91, 0x8b, 0xa5, 0x7b, 0xf4, 0x0a, + 0x9c, 0x75, 0xc9, 0x81, 0x28, 0x07, 0x34, 0xe4, 0x62, 0x10, 0x5b, 0x94, 0x9b, 0x5f, 0x10, 0x4d, + 0xca, 0x66, 0x5a, 0x81, 0xb3, 0x76, 0x72, 0xa1, 0xed, 0xa5, 0x16, 0x9e, 0x4f, 0x2d, 0x4c, 0x2b, + 0x70, 0xd6, 0x4e, 0x44, 0x3a, 0xa4, 0x0f, 0x22, 0x3b, 0xa4, 0x1d, 0xeb, 0x33, 0xb2, 0xaf, 0x91, + 0x91, 0xc6, 0x5a, 0x86, 0x8d, 0x16, 0xf5, 0xe2, 0xb9, 0xdc, 0x92, 0xd7, 0xf0, 0xee, 0x68, 0x2b, + 0xf9, 0x56, 0xb8, 0x16, 0x86, 0xe4, 0x50, 0xbd, 0x34, 0xe9, 0x89, 0x1c, 0x31, 0x58, 0x22, 0x8e, + 0xb3, 0xb5, 0x6b, 0x5d, 0x90, 0xb1, 0x1f, 0xf5, 0x0b, 0x62, 0xaa, 0xce, 0x9a, 0x00, 0xc1, 0x0a, + 0x4b, 0x80, 0xfa, 0x9e, 0x48, 0x8d, 0xa5, 0xf1, 0x82, 0x6e, 0x09, 0x10, 0xac, 0xb0, 0xe4, 0x4e, + 0xbd, 0xc3, 0xad, 0x5d, 0xeb, 0xb3, 0x63, 0xde, 0xa9, 0x00, 0xc1, 0x0a, 0x0b, 0xd9, 0xb0, 0xe8, + 0xf9, 0xdc, 0xba, 0x38, 0x96, 0xe7, 0x59, 0x3e, 0x38, 0xb7, 0x7d, 0x8e, 0x05, 0x06, 0xfa, 0x35, + 0x80, 0x30, 0x48, 0x52, 0xf4, 0xd2, 0x48, 0xc6, 0xbd, 0x1c, 0x64, 0x23, 0xc9, 0xed, 0x1b, 0x1e, + 0x0f, 0x0f, 0x93, 0xd1, 0x23, 0x75, 0x07, 0x52, 0x2c, 0xd0, 0x1f, 0x00, 0x3c, 0x97, 0x9e, 0xa8, + 0x0c, 0xbd, 0xaa, 0x8c, 0xc8, 0x9d, 0x51, 0xa7, 0x79, 0xd3, 0xf7, 0x9d, 0xa6, 0x35, 0xe8, 0xd7, + 0xce, 0xad, 0x1d, 0x83, 0x8a, 0x8f, 0xe5, 0x82, 0xfe, 0x02, 0xe0, 0x82, 0xae, 0xa2, 0x29, 0x86, + 0x35, 0x19, 0x40, 0x3a, 0xea, 0x00, 0xe6, 0x71, 0x54, 0x1c, 0x2f, 0xe8, 0x38, 0x2e, 0x0c, 0xe9, + 0xf1, 0x30, 0x35, 0xf4, 0x77, 0x00, 0x67, 0x3a, 0x34, 0xa0, 0x5e, 0x87, 0x7a, 0x6d, 0xc1, 0x75, + 0x79, 0x24, 0x93, 0x66, 0x9e, 0xeb, 0x46, 0x0a, 0x42, 0xd1, 0x6c, 0x68, 0x9a, 0x33, 0x69, 0xd5, + 0x51, 0xbf, 0x76, 0x3e, 0x59, 0x9a, 0xd6, 0xe0, 0x0c, 0x4b, 0xf4, 0x01, 0x80, 0x73, 0xc9, 0x01, + 0xa8, 0x27, 0xe5, 0xf2, 0x18, 0xf3, 0x40, 0xb6, 0xaf, 0x6b, 0x59, 0x40, 0x9c, 0x67, 0x80, 0xfe, + 0x0a, 0x44, 0xa7, 0x16, 0xcf, 0x8d, 0xcc, 0xaa, 0xcb, 0x58, 0xbe, 0x33, 0xf2, 0x58, 0x1a, 0x04, + 0x15, 0xca, 0x17, 0x93, 0x56, 0xd0, 0x68, 0x8e, 0xfa, 0xb5, 0xc5, 0x74, 0x24, 0x8d, 0x02, 0xa7, + 0x19, 0xa2, 0x9f, 0x02, 0x38, 0x43, 0x93, 0x8e, 0x9b, 0x59, 0x57, 0x46, 0x12, 0xc4, 0x63, 0x9b, + 0x78, 0xf5, 0x37, 0xa6, 0x94, 0x8a, 0xe1, 0x0c, 0xb6, 0xe8, 0x20, 0xe9, 0x01, 0x71, 0x03, 0x87, + 0x5a, 0x9f, 0x1b, 0x71, 0x07, 0x79, 0x43, 0xf9, 0xc5, 0x31, 0xc0, 0x92, 0x98, 0x7c, 0x72, 0x37, + 0x07, 0xcd, 0xc3, 0xe2, 0x3e, 0x3d, 0x54, 0x8d, 0x3d, 0x16, 0x3f, 0x51, 0x07, 0x96, 0x7a, 0xc4, + 0x89, 0xe2, 0xe1, 0x6d, 0xc4, 0x55, 0x17, 0x2b, 0xe7, 0xaf, 0x15, 0x5e, 0x05, 0x4b, 0x8f, 0x00, + 0x3c, 0x7f, 0xfc, 0x85, 0x7e, 0xa6, 0xb4, 0x7e, 0x07, 0xe0, 0xc2, 0xd0, 0xdd, 0x3d, 0x86, 0xd1, + 0x83, 0x2c, 0xa3, 0x37, 0x46, 0x7d, 0x09, 0x5b, 0x3c, 0xb4, 0xbd, 0xae, 0xec, 0x3c, 0xd2, 0xf4, + 0x7e, 0x01, 0xe0, 0x7c, 0xfe, 0x3a, 0x3c, 0xcb, 0x78, 0xd5, 0x1f, 0x15, 0xe0, 0xf9, 0xe3, 0x1b, + 0x26, 0x14, 0x9a, 0xc9, 0x70, 0x3c, 0x13, 0x36, 0x4c, 0xa6, 0x4c, 0x33, 0x54, 0xbe, 0x07, 0x60, + 0xe5, 0xbe, 0xb1, 0x8b, 0xff, 0x53, 0x33, 0xf2, 0xd9, 0x3e, 0xae, 0x3f, 0x89, 0x82, 0xe1, 0x34, + 0x6e, 0xfd, 0x6f, 0x00, 0x2e, 0x1e, 0x5b, 0x58, 0xc5, 0x08, 0x4a, 0x1c, 0xc7, 0x7f, 0xa8, 0xfe, + 0x44, 0x93, 0xfa, 0x93, 0xd9, 0x9a, 0x94, 0x62, 0xad, 0x4d, 0x45, 0xaf, 0xf0, 0x69, 0x45, 0xaf, + 0xfe, 0x4f, 0x00, 0x2f, 0x7e, 0x5c, 0x26, 0x3e, 0x93, 0x23, 0x5d, 0x81, 0x65, 0xdd, 0x14, 0x1d, + 0xca, 0xe3, 0xd4, 0x73, 0x80, 0x2e, 0x1a, 0xf2, 0xbf, 0xe7, 0xea, 0x57, 0xf3, 0xea, 0xe3, 0x27, + 0xd5, 0x33, 0x1f, 0x3e, 0xa9, 0x9e, 0xf9, 0xe8, 0x49, 0xf5, 0xcc, 0x0f, 0x06, 0x55, 0xf0, 0x78, + 0x50, 0x05, 0x1f, 0x0e, 0xaa, 0xe0, 0xa3, 0x41, 0x15, 0xfc, 0x6b, 0x50, 0x05, 0xbf, 0xfc, 0x77, + 0xf5, 0xcc, 0x77, 0xa6, 0x34, 0xf8, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x5b, 0x62, 0x04, + 0xd6, 0x21, 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 new file mode 100644 index 0000000000..b23163d04a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto @@ -0,0 +1,365 @@ +/* +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"; + +// 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 + optional string format = 3; + + // description is a human readable description of this column. + // +optional + 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 + 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 + 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 + optional string singular = 2; + + // ShortNames are short names for the resource. It must be all lowercase. + // +optional + 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 + 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. + // +optional + repeated CustomResourceDefinitionVersion versions = 7; + + // AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column. + // +optional + 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 + optional CustomResourceSubresourceStatus status = 1; + + // Scale denotes the scale subresource for CustomResources + // +optional + 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 + 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 new file mode 100644 index 0000000000..9a8fad3b77 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal.go @@ -0,0 +1,135 @@ +/* +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 new file mode 100644 index 0000000000..99065ff95a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/marshal_test.go @@ -0,0 +1,150 @@ +/* +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 new file mode 100644 index 0000000000..77f849975f --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/register.go @@ -0,0 +1,61 @@ +/* +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 new file mode 100644 index 0000000000..cab705d927 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.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 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. + // +optional + 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. + // +optional + 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. + // +optional + Format string `json:"format,omitempty" protobuf:"bytes,3,opt,name=format"` + // description is a human readable description of this column. + // +optional + 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. + // +optional + 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 + // +optional + Singular string `json:"singular,omitempty" protobuf:"bytes,2,opt,name=singular"` + // ShortNames are short names for the resource. It must be all lowercase. + // +optional + 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. + // +optional + 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" protobuf:"bytes,2,opt,name=spec"` + // Status indicates the actual state of the CustomResourceDefinition + // +optional + 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. + // +optional + 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 + // +optional + Status *CustomResourceSubresourceStatus `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"` + // Scale denotes the scale subresource for CustomResources + // +optional + 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 new file mode 100644 index 0000000000..9776731cf9 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types_jsonschema.go @@ -0,0 +1,150 @@ +/* +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 new file mode 100644 index 0000000000..32fe1c8af9 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.conversion.go @@ -0,0 +1,1125 @@ +// +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(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*CustomResourceColumnDefinition)(nil), (*apiextensions.CustomResourceColumnDefinition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceColumnDefinition_To_apiextensions_CustomResourceColumnDefinition(a.(*CustomResourceColumnDefinition), b.(*apiextensions.CustomResourceColumnDefinition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceColumnDefinition)(nil), (*CustomResourceColumnDefinition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceColumnDefinition_To_v1beta1_CustomResourceColumnDefinition(a.(*apiextensions.CustomResourceColumnDefinition), b.(*CustomResourceColumnDefinition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinition)(nil), (*apiextensions.CustomResourceDefinition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(a.(*CustomResourceDefinition), b.(*apiextensions.CustomResourceDefinition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceDefinition)(nil), (*CustomResourceDefinition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceDefinition_To_v1beta1_CustomResourceDefinition(a.(*apiextensions.CustomResourceDefinition), b.(*CustomResourceDefinition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinitionCondition)(nil), (*apiextensions.CustomResourceDefinitionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition(a.(*CustomResourceDefinitionCondition), b.(*apiextensions.CustomResourceDefinitionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceDefinitionCondition)(nil), (*CustomResourceDefinitionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceDefinitionCondition_To_v1beta1_CustomResourceDefinitionCondition(a.(*apiextensions.CustomResourceDefinitionCondition), b.(*CustomResourceDefinitionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinitionList)(nil), (*apiextensions.CustomResourceDefinitionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList(a.(*CustomResourceDefinitionList), b.(*apiextensions.CustomResourceDefinitionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceDefinitionList)(nil), (*CustomResourceDefinitionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceDefinitionList_To_v1beta1_CustomResourceDefinitionList(a.(*apiextensions.CustomResourceDefinitionList), b.(*CustomResourceDefinitionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinitionNames)(nil), (*apiextensions.CustomResourceDefinitionNames)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(a.(*CustomResourceDefinitionNames), b.(*apiextensions.CustomResourceDefinitionNames), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceDefinitionNames)(nil), (*CustomResourceDefinitionNames)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceDefinitionNames_To_v1beta1_CustomResourceDefinitionNames(a.(*apiextensions.CustomResourceDefinitionNames), b.(*CustomResourceDefinitionNames), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinitionSpec)(nil), (*apiextensions.CustomResourceDefinitionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(a.(*CustomResourceDefinitionSpec), b.(*apiextensions.CustomResourceDefinitionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceDefinitionSpec)(nil), (*CustomResourceDefinitionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceDefinitionSpec_To_v1beta1_CustomResourceDefinitionSpec(a.(*apiextensions.CustomResourceDefinitionSpec), b.(*CustomResourceDefinitionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinitionStatus)(nil), (*apiextensions.CustomResourceDefinitionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(a.(*CustomResourceDefinitionStatus), b.(*apiextensions.CustomResourceDefinitionStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceDefinitionStatus)(nil), (*CustomResourceDefinitionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceDefinitionStatus_To_v1beta1_CustomResourceDefinitionStatus(a.(*apiextensions.CustomResourceDefinitionStatus), b.(*CustomResourceDefinitionStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceDefinitionVersion)(nil), (*apiextensions.CustomResourceDefinitionVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceDefinitionVersion_To_apiextensions_CustomResourceDefinitionVersion(a.(*CustomResourceDefinitionVersion), b.(*apiextensions.CustomResourceDefinitionVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceDefinitionVersion)(nil), (*CustomResourceDefinitionVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceDefinitionVersion_To_v1beta1_CustomResourceDefinitionVersion(a.(*apiextensions.CustomResourceDefinitionVersion), b.(*CustomResourceDefinitionVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceSubresourceScale)(nil), (*apiextensions.CustomResourceSubresourceScale)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceSubresourceScale_To_apiextensions_CustomResourceSubresourceScale(a.(*CustomResourceSubresourceScale), b.(*apiextensions.CustomResourceSubresourceScale), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceSubresourceScale)(nil), (*CustomResourceSubresourceScale)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceSubresourceScale_To_v1beta1_CustomResourceSubresourceScale(a.(*apiextensions.CustomResourceSubresourceScale), b.(*CustomResourceSubresourceScale), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceSubresourceStatus)(nil), (*apiextensions.CustomResourceSubresourceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceSubresourceStatus_To_apiextensions_CustomResourceSubresourceStatus(a.(*CustomResourceSubresourceStatus), b.(*apiextensions.CustomResourceSubresourceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceSubresourceStatus)(nil), (*CustomResourceSubresourceStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceSubresourceStatus_To_v1beta1_CustomResourceSubresourceStatus(a.(*apiextensions.CustomResourceSubresourceStatus), b.(*CustomResourceSubresourceStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceSubresources)(nil), (*apiextensions.CustomResourceSubresources)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceSubresources_To_apiextensions_CustomResourceSubresources(a.(*CustomResourceSubresources), b.(*apiextensions.CustomResourceSubresources), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceSubresources)(nil), (*CustomResourceSubresources)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceSubresources_To_v1beta1_CustomResourceSubresources(a.(*apiextensions.CustomResourceSubresources), b.(*CustomResourceSubresources), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CustomResourceValidation)(nil), (*apiextensions.CustomResourceValidation)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CustomResourceValidation_To_apiextensions_CustomResourceValidation(a.(*CustomResourceValidation), b.(*apiextensions.CustomResourceValidation), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.CustomResourceValidation)(nil), (*CustomResourceValidation)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_CustomResourceValidation_To_v1beta1_CustomResourceValidation(a.(*apiextensions.CustomResourceValidation), b.(*CustomResourceValidation), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ExternalDocumentation)(nil), (*apiextensions.ExternalDocumentation)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ExternalDocumentation_To_apiextensions_ExternalDocumentation(a.(*ExternalDocumentation), b.(*apiextensions.ExternalDocumentation), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.ExternalDocumentation)(nil), (*ExternalDocumentation)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_ExternalDocumentation_To_v1beta1_ExternalDocumentation(a.(*apiextensions.ExternalDocumentation), b.(*ExternalDocumentation), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*JSON)(nil), (*apiextensions.JSON)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JSON_To_apiextensions_JSON(a.(*JSON), b.(*apiextensions.JSON), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.JSON)(nil), (*JSON)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_JSON_To_v1beta1_JSON(a.(*apiextensions.JSON), b.(*JSON), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*JSONSchemaProps)(nil), (*apiextensions.JSONSchemaProps)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(a.(*JSONSchemaProps), b.(*apiextensions.JSONSchemaProps), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.JSONSchemaProps)(nil), (*JSONSchemaProps)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(a.(*apiextensions.JSONSchemaProps), b.(*JSONSchemaProps), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*JSONSchemaPropsOrArray)(nil), (*apiextensions.JSONSchemaPropsOrArray)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JSONSchemaPropsOrArray_To_apiextensions_JSONSchemaPropsOrArray(a.(*JSONSchemaPropsOrArray), b.(*apiextensions.JSONSchemaPropsOrArray), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.JSONSchemaPropsOrArray)(nil), (*JSONSchemaPropsOrArray)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_JSONSchemaPropsOrArray_To_v1beta1_JSONSchemaPropsOrArray(a.(*apiextensions.JSONSchemaPropsOrArray), b.(*JSONSchemaPropsOrArray), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*JSONSchemaPropsOrBool)(nil), (*apiextensions.JSONSchemaPropsOrBool)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JSONSchemaPropsOrBool_To_apiextensions_JSONSchemaPropsOrBool(a.(*JSONSchemaPropsOrBool), b.(*apiextensions.JSONSchemaPropsOrBool), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.JSONSchemaPropsOrBool)(nil), (*JSONSchemaPropsOrBool)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_JSONSchemaPropsOrBool_To_v1beta1_JSONSchemaPropsOrBool(a.(*apiextensions.JSONSchemaPropsOrBool), b.(*JSONSchemaPropsOrBool), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*JSONSchemaPropsOrStringArray)(nil), (*apiextensions.JSONSchemaPropsOrStringArray)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JSONSchemaPropsOrStringArray_To_apiextensions_JSONSchemaPropsOrStringArray(a.(*JSONSchemaPropsOrStringArray), b.(*apiextensions.JSONSchemaPropsOrStringArray), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiextensions.JSONSchemaPropsOrStringArray)(nil), (*JSONSchemaPropsOrStringArray)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_JSONSchemaPropsOrStringArray_To_v1beta1_JSONSchemaPropsOrStringArray(a.(*apiextensions.JSONSchemaPropsOrStringArray), b.(*JSONSchemaPropsOrStringArray), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiextensions.JSONSchemaProps)(nil), (*JSONSchemaProps)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(a.(*apiextensions.JSONSchemaProps), b.(*JSONSchemaProps), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiextensions.JSON)(nil), (*JSON)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiextensions_JSON_To_v1beta1_JSON(a.(*apiextensions.JSON), b.(*JSON), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*JSON)(nil), (*apiextensions.JSON)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_JSON_To_apiextensions_JSON(a.(*JSON), b.(*apiextensions.JSON), scope) + }); err != nil { + return err + } + return nil +} + +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 new file mode 100644 index 0000000000..5e14efbc84 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,470 @@ +// +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 + *out = new(CustomResourceValidation) + (*in).DeepCopyInto(*out) + } + if in.Subresources != nil { + in, out := &in.Subresources, &out.Subresources + *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 + *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 + *out = new(CustomResourceSubresourceStatus) + **out = **in + } + if in.Scale != nil { + in, out := &in.Scale, &out.Scale + *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 + *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 + *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 + *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 + *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 new file mode 100644 index 0000000000..f65f47a03b --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/zz_generated.defaults.go @@ -0,0 +1,48 @@ +// +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 new file mode 100644 index 0000000000..0568bc1810 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go @@ -0,0 +1,546 @@ +/* +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("name"), "")) + } + + 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("JSONPath"), "")) + } else if errs := validateSimpleJSONPath(col.JSONPath, fldPath.Child("JSONPath")); 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 the status subresource is enabled, only certain fields are allowed inside the root schema. + // these fields are chosen such that, if status is extracted as properties["status"], it's validation is not lost. + 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 + } + + fieldName := v.Type().Field(i).Name + + // only "object" type is valid at root of the schema since validation schema for status is extracted as properties["status"] + if fieldName == "Type" { + if schema.Type != "object" { + allErrs = append(allErrs, field.Invalid(fldPath.Child("openAPIV3Schema.type"), schema.Type, fmt.Sprintf(`only "object" is allowed as the type at the root of the schema if the status subresource is enabled`))) + break + } + continue + } + + if !allowedAtRootSchema(fieldName) { + allErrs = append(allErrs, field.Invalid(fldPath.Child("openAPIV3Schema"), *schema, fmt.Sprintf(`only %v fields are allowed at the root of the schema if the status subresource is enabled`, allowedFieldsAtRootSchema))) + 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 +} + +var allowedFieldsAtRootSchema = []string{"Description", "Type", "Format", "Title", "Maximum", "ExclusiveMaximum", "Minimum", "ExclusiveMinimum", "MaxLength", "MinLength", "Pattern", "MaxItems", "MinItems", "UniqueItems", "MultipleOf", "Required", "Items", "Properties", "ExternalDocs", "Example"} + +func allowedAtRootSchema(field string) bool { + for _, v := range allowedFieldsAtRootSchema { + if field == v { + return true + } + } + return false +} 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 new file mode 100644 index 0000000000..794142b707 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation_test.go @@ -0,0 +1,926 @@ +/* +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: "string", + }, + }, + statusEnabled: false, + wantError: false, + }, + { + name: "root type having invalid value, with status", + input: apiextensions.CustomResourceValidation{ + OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ + Type: "string", + }, + }, + statusEnabled: true, + wantError: true, + }, + { + name: "non-allowed root field with status", + input: apiextensions.CustomResourceValidation{ + OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ + AnyOf: []apiextensions.JSONSchemaProps{ + { + Description: "First schema", + }, + { + Description: "Second schema", + }, + }, + }, + }, + statusEnabled: true, + wantError: true, + }, + { + name: "all allowed fields at the root of the schema with status", + input: apiextensions.CustomResourceValidation{ + OpenAPIV3Schema: &apiextensions.JSONSchemaProps{ + Description: "This is a description", + Type: "object", + Format: "date-time", + Title: "This is a title", + Maximum: float64Ptr(10), + ExclusiveMaximum: true, + Minimum: float64Ptr(5), + ExclusiveMinimum: true, + MaxLength: int64Ptr(10), + MinLength: int64Ptr(5), + Pattern: "^[a-z]$", + MaxItems: int64Ptr(10), + MinItems: int64Ptr(5), + MultipleOf: float64Ptr(3), + Required: []string{"spec", "status"}, + Items: &apiextensions.JSONSchemaPropsOrArray{ + Schema: &apiextensions.JSONSchemaProps{ + Description: "This is a schema nested under Items", + }, + }, + Properties: map[string]apiextensions.JSONSchemaProps{ + "spec": {}, + "status": {}, + }, + ExternalDocs: &apiextensions.ExternalDocumentation{ + Description: "This is an external documentation description", + }, + Example: &example, + }, + }, + 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") + } + }) + } +} + +var example = apiextensions.JSON(`"This is an example"`) + +func float64Ptr(f float64) *float64 { + return &f +} + +func int64Ptr(f int64) *int64 { + return &f +} 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 new file mode 100644 index 0000000000..50e7ee880e --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/zz_generated.deepcopy.go @@ -0,0 +1,449 @@ +// +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 + *out = new(CustomResourceValidation) + (*in).DeepCopyInto(*out) + } + if in.Subresources != nil { + in, out := &in.Subresources, &out.Subresources + *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 + *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 + *out = new(CustomResourceSubresourceStatus) + **out = **in + } + if in.Scale != nil { + in, out := &in.Scale, &out.Scale + *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 + *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 + *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 + *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 + *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 new file mode 100644 index 0000000000..f1fc89ba96 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go @@ -0,0 +1,214 @@ +/* +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 new file mode 100644 index 0000000000..a66f82969d --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/converter.go @@ -0,0 +1,117 @@ +/* +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(gvk schema.GroupVersionKind, 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(gvk schema.GroupVersionKind, label, value string) (string, string, error) { + return c.unsafe.ConvertFieldLabel(gvk, 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 new file mode 100644 index 0000000000..7fae813759 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/nop_converter.go @@ -0,0 +1,79 @@ +/* +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(gvk schema.GroupVersionKind, 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 new file mode 100644 index 0000000000..f40c33791b --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery.go @@ -0,0 +1,127 @@ +/* +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 new file mode 100644 index 0000000000..e3b3d0a441 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery_controller.go @@ -0,0 +1,275 @@ +/* +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 new file mode 100644 index 0000000000..697c5e591a --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go @@ -0,0 +1,895 @@ +/* +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/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" + "k8s.io/apiextensions-apiserver/pkg/crdserverscheme" + 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, "crdNegotiatedSerializer") +} + +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: crdserverscheme.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 + CountMetricPollPeriod time.Duration +} + +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, + CountMetricPollPeriod: t.CountMetricPollPeriod, + } + 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{}, + crdserverscheme.NewUnstructuredObjectTyper(), + &unstructuredDefaulter{delegate: Scheme}, + t.encoderVersion, + t.decoderVersion, + "crdRESTOptions", + ) + } + 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(gvk schema.GroupVersionKind, label, value string) (string, string, error) { + return v.delegate.ConvertFieldLabel(gvk, 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 new file mode 100644 index 0000000000..fa7c84e663 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler_test.go @@ -0,0 +1,309 @@ +/* +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/apitesting/fuzzer" + "k8s.io/apimachinery/pkg/api/equality" + 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/schema" + "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(schema.GroupVersionKind{}, 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 new file mode 100644 index 0000000000..8d9bb24f87 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/jsonpath_test.go @@ -0,0 +1,235 @@ +/* +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 new file mode 100644 index 0000000000..558ddb1fcd --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go @@ -0,0 +1,249 @@ +/* +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 new file mode 100644 index 0000000000..ef73c008b0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go @@ -0,0 +1,87 @@ +/* +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" + + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + apiequality "k8s.io/apimachinery/pkg/api/equality" + "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 new file mode 100644 index 0000000000..63fcb510ab --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/clientset.go @@ -0,0 +1,98 @@ +/* +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 new file mode 100644 index 0000000000..ee865e56d1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..e65fe63eae --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/clientset_generated.go @@ -0,0 +1,82 @@ +/* +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 new file mode 100644 index 0000000000..9b99e71670 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..c4c1d2ba8c --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake/register.go @@ -0,0 +1,56 @@ +/* +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" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + apiextensionsv1beta1.AddToScheme, +} + +// 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. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(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 new file mode 100644 index 0000000000..7dc3756168 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..4232ce5ce1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme/register.go @@ -0,0 +1,56 @@ +/* +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" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + apiextensionsv1beta1.AddToScheme, +} + +// 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. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(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 new file mode 100644 index 0000000000..a1fd337f98 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/apiextensions_client.go @@ -0,0 +1,90 @@ +/* +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 new file mode 100644 index 0000000000..f25a6ce345 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go @@ -0,0 +1,163 @@ +/* +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 new file mode 100644 index 0000000000..771101956f --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..16f4439906 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..288683ef97 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go @@ -0,0 +1,40 @@ +/* +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 new file mode 100644 index 0000000000..11aefe8696 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go @@ -0,0 +1,131 @@ +/* +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/clientset/typed/apiextensions/v1beta1/generated_expansion.go b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/generated_expansion.go new file mode 100644 index 0000000000..2a989d4bea --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +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 + +type CustomResourceDefinitionExpansion interface{} 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 new file mode 100644 index 0000000000..152a9fea00 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/clientset.go @@ -0,0 +1,90 @@ +/* +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 new file mode 100644 index 0000000000..01b3d5e0f6 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..72ab169e99 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/clientset_generated.go @@ -0,0 +1,77 @@ +/* +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 new file mode 100644 index 0000000000..9b99e71670 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..884c7095db --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/fake/register.go @@ -0,0 +1,56 @@ +/* +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" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + apiextensionsinternalversion.AddToScheme, +} + +// 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. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(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 new file mode 100644 index 0000000000..7dc3756168 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..01df98a6be --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/scheme/register.go @@ -0,0 +1,41 @@ +/* +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 new file mode 100644 index 0000000000..31b34404c4 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/apiextensions_client.go @@ -0,0 +1,96 @@ +/* +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 new file mode 100644 index 0000000000..f3ddc8044b --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/customresourcedefinition.go @@ -0,0 +1,163 @@ +/* +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 new file mode 100644 index 0000000000..86602442ba --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..16f4439906 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/doc.go @@ -0,0 +1,20 @@ +/* +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 new file mode 100644 index 0000000000..1a601e5b09 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_apiextensions_client.go @@ -0,0 +1,40 @@ +/* +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 new file mode 100644 index 0000000000..74016362d6 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake/fake_customresourcedefinition.go @@ -0,0 +1,131 @@ +/* +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 new file mode 100644 index 0000000000..a888210213 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/generated_expansion.go @@ -0,0 +1,21 @@ +/* +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 new file mode 100644 index 0000000000..7b48c57ca4 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/interface.go @@ -0,0 +1,46 @@ +/* +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 new file mode 100644 index 0000000000..05e8c42179 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/customresourcedefinition.go @@ -0,0 +1,88 @@ +/* +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" + + apiextensionsv1beta1 "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) + }, + }, + &apiextensionsv1beta1.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(&apiextensionsv1beta1.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 new file mode 100644 index 0000000000..f78edbb593 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/interface.go @@ -0,0 +1,45 @@ +/* +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 new file mode 100644 index 0000000000..94d039c729 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,180 @@ +/* +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 new file mode 100644 index 0000000000..da8a2ab0c6 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +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 new file mode 100644 index 0000000000..3b17f5a1a5 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,38 @@ +/* +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 new file mode 100644 index 0000000000..8236e2acce --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/interface.go @@ -0,0 +1,46 @@ +/* +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 new file mode 100644 index 0000000000..2c54f3ce5f --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/customresourcedefinition.go @@ -0,0 +1,88 @@ +/* +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 new file mode 100644 index 0000000000..d9444144b1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/apiextensions/internalversion/interface.go @@ -0,0 +1,45 @@ +/* +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 new file mode 100644 index 0000000000..84b04523d2 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/factory.go @@ -0,0 +1,180 @@ +/* +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 new file mode 100644 index 0000000000..c12c440749 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/generic.go @@ -0,0 +1,62 @@ +/* +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 new file mode 100644 index 0000000000..5854db0ca0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/informers/internalversion/internalinterfaces/factory_interfaces.go @@ -0,0 +1,38 @@ +/* +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 new file mode 100644 index 0000000000..f64f01d9d0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/customresourcedefinition.go @@ -0,0 +1,65 @@ +/* +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 new file mode 100644 index 0000000000..5e3ae381dd --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/internalversion/expansion_generated.go @@ -0,0 +1,23 @@ +/* +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 new file mode 100644 index 0000000000..87633217b0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/customresourcedefinition.go @@ -0,0 +1,65 @@ +/* +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 new file mode 100644 index 0000000000..429782deb0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1/expansion_generated.go @@ -0,0 +1,23 @@ +/* +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/options/options.go b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go new file mode 100644 index 0000000000..995a315555 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go @@ -0,0 +1,116 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package options + +import ( + "fmt" + "io" + "net" + + "github.com/spf13/pflag" + + "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" + +// CustomResourceDefinitionsServerOptions describes the runtime options of an apiextensions-apiserver. +type CustomResourceDefinitionsServerOptions struct { + RecommendedOptions *genericoptions.RecommendedOptions + APIEnablement *genericoptions.APIEnablementOptions + + StdOut io.Writer + StdErr io.Writer +} + +// NewCustomResourceDefinitionsServerOptions creates default options of an apiextensions-apiserver. +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, + } + + return o +} + +// AddFlags adds the apiextensions-apiserver flags to the flagset. +func (o CustomResourceDefinitionsServerOptions) AddFlags(fs *pflag.FlagSet) { + o.RecommendedOptions.AddFlags(fs) + o.APIEnablement.AddFlags(fs) +} + +// Validate validates the apiextensions-apiserver options. +func (o CustomResourceDefinitionsServerOptions) Validate() error { + errors := []error{} + errors = append(errors, o.RecommendedOptions.Validate()...) + errors = append(errors, o.APIEnablement.Validate(apiserver.Scheme)...) + return utilerrors.NewAggregate(errors) +} + +// Complete fills in missing options. +func (o *CustomResourceDefinitionsServerOptions) Complete() error { + return nil +} + +// Config returns an apiextensions-apiserver configuration. +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 +} + +// NewCRDRESTOptionsGetter create a RESTOptionsGetter for CustomResources. +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, + CountMetricPollPeriod: etcdOptions.StorageConfig.CountMetricPollPeriod, + } + ret.StorageConfig.Codec = unstructured.UnstructuredJSONScheme + + return ret +} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/server.go b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/server.go new file mode 100644 index 0000000000..b30b9cb65c --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/server.go @@ -0,0 +1,64 @@ +/* +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 server + +import ( + "io" + + "github.com/spf13/cobra" + + "k8s.io/apiextensions-apiserver/pkg/cmd/server/options" + genericapiserver "k8s.io/apiserver/pkg/server" +) + +func NewServerCommand(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command { + o := options.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(); err != nil { + return err + } + if err := Run(o, stopCh); err != nil { + return err + } + return nil + }, + } + + fs := cmd.Flags() + o.AddFlags(fs) + return cmd +} + +func Run(o *options.CustomResourceDefinitionsServerOptions, 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/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.crt b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.crt new file mode 100644 index 0000000000..6143ecc607 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.crt @@ -0,0 +1,37 @@ +-----BEGIN CERTIFICATE----- +MIIDGjCCAgKgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdsb2Nh +bGhvc3QtY2FAMTUzMTQ2ODA4NTAgFw0xODA3MTMwNjQ4MDVaGA8yMTE4MDYxOTA2 +NDgwNVowHzEdMBsGA1UEAwwUbG9jYWxob3N0QDE1MzE0NjgwODYwggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDC9Qfx1YAEp+wrSIjbinWw3pWIDbf57Lut +fXgS84ilZpc7M2zeu1QrPyhCedL/gPP0QxKbPS6AR5R/DibH4RWcujL6CU5FB0Y9 +on+IpN/Iml2XzgGiU82gTkJg185VgWwDaHOPKvUF9N1GpvxcSvRsNGoiBJ/LlE4N +hxyUQ0V/lAalYxYybxgl8/xghWMkGnQc3YKWKqGmtBaaax3xvMzamxpWPphoLG07 ++YZfAf0Q7vslVMmlslRmx9OpJFvRnkelbXoHHx73umbMiFp28njY8NK2dqXwb6Z8 +0BCezppCKYpbjnupOIDAAE0KvjzhhzSS68ZgukiBZOcUlnWLzL39AgMBAAGjXDBa +MA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATAMBgNVHRMBAf8E +AjAAMCUGA1UdEQQeMByCCWxvY2FsaG9zdIIJbG9jYWxob3N0hwR/AAABMA0GCSqG +SIb3DQEBCwUAA4IBAQBm9Z15QxsRqoaRDh/ELA93eE9105gwrXrR3AK/iKuJyxIc +/SXVbpAaYHArMrUzaZs0GXEzgW31tZn8D3dgFy8XdZxk1ztaFTm+QTnFRogMNB8A +kvpq7jwTa44c7G0wuNO2nATMu2Ifi/nSdQadTxzmZacSrevN/zcjmvSoV4VFkKO5 +VBnr7e1ruffxAaVAzrRraplpZvuJzlcvqTYAME8fq8H9QidvaXF6yIbEPwwUHK67 +8W4rXn9Zp6NDuQhH0eNPAGlEAaYuyCJvJZeM68ootMi7Uh6RJOTDw1HIdekYEr1/ +FAg4+rH/9Gi+o/LXsBmYXabO+GjsOwfezv3THDnw +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIC5DCCAcygAwIBAgIBATANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdsb2Nh +bGhvc3QtY2FAMTUzMTQ2ODA4NTAgFw0xODA3MTMwNjQ4MDVaGA8yMTE4MDYxOTA2 +NDgwNVowIjEgMB4GA1UEAwwXbG9jYWxob3N0LWNhQDE1MzE0NjgwODUwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDFDtkZLlseubpzPQr1IT3xE28/1cDM +3UB2vp+pbiwvkmHvfm9RxMmDZbYWqXL5beCG/ladHaJ0RW4f3sBPzxDzUP1zFM94 +iYDZmVA0f7ZvtijuiUrwc6TP21ctX5TlN2YYoh4Er+aZ6E5MQIMAxkP+w1lwyYmj +oxopD1wf/4cmZgv9axZV1zR5MrpyVboQa4mQRUoMlLQFE0erMc0yIJsIVWXx9yS7 +9dzhEXC2WPYnPHh6AYSQZBdzumj5HdZhOQhL/UOWq6AJGP1p7l0uXPArmDG0g9pS +aFxAQx6IxtdSUOZFBlel/p+iOab3H8eoNkgCPMXmrM3WZLW7Uy5Onx6LAgMBAAGj +IzAhMA4GA1UdDwEB/wQEAwICpDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB +CwUAA4IBAQC0BaURRhpRbORaOiZJFeQR0gCD9goggXNj+cPh8yYol2GNBdLfed6x +B6ZxGW2Y14pOjo2Ba5FdZyzfOenjhkqhUujQSMxKjkWxX03blLjPEvLo/Wi6TLnp +H3Qmm/Gq1GAxmkZUaovcE71/zpZ/lJLWVVxz21wxcGQIA30DUKgdycfOvWdYkYGf +tnsXpY4yIyHvKvfeIbxo8doBnoRvYd4a7QyY0zw/Q3qaCdINo9zKJYV0CnpSZhKy +5RLcrlfvXttEYryP57RWP9GYJMNmiovGcbls4pOwZMNueUx5qEzIbC9lsfyt13Bc +oZ1lk1TqzwJERoALmgT0ccp7LRxIV90P +-----END CERTIFICATE----- diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.key b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.key new file mode 100644 index 0000000000..3d652c869c --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpgIBAAKCAQEAwvUH8dWABKfsK0iI24p1sN6ViA23+ey7rX14EvOIpWaXOzNs +3rtUKz8oQnnS/4Dz9EMSmz0ugEeUfw4mx+EVnLoy+glORQdGPaJ/iKTfyJpdl84B +olPNoE5CYNfOVYFsA2hzjyr1BfTdRqb8XEr0bDRqIgSfy5RODYcclENFf5QGpWMW +Mm8YJfP8YIVjJBp0HN2CliqhprQWmmsd8bzM2psaVj6YaCxtO/mGXwH9EO77JVTJ +pbJUZsfTqSRb0Z5HpW16Bx8e97pmzIhadvJ42PDStnal8G+mfNAQns6aQimKW457 +qTiAwABNCr484Yc0kuvGYLpIgWTnFJZ1i8y9/QIDAQABAoIBAQC3rgioLpEI0fVO +6m4W+iLcWznjD5nQnNxOHrJsmIqb20aM/myKhVBN1pll2EWVeLdf4Xm8TS5sqgQc +mQast0KXgU7aCL53ht0E4P7rjPtSky2vAubDO9W2PUWI3IqIQQG1TEnkD4L+868v +C9EkW3JiKBf+qQCs27OWR0AD6EWoZfc9NT5AVnL1aTwKnLpSt80umXUMmR5c4ddT +58FO9JgZCzHbcoAyosf4v8fiz588zjBDRRienHourxmUnsKJrIyCMrygBpQ7wIcO +R86e+PuQ+toeSbldq8EfN/XoY0POUvLL/zu6HkbZLhOEjEHQMkMRCMtmLCjuU+sy +TwdRl0xBAoGBAOtC+kqh5eYgQAYtvPaW/XQwrang+G2xIYd/OTXzIlU2T3sTPrDo +IEkwsXwAeKcJx+Z7XcipSG5l1s5QZbc+GIARmJ0DrAwLkDhlwz8RssxBY4q64Jtn +FWRm6CBJkPDq4t16ZbXDdUleXAaqbvxTTnPZMz2o1XHEDpUcPG29MnF1AoGBANQk +hh44qY3IUxRwp6ZoNHVRz7oJC2JLj1++QNoLXX/8LWTXd49RZpI7Byk2lEXl7clf +3rErBuWElrxxuikOahEdzkjKSZq4RSKj1lNpy14spBRo7O9Q+GrJgcr3tcuyT6ri +sXOo6ET5bG72j+uVzv/QbuyCS8elZQHifBIi58FpAoGBAIXsQ8TWcqPUuf2KbeZF +v5Qz3bg1y9XNnpOedbfjZyjw2L/sDaTxDuf7Ix2+uvADnlry4UlILGZD7MrXc3+j +hpjo62J+Y6MbtgaUz1eIwKqLkpm3lgKA5OmZtwwiNLMgUvLXKS0WTh7s6yAUR0e2 +OJO0EfpIsPCpNc/mGfQyXpO9AoGBANEVblo63mGvHrL2lUWdTpaSm3lvkJjAf/6N +NL2yleSeVt8cvemzALT/GH+2G00I4OOoaYOUNKfhle8E58WvPzq/daCoPwMOupT5 +hTORAa8/sDetclgsJaqaECJLIhIxG/QAmYS05LeWXRjASfiXHf1jIPBZOvb6PCMv +Zbk6TdCBAoGBAIxT9W5FhHl+uUpuHIuFvCUg0AoERk9dUPXVEz1C1lqsYfetZ0uz +wh9KtFq2puWrez+K4o04LoInXHFeb34Hx/9SRDCTawmMicuLxivbTm4yjG2RsShl +nbq376nyawu9rcjM3F5ucYLiGHmQOPYWSOvGr2QhGgFgzXiBQ1RcAYdH +-----END RSA PRIVATE KEY----- diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testserver.go b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testserver.go new file mode 100644 index 0000000000..3d705576f1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/cmd/server/testing/testserver.go @@ -0,0 +1,211 @@ +/* +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 testing + +import ( + "fmt" + "io/ioutil" + "net" + "os" + "path" + "runtime" + "time" + + "github.com/spf13/pflag" + + "k8s.io/apiextensions-apiserver/pkg/cmd/server/options" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/apiserver/pkg/registry/generic/registry" + genericapiserver "k8s.io/apiserver/pkg/server" + "k8s.io/apiserver/pkg/storage/storagebackend" + "k8s.io/client-go/kubernetes" + restclient "k8s.io/client-go/rest" +) + +// TearDownFunc is to be called to tear down a test server. +type TearDownFunc func() + +// TestServerInstanceOptions Instance options the TestServer +type TestServerInstanceOptions struct { + // DisableStorageCleanup Disable the automatic storage cleanup + DisableStorageCleanup bool +} + +// TestServer return values supplied by kube-test-ApiServer +type TestServer struct { + ClientConfig *restclient.Config // Rest client config + ServerOpts *options.CustomResourceDefinitionsServerOptions // ServerOpts + TearDownFn TearDownFunc // TearDown function + TmpDir string // Temp Dir used, by the apiserver +} + +// Logger allows t.Testing and b.Testing to be passed to StartTestServer and StartTestServerOrDie +type Logger interface { + Errorf(format string, args ...interface{}) + Fatalf(format string, args ...interface{}) + Logf(format string, args ...interface{}) +} + +// NewDefaultTestServerOptions Default options for TestServer instances +func NewDefaultTestServerOptions() *TestServerInstanceOptions { + return &TestServerInstanceOptions{ + DisableStorageCleanup: false, + } +} + +// StartTestServer starts a apiextensions-apiserver. A rest client config and a tear-down func, +// and location of the tmpdir are returned. +// +// Note: we return a tear-down func instead of a stop channel because the later will leak temporary +// files that because Golang testing's call to os.Exit will not give a stop channel go routine +// enough time to remove temporary files. +func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, customFlags []string, storageConfig *storagebackend.Config) (result TestServer, err error) { + if instanceOptions == nil { + instanceOptions = NewDefaultTestServerOptions() + } + + // TODO : Remove TrackStorageCleanup below when PR + // https://github.com/kubernetes/kubernetes/pull/50690 + // merges as that shuts down storage properly + if !instanceOptions.DisableStorageCleanup { + registry.TrackStorageCleanup() + } + + stopCh := make(chan struct{}) + tearDown := func() { + if !instanceOptions.DisableStorageCleanup { + registry.CleanupStorage() + } + close(stopCh) + if len(result.TmpDir) != 0 { + os.RemoveAll(result.TmpDir) + } + } + defer func() { + if result.TearDownFn == nil { + tearDown() + } + }() + + result.TmpDir, err = ioutil.TempDir("", "apiextensions-apiserver") + if err != nil { + return result, fmt.Errorf("failed to create temp dir: %v", err) + } + + fs := pflag.NewFlagSet("test", pflag.PanicOnError) + + s := options.NewCustomResourceDefinitionsServerOptions(os.Stdout, os.Stderr) + s.AddFlags(fs) + + s.RecommendedOptions.SecureServing.Listener, s.RecommendedOptions.SecureServing.BindPort, err = createLocalhostListenerOnFreePort() + if err != nil { + return result, fmt.Errorf("failed to create listener: %v", err) + } + s.RecommendedOptions.SecureServing.ServerCert.CertDirectory = result.TmpDir + s.RecommendedOptions.SecureServing.ExternalAddress = s.RecommendedOptions.SecureServing.Listener.Addr().(*net.TCPAddr).IP // use listener addr although it is a loopback device + + _, thisFile, _, ok := runtime.Caller(0) + if !ok { + return result, fmt.Errorf("failed to get current file") + } + s.RecommendedOptions.SecureServing.ServerCert.FixtureDirectory = path.Join(path.Dir(thisFile), "testdata") + + if storageConfig != nil { + s.RecommendedOptions.Etcd.StorageConfig = *storageConfig + } + s.APIEnablement.RuntimeConfig.Set("api/all=true") + + fs.Parse(customFlags) + + if err := s.Complete(); err != nil { + return result, fmt.Errorf("failed to set default options: %v", err) + } + if err := s.Validate(); err != nil { + return result, fmt.Errorf("failed to validate options: %v", err) + } + + t.Logf("runtime-config=%v", s.APIEnablement.RuntimeConfig) + t.Logf("Starting apiextensions-apiserver on port %d...", s.RecommendedOptions.SecureServing.BindPort) + + config, err := s.Config() + if err != nil { + return result, fmt.Errorf("failed to create config from options: %v", err) + } + server, err := config.Complete().New(genericapiserver.NewEmptyDelegate()) + if err != nil { + return result, fmt.Errorf("failed to create server: %v", err) + } + + go func(stopCh <-chan struct{}) { + if err := server.GenericAPIServer.PrepareRun().Run(stopCh); err != nil { + t.Errorf("apiextensions-apiserver failed run: %v", err) + } + }(stopCh) + + t.Logf("Waiting for /healthz to be ok...") + + client, err := kubernetes.NewForConfig(server.GenericAPIServer.LoopbackClientConfig) + if err != nil { + return result, fmt.Errorf("failed to create a client: %v", err) + } + err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) { + result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do() + status := 0 + result.StatusCode(&status) + if status == 200 { + return true, nil + } + return false, nil + }) + if err != nil { + return result, fmt.Errorf("failed to wait for /healthz to return ok: %v", err) + } + + // from here the caller must call tearDown + result.ClientConfig = server.GenericAPIServer.LoopbackClientConfig + result.ServerOpts = s + result.TearDownFn = tearDown + + return result, nil +} + +// StartTestServerOrDie calls StartTestServer t.Fatal if it does not succeed. +func StartTestServerOrDie(t Logger, instanceOptions *TestServerInstanceOptions, flags []string, storageConfig *storagebackend.Config) *TestServer { + result, err := StartTestServer(t, instanceOptions, flags, storageConfig) + if err == nil { + return &result + } + + t.Fatalf("failed to launch server: %v", err) + return nil +} + +func createLocalhostListenerOnFreePort() (net.Listener, int, error) { + ln, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + return nil, 0, err + } + + // get port + tcpAddr, ok := ln.Addr().(*net.TCPAddr) + if !ok { + ln.Close() + return nil, 0, fmt.Errorf("invalid listen address: %q", ln.Addr().String()) + } + + return ln, tcpAddr.Port, nil +} 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 new file mode 100644 index 0000000000..6420c3a6f1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/establish/establishing_controller.go @@ -0,0 +1,143 @@ +/* +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 { + ec.queue.Forget(key) + 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 new file mode 100644 index 0000000000..f881427efd --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go @@ -0,0 +1,327 @@ +/* +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 new file mode 100644 index 0000000000..f00def4b12 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go @@ -0,0 +1,374 @@ +/* +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 new file mode 100644 index 0000000000..717e528848 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller_test.go @@ -0,0 +1,344 @@ +/* +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/crdserverscheme/unstructured.go b/vendor/k8s.io/apiextensions-apiserver/pkg/crdserverscheme/unstructured.go new file mode 100644 index 0000000000..b5e3347987 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/crdserverscheme/unstructured.go @@ -0,0 +1,67 @@ +/* +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 crdserverscheme + +import ( + "reflect" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// UnstructuredObjectTyper provides a runtime.ObjectTyper implementation for +// runtime.Unstructured object based on discovery information. +type UnstructuredObjectTyper struct { +} + +// NewUnstructuredObjectTyper returns a runtime.ObjectTyper for +// unstructured objects based on discovery information. It accepts a list of fallback typers +// for handling objects that are not runtime.Unstructured. It does not delegate the Recognizes +// check, only ObjectKinds. +// TODO this only works for the apiextensions server and doesn't recognize any types. Move to point of use. +func NewUnstructuredObjectTyper() *UnstructuredObjectTyper { + dot := &UnstructuredObjectTyper{} + return dot +} + +// ObjectKinds returns a slice of one element with the group,version,kind of the +// provided object, or an error if the object is not runtime.Unstructured or +// has no group,version,kind information. unversionedType will always be false +// because runtime.Unstructured object should always have group,version,kind +// information set. +func (d *UnstructuredObjectTyper) ObjectKinds(obj runtime.Object) (gvks []schema.GroupVersionKind, unversionedType bool, err error) { + if _, ok := obj.(runtime.Unstructured); ok { + gvk := obj.GetObjectKind().GroupVersionKind() + if len(gvk.Kind) == 0 { + return nil, false, runtime.NewMissingKindErr("object has no kind field ") + } + if len(gvk.Version) == 0 { + return nil, false, runtime.NewMissingVersionErr("object has no apiVersion field") + } + return []schema.GroupVersionKind{gvk}, false, nil + } + + return nil, false, runtime.NewNotRegisteredErrForType("crdserverscheme.UnstructuredObjectTyper", reflect.TypeOf(obj)) +} + +// Recognizes returns true if the provided group,version,kind was in the +// discovery information. +func (d *UnstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool { + return false +} + +var _ runtime.ObjectTyper = &UnstructuredObjectTyper{} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/features/OWNERS b/vendor/k8s.io/apiextensions-apiserver/pkg/features/OWNERS new file mode 100644 index 0000000000..fe7b0144e0 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/features/OWNERS @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000000..24e72f91e5 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/features/kube_features.go @@ -0,0 +1,55 @@ +/* +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 new file mode 100644 index 0000000000..0a94bc5c49 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd.go @@ -0,0 +1,325 @@ +/* +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) + + 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{ + store: customResourceREST.Store, + 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, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + // We are explicitly setting forceAllowCreate to false in the call to the underlying storage because + // subresources should never allow create on update. + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} + +type ScaleREST struct { + store *genericregistry.Store + 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) { + obj, err := r.store.Get(ctx, name, options) + if err != nil { + return nil, err + } + cr := obj.(*unstructured.Unstructured) + + 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, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + obj, err := r.store.Get(ctx, name, &metav1.GetOptions{}) + if err != nil { + return nil, false, err + } + cr := obj.(*unstructured.Unstructured) + + 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) + + obj, _, err = r.store.Update(ctx, cr.GetName(), rest.DefaultUpdatedObjectInfo(cr), createValidation, updateValidation, false, options) + if err != nil { + return nil, false, err + } + cr = obj.(*unstructured.Unstructured) + + 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 new file mode 100644 index 0000000000..0a6870dc05 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/etcd_test.go @@ -0,0 +1,575 @@ +/* +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/apiextensions-apiserver/pkg/apis/apiextensions" + "k8s.io/apiextensions-apiserver/pkg/apiserver" + "k8s.io/apiextensions-apiserver/pkg/crdserverscheme" + "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: crdserverscheme.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, &metav1.CreateOptions{}) + 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, false, &metav1.UpdateOptions{}); 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, false, &metav1.UpdateOptions{}); 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, false); 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, false); 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, false, &metav1.UpdateOptions{}); 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, false); 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, false); 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, false); 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, false, &metav1.UpdateOptions{}); 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, false, &metav1.UpdateOptions{}); 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, false); 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, false, &metav1.UpdateOptions{}); 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/status_strategy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go new file mode 100644 index 0000000000..1710eb2e15 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy.go @@ -0,0 +1,59 @@ +/* +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 new file mode 100644 index 0000000000..8a651d12bb --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/status_strategy_test.go @@ -0,0 +1,138 @@ +/* +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 new file mode 100644 index 0000000000..4895e287af --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/strategy.go @@ -0,0 +1,185 @@ +/* +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 new file mode 100644 index 0000000000..e1bed809d9 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor.go @@ -0,0 +1,172 @@ +/* +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 new file mode 100644 index 0000000000..179aabb8ab --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/tableconvertor/tableconvertor_test.go @@ -0,0 +1,68 @@ +/* +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 new file mode 100644 index 0000000000..5206a17ebe --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresource/validator.go @@ -0,0 +1,195 @@ +/* +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 new file mode 100644 index 0000000000..c6b50915f1 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go @@ -0,0 +1,181 @@ +/* +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" + "k8s.io/apiserver/pkg/util/dryrun" +) + +// 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 + }), + dryrun.IsDryRun(options.DryRun), + ) + + 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, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { + // We are explicitly setting forceAllowCreate to false in the call to the underlying storage because + // subresources should never allow create on update. + return r.store.Update(ctx, name, objInfo, createValidation, updateValidation, false, options) +} diff --git a/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go new file mode 100644 index 0000000000..a0bebb7a7b --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go @@ -0,0 +1,202 @@ +/* +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 new file mode 100644 index 0000000000..0b52619bf2 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.crt @@ -0,0 +1,19 @@ +-----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 new file mode 100644 index 0000000000..d4878784e9 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/apiserver.local.config/certificates/apiserver.key @@ -0,0 +1,27 @@ +-----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 new file mode 100644 index 0000000000..b9f34b3cb4 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/basic_test.go @@ -0,0 +1,982 @@ +/* +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" + "strings" + "testing" + "time" + + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + "k8s.io/apiextensions-apiserver/test/integration/fixtures" + "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" + "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) { + tearDown, _, _, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() +} + +func TestNamespaceScopedCRUD(t *testing.T) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + noxuDefinition, err = fixtures.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 !errors.IsNotFound(err) { + t.Errorf("expected the watch operation fail with NotFound for disabled version %s, got error: %v", v.Name, err) + } + } 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, fixtures.NewVersionedNoxuInstance(ns, "foo", version), noxuResourceClient, noxuDefinition, version) + if disabledVersions[version] { + if !errors.IsNotFound(err) { + t.Errorf("expected the CR creation fail with NotFound for disabled version %s, got error: %v", version, err) + } + 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 !errors.IsNotFound(err) { + t.Errorf("expected the get operation fail with NotFound for disabled version %s, got error: %v", version2, err) + + } + } 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 !errors.IsNotFound(err) { + t.Errorf("expected the list operation fail with NotFound for disabled version %s, got error: %v", version2, err) + + } + } 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) + } + } + } + + // Update test + for version2, noxuResourceClient2 := range noxuResourceClients { + var gottenNoxuInstance *unstructured.Unstructured + if disabledVersions[version2] { + gottenNoxuInstance = &unstructured.Unstructured{} + gottenNoxuInstance.SetName("foo") + } else { + gottenNoxuInstance, err = noxuResourceClient2.Get("foo", metav1.GetOptions{}) + if err != nil { + t.Fatal(err) + } + } + + gottenNoxuInstance.Object["updated"] = version2 + updatedNoxuInstance, err := noxuResourceClient2.Update(gottenNoxuInstance, metav1.UpdateOptions{}) + if disabledVersions[version2] { + if !errors.IsNotFound(err) { + t.Errorf("expected the update operation fail with NotFound for disabled version %s, got error: %v", version2, err) + } + } else { + if err != nil { + t.Fatal(err) + } + + if updated, ok := updatedNoxuInstance.Object["updated"]; !ok { + t.Errorf("expected string 'updated' field") + } else if updated, ok := updated.(string); !ok || updated != version2 { + t.Errorf("expected string 'updated' field to equal %q, got %q of type %T", version2, updated, updated) + } + + if e, a := version2, updatedNoxuInstance.GroupVersionKind().Version; !reflect.DeepEqual(e, a) { + t.Errorf("expected %v, got %v", e, a) + } + + for _, noxuWatch := range noxuWatchs { + select { + case watchEvent := <-noxuWatch.ResultChan(): + eventMetadata, err := meta.Accessor(watchEvent.Object) + if err != nil { + t.Fatal(err) + } + + if watchEvent.Type != watch.Modified { + t.Errorf("expected modified event, got %v", watchEvent.Type) + break + } + + // it should have a UUID + createdMetadata, err := meta.Accessor(createdNoxuInstance) + if err != nil { + t.Fatal(err) + } + if e, a := createdMetadata.GetUID(), eventMetadata.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.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(): + eventMetadata, err := meta.Accessor(watchEvent.Object) + if err != nil { + t.Fatal(err) + } + + if watchEvent.Type != watch.Deleted { + t.Errorf("expected delete event, got %v", watchEvent.Type) + break + } + + // it should have a UUID + createdMetadata, err := meta.Accessor(createdNoxuInstance) + if err != nil { + t.Fatal(err) + } + if e, a := createdMetadata.GetUID(), eventMetadata.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, fixtures.NewNoxuInstance(ns, "bar"), noxuResourceClient, noxuDefinition) + if err != nil { + t.Fatalf("unable to create noxu Instance:%v", err) + } + createdNoxuInstanceFoo, err := instantiateCustomResource(t, fixtures.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" + + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + scope := apiextensionsv1beta1.NamespaceScoped + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(scope) + noxuDefinition, err = fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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, fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + // namespace scoped + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + ns := "not-the-default" + noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) + + noxuInstanceToCreate := fixtures.NewNoxuInstance(ns, "foo") + createdNoxuInstance, err := noxuNamespacedResourceClient.Create(noxuInstanceToCreate, metav1.CreateOptions{}) + 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 := fixtures.NewCurletCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + curletDefinition, err = fixtures.CreateNewCustomResourceDefinition(curletDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + curletResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, curletDefinition) + + curletInstanceToCreate := fixtures.NewCurletInstance(ns, "foo") + createdCurletInstance, err := curletResourceClient.Create(curletInstanceToCreate, metav1.CreateOptions{}) + 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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + ns := "not-the-default" + noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) + + noxuInstanceToCreate := fixtures.NewNoxuInstance(ns, "foo") + createdNoxuInstance, err := noxuNamespacedResourceClient.Create(noxuInstanceToCreate, metav1.CreateOptions{}) + 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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + ns := "not-the-default" + noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) + + t.Logf("Creating foo") + noxuInstanceToCreate := fixtures.NewNoxuInstance(ns, "foo") + _, err = noxuNamespacedResourceClient.Create(noxuInstanceToCreate, metav1.CreateOptions{}) + if err != nil { + t.Fatal(err) + } + + t.Logf("Patching .num.num2 to 999") + patch := []byte(`{"num": {"num2":999}}`) + patchedNoxuInstance, err := noxuNamespacedResourceClient.Patch("foo", types.MergePatchType, patch, metav1.UpdateOptions{}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 999, "num", "num2") + rv, found, err := unstructured.NestedString(patchedNoxuInstance.UnstructuredContent(), "metadata", "resourceVersion") + if err != nil { + t.Fatal(err) + } + if !found { + t.Fatalf("metadata.resourceVersion not found") + } + + // a patch with no change + t.Logf("Patching .num.num2 again to 999") + patchedNoxuInstance, err = noxuNamespacedResourceClient.Patch("foo", types.MergePatchType, patch, metav1.UpdateOptions{}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + // make sure no-op patch does not increment resourceVersion + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 999, "num", "num2") + expectString(t, patchedNoxuInstance.UnstructuredContent(), rv, "metadata", "resourceVersion") + + // an empty patch + t.Logf("Applying empty patch") + patchedNoxuInstance, err = noxuNamespacedResourceClient.Patch("foo", types.MergePatchType, []byte(`{}`), metav1.UpdateOptions{}) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + // an empty patch is a no-op patch. make sure it does not increment resourceVersion + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 999, "num", "num2") + expectString(t, patchedNoxuInstance.UnstructuredContent(), rv, "metadata", "resourceVersion") + + originalJSON, err := runtime.Encode(unstructured.UnstructuredJSONScheme, patchedNoxuInstance) + 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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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, fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + noxu2Definition := fixtures.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 = fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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) + } +} + +func expectInt64(t *testing.T, obj map[string]interface{}, value int64, pth ...string) { + if v, found, err := unstructured.NestedInt64(obj, pth...); err != nil { + t.Fatalf("failed to access .%s: %v", strings.Join(pth, "."), err) + } else if !found { + t.Fatalf("failed to find .%s", strings.Join(pth, ".")) + } else if v != value { + t.Fatalf("wanted %d at .%s, got %d", value, strings.Join(pth, "."), v) + } +} +func expectString(t *testing.T, obj map[string]interface{}, value string, pth ...string) { + if v, found, err := unstructured.NestedString(obj, pth...); err != nil { + t.Fatalf("failed to access .%s: %v", strings.Join(pth, "."), err) + } else if !found { + t.Fatalf("failed to find .%s", strings.Join(pth, ".")) + } else if v != value { + t.Fatalf("wanted %q at .%s, got %q", value, strings.Join(pth, "."), v) + } +} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go new file mode 100644 index 0000000000..745aa58541 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/finalization_test.go @@ -0,0 +1,165 @@ +/* +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/fixtures" + "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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + require.NoError(t, err) + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + require.NoError(t, err) + + ns := "not-the-default" + name := "foo123" + noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) + + instance := fixtures.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, metav1.UpdateOptions{}) + 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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + require.NoError(t, err) + defer tearDown() + + // Create a CRD. + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + noxuDefinition, err = fixtures.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 := fixtures.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. + fixtures.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, metav1.UpdateOptions{}) + 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/fixtures/resources.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/fixtures/resources.go new file mode 100644 index 0000000000..9a1f2d8484 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/fixtures/resources.go @@ -0,0 +1,403 @@ +/* +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 fixtures + +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, + }, + } +} + +// NewNoxuCustomResourceDefinition returns a WishIHadChosenNoxu CRD. +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, + }, + } +} + +// NewVersionedNoxuInstance returns a WishIHadChosenNoxu instance for a given version +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, + }, + }, + } +} + +// NewNoxuInstance returns a WishIHadChosenNoxu instance for v1beta1. +func NewNoxuInstance(namespace, name string) *unstructured.Unstructured { + return NewVersionedNoxuInstance(namespace, name, "v1beta1") +} + +// NewMultipleVersionNoxuCRD returns a WishIHadChosenNoxu with multiple versions. +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, + }, + }, + }, + } +} + +// NewNoxu2CustomResourceDefinition returns a WishIHadChosenNoxu2 CRD. +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, + }, + } +} + +// NewCurletCustomResourceDefinition returns a Curlet CRD. +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, + }, + } +} + +// NewCurletInstance returns a Curlet instance. +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 +} + +// CreateNewCustomResourceDefinition creates the given CRD and makes sure its watch cache is primed on the server. +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. + err = wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) { + return isWatchCachePrimed(crd, dynamicClientSet) + }) + if err != nil { + return nil, err + } + return crd, nil +} + +func resourceClientForVersion(crd *apiextensionsv1beta1.CustomResourceDefinition, dynamicClientSet dynamic.Interface, namespace, 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 dynamicClientSet.Resource(gvr).Namespace(namespace) + } + return dynamicClientSet.Resource(gvr) +} + +// isWatchCachePrimed returns true if the watch is primed for an specified version of CRD watch +func isWatchCachePrimed(crd *apiextensionsv1beta1.CustomResourceDefinition, dynamicClientSet dynamic.Interface) (bool, error) { + ns := "" + if crd.Spec.Scope != apiextensionsv1beta1.ClusterScoped { + ns = "aval" + } + + versions := servedVersions(crd) + if len(versions) == 0 { + return true, nil + } + + resourceClient := resourceClientForVersion(crd, dynamicClientSet, ns, versions[0]) + instanceName := "setup-instance" + instance := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": crd.Spec.Group + "/" + versions[0], + "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, metav1.CreateOptions{}) + if err != nil { + return false, err + } + err = resourceClient.Delete(createdInstance.GetName(), nil) + if err != nil { + return false, err + } + + // Wait for all versions of watch cache to be primed and also make sure we consumed the DELETE event for all + // versions so that any new watch with ResourceVersion=0 does not get those events. This is source of some flaky tests. + // When a client creates a watch with resourceVersion=0, it will get an ADD event for any existing objects + // but because they specified resourceVersion=0, there is no starting point in the cache buffer to return existing events + // from, thus the server will return anything from current head of the cache to the end. By accessing the delete + // events for all versions here, we make sure that the head of the cache is passed those events and they will not being + // delivered to any future watch with resourceVersion=0. + for _, v := range versions { + noxuWatch, err := resourceClientForVersion(crd, dynamicClientSet, ns, v).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) + } + case <-time.After(5 * time.Second): + return false, fmt.Errorf("gave up waiting for watch event") + } + } + + return true, nil +} + +// DeleteCustomResourceDefinition deletes a CRD and waits until it disappears from discovery. +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 +} + +// CreateNewScaleClient returns a scale client. +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/fixtures/server.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/fixtures/server.go new file mode 100644 index 0000000000..0a3d6444e9 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/fixtures/server.go @@ -0,0 +1,108 @@ +/* +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 fixtures + +import ( + "io/ioutil" + "os" + "strings" + + "github.com/pborman/uuid" + "k8s.io/apiextensions-apiserver/pkg/cmd/server/options" + + "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + servertesting "k8s.io/apiextensions-apiserver/pkg/cmd/server/testing" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/rest" +) + +// StartDefaultServer starts a test server. +func StartDefaultServer(t servertesting.Logger) (func(), *rest.Config, *options.CustomResourceDefinitionsServerOptions, error) { + // create kubeconfig which will not actually be used. But authz/authn needs it to startup. + fakeKubeConfig, err := ioutil.TempFile("", "kubeconfig") + fakeKubeConfig.WriteString(` +apiVersion: v1 +kind: Config +clusters: +- cluster: + server: http://127.1.2.3:12345 + name: integration +contexts: +- context: + cluster: integration + user: test + name: default-context +current-context: default-context +users: +- name: test + user: + password: test + username: test +`) + fakeKubeConfig.Close() + + s, err := servertesting.StartTestServer(t, nil, []string{ + "--etcd-prefix", uuid.New(), + "--etcd-servers", strings.Join(IntegrationEtcdServers(), ","), + "--authentication-skip-lookup", + "--authentication-kubeconfig", fakeKubeConfig.Name(), + "--authorization-kubeconfig", fakeKubeConfig.Name(), + "--kubeconfig", fakeKubeConfig.Name(), + "--disable-admission-plugins", "NamespaceLifecycle,MutatingAdmissionWebhook,ValidatingAdmissionWebhook", + }, nil) + if err != nil { + os.Remove(fakeKubeConfig.Name()) + return nil, nil, nil, err + } + + tearDownFn := func() { + defer os.Remove(fakeKubeConfig.Name()) + s.TearDownFn() + } + + return tearDownFn, s.ClientConfig, s.ServerOpts, nil +} + +// StartDefaultServerWithClients starts a test server and returns clients for it. +func StartDefaultServerWithClients(t servertesting.Logger) (func(), clientset.Interface, dynamic.Interface, error) { + tearDown, config, _, err := StartDefaultServer(t) + if err != nil { + return nil, nil, nil, err + } + + apiExtensionsClient, err := clientset.NewForConfig(config) + if err != nil { + tearDown() + return nil, nil, nil, err + } + + dynamicClient, err := dynamic.NewForConfig(config) + if err != nil { + tearDown() + return nil, nil, nil, err + } + + return tearDown, apiExtensionsClient, dynamicClient, nil +} + +// IntegrationEtcdServers returns etcd server URLs. +func IntegrationEtcdServers() []string { + if etcdURL, ok := os.LookupEnv("KUBE_INTEGRATION_ETCD_URL"); ok { + return []string{etcdURL} + } + return []string{"http://127.0.0.1:2379"} +} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/helpers.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/helpers.go new file mode 100644 index 0000000000..7634403456 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/helpers.go @@ -0,0 +1,94 @@ +/* +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, metav1.CreateOptions{}) + 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 new file mode 100644 index 0000000000..1ce637aa70 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/objectmeta_test.go @@ -0,0 +1,164 @@ +/* +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" + serveroptions "k8s.io/apiextensions-apiserver/pkg/cmd/server/options" + "k8s.io/apiextensions-apiserver/test/integration/fixtures" + "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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + noxuResourceClient := newNamespacedCustomResourceClient("default", dynamicClient, noxuDefinition) + + obj := fixtures.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) { + tearDown, config, options, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + apiExtensionClient, err := clientset.NewForConfig(config) + if err != nil { + t.Fatal(err) + } + + dynamicClient, err := dynamic.NewForConfig(config) + if err != nil { + t.Fatal(err) + } + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + RESTOptionsGetter := serveroptions.NewCRDRESTOptionsGetter(*options.RecommendedOptions.Etcd) + restOptions, err := 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 := fixtures.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 new file mode 100644 index 0000000000..2523210c81 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/registration_test.go @@ -0,0 +1,456 @@ +/* +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" + apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + "k8s.io/apiextensions-apiserver/test/integration/fixtures" + "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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + ns := "not-the-default" + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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, fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + ns := "not-the-default" + sameInstanceName := "foo" + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) + createdNoxuInstance, err := instantiateCustomResource(t, fixtures.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 := fixtures.NewCurletCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + curletDefinition, err = fixtures.CreateNewCustomResourceDefinition(curletDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + curletNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, curletDefinition) + createdCurletInstance, err := instantiateCustomResource(t, fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + ns := "not-the-default" + sameInstanceName := "foo" + func() { + noxuDefinition, err := fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) + if _, err := instantiateCustomResource(t, fixtures.NewNoxuInstance(ns, sameInstanceName), noxuNamespacedResourceClient, noxuDefinition); err != nil { + t.Fatal(err) + } + if err := fixtures.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 := fixtures.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, fixtures.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) { + tearDown, clientConfig, s, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + apiExtensionClient, err := apiextensionsclientset.NewForConfig(clientConfig) + if err != nil { + t.Fatal(err) + } + dynamicClient, err := dynamic.NewForConfig(clientConfig) + if err != nil { + t.Fatal(err) + } + + etcdPrefix := s.RecommendedOptions.Etcd.StorageConfig.Prefix + + ns1 := "another-default-is-possible" + curletDefinition := fixtures.NewCurletCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + curletDefinition, err = fixtures.CreateNewCustomResourceDefinition(curletDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + curletNamespacedResourceClient := newNamespacedCustomResourceClient(ns1, dynamicClient, curletDefinition) + if _, err := instantiateCustomResource(t, fixtures.NewCurletInstance(ns1, "bar"), curletNamespacedResourceClient, curletDefinition); err != nil { + t.Fatalf("unable to create curlet cluster scoped Instance:%v", err) + } + + ns2 := "the-cruel-default" + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + noxuNamespacedResourceClient := newNamespacedCustomResourceClient(ns2, dynamicClient, noxuDefinition) + if _, err := instantiateCustomResource(t, fixtures.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 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 new file mode 100644 index 0000000000..c8c8728ee5 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/subresources_test.go @@ -0,0 +1,770 @@ +/* +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/fixtures" +) + +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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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, metav1.UpdateOptions{}) + 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, metav1.UpdateOptions{}) + 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", + } + + tearDown, config, _, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + 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 = fixtures.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 = fixtures.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 := fixtures.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, metav1.UpdateOptions{}) + 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, metav1.UpdateOptions{}) + if err == nil { + t.Fatalf("unexpected non-error: .spec.replicas should be less than 2147483647") + } +} + +func TestValidationSchemaWithStatus(t *testing.T) { + tearDown, config, _, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + 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 = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err == nil { + t.Fatalf(`unexpected non-error, expected: must not have "additionalProperties" at the root of the schema 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 = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatalf("unable to created crd %v: %v", noxuDefinition.Name, err) + } +} + +func TestValidateOnlyStatus(t *testing.T) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + // 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 = fixtures.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, metav1.UpdateOptions{}) + 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, metav1.UpdateOptions{}) + 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) { + tearDown, config, _, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + 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 = fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := NewNoxuSubresourcesCRD(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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, metav1.UpdateOptions{}) + 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, metav1.UpdateOptions{}) + 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", + } + + tearDown, config, _, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + 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 = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + ns := "not-the-default" + noxuResourceClient := newNamespacedCustomResourceClient(ns, dynamicClient, noxuDefinition) + + t.Logf("Creating foo") + _, err = instantiateCustomResource(t, NewNoxuSubresourceInstance(ns, "foo"), noxuResourceClient, noxuDefinition) + if err != nil { + t.Fatalf("unable to create noxu instance: %v", err) + } + + scaleClient, err := fixtures.CreateNewScaleClient(noxuDefinition, config) + if err != nil { + t.Fatal(err) + } + + t.Logf("Patching .status.num to 999") + patch := []byte(`{"spec": {"num":999}, "status": {"num":999}}`) + patchedNoxuInstance, err := noxuResourceClient.Patch("foo", types.MergePatchType, patch, metav1.UpdateOptions{}, "status") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 999, "status", "num") // .status.num should be 999 + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 10, "spec", "num") // .spec.num should remain 10 + rv, found, err := unstructured.NestedString(patchedNoxuInstance.UnstructuredContent(), "metadata", "resourceVersion") + if err != nil { + t.Fatal(err) + } + if !found { + t.Fatalf("metadata.resourceVersion not found") + } + + // 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 + t.Logf("Patching .status.num again to 999") + patchedNoxuInstance, err = noxuResourceClient.Patch("foo", types.MergePatchType, patch, metav1.UpdateOptions{}, "status") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + // make sure no-op patch does not increment resourceVersion + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 999, "status", "num") + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 10, "spec", "num") + expectString(t, patchedNoxuInstance.UnstructuredContent(), rv, "metadata", "resourceVersion") + + // empty patch + t.Logf("Applying empty patch") + patchedNoxuInstance, err = noxuResourceClient.Patch("foo", types.MergePatchType, []byte(`{}`), metav1.UpdateOptions{}, "status") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + // an empty patch is a no-op patch. make sure it does not increment resourceVersion + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 999, "status", "num") + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 10, "spec", "num") + expectString(t, patchedNoxuInstance.UnstructuredContent(), rv, "metadata", "resourceVersion") + + t.Logf("Patching .spec.replicas to 7") + patch = []byte(`{"spec": {"replicas":7}, "status": {"replicas":7}}`) + patchedNoxuInstance, err = noxuResourceClient.Patch("foo", types.MergePatchType, patch, metav1.UpdateOptions{}, "scale") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 7, "spec", "replicas") + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 0, "status", "replicas") // .status.replicas should remain 0 + rv, found, err = unstructured.NestedString(patchedNoxuInstance.UnstructuredContent(), "metadata", "resourceVersion") + if err != nil { + t.Fatal(err) + } + if !found { + t.Fatalf("metadata.resourceVersion not found") + } + + // 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 0 + 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 + t.Logf("Patching .spec.replicas again to 7") + patchedNoxuInstance, err = noxuResourceClient.Patch("foo", types.MergePatchType, patch, metav1.UpdateOptions{}, "scale") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + // make sure no-op patch does not increment resourceVersion + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 7, "spec", "replicas") + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 0, "status", "replicas") + expectString(t, patchedNoxuInstance.UnstructuredContent(), rv, "metadata", "resourceVersion") + + // empty patch + t.Logf("Applying empty patch") + patchedNoxuInstance, err = noxuResourceClient.Patch("foo", types.MergePatchType, []byte(`{}`), metav1.UpdateOptions{}, "scale") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + // an empty patch is a no-op patch. make sure it does not increment resourceVersion + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 7, "spec", "replicas") + expectInt64(t, patchedNoxuInstance.UnstructuredContent(), 0, "status", "replicas") + expectString(t, patchedNoxuInstance.UnstructuredContent(), rv, "metadata", "resourceVersion") + + // make sure strategic merge patch is not supported for both status and scale + _, err = noxuResourceClient.Patch("foo", types.StrategicMergePatchType, patch, metav1.UpdateOptions{}, "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, metav1.UpdateOptions{}, "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 new file mode 100644 index 0000000000..7aab4f4086 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/table_test.go @@ -0,0 +1,218 @@ +/* +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" + "time" + + "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/fixtures" +) + +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"}, + {Name: "Epsilon", Type: "string", Description: "an array of integers as string", JSONPath: ".spec.epsilon"}, + }, + }, + } +} + +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", + "epsilon": []int64{1, 2, 3}, + }, + }, + } +} + +func TestTableGet(t *testing.T) { + tearDown, config, _, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + 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 = fixtures.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"), metav1.CreateOptions{}) + 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), 6; got != expected { + t.Errorf("expected %d headers, got %d", expected, got) + } else { + age := metav1beta1.TableColumnDefinition{Name: "Age", Type: "date", Format: "", Description: "Custom resource definition column (in JSONPath format): .metadata.creationTimestamp", Priority: 0} + if got, expected := tbl.ColumnDefinitions[1], age; got != expected { + t.Errorf("expected column definition %#v, got %#v", expected, got) + } + + 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) + } + + epsilon := metav1beta1.TableColumnDefinition{Name: "Epsilon", Type: "string", Description: "an array of integers as string"} + if got, expected := tbl.ColumnDefinitions[5], epsilon; 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), 6; 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 s, ok := tbl.Rows[0].Cells[1].(string); !ok { + t.Errorf("expected cell[1] to be a string, got: %#v", tbl.Rows[0].Cells[1]) + } else { + dur, err := time.ParseDuration(s) + if err != nil { + t.Errorf("expected cell[1] to be a duration: %v", err) + } else if abs(dur.Seconds()) > 30.0 { + t.Errorf("expected cell[1] to be a small age, but got: %v", dur) + } + } + 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[4] to equal %#v although the type does not match the column, got %#v", expected, got) + } + if got, expected := tbl.Rows[0].Cells[5], "[1 2 3]"; got != expected { + t.Errorf("expected cell[5] to equal %q, got %q", expected, got) + } + } +} + +func abs(x float64) float64 { + if x < 0 { + return -x + } + return x +} diff --git a/vendor/k8s.io/apiextensions-apiserver/test/integration/validation_test.go b/vendor/k8s.io/apiextensions-apiserver/test/integration/validation_test.go new file mode 100644 index 0000000000..37f9d09438 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/validation_test.go @@ -0,0 +1,431 @@ +/* +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/fixtures" +) + +func TestForProperValidationErrors(t *testing.T) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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 := fixtures.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 := fixtures.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(), metav1.CreateOptions{}) + 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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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, metav1.UpdateOptions{}) + if err == nil { + t.Fatalf("unexpected non-error: alpha and beta should be present while updating %v", gottenNoxuInstance) + } +} + +func TestCustomResourceValidationErrors(t *testing.T) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.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(), metav1.CreateOptions{}) + 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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) + + // set stricter schema + noxuDefinition.Spec.Validation.OpenAPIV3Schema.Required = []string{"alpha", "beta", "epsilon"} + + noxuDefinition, err = fixtures.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"), metav1.CreateOptions{}) + 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) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := newNoxuValidationCRD(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition.Spec.Validation.OpenAPIV3Schema.AdditionalProperties.Allows = false + + _, err = fixtures.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 = fixtures.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 = fixtures.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 = fixtures.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 new file mode 100644 index 0000000000..7d305b081f --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/versioning_test.go @@ -0,0 +1,138 @@ +/* +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/fixtures" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestVersionedNamspacedScopedCRD(t *testing.T) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewMultipleVersionNoxuCRD(apiextensionsv1beta1.NamespaceScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + ns := "not-the-default" + testSimpleCRUD(t, ns, noxuDefinition, dynamicClient) +} + +func TestVersionedClusterScopedCRD(t *testing.T) { + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition := fixtures.NewMultipleVersionNoxuCRD(apiextensionsv1beta1.ClusterScoped) + noxuDefinition, err = fixtures.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient) + if err != nil { + t.Fatal(err) + } + + ns := "" + testSimpleCRUD(t, ns, noxuDefinition, dynamicClient) +} + +func TestStoragedVersionInNamespacedCRDStatus(t *testing.T) { + noxuDefinition := fixtures.NewMultipleVersionNoxuCRD(apiextensionsv1beta1.NamespaceScoped) + ns := "not-the-default" + testStoragedVersionInCRDStatus(t, ns, noxuDefinition) +} + +func TestStoragedVersionInClusterScopedCRDStatus(t *testing.T) { + noxuDefinition := fixtures.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, + }, + } + tearDown, apiExtensionClient, dynamicClient, err := fixtures.StartDefaultServerWithClients(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + noxuDefinition.Spec.Versions = versionsV1Beta1Storage + noxuDefinition, err = fixtures.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 = fixtures.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 new file mode 100644 index 0000000000..45e5176b00 --- /dev/null +++ b/vendor/k8s.io/apiextensions-apiserver/test/integration/yaml_test.go @@ -0,0 +1,541 @@ +/* +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/fixtures" +) + +func TestYAML(t *testing.T) { + tearDown, config, _, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + apiExtensionClient, err := clientset.NewForConfig(config) + if err != nil { + t.Fatal(err) + } + dynamicClient, err := dynamic.NewForConfig(config) + if err != nil { + t.Fatal(err) + } + + noxuDefinition := fixtures.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped) + noxuDefinition, err = fixtures.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) { + tearDown, config, _, err := fixtures.StartDefaultServer(t) + if err != nil { + t.Fatal(err) + } + defer tearDown() + + 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 = fixtures.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 +} From 0e24579513b8c3cbe174b9a476986da5c488eda2 Mon Sep 17 00:00:00 2001 From: Michael Henriksen Date: Wed, 9 Jan 2019 19:06:04 -0500 Subject: [PATCH 2/2] move to v1 rbac --- pkg/operator/resources/cluster/apiserver.go | 10 +++++----- pkg/operator/resources/cluster/controller.go | 8 ++++---- pkg/operator/resources/cluster/datavolume.go | 2 +- pkg/operator/resources/cluster/rbac.go | 18 +++++++++--------- pkg/operator/resources/namespaced/apiserver.go | 14 +++++++------- pkg/operator/resources/namespaced/common.go | 18 +++++++++--------- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/pkg/operator/resources/cluster/apiserver.go b/pkg/operator/resources/cluster/apiserver.go index e75d3e8c05..8f40b766cd 100644 --- a/pkg/operator/resources/cluster/apiserver.go +++ b/pkg/operator/resources/cluster/apiserver.go @@ -17,7 +17,7 @@ limitations under the License. package cluster import ( - rbacv1beta1 "k8s.io/api/rbac/v1beta1" + rbacv1 "k8s.io/api/rbac/v1" ) const ( @@ -32,13 +32,13 @@ func createAPIServerResources(args *FactoryArgs) []Resource { } } -func createAPIServerClusterRoleBinding(namespace string) *rbacv1beta1.ClusterRoleBinding { +func createAPIServerClusterRoleBinding(namespace string) *rbacv1.ClusterRoleBinding { return createClusterRoleBinding(apiServerResourceName, apiServerResourceName, apiServerResourceName, namespace) } -func createAPIServerClusterRole() *rbacv1beta1.ClusterRole { +func createAPIServerClusterRole() *rbacv1.ClusterRole { clusterRole := createClusterRole(apiServerResourceName) - clusterRole.Rules = []rbacv1beta1.PolicyRule{ + clusterRole.Rules = []rbacv1.PolicyRule{ { APIGroups: []string{ "admissionregistration.k8s.io", @@ -82,6 +82,6 @@ func createAPIServerClusterRole() *rbacv1beta1.ClusterRole { return clusterRole } -func createAPIServerAuthClusterRoleBinding(namespace string) *rbacv1beta1.ClusterRoleBinding { +func createAPIServerAuthClusterRoleBinding(namespace string) *rbacv1.ClusterRoleBinding { return createClusterRoleBinding("cdi-apiserver-auth-delegator", "system:auth-delegator", apiServerResourceName, namespace) } diff --git a/pkg/operator/resources/cluster/controller.go b/pkg/operator/resources/cluster/controller.go index b409d2d789..abfd2c89ed 100644 --- a/pkg/operator/resources/cluster/controller.go +++ b/pkg/operator/resources/cluster/controller.go @@ -17,7 +17,7 @@ limitations under the License. package cluster import ( - rbacv1beta1 "k8s.io/api/rbac/v1beta1" + rbacv1 "k8s.io/api/rbac/v1" ) const ( @@ -32,13 +32,13 @@ func createControllerResources(args *FactoryArgs) []Resource { } } -func createControllerClusterRoleBinding(namespace string) *rbacv1beta1.ClusterRoleBinding { +func createControllerClusterRoleBinding(namespace string) *rbacv1.ClusterRoleBinding { return createClusterRoleBinding(controllerServiceAccountName, controlerClusterRoleName, controllerServiceAccountName, namespace) } -func createControllerClusterRole() *rbacv1beta1.ClusterRole { +func createControllerClusterRole() *rbacv1.ClusterRole { clusterRole := createClusterRole(controlerClusterRoleName) - clusterRole.Rules = []rbacv1beta1.PolicyRule{ + clusterRole.Rules = []rbacv1.PolicyRule{ { APIGroups: []string{ "", diff --git a/pkg/operator/resources/cluster/datavolume.go b/pkg/operator/resources/cluster/datavolume.go index c6c7aff51f..ef7a1f1d80 100644 --- a/pkg/operator/resources/cluster/datavolume.go +++ b/pkg/operator/resources/cluster/datavolume.go @@ -36,7 +36,7 @@ func createDataVolumeCRD() *extv1beta1.CustomResourceDefinition { ObjectMeta: metav1.ObjectMeta{ Name: "datavolumes.cdi.kubevirt.io", Labels: map[string]string{ - "cdikubevirt.io": "", + "cdi.kubevirt.io": "", }, }, Spec: extv1beta1.CustomResourceDefinitionSpec{ diff --git a/pkg/operator/resources/cluster/rbac.go b/pkg/operator/resources/cluster/rbac.go index 074447b2ac..a64e15742c 100644 --- a/pkg/operator/resources/cluster/rbac.go +++ b/pkg/operator/resources/cluster/rbac.go @@ -17,14 +17,14 @@ limitations under the License. package cluster import ( - rbacv1beta1 "k8s.io/api/rbac/v1beta1" + rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func createClusterRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace string) *rbacv1beta1.ClusterRoleBinding { - return &rbacv1beta1.ClusterRoleBinding{ +func createClusterRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace string) *rbacv1.ClusterRoleBinding { + return &rbacv1.ClusterRoleBinding{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rbac.authorization.k8s.io/v1beta1", + APIVersion: "rbac.authorization.k8s.io/v1", Kind: "ClusterRoleBinding", }, ObjectMeta: metav1.ObjectMeta{ @@ -33,12 +33,12 @@ func createClusterRoleBinding(name, roleRef, serviceAccount, serviceAccountNames "cdi.kubevirt.io": "", }, }, - RoleRef: rbacv1beta1.RoleRef{ + RoleRef: rbacv1.RoleRef{ Kind: "ClusterRole", Name: roleRef, APIGroup: "rbac.authorization.k8s.io", }, - Subjects: []rbacv1beta1.Subject{ + Subjects: []rbacv1.Subject{ { Kind: "ServiceAccount", Name: serviceAccount, @@ -48,10 +48,10 @@ func createClusterRoleBinding(name, roleRef, serviceAccount, serviceAccountNames } } -func createClusterRole(name string) *rbacv1beta1.ClusterRole { - return &rbacv1beta1.ClusterRole{ +func createClusterRole(name string) *rbacv1.ClusterRole { + return &rbacv1.ClusterRole{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rbac.authorization.k8s.io/v1beta1", + APIVersion: "rbac.authorization.k8s.io/v1", Kind: "ClusterRole", }, ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/operator/resources/namespaced/apiserver.go b/pkg/operator/resources/namespaced/apiserver.go index a3847342a5..79493abc12 100644 --- a/pkg/operator/resources/namespaced/apiserver.go +++ b/pkg/operator/resources/namespaced/apiserver.go @@ -19,7 +19,7 @@ package namespaced import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - rbacv1beta1 "k8s.io/api/rbac/v1beta1" + rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/util/intstr" "kubevirt.io/containerized-data-importer/pkg/common" @@ -48,13 +48,13 @@ func createAPIServerServiceAccount() *corev1.ServiceAccount { return createServiceAccount(apiServerRessouceName) } -func createAPIServerRoleBinding(serviceAccountNamespace string) *rbacv1beta1.RoleBinding { +func createAPIServerRoleBinding(serviceAccountNamespace string) *rbacv1.RoleBinding { return createRoleBinding(apiServerRessouceName, apiServerRessouceName, apiServerRessouceName, serviceAccountNamespace) } -func createAPIServerRole() *rbacv1beta1.Role { +func createAPIServerRole() *rbacv1.Role { role := createRole(apiServerRessouceName) - role.Rules = []rbacv1beta1.PolicyRule{ + role.Rules = []rbacv1.PolicyRule{ { APIGroups: []string{ "", @@ -72,7 +72,7 @@ func createAPIServerRole() *rbacv1beta1.Role { return role } -func createExtensionAPIServerRoleBinding(serviceAccountNamespace string) *rbacv1beta1.RoleBinding { +func createExtensionAPIServerRoleBinding(serviceAccountNamespace string) *rbacv1.RoleBinding { roleBinding := createRoleBinding( extensionAPIResourceName, extensionAPIResourceName, @@ -83,9 +83,9 @@ func createExtensionAPIServerRoleBinding(serviceAccountNamespace string) *rbacv1 return roleBinding } -func createExtensionAPIServerRole() *rbacv1beta1.Role { +func createExtensionAPIServerRole() *rbacv1.Role { role := createRole(extensionAPIResourceName) - role.Rules = []rbacv1beta1.PolicyRule{ + role.Rules = []rbacv1.PolicyRule{ { APIGroups: []string{ "", diff --git a/pkg/operator/resources/namespaced/common.go b/pkg/operator/resources/namespaced/common.go index 16fe2a125b..ab001919f7 100644 --- a/pkg/operator/resources/namespaced/common.go +++ b/pkg/operator/resources/namespaced/common.go @@ -21,7 +21,7 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - rbacv1beta1 "k8s.io/api/rbac/v1beta1" + rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -57,22 +57,22 @@ func createServiceAccount(name string) *corev1.ServiceAccount { } } -func createRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace string) *rbacv1beta1.RoleBinding { - return &rbacv1beta1.RoleBinding{ +func createRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace string) *rbacv1.RoleBinding { + return &rbacv1.RoleBinding{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rbac.authorization.k8s.io/v1beta1", + APIVersion: "rbac.authorization.k8s.io/v1", Kind: "RoleBinding", }, ObjectMeta: metav1.ObjectMeta{ Name: name, Labels: withCommonLabels(nil), }, - RoleRef: rbacv1beta1.RoleRef{ + RoleRef: rbacv1.RoleRef{ Kind: "Role", Name: roleRef, APIGroup: "rbac.authorization.k8s.io", }, - Subjects: []rbacv1beta1.Subject{ + Subjects: []rbacv1.Subject{ { Kind: "ServiceAccount", Name: serviceAccount, @@ -82,10 +82,10 @@ func createRoleBinding(name, roleRef, serviceAccount, serviceAccountNamespace st } } -func createRole(name string) *rbacv1beta1.Role { - return &rbacv1beta1.Role{ +func createRole(name string) *rbacv1.Role { + return &rbacv1.Role{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rbac.authorization.k8s.io/v1beta1", + APIVersion: "rbac.authorization.k8s.io/v1", Kind: "Role", }, ObjectMeta: metav1.ObjectMeta{