├── .github └── PULL_REQUEST_TEMPLATE.md ├── CONTRIBUTING.md ├── LICENSE ├── OWNERS ├── README.md ├── SECURITY_CONTACTS ├── artifacts └── simple-image │ └── Dockerfile ├── code-of-conduct.md ├── examples └── client-go │ ├── README.md │ ├── hack │ ├── boilerplate.go.txt │ ├── tools.go │ ├── update-codegen.sh │ └── verify-codegen.sh │ └── pkg │ ├── apis │ └── cr │ │ ├── register.go │ │ └── v1 │ │ ├── doc.go │ │ ├── register.go │ │ ├── types.go │ │ └── zz_generated.deepcopy.go │ └── client │ ├── applyconfiguration │ ├── cr │ │ └── v1 │ │ │ ├── example.go │ │ │ ├── examplespec.go │ │ │ └── examplestatus.go │ ├── internal │ │ └── internal.go │ └── utils.go │ ├── clientset │ └── versioned │ │ ├── clientset.go │ │ ├── fake │ │ ├── clientset_generated.go │ │ ├── doc.go │ │ └── register.go │ │ ├── scheme │ │ ├── doc.go │ │ └── register.go │ │ └── typed │ │ └── cr │ │ └── v1 │ │ ├── cr_client.go │ │ ├── doc.go │ │ ├── example.go │ │ ├── fake │ │ ├── doc.go │ │ ├── fake_cr_client.go │ │ └── fake_example.go │ │ └── generated_expansion.go │ ├── informers │ └── externalversions │ │ ├── cr │ │ ├── interface.go │ │ └── v1 │ │ │ ├── example.go │ │ │ └── interface.go │ │ ├── factory.go │ │ ├── generic.go │ │ └── internalinterfaces │ │ └── factory_interfaces.go │ └── listers │ └── cr │ └── v1 │ ├── example.go │ └── expansion_generated.go ├── go.mod ├── go.sum ├── hack ├── boilerplate.go.txt ├── build-image.sh ├── update-codegen.sh └── verify-codegen.sh ├── main.go ├── pkg ├── apihelpers │ ├── helpers.go │ └── helpers_test.go ├── apis │ ├── .import-restrictions │ ├── OWNERS │ ├── apiextensions │ │ ├── deepcopy.go │ │ ├── doc.go │ │ ├── fuzzer │ │ │ └── fuzzer.go │ │ ├── helpers.go │ │ ├── helpers_test.go │ │ ├── install │ │ │ ├── install.go │ │ │ └── roundtrip_test.go │ │ ├── register.go │ │ ├── types.go │ │ ├── types_jsonschema.go │ │ ├── v1 │ │ │ ├── .import-restrictions │ │ │ ├── conversion.go │ │ │ ├── conversion_test.go │ │ │ ├── deepcopy.go │ │ │ ├── defaults.go │ │ │ ├── defaults_test.go │ │ │ ├── doc.go │ │ │ ├── generated.pb.go │ │ │ ├── generated.proto │ │ │ ├── marshal.go │ │ │ ├── marshal_test.go │ │ │ ├── register.go │ │ │ ├── types.go │ │ │ ├── types_jsonschema.go │ │ │ ├── zz_generated.conversion.go │ │ │ ├── zz_generated.deepcopy.go │ │ │ ├── zz_generated.defaults.go │ │ │ └── zz_generated.prerelease-lifecycle.go │ │ ├── v1beta1 │ │ │ ├── .import-restrictions │ │ │ ├── conversion.go │ │ │ ├── conversion_test.go │ │ │ ├── deepcopy.go │ │ │ ├── defaults.go │ │ │ ├── defaults_test.go │ │ │ ├── doc.go │ │ │ ├── generated.pb.go │ │ │ ├── generated.proto │ │ │ ├── marshal.go │ │ │ ├── marshal_test.go │ │ │ ├── register.go │ │ │ ├── types.go │ │ │ ├── types_jsonschema.go │ │ │ ├── zz_generated.conversion.go │ │ │ ├── zz_generated.deepcopy.go │ │ │ ├── zz_generated.defaults.go │ │ │ └── zz_generated.prerelease-lifecycle.go │ │ ├── validation │ │ │ ├── cel_validation.go │ │ │ ├── validation.go │ │ │ └── validation_test.go │ │ └── zz_generated.deepcopy.go │ ├── roundtrip_test.go │ └── testdata │ │ ├── HEAD │ │ ├── apiextensions.k8s.io.v1.ConversionReview.json │ │ ├── apiextensions.k8s.io.v1.ConversionReview.pb │ │ ├── apiextensions.k8s.io.v1.ConversionReview.yaml │ │ ├── apiextensions.k8s.io.v1.CustomResourceDefinition.json │ │ ├── apiextensions.k8s.io.v1.CustomResourceDefinition.pb │ │ ├── apiextensions.k8s.io.v1.CustomResourceDefinition.yaml │ │ ├── apiextensions.k8s.io.v1beta1.ConversionReview.json │ │ ├── apiextensions.k8s.io.v1beta1.ConversionReview.pb │ │ ├── apiextensions.k8s.io.v1beta1.ConversionReview.yaml │ │ ├── apiextensions.k8s.io.v1beta1.CustomResourceDefinition.json │ │ ├── apiextensions.k8s.io.v1beta1.CustomResourceDefinition.pb │ │ └── apiextensions.k8s.io.v1beta1.CustomResourceDefinition.yaml │ │ └── README.md ├── apiserver │ ├── apiserver.go │ ├── conversion │ │ ├── converter.go │ │ ├── converter_test.go │ │ ├── metrics.go │ │ ├── metrics_test.go │ │ ├── nop_converter.go │ │ ├── webhook_converter.go │ │ └── webhook_converter_test.go │ ├── customresource_discovery.go │ ├── customresource_discovery_controller.go │ ├── customresource_discovery_controller_test.go │ ├── customresource_handler.go │ ├── customresource_handler_test.go │ ├── helpers.go │ ├── schema │ │ ├── cel │ │ │ ├── celcoststability_test.go │ │ │ ├── compilation.go │ │ │ ├── compilation_test.go │ │ │ ├── maplist.go │ │ │ ├── maplist_test.go │ │ │ ├── model │ │ │ │ ├── adaptor.go │ │ │ │ ├── schemas.go │ │ │ │ ├── schemas_test.go │ │ │ │ └── types_test.go │ │ │ ├── validation.go │ │ │ ├── validation_test.go │ │ │ ├── values.go │ │ │ └── values_test.go │ │ ├── complete.go │ │ ├── convert.go │ │ ├── convert_test.go │ │ ├── defaulting │ │ │ ├── algorithm.go │ │ │ ├── algorithm_test.go │ │ │ ├── prune.go │ │ │ ├── prunenulls.go │ │ │ ├── prunenulls_test.go │ │ │ ├── surroundingobject.go │ │ │ ├── validation.go │ │ │ └── validation_test.go │ │ ├── kubeopenapi.go │ │ ├── kubeopenapi_test.go │ │ ├── listtype │ │ │ ├── validation.go │ │ │ └── validation_test.go │ │ ├── objectmeta │ │ │ ├── algorithm.go │ │ │ ├── algorithm_test.go │ │ │ ├── coerce.go │ │ │ ├── coerce_test.go │ │ │ ├── jsonpath_test.go │ │ │ ├── validation.go │ │ │ └── validation_test.go │ │ ├── options.go │ │ ├── pruning │ │ │ ├── algorithm.go │ │ │ └── algorithm_test.go │ │ ├── skeleton.go │ │ ├── structural.go │ │ ├── unfold.go │ │ ├── unfold_test.go │ │ ├── validation.go │ │ ├── validation_test.go │ │ ├── visitor.go │ │ └── zz_generated.deepcopy.go │ ├── testdata │ │ ├── README.md │ │ └── swagger.json │ └── validation │ │ ├── formats.go │ │ ├── formats_test.go │ │ ├── metrics.go │ │ ├── metrics_test.go │ │ ├── ratcheting.go │ │ ├── ratcheting_test.go │ │ ├── validation.go │ │ └── validation_test.go ├── client │ ├── applyconfiguration │ │ ├── apiextensions │ │ │ ├── v1 │ │ │ │ ├── customresourcecolumndefinition.go │ │ │ │ ├── customresourceconversion.go │ │ │ │ ├── customresourcedefinition.go │ │ │ │ ├── customresourcedefinitioncondition.go │ │ │ │ ├── customresourcedefinitionnames.go │ │ │ │ ├── customresourcedefinitionspec.go │ │ │ │ ├── customresourcedefinitionstatus.go │ │ │ │ ├── customresourcedefinitionversion.go │ │ │ │ ├── customresourcesubresources.go │ │ │ │ ├── customresourcesubresourcescale.go │ │ │ │ ├── customresourcevalidation.go │ │ │ │ ├── externaldocumentation.go │ │ │ │ ├── jsonschemaprops.go │ │ │ │ ├── selectablefield.go │ │ │ │ ├── servicereference.go │ │ │ │ ├── validationrule.go │ │ │ │ ├── webhookclientconfig.go │ │ │ │ └── webhookconversion.go │ │ │ └── v1beta1 │ │ │ │ ├── customresourcecolumndefinition.go │ │ │ │ ├── customresourceconversion.go │ │ │ │ ├── customresourcedefinition.go │ │ │ │ ├── customresourcedefinitioncondition.go │ │ │ │ ├── customresourcedefinitionnames.go │ │ │ │ ├── customresourcedefinitionspec.go │ │ │ │ ├── customresourcedefinitionstatus.go │ │ │ │ ├── customresourcedefinitionversion.go │ │ │ │ ├── customresourcesubresources.go │ │ │ │ ├── customresourcesubresourcescale.go │ │ │ │ ├── customresourcevalidation.go │ │ │ │ ├── externaldocumentation.go │ │ │ │ ├── jsonschemaprops.go │ │ │ │ ├── selectablefield.go │ │ │ │ ├── servicereference.go │ │ │ │ ├── validationrule.go │ │ │ │ └── webhookclientconfig.go │ │ ├── internal │ │ │ └── internal.go │ │ └── utils.go │ ├── clientset │ │ └── clientset │ │ │ ├── clientset.go │ │ │ ├── fake │ │ │ ├── clientset_generated.go │ │ │ ├── doc.go │ │ │ └── register.go │ │ │ ├── scheme │ │ │ ├── doc.go │ │ │ └── register.go │ │ │ └── typed │ │ │ └── apiextensions │ │ │ ├── v1 │ │ │ ├── apiextensions_client.go │ │ │ ├── customresourcedefinition.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ │ ├── doc.go │ │ │ │ ├── fake_apiextensions_client.go │ │ │ │ └── fake_customresourcedefinition.go │ │ │ └── generated_expansion.go │ │ │ └── v1beta1 │ │ │ ├── apiextensions_client.go │ │ │ ├── customresourcedefinition.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ ├── doc.go │ │ │ ├── fake_apiextensions_client.go │ │ │ └── fake_customresourcedefinition.go │ │ │ └── generated_expansion.go │ ├── informers │ │ └── externalversions │ │ │ ├── apiextensions │ │ │ ├── interface.go │ │ │ ├── v1 │ │ │ │ ├── customresourcedefinition.go │ │ │ │ └── interface.go │ │ │ └── v1beta1 │ │ │ │ ├── customresourcedefinition.go │ │ │ │ └── interface.go │ │ │ ├── factory.go │ │ │ ├── generic.go │ │ │ └── internalinterfaces │ │ │ └── factory_interfaces.go │ └── listers │ │ └── apiextensions │ │ ├── v1 │ │ ├── customresourcedefinition.go │ │ └── expansion_generated.go │ │ └── v1beta1 │ │ ├── customresourcedefinition.go │ │ └── expansion_generated.go ├── cmd │ └── server │ │ ├── options │ │ └── options.go │ │ ├── server.go │ │ └── testing │ │ ├── testdata │ │ ├── README.md │ │ ├── localhost_127.0.0.1_localhost.crt │ │ └── localhost_127.0.0.1_localhost.key │ │ └── testserver.go ├── controller │ ├── apiapproval │ │ ├── apiapproval_controller.go │ │ └── apiapproval_controller_test.go │ ├── establish │ │ └── establishing_controller.go │ ├── finalizer │ │ └── crd_finalizer.go │ ├── nonstructuralschema │ │ ├── nonstructuralschema_controller.go │ │ └── nonstructuralschema_controller_test.go │ ├── openapi │ │ ├── builder │ │ │ ├── builder.go │ │ │ ├── builder_test.go │ │ │ ├── merge.go │ │ │ └── merge_test.go │ │ ├── controller.go │ │ ├── controller_test.go │ │ ├── metrics.go │ │ └── v2 │ │ │ ├── conversion.go │ │ │ └── conversion_test.go │ ├── openapiv3 │ │ ├── controller.go │ │ ├── metrics.go │ │ └── util.go │ └── status │ │ ├── naming_controller.go │ │ └── naming_controller_test.go ├── crdserverscheme │ └── unstructured.go ├── features │ ├── OWNERS │ └── kube_features.go ├── generated │ └── openapi │ │ ├── doc.go │ │ └── zz_generated.openapi.go ├── registry │ ├── customresource │ │ ├── etcd.go │ │ ├── etcd_test.go │ │ ├── status_strategy.go │ │ ├── status_strategy_test.go │ │ ├── strategy.go │ │ ├── strategy_test.go │ │ ├── tableconvertor │ │ │ ├── tableconvertor.go │ │ │ └── tableconvertor_test.go │ │ └── validator.go │ └── customresourcedefinition │ │ ├── etcd.go │ │ ├── strategy.go │ │ └── strategy_test.go └── test │ ├── cel.go │ ├── example │ ├── apiexports_crd.yaml │ └── apiexports_test.go │ └── pattern.go └── test └── integration ├── apiapproval_test.go ├── apiserver.local.config └── certificates │ ├── README.md │ ├── apiserver.crt │ └── apiserver.key ├── apply_test.go ├── basic_test.go ├── cabundle_test.go ├── cbor_test.go ├── change_test.go ├── conversion ├── conversion_test.go └── webhook.go ├── defaulting_test.go ├── deprecation_test.go ├── fieldselector_test.go ├── finalization_test.go ├── fixtures ├── etcd.go ├── resources.go └── server.go ├── helpers.go ├── limit_test.go ├── listtype_test.go ├── objectmeta_test.go ├── pruning_test.go ├── ratcheting_test.go ├── ratcheting_test_cases ├── crds │ └── standard-install.yaml ├── invalid │ ├── gateway │ │ ├── duplicate-listeners.yaml │ │ ├── hostname-tcp.yaml │ │ ├── hostname-udp.yaml │ │ ├── invalid-addresses.yaml │ │ ├── invalid-listener-name.yaml │ │ ├── invalid-listener-port.yaml │ │ └── tlsconfig-tcp.yaml │ ├── gatewayclass │ │ └── invalid-controller.yaml │ ├── httproute │ │ ├── duplicate-header-match.yaml │ │ ├── duplicate-query-match.yaml │ │ ├── httproute-portless-backend.yaml │ │ ├── httproute-portless-service.yaml │ │ ├── invalid-backend-group.yaml │ │ ├── invalid-backend-kind.yaml │ │ ├── invalid-backend-port.yaml │ │ ├── invalid-filter-duplicate-header.yaml │ │ ├── invalid-filter-duplicate.yaml │ │ ├── invalid-filter-empty.yaml │ │ ├── invalid-filter-wrong-field.yaml │ │ ├── invalid-header-name.yaml │ │ ├── invalid-hostname.yaml │ │ ├── invalid-httredirect-hostname.yaml │ │ ├── invalid-method.yaml │ │ ├── invalid-path-alphanum-specialchars-mix.yaml │ │ ├── invalid-path-specialchars.yaml │ │ └── invalid-request-redirect-with-backendref.yaml │ └── referencegrant │ │ ├── missing-from.yaml │ │ ├── missing-ns.yaml │ │ └── missing-to.yaml └── valid │ ├── 0-namespaces.yaml │ ├── basic-http.yaml │ ├── cross-namespace-routing │ ├── 0-namespaces.yaml │ ├── gateway.yaml │ ├── site-route.yaml │ └── store-route.yaml │ ├── default-match-http.yaml │ ├── gateway-addresses.yaml │ ├── http-filter.yaml │ ├── http-redirect-path.yaml │ ├── http-redirect-rewrite │ ├── httproute-redirect-full.yaml │ ├── httproute-redirect-https.yaml │ ├── httproute-redirect-prefix.yaml │ ├── httproute-rewrite-path.yaml │ ├── httproute-rewrite.yaml │ └── httproute-rewritepath.yaml │ ├── http-redirect.yaml │ ├── http-request-header-add.yaml │ ├── http-request-header-remove.yaml │ ├── http-request-header-set.yaml │ ├── http-rewrite.yaml │ ├── http-route-attachment │ ├── gateway-namespaces.yaml │ ├── gateway-strict.yaml │ └── httproute.yaml │ ├── http-routing │ ├── bar-httproute.yaml │ ├── foo-httproute.yaml │ └── gateway.yaml │ ├── httproute.yaml │ ├── multicluster │ ├── 0-namespaces.yaml │ ├── httproute-gamma.yaml │ ├── httproute-hybrid.yaml │ ├── httproute-location.yaml │ ├── httproute-method.yaml │ ├── httproute-referencegrant.yaml │ └── httproute-simple.yaml │ ├── reference-grant.yaml │ ├── simple-gateway │ ├── gateway.yaml │ └── httproute.yaml │ ├── simple-http-https │ ├── bar-route.yaml │ ├── foo-route.yaml │ ├── gateway.yaml │ └── tls-redirect-route.yaml │ ├── tls-basic.yaml │ ├── tls-cert-cross-namespace.yaml │ ├── traffic-splitting │ ├── simple-split.yaml │ ├── traffic-split-1.yaml │ ├── traffic-split-2.yaml │ └── traffic-split-3.yaml │ └── wildcard-tls-gateway.yaml ├── registration_test.go ├── scope_test.go ├── storage └── objectreader.go ├── subresources_test.go ├── table_test.go ├── validation_test.go ├── versioning_test.go └── yaml_test.go /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Sorry, we do not accept changes directly against this repository. Please see 2 | CONTRIBUTING.md for information on where and how to contribute instead. 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | 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. 4 | 5 | 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). 6 | 7 | Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/sig-architecture/staging.md) for more information 8 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - deads2k 5 | - sttts 6 | - jpbetz 7 | reviewers: 8 | - deads2k 9 | - sttts 10 | - yue9944882 11 | - logicalhan 12 | - jpbetz 13 | - roycaihw 14 | - alexzielenski 15 | - jefftree 16 | labels: 17 | - sig/api-machinery 18 | emeritus_approvers: 19 | - lavalamp 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # apiextensions-apiserver 2 | 3 | Implements: https://github.com/kubernetes/design-proposals-archive/blob/main/api-machinery/thirdpartyresources.md 4 | 5 | It provides an API for registering `CustomResourceDefinitions`. 6 | 7 | ## Purpose 8 | 9 | This API server provides the implementation for `CustomResourceDefinitions` which is included as 10 | delegate server inside of `kube-apiserver`. 11 | 12 | 13 | ## Compatibility 14 | 15 | HEAD of this repo will match HEAD of k8s.io/apiserver, k8s.io/apimachinery, and k8s.io/client-go. 16 | 17 | ## Where does it come from? 18 | 19 | `apiextensions-apiserver` is synced from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver. 20 | Code changes are made in that location, merged into `k8s.io/kubernetes` and later synced here. 21 | 22 | -------------------------------------------------------------------------------- /SECURITY_CONTACTS: -------------------------------------------------------------------------------- 1 | # Defined below are the security contacts for this repo. 2 | # 3 | # They are the contact point for the Product Security Committee to reach out 4 | # to for triaging and handling of incoming issues. 5 | # 6 | # The below names agree to abide by the 7 | # [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy) 8 | # and will be removed and replaced if they violate that agreement. 9 | # 10 | # DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE 11 | # INSTRUCTIONS AT https://kubernetes.io/security/ 12 | 13 | cheftako 14 | deads2k 15 | lavalamp 16 | sttts 17 | -------------------------------------------------------------------------------- /artifacts/simple-image/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Kubernetes Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM gcr.io/distroless/base-debian10:latest 16 | ADD apiextensions-apiserver / 17 | ENTRYPOINT ["/apiextensions-apiserver"] 18 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Kubernetes Community Code of Conduct 2 | 3 | Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /examples/client-go/hack/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /examples/client-go/hack/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | /* 5 | Copyright 2019 The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // This package imports things required by build scripts, to force `go mod` to see them as dependencies 21 | package tools 22 | 23 | import _ "k8s.io/code-generator" 24 | -------------------------------------------------------------------------------- /examples/client-go/hack/update-codegen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. 22 | CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../../../code-generator)} 23 | 24 | source "${CODEGEN_PKG}/kube_codegen.sh" 25 | 26 | THIS_PKG="k8s.io/apiextensions-apiserver/examples/client-go" 27 | 28 | kube::codegen::gen_helpers \ 29 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 30 | "${SCRIPT_ROOT}/pkg/apis" 31 | 32 | kube::codegen::gen_client \ 33 | --with-watch \ 34 | --with-applyconfig \ 35 | --output-dir "${SCRIPT_ROOT}/pkg/client" \ 36 | --output-pkg "${THIS_PKG}/pkg/client" \ 37 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 38 | "${SCRIPT_ROOT}/pkg/apis" 39 | -------------------------------------------------------------------------------- /examples/client-go/hack/verify-codegen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" 22 | DIFFROOT="${SCRIPT_ROOT}/pkg" 23 | TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg" 24 | 25 | cleanup() { 26 | rm -rf "${TMP_DIFFROOT}" 27 | } 28 | trap "cleanup" EXIT SIGINT 29 | 30 | cleanup 31 | 32 | mkdir -p "${TMP_DIFFROOT}" 33 | cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" 34 | 35 | "${SCRIPT_ROOT}/hack/update-codegen.sh" 36 | echo "diffing ${DIFFROOT} against freshly generated codegen" 37 | ret=0 38 | diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? 39 | if [[ $ret -eq 0 ]]; then 40 | echo "${DIFFROOT} up to date." 41 | else 42 | echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" 43 | fi 44 | exit $ret 45 | -------------------------------------------------------------------------------- /examples/client-go/pkg/apis/cr/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cr 18 | 19 | const ( 20 | GroupName = "cr.example.apiextensions.k8s.io" 21 | ) 22 | -------------------------------------------------------------------------------- /examples/client-go/pkg/apis/cr/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +groupName=cr.example.apiextensions.k8s.io 19 | 20 | // Package v1 is the v1 version of the API. 21 | package v1 22 | -------------------------------------------------------------------------------- /examples/client-go/pkg/apis/cr/v1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | 24 | cr "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr" 25 | ) 26 | 27 | // SchemeGroupVersion is group version used to register these objects 28 | var SchemeGroupVersion = schema.GroupVersion{Group: cr.GroupName, Version: "v1"} 29 | 30 | // Kind takes an unqualified kind and returns back a Group qualified GroupKind 31 | func Kind(kind string) schema.GroupKind { 32 | return SchemeGroupVersion.WithKind(kind).GroupKind() 33 | } 34 | 35 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 36 | func Resource(resource string) schema.GroupResource { 37 | return SchemeGroupVersion.WithResource(resource).GroupResource() 38 | } 39 | 40 | var ( 41 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 42 | AddToScheme = SchemeBuilder.AddToScheme 43 | ) 44 | 45 | // Adds the list of known types to Scheme. 46 | func addKnownTypes(scheme *runtime.Scheme) error { 47 | scheme.AddKnownTypes(SchemeGroupVersion, 48 | &Example{}, 49 | &ExampleList{}, 50 | ) 51 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /examples/client-go/pkg/apis/cr/v1/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +genclient 24 | // +genclient:noStatus 25 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 | 27 | // Example is a specification for an Example resource 28 | type Example struct { 29 | metav1.TypeMeta `json:",inline"` 30 | metav1.ObjectMeta `json:"metadata"` 31 | 32 | Spec ExampleSpec `json:"spec"` 33 | Status ExampleStatus `json:"status,omitempty"` 34 | } 35 | 36 | // ExampleSpec is the spec for an Example resource 37 | type ExampleSpec struct { 38 | Foo string `json:"foo"` 39 | Bar bool `json:"bar"` 40 | } 41 | 42 | // ExampleStatus is the status for an Example resource 43 | type ExampleStatus struct { 44 | State ExampleState `json:"state,omitempty"` 45 | Message string `json:"message,omitempty"` 46 | } 47 | 48 | type ExampleState string 49 | 50 | const ( 51 | ExampleStateCreated ExampleState = "Created" 52 | ExampleStateProcessed ExampleState = "Processed" 53 | ) 54 | 55 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 56 | 57 | // ExampleList is a list of Example resources 58 | type ExampleList struct { 59 | metav1.TypeMeta `json:",inline"` 60 | metav1.ListMeta `json:"metadata"` 61 | 62 | Items []Example `json:"items"` 63 | } 64 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/applyconfiguration/cr/v1/examplespec.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // ExampleSpecApplyConfiguration represents a declarative configuration of the ExampleSpec type for use 22 | // with apply. 23 | type ExampleSpecApplyConfiguration struct { 24 | Foo *string `json:"foo,omitempty"` 25 | Bar *bool `json:"bar,omitempty"` 26 | } 27 | 28 | // ExampleSpecApplyConfiguration constructs a declarative configuration of the ExampleSpec type for use with 29 | // apply. 30 | func ExampleSpec() *ExampleSpecApplyConfiguration { 31 | return &ExampleSpecApplyConfiguration{} 32 | } 33 | 34 | // WithFoo sets the Foo field in the declarative configuration to the given value 35 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 36 | // If called multiple times, the Foo field is set to the value of the last call. 37 | func (b *ExampleSpecApplyConfiguration) WithFoo(value string) *ExampleSpecApplyConfiguration { 38 | b.Foo = &value 39 | return b 40 | } 41 | 42 | // WithBar sets the Bar field in the declarative configuration to the given value 43 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 44 | // If called multiple times, the Bar field is set to the value of the last call. 45 | func (b *ExampleSpecApplyConfiguration) WithBar(value bool) *ExampleSpecApplyConfiguration { 46 | b.Bar = &value 47 | return b 48 | } 49 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/applyconfiguration/cr/v1/examplestatus.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | import ( 22 | crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" 23 | ) 24 | 25 | // ExampleStatusApplyConfiguration represents a declarative configuration of the ExampleStatus type for use 26 | // with apply. 27 | type ExampleStatusApplyConfiguration struct { 28 | State *crv1.ExampleState `json:"state,omitempty"` 29 | Message *string `json:"message,omitempty"` 30 | } 31 | 32 | // ExampleStatusApplyConfiguration constructs a declarative configuration of the ExampleStatus type for use with 33 | // apply. 34 | func ExampleStatus() *ExampleStatusApplyConfiguration { 35 | return &ExampleStatusApplyConfiguration{} 36 | } 37 | 38 | // WithState sets the State field in the declarative configuration to the given value 39 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 40 | // If called multiple times, the State field is set to the value of the last call. 41 | func (b *ExampleStatusApplyConfiguration) WithState(value crv1.ExampleState) *ExampleStatusApplyConfiguration { 42 | b.State = &value 43 | return b 44 | } 45 | 46 | // WithMessage sets the Message field in the declarative configuration to the given value 47 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 48 | // If called multiple times, the Message field is set to the value of the last call. 49 | func (b *ExampleStatusApplyConfiguration) WithMessage(value string) *ExampleStatusApplyConfiguration { 50 | b.Message = &value 51 | return b 52 | } 53 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/applyconfiguration/internal/internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package internal 20 | 21 | import ( 22 | fmt "fmt" 23 | sync "sync" 24 | 25 | typed "sigs.k8s.io/structured-merge-diff/v4/typed" 26 | ) 27 | 28 | func Parser() *typed.Parser { 29 | parserOnce.Do(func() { 30 | var err error 31 | parser, err = typed.NewParser(schemaYAML) 32 | if err != nil { 33 | panic(fmt.Sprintf("Failed to parse schema: %v", err)) 34 | } 35 | }) 36 | return parser 37 | } 38 | 39 | var parserOnce sync.Once 40 | var parser *typed.Parser 41 | var schemaYAML = typed.YAMLObject(`types: 42 | - name: __untyped_atomic_ 43 | scalar: untyped 44 | list: 45 | elementType: 46 | namedType: __untyped_atomic_ 47 | elementRelationship: atomic 48 | map: 49 | elementType: 50 | namedType: __untyped_atomic_ 51 | elementRelationship: atomic 52 | - name: __untyped_deduced_ 53 | scalar: untyped 54 | list: 55 | elementType: 56 | namedType: __untyped_atomic_ 57 | elementRelationship: atomic 58 | map: 59 | elementType: 60 | namedType: __untyped_deduced_ 61 | elementRelationship: separable 62 | `) 63 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/applyconfiguration/utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package applyconfiguration 20 | 21 | import ( 22 | v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" 23 | crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1" 24 | internal "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/internal" 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | schema "k8s.io/apimachinery/pkg/runtime/schema" 27 | managedfields "k8s.io/apimachinery/pkg/util/managedfields" 28 | ) 29 | 30 | // ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no 31 | // apply configuration type exists for the given GroupVersionKind. 32 | func ForKind(kind schema.GroupVersionKind) interface{} { 33 | switch kind { 34 | // Group=cr.example.apiextensions.k8s.io, Version=v1 35 | case v1.SchemeGroupVersion.WithKind("Example"): 36 | return &crv1.ExampleApplyConfiguration{} 37 | case v1.SchemeGroupVersion.WithKind("ExampleSpec"): 38 | return &crv1.ExampleSpecApplyConfiguration{} 39 | case v1.SchemeGroupVersion.WithKind("ExampleStatus"): 40 | return &crv1.ExampleStatusApplyConfiguration{} 41 | 42 | } 43 | return nil 44 | } 45 | 46 | func NewTypeConverter(scheme *runtime.Scheme) managedfields.TypeConverter { 47 | return managedfields.NewSchemeTypeConverter(scheme, internal.Parser()) 48 | } 49 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/fake/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var scheme = runtime.NewScheme() 31 | var codecs = serializer.NewCodecFactory(scheme) 32 | 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | crv1.AddToScheme, 35 | } 36 | 37 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 38 | // of clientsets, like in: 39 | // 40 | // import ( 41 | // "k8s.io/client-go/kubernetes" 42 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 43 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 44 | // ) 45 | // 46 | // kclientset, _ := kubernetes.NewForConfig(c) 47 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 48 | // 49 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 50 | // correctly. 51 | var AddToScheme = localSchemeBuilder.AddToScheme 52 | 53 | func init() { 54 | v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) 55 | utilruntime.Must(AddToScheme(scheme)) 56 | } 57 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/scheme/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package scheme 20 | 21 | import ( 22 | crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var Scheme = runtime.NewScheme() 31 | var Codecs = serializer.NewCodecFactory(Scheme) 32 | var ParameterCodec = runtime.NewParameterCodec(Scheme) 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | crv1.AddToScheme, 35 | } 36 | 37 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 38 | // of clientsets, like in: 39 | // 40 | // import ( 41 | // "k8s.io/client-go/kubernetes" 42 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 43 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 44 | // ) 45 | // 46 | // kclientset, _ := kubernetes.NewForConfig(c) 47 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 48 | // 49 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 50 | // correctly. 51 | var AddToScheme = localSchemeBuilder.AddToScheme 52 | 53 | func init() { 54 | v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 55 | utilruntime.Must(AddToScheme(Scheme)) 56 | } 57 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeCrV1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeCrV1) Examples(namespace string) v1.ExampleInterface { 32 | return newFakeExamples(c, namespace) 33 | } 34 | 35 | // RESTClient returns a RESTClient that is used to communicate 36 | // with API server by this client implementation. 37 | func (c *FakeCrV1) RESTClient() rest.Interface { 38 | var ret *rest.RESTClient 39 | return ret 40 | } 41 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" 23 | crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1" 24 | typedcrv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1" 25 | gentype "k8s.io/client-go/gentype" 26 | ) 27 | 28 | // fakeExamples implements ExampleInterface 29 | type fakeExamples struct { 30 | *gentype.FakeClientWithListAndApply[*v1.Example, *v1.ExampleList, *crv1.ExampleApplyConfiguration] 31 | Fake *FakeCrV1 32 | } 33 | 34 | func newFakeExamples(fake *FakeCrV1, namespace string) typedcrv1.ExampleInterface { 35 | return &fakeExamples{ 36 | gentype.NewFakeClientWithListAndApply[*v1.Example, *v1.ExampleList, *crv1.ExampleApplyConfiguration]( 37 | fake.Fake, 38 | namespace, 39 | v1.SchemeGroupVersion.WithResource("examples"), 40 | v1.SchemeGroupVersion.WithKind("Example"), 41 | func() *v1.Example { return &v1.Example{} }, 42 | func() *v1.ExampleList { return &v1.ExampleList{} }, 43 | func(dst, src *v1.ExampleList) { dst.ListMeta = src.ListMeta }, 44 | func(list *v1.ExampleList) []*v1.Example { return gentype.ToPointerSlice(list.Items) }, 45 | func(list *v1.ExampleList, items []*v1.Example) { list.Items = gentype.FromPointerSlice(items) }, 46 | ), 47 | fake, 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type ExampleExpansion interface{} 22 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/informers/externalversions/cr/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package cr 20 | 21 | import ( 22 | v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1" 23 | internalinterfaces "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces" 24 | ) 25 | 26 | // Interface provides access to each of this group's versions. 27 | type Interface interface { 28 | // V1 provides access to shared informers for resources in V1. 29 | V1() v1.Interface 30 | } 31 | 32 | type group struct { 33 | factory internalinterfaces.SharedInformerFactory 34 | namespace string 35 | tweakListOptions internalinterfaces.TweakListOptionsFunc 36 | } 37 | 38 | // New returns a new Interface. 39 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 40 | return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 41 | } 42 | 43 | // V1 returns a new v1.Interface. 44 | func (g *group) V1() v1.Interface { 45 | return v1.New(g.factory, g.namespace, g.tweakListOptions) 46 | } 47 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/informers/externalversions/cr/v1/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | import ( 22 | internalinterfaces "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces" 23 | ) 24 | 25 | // Interface provides access to all the informers in this group version. 26 | type Interface interface { 27 | // Examples returns a ExampleInformer. 28 | Examples() ExampleInformer 29 | } 30 | 31 | type version struct { 32 | factory internalinterfaces.SharedInformerFactory 33 | namespace string 34 | tweakListOptions internalinterfaces.TweakListOptionsFunc 35 | } 36 | 37 | // New returns a new Interface. 38 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 39 | return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 40 | } 41 | 42 | // Examples returns a ExampleInformer. 43 | func (v *version) Examples() ExampleInformer { 44 | return &exampleInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} 45 | } 46 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/informers/externalversions/generic.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package externalversions 20 | 21 | import ( 22 | fmt "fmt" 23 | 24 | v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | cache "k8s.io/client-go/tools/cache" 27 | ) 28 | 29 | // GenericInformer is type of SharedIndexInformer which will locate and delegate to other 30 | // sharedInformers based on type 31 | type GenericInformer interface { 32 | Informer() cache.SharedIndexInformer 33 | Lister() cache.GenericLister 34 | } 35 | 36 | type genericInformer struct { 37 | informer cache.SharedIndexInformer 38 | resource schema.GroupResource 39 | } 40 | 41 | // Informer returns the SharedIndexInformer. 42 | func (f *genericInformer) Informer() cache.SharedIndexInformer { 43 | return f.informer 44 | } 45 | 46 | // Lister returns the GenericLister. 47 | func (f *genericInformer) Lister() cache.GenericLister { 48 | return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 49 | } 50 | 51 | // ForResource gives generic access to a shared informer of the matching type 52 | // TODO extend this to unknown resources with a client pool 53 | func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 54 | switch resource { 55 | // Group=cr.example.apiextensions.k8s.io, Version=v1 56 | case v1.SchemeGroupVersion.WithResource("examples"): 57 | return &genericInformer{resource: resource.GroupResource(), informer: f.Cr().V1().Examples().Informer()}, nil 58 | 59 | } 60 | 61 | return nil, fmt.Errorf("no informer found for %v", resource) 62 | } 63 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package internalinterfaces 20 | 21 | import ( 22 | time "time" 23 | 24 | versioned "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | runtime "k8s.io/apimachinery/pkg/runtime" 27 | cache "k8s.io/client-go/tools/cache" 28 | ) 29 | 30 | // NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. 31 | type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer 32 | 33 | // SharedInformerFactory a small interface to allow for adding an informer without an import cycle 34 | type SharedInformerFactory interface { 35 | Start(stopCh <-chan struct{}) 36 | InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer 37 | } 38 | 39 | // TweakListOptionsFunc is a function that transforms a v1.ListOptions. 40 | type TweakListOptionsFunc func(*v1.ListOptions) 41 | -------------------------------------------------------------------------------- /examples/client-go/pkg/client/listers/cr/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // ExampleListerExpansion allows custom methods to be added to 22 | // ExampleLister. 23 | type ExampleListerExpansion interface{} 24 | 25 | // ExampleNamespaceListerExpansion allows custom methods to be added to 26 | // ExampleNamespaceLister. 27 | type ExampleNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /hack/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /hack/build-image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2014 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../../../../.. 22 | source "${KUBE_ROOT}/hack/lib/util.sh" 23 | 24 | # Register function to be called on EXIT to remove generated binary. 25 | function cleanup { 26 | rm "${KUBE_ROOT}/staging/src/k8s.io/apiextensions-apiserver/artifacts/simple-image/apiextensions-apiserver" 27 | } 28 | trap cleanup EXIT 29 | 30 | pushd "${KUBE_ROOT}/staging/src/k8s.io/apiextensions-apiserver" 31 | cp -v ../../../../_output/local/bin/linux/amd64/apiextensions-apiserver ./artifacts/simple-image/apiextensions-apiserver 32 | docker build -t apiextensions-apiserver:latest ./artifacts/simple-image 33 | popd 34 | -------------------------------------------------------------------------------- /hack/update-codegen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. 22 | CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} 23 | 24 | source "${CODEGEN_PKG}/kube_codegen.sh" 25 | 26 | THIS_PKG="k8s.io/apiextensions-apiserver" 27 | 28 | kube::codegen::gen_helpers \ 29 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 30 | "${SCRIPT_ROOT}/pkg" 31 | 32 | if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then 33 | report_filename="${API_KNOWN_VIOLATIONS_DIR}/apiextensions_violation_exceptions.list" 34 | if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then 35 | update_report="--update-report" 36 | fi 37 | fi 38 | 39 | kube::codegen::gen_openapi \ 40 | --extra-pkgs k8s.io/api/autoscaling/v1 `# needed for Scale type` \ 41 | --output-dir "${SCRIPT_ROOT}/pkg/generated/openapi" \ 42 | --output-pkg "${THIS_PKG}/pkg/generated/openapi" \ 43 | --report-filename "${report_filename:-"/dev/null"}" \ 44 | ${update_report:+"${update_report}"} \ 45 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 46 | "${SCRIPT_ROOT}/pkg" 47 | 48 | kube::codegen::gen_client \ 49 | --with-watch \ 50 | --with-applyconfig \ 51 | --output-dir "${SCRIPT_ROOT}/pkg/client" \ 52 | --output-pkg "${THIS_PKG}/pkg/client" \ 53 | --versioned-name "clientset" \ 54 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 55 | --prefers-protobuf \ 56 | "${SCRIPT_ROOT}/pkg/apis" 57 | -------------------------------------------------------------------------------- /hack/verify-codegen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 The Kubernetes Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" 22 | DIFFROOT="${SCRIPT_ROOT}/pkg" 23 | TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg" 24 | 25 | cleanup() { 26 | rm -rf "${TMP_DIFFROOT}" 27 | } 28 | trap "cleanup" EXIT SIGINT 29 | 30 | cleanup 31 | 32 | mkdir -p "${TMP_DIFFROOT}" 33 | cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" 34 | 35 | "${SCRIPT_ROOT}/hack/update-codegen.sh" 36 | echo "diffing ${DIFFROOT} against freshly generated codegen" 37 | ret=0 38 | diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? 39 | if [[ $ret -eq 0 ]]; then 40 | echo "${DIFFROOT} up to date." 41 | else 42 | echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" 43 | fi 44 | exit $ret 45 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "os" 21 | 22 | "k8s.io/apiextensions-apiserver/pkg/cmd/server" 23 | genericapiserver "k8s.io/apiserver/pkg/server" 24 | "k8s.io/component-base/cli" 25 | ) 26 | 27 | func main() { 28 | ctx := genericapiserver.SetupSignalContext() 29 | cmd := server.NewServerCommand(ctx, os.Stdout, os.Stderr) 30 | code := cli.Run(cmd) 31 | os.Exit(code) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/apis/.import-restrictions: -------------------------------------------------------------------------------- 1 | inverseRules: 2 | # Allow Internal packages only in apiextensions-apiserver itself, discourage use elsewhere. 3 | - selectorRegexp: k8s[.]io/apiextensions-apiserver 4 | allowedPrefixes: 5 | - '' 6 | # Allow use from within e2e tests. 7 | - selectorRegexp: k8s[.]io/kubernetes/test 8 | allowedPrefixes: 9 | - k8s.io/kubernetes/test/e2e/apimachinery 10 | # Forbid use of this package in other k8s.io packages. 11 | - selectorRegexp: k8s[.]io 12 | forbiddenPrefixes: 13 | - '' 14 | -------------------------------------------------------------------------------- /pkg/apis/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | # Disable inheritance as this is an api owners file 4 | options: 5 | no_parent_owners: true 6 | approvers: 7 | - api-approvers 8 | reviewers: 9 | - api-reviewers 10 | labels: 11 | - kind/api-change 12 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +groupName=apiextensions.k8s.io 19 | 20 | // Package apiextensions is the internal version of the API. 21 | package apiextensions 22 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package install 18 | 19 | import ( 20 | "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" 21 | v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 22 | "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" 23 | "k8s.io/apimachinery/pkg/runtime" 24 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 25 | ) 26 | 27 | // Install registers the API group and adds types to a scheme 28 | func Install(scheme *runtime.Scheme) { 29 | utilruntime.Must(apiextensions.AddToScheme(scheme)) 30 | utilruntime.Must(v1beta1.AddToScheme(scheme)) 31 | utilruntime.Must(v1.AddToScheme(scheme)) 32 | utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v1beta1.SchemeGroupVersion)) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/install/roundtrip_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package install 18 | 19 | import ( 20 | "testing" 21 | 22 | apiextensionsfuzzer "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/fuzzer" 23 | "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" 24 | ) 25 | 26 | func TestRoundTrip(t *testing.T) { 27 | roundtrip.RoundTripTestForAPIGroup(t, Install, apiextensionsfuzzer.Funcs) 28 | roundtrip.RoundTripProtobufTestForAPIGroup(t, Install, apiextensionsfuzzer.Funcs) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package apiextensions 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "k8s.io/apimachinery/pkg/runtime/schema" 22 | ) 23 | 24 | const GroupName = "apiextensions.k8s.io" 25 | 26 | // SchemeGroupVersion is group version used to register these objects 27 | var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} 28 | 29 | // Kind takes an unqualified kind and returns back a Group qualified GroupKind 30 | func Kind(kind string) schema.GroupKind { 31 | return SchemeGroupVersion.WithKind(kind).GroupKind() 32 | } 33 | 34 | // Resource takes an unqualified resource and returns back a Group qualified GroupResource 35 | func Resource(resource string) schema.GroupResource { 36 | return SchemeGroupVersion.WithResource(resource).GroupResource() 37 | } 38 | 39 | var ( 40 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 41 | AddToScheme = SchemeBuilder.AddToScheme 42 | ) 43 | 44 | // Adds the list of known types to the given scheme. 45 | func addKnownTypes(scheme *runtime.Scheme) error { 46 | scheme.AddKnownTypes(SchemeGroupVersion, 47 | &CustomResourceDefinition{}, 48 | &CustomResourceDefinitionList{}, 49 | ) 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1/.import-restrictions: -------------------------------------------------------------------------------- 1 | inverseRules: 2 | # Allow use of this package in all k8s.io packages. 3 | - selectorRegexp: k8s[.]io 4 | allowedPrefixes: 5 | - '' 6 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "strings" 21 | 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilpointer "k8s.io/utils/pointer" 24 | ) 25 | 26 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 27 | return RegisterDefaults(scheme) 28 | } 29 | 30 | func SetDefaults_CustomResourceDefinition(obj *CustomResourceDefinition) { 31 | SetDefaults_CustomResourceDefinitionSpec(&obj.Spec) 32 | if len(obj.Status.StoredVersions) == 0 { 33 | for _, v := range obj.Spec.Versions { 34 | if v.Storage { 35 | obj.Status.StoredVersions = append(obj.Status.StoredVersions, v.Name) 36 | break 37 | } 38 | } 39 | } 40 | } 41 | 42 | func SetDefaults_CustomResourceDefinitionSpec(obj *CustomResourceDefinitionSpec) { 43 | if len(obj.Names.Singular) == 0 { 44 | obj.Names.Singular = strings.ToLower(obj.Names.Kind) 45 | } 46 | if len(obj.Names.ListKind) == 0 && len(obj.Names.Kind) > 0 { 47 | obj.Names.ListKind = obj.Names.Kind + "List" 48 | } 49 | if obj.Conversion == nil { 50 | obj.Conversion = &CustomResourceConversion{ 51 | Strategy: NoneConverter, 52 | } 53 | } 54 | } 55 | 56 | // SetDefaults_ServiceReference sets defaults for Webhook's ServiceReference 57 | func SetDefaults_ServiceReference(obj *ServiceReference) { 58 | if obj.Port == nil { 59 | obj.Port = utilpointer.Int32Ptr(443) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:protobuf-gen=package 19 | // +k8s:conversion-gen=k8s.io/apiextensions-apiserver/pkg/apis/apiextensions 20 | // +k8s:defaulter-gen=TypeMeta 21 | // +k8s:openapi-gen=true 22 | // +k8s:prerelease-lifecycle-gen=true 23 | // +groupName=apiextensions.k8s.io 24 | 25 | // Package v1 is the v1 version of the API. 26 | package v1 27 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | const GroupName = "apiextensions.k8s.io" 26 | 27 | // SchemeGroupVersion is group version used to register these objects 28 | var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} 29 | 30 | // Kind takes an unqualified kind and returns back a Group qualified GroupKind 31 | func Kind(kind string) schema.GroupKind { 32 | return SchemeGroupVersion.WithKind(kind).GroupKind() 33 | } 34 | 35 | // Resource takes an unqualified resource and returns back a Group qualified GroupResource 36 | func Resource(resource string) schema.GroupResource { 37 | return SchemeGroupVersion.WithResource(resource).GroupResource() 38 | } 39 | 40 | var ( 41 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs) 42 | localSchemeBuilder = &SchemeBuilder 43 | AddToScheme = localSchemeBuilder.AddToScheme 44 | ) 45 | 46 | // Adds the list of known types to the given scheme. 47 | func addKnownTypes(scheme *runtime.Scheme) error { 48 | scheme.AddKnownTypes(SchemeGroupVersion, 49 | &CustomResourceDefinition{}, 50 | &CustomResourceDefinitionList{}, 51 | &ConversionReview{}, 52 | ) 53 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 54 | return nil 55 | } 56 | 57 | func init() { 58 | // We only register manually written functions here. The registration of the 59 | // generated functions takes place in the generated files. The separation 60 | // makes the code compile even when the generated files are missing. 61 | localSchemeBuilder.Register(addDefaultingFuncs) 62 | } 63 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | scheme.AddTypeDefaultingFunc(&CustomResourceDefinition{}, func(obj interface{}) { SetObjectDefaults_CustomResourceDefinition(obj.(*CustomResourceDefinition)) }) 33 | scheme.AddTypeDefaultingFunc(&CustomResourceDefinitionList{}, func(obj interface{}) { 34 | SetObjectDefaults_CustomResourceDefinitionList(obj.(*CustomResourceDefinitionList)) 35 | }) 36 | return nil 37 | } 38 | 39 | func SetObjectDefaults_CustomResourceDefinition(in *CustomResourceDefinition) { 40 | SetDefaults_CustomResourceDefinition(in) 41 | SetDefaults_CustomResourceDefinitionSpec(&in.Spec) 42 | if in.Spec.Conversion != nil { 43 | if in.Spec.Conversion.Webhook != nil { 44 | if in.Spec.Conversion.Webhook.ClientConfig != nil { 45 | if in.Spec.Conversion.Webhook.ClientConfig.Service != nil { 46 | SetDefaults_ServiceReference(in.Spec.Conversion.Webhook.ClientConfig.Service) 47 | } 48 | } 49 | } 50 | } 51 | } 52 | 53 | func SetObjectDefaults_CustomResourceDefinitionList(in *CustomResourceDefinitionList) { 54 | for i := range in.Items { 55 | a := &in.Items[i] 56 | SetObjectDefaults_CustomResourceDefinition(a) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1/zz_generated.prerelease-lifecycle.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by prerelease-lifecycle-gen. DO NOT EDIT. 21 | 22 | package v1 23 | 24 | // APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison. 25 | // It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go. 26 | func (in *ConversionReview) APILifecycleIntroduced() (major, minor int) { 27 | return 1, 16 28 | } 29 | 30 | // APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison. 31 | // It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go. 32 | func (in *CustomResourceDefinition) APILifecycleIntroduced() (major, minor int) { 33 | return 1, 16 34 | } 35 | 36 | // APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison. 37 | // It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go. 38 | func (in *CustomResourceDefinitionList) APILifecycleIntroduced() (major, minor int) { 39 | return 1, 16 40 | } 41 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1beta1/.import-restrictions: -------------------------------------------------------------------------------- 1 | inverseRules: 2 | # Allow use of this package in all k8s.io packages. 3 | - selectorRegexp: k8s[.]io 4 | allowedPrefixes: 5 | - '' 6 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1beta1/conversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "bytes" 21 | 22 | "k8s.io/apimachinery/pkg/conversion" 23 | "k8s.io/apimachinery/pkg/util/json" 24 | 25 | "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" 26 | ) 27 | 28 | func Convert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in *apiextensions.JSONSchemaProps, out *JSONSchemaProps, s conversion.Scope) error { 29 | if err := autoConvert_apiextensions_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in, out, s); err != nil { 30 | return err 31 | } 32 | if in.Default != nil && *(in.Default) == nil { 33 | out.Default = nil 34 | } 35 | if in.Example != nil && *(in.Example) == nil { 36 | out.Example = nil 37 | } 38 | return nil 39 | } 40 | 41 | var nullLiteral = []byte(`null`) 42 | 43 | func Convert_apiextensions_JSON_To_v1beta1_JSON(in *apiextensions.JSON, out *JSON, s conversion.Scope) error { 44 | raw, err := json.Marshal(*in) 45 | if err != nil { 46 | return err 47 | } 48 | if len(raw) == 0 || bytes.Equal(raw, nullLiteral) { 49 | // match JSON#UnmarshalJSON treatment of literal nulls 50 | out.Raw = nil 51 | } else { 52 | out.Raw = raw 53 | } 54 | return nil 55 | } 56 | 57 | func Convert_v1beta1_JSON_To_apiextensions_JSON(in *JSON, out *apiextensions.JSON, s conversion.Scope) error { 58 | if in != nil { 59 | var i interface{} 60 | if len(in.Raw) > 0 && !bytes.Equal(in.Raw, nullLiteral) { 61 | if err := json.Unmarshal(in.Raw, &i); err != nil { 62 | return err 63 | } 64 | } 65 | *out = i 66 | } else { 67 | *out = nil 68 | } 69 | return nil 70 | } 71 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package 18 | // +k8s:protobuf-gen=package 19 | // +k8s:conversion-gen=k8s.io/apiextensions-apiserver/pkg/apis/apiextensions 20 | // +k8s:defaulter-gen=TypeMeta 21 | // +k8s:openapi-gen=true 22 | // +k8s:prerelease-lifecycle-gen=true 23 | // +groupName=apiextensions.k8s.io 24 | 25 | // Package v1beta1 is the v1beta1 version of the API. 26 | package v1beta1 27 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1beta1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | const GroupName = "apiextensions.k8s.io" 26 | 27 | // SchemeGroupVersion is group version used to register these objects 28 | var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} 29 | 30 | // Kind takes an unqualified kind and returns back a Group qualified GroupKind 31 | func Kind(kind string) schema.GroupKind { 32 | return SchemeGroupVersion.WithKind(kind).GroupKind() 33 | } 34 | 35 | // Resource takes an unqualified resource and returns back a Group qualified GroupResource 36 | func Resource(resource string) schema.GroupResource { 37 | return SchemeGroupVersion.WithResource(resource).GroupResource() 38 | } 39 | 40 | var ( 41 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs) 42 | localSchemeBuilder = &SchemeBuilder 43 | AddToScheme = localSchemeBuilder.AddToScheme 44 | ) 45 | 46 | // Adds the list of known types to the given scheme. 47 | func addKnownTypes(scheme *runtime.Scheme) error { 48 | scheme.AddKnownTypes(SchemeGroupVersion, 49 | &CustomResourceDefinition{}, 50 | &CustomResourceDefinitionList{}, 51 | &ConversionReview{}, 52 | ) 53 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 54 | return nil 55 | } 56 | 57 | func init() { 58 | // We only register manually written functions here. The registration of the 59 | // generated functions takes place in the generated files. The separation 60 | // makes the code compile even when the generated files are missing. 61 | localSchemeBuilder.Register(addDefaultingFuncs) 62 | } 63 | -------------------------------------------------------------------------------- /pkg/apis/apiextensions/v1beta1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The Kubernetes Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // Code generated by defaulter-gen. DO NOT EDIT. 21 | 22 | package v1beta1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // RegisterDefaults adds defaulters functions to the given scheme. 29 | // Public to allow building arbitrary schemes. 30 | // All generated defaulters are covering - they call all nested defaulters. 31 | func RegisterDefaults(scheme *runtime.Scheme) error { 32 | scheme.AddTypeDefaultingFunc(&CustomResourceDefinition{}, func(obj interface{}) { SetObjectDefaults_CustomResourceDefinition(obj.(*CustomResourceDefinition)) }) 33 | scheme.AddTypeDefaultingFunc(&CustomResourceDefinitionList{}, func(obj interface{}) { 34 | SetObjectDefaults_CustomResourceDefinitionList(obj.(*CustomResourceDefinitionList)) 35 | }) 36 | return nil 37 | } 38 | 39 | func SetObjectDefaults_CustomResourceDefinition(in *CustomResourceDefinition) { 40 | SetDefaults_CustomResourceDefinition(in) 41 | SetDefaults_CustomResourceDefinitionSpec(&in.Spec) 42 | if in.Spec.Conversion != nil { 43 | if in.Spec.Conversion.WebhookClientConfig != nil { 44 | if in.Spec.Conversion.WebhookClientConfig.Service != nil { 45 | SetDefaults_ServiceReference(in.Spec.Conversion.WebhookClientConfig.Service) 46 | } 47 | } 48 | } 49 | } 50 | 51 | func SetObjectDefaults_CustomResourceDefinitionList(in *CustomResourceDefinitionList) { 52 | for i := range in.Items { 53 | a := &in.Items[i] 54 | SetObjectDefaults_CustomResourceDefinition(a) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1.ConversionReview.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ConversionReview", 3 | "apiVersion": "apiextensions.k8s.io/v1", 4 | "request": { 5 | "uid": "uidValue", 6 | "desiredAPIVersion": "desiredAPIVersionValue", 7 | "objects": [ 8 | { 9 | "apiVersion": "example.com/v1", 10 | "kind": "CustomType", 11 | "spec": { 12 | "replicas": 1 13 | }, 14 | "status": { 15 | "available": 1 16 | } 17 | } 18 | ] 19 | }, 20 | "response": { 21 | "uid": "uidValue", 22 | "convertedObjects": [ 23 | { 24 | "apiVersion": "example.com/v1", 25 | "kind": "CustomType", 26 | "spec": { 27 | "replicas": 1 28 | }, 29 | "status": { 30 | "available": 1 31 | } 32 | } 33 | ], 34 | "result": { 35 | "metadata": { 36 | "selfLink": "selfLinkValue", 37 | "resourceVersion": "resourceVersionValue", 38 | "continue": "continueValue", 39 | "remainingItemCount": 4 40 | }, 41 | "status": "statusValue", 42 | "message": "messageValue", 43 | "reason": "reasonValue", 44 | "details": { 45 | "name": "nameValue", 46 | "group": "groupValue", 47 | "kind": "kindValue", 48 | "uid": "uidValue", 49 | "causes": [ 50 | { 51 | "reason": "reasonValue", 52 | "message": "messageValue", 53 | "field": "fieldValue" 54 | } 55 | ], 56 | "retryAfterSeconds": 5 57 | }, 58 | "code": 6 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1.ConversionReview.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kubernetes/apiextensions-apiserver/1e69f9c86d5aeecf08e23758bfc47970e3f8656e/pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1.ConversionReview.pb -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1.ConversionReview.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1 2 | kind: ConversionReview 3 | request: 4 | desiredAPIVersion: desiredAPIVersionValue 5 | objects: 6 | - apiVersion: example.com/v1 7 | kind: CustomType 8 | spec: 9 | replicas: 1 10 | status: 11 | available: 1 12 | uid: uidValue 13 | response: 14 | convertedObjects: 15 | - apiVersion: example.com/v1 16 | kind: CustomType 17 | spec: 18 | replicas: 1 19 | status: 20 | available: 1 21 | result: 22 | code: 6 23 | details: 24 | causes: 25 | - field: fieldValue 26 | message: messageValue 27 | reason: reasonValue 28 | group: groupValue 29 | kind: kindValue 30 | name: nameValue 31 | retryAfterSeconds: 5 32 | uid: uidValue 33 | message: messageValue 34 | metadata: 35 | continue: continueValue 36 | remainingItemCount: 4 37 | resourceVersion: resourceVersionValue 38 | selfLink: selfLinkValue 39 | reason: reasonValue 40 | status: statusValue 41 | uid: uidValue 42 | -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1.CustomResourceDefinition.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kubernetes/apiextensions-apiserver/1e69f9c86d5aeecf08e23758bfc47970e3f8656e/pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1.CustomResourceDefinition.pb -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1beta1.ConversionReview.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ConversionReview", 3 | "apiVersion": "apiextensions.k8s.io/v1beta1", 4 | "request": { 5 | "uid": "uidValue", 6 | "desiredAPIVersion": "desiredAPIVersionValue", 7 | "objects": [ 8 | { 9 | "apiVersion": "example.com/v1", 10 | "kind": "CustomType", 11 | "spec": { 12 | "replicas": 1 13 | }, 14 | "status": { 15 | "available": 1 16 | } 17 | } 18 | ] 19 | }, 20 | "response": { 21 | "uid": "uidValue", 22 | "convertedObjects": [ 23 | { 24 | "apiVersion": "example.com/v1", 25 | "kind": "CustomType", 26 | "spec": { 27 | "replicas": 1 28 | }, 29 | "status": { 30 | "available": 1 31 | } 32 | } 33 | ], 34 | "result": { 35 | "metadata": { 36 | "selfLink": "selfLinkValue", 37 | "resourceVersion": "resourceVersionValue", 38 | "continue": "continueValue", 39 | "remainingItemCount": 4 40 | }, 41 | "status": "statusValue", 42 | "message": "messageValue", 43 | "reason": "reasonValue", 44 | "details": { 45 | "name": "nameValue", 46 | "group": "groupValue", 47 | "kind": "kindValue", 48 | "uid": "uidValue", 49 | "causes": [ 50 | { 51 | "reason": "reasonValue", 52 | "message": "messageValue", 53 | "field": "fieldValue" 54 | } 55 | ], 56 | "retryAfterSeconds": 5 57 | }, 58 | "code": 6 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1beta1.ConversionReview.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kubernetes/apiextensions-apiserver/1e69f9c86d5aeecf08e23758bfc47970e3f8656e/pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1beta1.ConversionReview.pb -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1beta1.ConversionReview.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1beta1 2 | kind: ConversionReview 3 | request: 4 | desiredAPIVersion: desiredAPIVersionValue 5 | objects: 6 | - apiVersion: example.com/v1 7 | kind: CustomType 8 | spec: 9 | replicas: 1 10 | status: 11 | available: 1 12 | uid: uidValue 13 | response: 14 | convertedObjects: 15 | - apiVersion: example.com/v1 16 | kind: CustomType 17 | spec: 18 | replicas: 1 19 | status: 20 | available: 1 21 | result: 22 | code: 6 23 | details: 24 | causes: 25 | - field: fieldValue 26 | message: messageValue 27 | reason: reasonValue 28 | group: groupValue 29 | kind: kindValue 30 | name: nameValue 31 | retryAfterSeconds: 5 32 | uid: uidValue 33 | message: messageValue 34 | metadata: 35 | continue: continueValue 36 | remainingItemCount: 4 37 | resourceVersion: resourceVersionValue 38 | selfLink: selfLinkValue 39 | reason: reasonValue 40 | status: statusValue 41 | uid: uidValue 42 | -------------------------------------------------------------------------------- /pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1beta1.CustomResourceDefinition.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kubernetes/apiextensions-apiserver/1e69f9c86d5aeecf08e23758bfc47970e3f8656e/pkg/apis/testdata/HEAD/apiextensions.k8s.io.v1beta1.CustomResourceDefinition.pb -------------------------------------------------------------------------------- /pkg/apis/testdata/README.md: -------------------------------------------------------------------------------- 1 | # API serialization compatibility tests 2 | 3 | This directory tree contains serialized API objects in json, yaml, and protobuf formats. -------------------------------------------------------------------------------- /pkg/apiserver/conversion/nop_converter.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package conversion 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | // nopConverter is a converter that only sets the apiVersion fields, but does not real conversion. 26 | type nopConverter struct { 27 | } 28 | 29 | var _ crConverterInterface = &nopConverter{} 30 | 31 | // ConvertToVersion converts in object to the given gv in place and returns the same `in` object. 32 | func (c *nopConverter) Convert(in runtime.Object, targetGV schema.GroupVersion) (runtime.Object, error) { 33 | // Run the converter on the list items instead of list itself 34 | if list, ok := in.(*unstructured.UnstructuredList); ok { 35 | for i := range list.Items { 36 | list.Items[i].SetGroupVersionKind(targetGV.WithKind(list.Items[i].GroupVersionKind().Kind)) 37 | } 38 | } 39 | in.GetObjectKind().SetGroupVersionKind(targetGV.WithKind(in.GetObjectKind().GroupVersionKind().Kind)) 40 | return in, nil 41 | } 42 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/cel/maplist.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cel 18 | 19 | import ( 20 | "k8s.io/apiextensions-apiserver/pkg/apiserver/schema" 21 | "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/model" 22 | "k8s.io/apiserver/pkg/cel/common" 23 | ) 24 | 25 | // makeMapList returns a queryable interface over the provided x-kubernetes-list-type=map 26 | // keyedItems. If the provided schema is _not_ an array with x-kubernetes-list-type=map, returns an 27 | // empty mapList. 28 | func makeMapList(sts *schema.Structural, items []interface{}) (rv common.MapList) { 29 | return common.MakeMapList(&model.Structural{Structural: sts}, items) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/cel/values.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cel 18 | 19 | import ( 20 | "github.com/google/cel-go/common/types/ref" 21 | 22 | structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema" 23 | "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/model" 24 | celopenapi "k8s.io/apiserver/pkg/cel/common" 25 | ) 26 | 27 | // UnstructuredToVal converts a Kubernetes unstructured data element to a CEL Val. 28 | // The root schema of custom resource schema is expected contain type meta and object meta schemas. 29 | // If Embedded resources do not contain type meta and object meta schemas, they will be added automatically. 30 | func UnstructuredToVal(unstructured interface{}, schema *structuralschema.Structural) ref.Val { 31 | return celopenapi.UnstructuredToVal(unstructured, &model.Structural{Structural: schema}) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/defaulting/algorithm.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package defaulting 18 | 19 | import ( 20 | structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | ) 23 | 24 | // isNonNullalbeNull returns true if the item is nil AND it's nullable 25 | func isNonNullableNull(x interface{}, s *structuralschema.Structural) bool { 26 | return x == nil && s != nil && s.Generic.Nullable == false 27 | } 28 | 29 | // Default does defaulting of x depending on default values in s. 30 | // Default values from s are deep-copied. 31 | // 32 | // PruneNonNullableNullsWithoutDefaults has left the non-nullable nulls 33 | // that have a default here. 34 | func Default(x interface{}, s *structuralschema.Structural) { 35 | if s == nil { 36 | return 37 | } 38 | 39 | switch x := x.(type) { 40 | case map[string]interface{}: 41 | for k, prop := range s.Properties { 42 | if prop.Default.Object == nil { 43 | continue 44 | } 45 | if _, found := x[k]; !found || isNonNullableNull(x[k], &prop) { 46 | x[k] = runtime.DeepCopyJSONValue(prop.Default.Object) 47 | } 48 | } 49 | for k := range x { 50 | if prop, found := s.Properties[k]; found { 51 | Default(x[k], &prop) 52 | } else if s.AdditionalProperties != nil { 53 | if isNonNullableNull(x[k], s.AdditionalProperties.Structural) { 54 | x[k] = runtime.DeepCopyJSONValue(s.AdditionalProperties.Structural.Default.Object) 55 | } 56 | Default(x[k], s.AdditionalProperties.Structural) 57 | } 58 | } 59 | case []interface{}: 60 | for i := range x { 61 | if isNonNullableNull(x[i], s.Items) { 62 | x[i] = runtime.DeepCopyJSONValue(s.Items.Default.Object) 63 | } 64 | Default(x[i], s.Items) 65 | } 66 | default: 67 | // scalars, do nothing 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/defaulting/prunenulls.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package defaulting 18 | 19 | import structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema" 20 | 21 | func isNonNullableNonDefaultableNull(x interface{}, s *structuralschema.Structural) bool { 22 | return x == nil && s != nil && s.Generic.Nullable == false && s.Default.Object == nil 23 | } 24 | 25 | func getSchemaForField(field string, s *structuralschema.Structural) *structuralschema.Structural { 26 | if s == nil { 27 | return nil 28 | } 29 | schema, ok := s.Properties[field] 30 | if ok { 31 | return &schema 32 | } 33 | if s.AdditionalProperties != nil { 34 | return s.AdditionalProperties.Structural 35 | } 36 | return nil 37 | } 38 | 39 | // PruneNonNullableNullsWithoutDefaults removes non-nullable 40 | // non-defaultable null values from object. 41 | // 42 | // Non-nullable nulls that have a default are left alone here and will 43 | // be defaulted later. 44 | func PruneNonNullableNullsWithoutDefaults(x interface{}, s *structuralschema.Structural) { 45 | switch x := x.(type) { 46 | case map[string]interface{}: 47 | for k, v := range x { 48 | schema := getSchemaForField(k, s) 49 | if isNonNullableNonDefaultableNull(v, schema) { 50 | delete(x, k) 51 | } else { 52 | PruneNonNullableNullsWithoutDefaults(v, schema) 53 | } 54 | } 55 | case []interface{}: 56 | var schema *structuralschema.Structural 57 | if s != nil { 58 | schema = s.Items 59 | } 60 | for i := range x { 61 | PruneNonNullableNullsWithoutDefaults(x[i], schema) 62 | } 63 | default: 64 | // scalars, do nothing 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/options.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package schema 18 | 19 | import ( 20 | "strconv" 21 | "strings" 22 | ) 23 | 24 | // UnknownFieldPathOptions allow for tracking paths to unknown fields. 25 | type UnknownFieldPathOptions struct { 26 | // TrackUnknownFieldPaths determines whether or not unknown field 27 | // paths should be stored or not. 28 | TrackUnknownFieldPaths bool 29 | // ParentPath builds the path to unknown fields as the object 30 | // is recursively traversed. 31 | ParentPath []string 32 | // UnknownFieldPaths is the list of all unknown fields identified. 33 | UnknownFieldPaths []string 34 | } 35 | 36 | // RecordUnknownFields adds a path to an unknown field to the 37 | // record of UnknownFieldPaths, if TrackUnknownFieldPaths is true 38 | func (o *UnknownFieldPathOptions) RecordUnknownField(field string) { 39 | if !o.TrackUnknownFieldPaths { 40 | return 41 | } 42 | l := len(o.ParentPath) 43 | o.AppendKey(field) 44 | o.UnknownFieldPaths = append(o.UnknownFieldPaths, strings.Join(o.ParentPath, "")) 45 | o.ParentPath = o.ParentPath[:l] 46 | } 47 | 48 | // AppendKey adds a key (i.e. field) to the current parent 49 | // path, if TrackUnknownFieldPaths is true. 50 | func (o *UnknownFieldPathOptions) AppendKey(key string) { 51 | if !o.TrackUnknownFieldPaths { 52 | return 53 | } 54 | if len(o.ParentPath) > 0 { 55 | o.ParentPath = append(o.ParentPath, ".") 56 | } 57 | o.ParentPath = append(o.ParentPath, key) 58 | } 59 | 60 | // AppendIndex adds an index to the most recent field of 61 | // the current parent path, if TrackUnknownFieldPaths is true. 62 | func (o *UnknownFieldPathOptions) AppendIndex(index int) { 63 | if !o.TrackUnknownFieldPaths { 64 | return 65 | } 66 | o.ParentPath = append(o.ParentPath, "[", strconv.Itoa(index), "]") 67 | } 68 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/skeleton.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package schema 18 | 19 | // StripValueValidations returns a copy without value validations. 20 | func (s *Structural) StripValueValidations() *Structural { 21 | s = s.DeepCopy() 22 | v := Visitor{ 23 | Structural: func(s *Structural) bool { 24 | changed := false 25 | if s.ValueValidation != nil { 26 | s.ValueValidation = nil 27 | changed = true 28 | } 29 | return changed 30 | }, 31 | } 32 | v.Visit(s) 33 | return s 34 | } 35 | 36 | // StripNullable returns a copy without nullable. 37 | func (s *Structural) StripNullable() *Structural { 38 | s = s.DeepCopy() 39 | v := Visitor{ 40 | Structural: func(s *Structural) bool { 41 | changed := s.Nullable 42 | s.Nullable = false 43 | return changed 44 | }, 45 | } 46 | v.Visit(s) 47 | return s 48 | } 49 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/unfold.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package schema 18 | 19 | // Unfold expands vendor extensions of a structural schema. 20 | // It mutates the receiver. 21 | func (s *Structural) Unfold() *Structural { 22 | if s == nil { 23 | return nil 24 | } 25 | 26 | mapper := Visitor{ 27 | Structural: func(s *Structural) bool { 28 | if !s.XIntOrString { 29 | return false 30 | } 31 | 32 | skipAnyOf := isIntOrStringAnyOfPattern(s) 33 | skipFirstAllOfAnyOf := isIntOrStringAllOfPattern(s) 34 | if skipAnyOf || skipFirstAllOfAnyOf { 35 | return false 36 | } 37 | 38 | if s.ValueValidation == nil { 39 | s.ValueValidation = &ValueValidation{} 40 | } 41 | if s.ValueValidation.AnyOf == nil { 42 | s.ValueValidation.AnyOf = []NestedValueValidation{ 43 | {ForbiddenGenerics: Generic{Type: "integer"}}, 44 | {ForbiddenGenerics: Generic{Type: "string"}}, 45 | } 46 | } else { 47 | s.ValueValidation.AllOf = append([]NestedValueValidation{ 48 | { 49 | ValueValidation: ValueValidation{ 50 | AnyOf: []NestedValueValidation{ 51 | {ForbiddenGenerics: Generic{Type: "integer"}}, 52 | {ForbiddenGenerics: Generic{Type: "string"}}, 53 | }, 54 | }, 55 | }, 56 | }, s.ValueValidation.AllOf...) 57 | } 58 | 59 | return true 60 | }, 61 | NestedValueValidation: nil, // x-kubernetes-int-or-string cannot be set in nested value validation 62 | } 63 | mapper.Visit(s) 64 | 65 | return s 66 | } 67 | -------------------------------------------------------------------------------- /pkg/apiserver/schema/unfold_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package schema 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | // TestStructuralUnfoldNilValueValidation tests that Unfold() does not crash 24 | // on a IntOrString pattern with nil ValueValidation. 25 | func TestStructuralUnfoldIntOrString(t *testing.T) { 26 | schema := Structural{ 27 | Extensions: Extensions{ 28 | XIntOrString: true, 29 | }, 30 | } 31 | schema.Unfold() 32 | } 33 | -------------------------------------------------------------------------------- /pkg/apiserver/testdata/README.md: -------------------------------------------------------------------------------- 1 | `swagger.json` contains static openapi definitions needed to build models for custom resource types. 2 | 3 | It was created by removing all path and non-objectmeta/int-or-string definitions from 4 | the `api/openapi-spec/swagger.json` in the `k8s.io/kubernetes` module. -------------------------------------------------------------------------------- /pkg/apiserver/validation/metrics.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package validation 18 | 19 | import ( 20 | "time" 21 | 22 | "k8s.io/component-base/metrics" 23 | "k8s.io/component-base/metrics/legacyregistry" 24 | ) 25 | 26 | const ( 27 | namespace = "apiextensions_apiserver" 28 | subsystem = "validation" 29 | ) 30 | 31 | // Interface to stub for tests 32 | type ValidationMetrics interface { 33 | ObserveRatchetingTime(d time.Duration) 34 | } 35 | 36 | var Metrics ValidationMetrics = &validationMetrics{ 37 | RatchetingTime: metrics.NewHistogram(&metrics.HistogramOpts{ 38 | Namespace: namespace, 39 | Subsystem: subsystem, 40 | Name: "ratcheting_seconds", 41 | Help: "Time for comparison of old to new for the purposes of CRDValidationRatcheting during an UPDATE in seconds.", 42 | StabilityLevel: metrics.ALPHA, 43 | // Start 0.01ms with the last bucket being [~2.5s, +Inf) 44 | Buckets: metrics.ExponentialBuckets(0.00001, 4, 10), 45 | }), 46 | } 47 | 48 | func init() { 49 | legacyregistry.MustRegister(Metrics.(*validationMetrics).RatchetingTime) 50 | } 51 | 52 | type validationMetrics struct { 53 | RatchetingTime *metrics.Histogram 54 | } 55 | 56 | // ObserveRatchetingTime records the time spent on ratcheting 57 | func (m *validationMetrics) ObserveRatchetingTime(d time.Duration) { 58 | m.RatchetingTime.Observe(d.Seconds()) 59 | } 60 | 61 | // Reset resets the metrics. This is meant to be used for testing. Panics 62 | // if the metrics cannot be re-registered. Returns all the reset metrics 63 | func (m *validationMetrics) Reset() []metrics.Registerable { 64 | m.RatchetingTime = metrics.NewHistogram(m.RatchetingTime.HistogramOpts) 65 | return []metrics.Registerable{m.RatchetingTime} 66 | } 67 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1/customresourceconversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | import ( 22 | apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 23 | ) 24 | 25 | // CustomResourceConversionApplyConfiguration represents a declarative configuration of the CustomResourceConversion type for use 26 | // with apply. 27 | type CustomResourceConversionApplyConfiguration struct { 28 | Strategy *apiextensionsv1.ConversionStrategyType `json:"strategy,omitempty"` 29 | Webhook *WebhookConversionApplyConfiguration `json:"webhook,omitempty"` 30 | } 31 | 32 | // CustomResourceConversionApplyConfiguration constructs a declarative configuration of the CustomResourceConversion type for use with 33 | // apply. 34 | func CustomResourceConversion() *CustomResourceConversionApplyConfiguration { 35 | return &CustomResourceConversionApplyConfiguration{} 36 | } 37 | 38 | // WithStrategy sets the Strategy field in the declarative configuration to the given value 39 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 40 | // If called multiple times, the Strategy field is set to the value of the last call. 41 | func (b *CustomResourceConversionApplyConfiguration) WithStrategy(value apiextensionsv1.ConversionStrategyType) *CustomResourceConversionApplyConfiguration { 42 | b.Strategy = &value 43 | return b 44 | } 45 | 46 | // WithWebhook sets the Webhook field in the declarative configuration to the given value 47 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 48 | // If called multiple times, the Webhook field is set to the value of the last call. 49 | func (b *CustomResourceConversionApplyConfiguration) WithWebhook(value *WebhookConversionApplyConfiguration) *CustomResourceConversionApplyConfiguration { 50 | b.Webhook = value 51 | return b 52 | } 53 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1/customresourcevalidation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // CustomResourceValidationApplyConfiguration represents a declarative configuration of the CustomResourceValidation type for use 22 | // with apply. 23 | type CustomResourceValidationApplyConfiguration struct { 24 | OpenAPIV3Schema *JSONSchemaPropsApplyConfiguration `json:"openAPIV3Schema,omitempty"` 25 | } 26 | 27 | // CustomResourceValidationApplyConfiguration constructs a declarative configuration of the CustomResourceValidation type for use with 28 | // apply. 29 | func CustomResourceValidation() *CustomResourceValidationApplyConfiguration { 30 | return &CustomResourceValidationApplyConfiguration{} 31 | } 32 | 33 | // WithOpenAPIV3Schema sets the OpenAPIV3Schema field in the declarative configuration to the given value 34 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 35 | // If called multiple times, the OpenAPIV3Schema field is set to the value of the last call. 36 | func (b *CustomResourceValidationApplyConfiguration) WithOpenAPIV3Schema(value *JSONSchemaPropsApplyConfiguration) *CustomResourceValidationApplyConfiguration { 37 | b.OpenAPIV3Schema = value 38 | return b 39 | } 40 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1/externaldocumentation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // ExternalDocumentationApplyConfiguration represents a declarative configuration of the ExternalDocumentation type for use 22 | // with apply. 23 | type ExternalDocumentationApplyConfiguration struct { 24 | Description *string `json:"description,omitempty"` 25 | URL *string `json:"url,omitempty"` 26 | } 27 | 28 | // ExternalDocumentationApplyConfiguration constructs a declarative configuration of the ExternalDocumentation type for use with 29 | // apply. 30 | func ExternalDocumentation() *ExternalDocumentationApplyConfiguration { 31 | return &ExternalDocumentationApplyConfiguration{} 32 | } 33 | 34 | // WithDescription sets the Description field in the declarative configuration to the given value 35 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 36 | // If called multiple times, the Description field is set to the value of the last call. 37 | func (b *ExternalDocumentationApplyConfiguration) WithDescription(value string) *ExternalDocumentationApplyConfiguration { 38 | b.Description = &value 39 | return b 40 | } 41 | 42 | // WithURL sets the URL field in the declarative configuration to the given value 43 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 44 | // If called multiple times, the URL field is set to the value of the last call. 45 | func (b *ExternalDocumentationApplyConfiguration) WithURL(value string) *ExternalDocumentationApplyConfiguration { 46 | b.URL = &value 47 | return b 48 | } 49 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1/selectablefield.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // SelectableFieldApplyConfiguration represents a declarative configuration of the SelectableField type for use 22 | // with apply. 23 | type SelectableFieldApplyConfiguration struct { 24 | JSONPath *string `json:"jsonPath,omitempty"` 25 | } 26 | 27 | // SelectableFieldApplyConfiguration constructs a declarative configuration of the SelectableField type for use with 28 | // apply. 29 | func SelectableField() *SelectableFieldApplyConfiguration { 30 | return &SelectableFieldApplyConfiguration{} 31 | } 32 | 33 | // WithJSONPath sets the JSONPath field in the declarative configuration to the given value 34 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 35 | // If called multiple times, the JSONPath field is set to the value of the last call. 36 | func (b *SelectableFieldApplyConfiguration) WithJSONPath(value string) *SelectableFieldApplyConfiguration { 37 | b.JSONPath = &value 38 | return b 39 | } 40 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1/webhookconversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // WebhookConversionApplyConfiguration represents a declarative configuration of the WebhookConversion type for use 22 | // with apply. 23 | type WebhookConversionApplyConfiguration struct { 24 | ClientConfig *WebhookClientConfigApplyConfiguration `json:"clientConfig,omitempty"` 25 | ConversionReviewVersions []string `json:"conversionReviewVersions,omitempty"` 26 | } 27 | 28 | // WebhookConversionApplyConfiguration constructs a declarative configuration of the WebhookConversion type for use with 29 | // apply. 30 | func WebhookConversion() *WebhookConversionApplyConfiguration { 31 | return &WebhookConversionApplyConfiguration{} 32 | } 33 | 34 | // WithClientConfig sets the ClientConfig field in the declarative configuration to the given value 35 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 36 | // If called multiple times, the ClientConfig field is set to the value of the last call. 37 | func (b *WebhookConversionApplyConfiguration) WithClientConfig(value *WebhookClientConfigApplyConfiguration) *WebhookConversionApplyConfiguration { 38 | b.ClientConfig = value 39 | return b 40 | } 41 | 42 | // WithConversionReviewVersions adds the given value to the ConversionReviewVersions field in the declarative configuration 43 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 44 | // If called multiple times, values provided by each call will be appended to the ConversionReviewVersions field. 45 | func (b *WebhookConversionApplyConfiguration) WithConversionReviewVersions(values ...string) *WebhookConversionApplyConfiguration { 46 | for i := range values { 47 | b.ConversionReviewVersions = append(b.ConversionReviewVersions, values[i]) 48 | } 49 | return b 50 | } 51 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1beta1/customresourcevalidation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | // CustomResourceValidationApplyConfiguration represents a declarative configuration of the CustomResourceValidation type for use 22 | // with apply. 23 | type CustomResourceValidationApplyConfiguration struct { 24 | OpenAPIV3Schema *JSONSchemaPropsApplyConfiguration `json:"openAPIV3Schema,omitempty"` 25 | } 26 | 27 | // CustomResourceValidationApplyConfiguration constructs a declarative configuration of the CustomResourceValidation type for use with 28 | // apply. 29 | func CustomResourceValidation() *CustomResourceValidationApplyConfiguration { 30 | return &CustomResourceValidationApplyConfiguration{} 31 | } 32 | 33 | // WithOpenAPIV3Schema sets the OpenAPIV3Schema field in the declarative configuration to the given value 34 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 35 | // If called multiple times, the OpenAPIV3Schema field is set to the value of the last call. 36 | func (b *CustomResourceValidationApplyConfiguration) WithOpenAPIV3Schema(value *JSONSchemaPropsApplyConfiguration) *CustomResourceValidationApplyConfiguration { 37 | b.OpenAPIV3Schema = value 38 | return b 39 | } 40 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1beta1/externaldocumentation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | // ExternalDocumentationApplyConfiguration represents a declarative configuration of the ExternalDocumentation type for use 22 | // with apply. 23 | type ExternalDocumentationApplyConfiguration struct { 24 | Description *string `json:"description,omitempty"` 25 | URL *string `json:"url,omitempty"` 26 | } 27 | 28 | // ExternalDocumentationApplyConfiguration constructs a declarative configuration of the ExternalDocumentation type for use with 29 | // apply. 30 | func ExternalDocumentation() *ExternalDocumentationApplyConfiguration { 31 | return &ExternalDocumentationApplyConfiguration{} 32 | } 33 | 34 | // WithDescription sets the Description field in the declarative configuration to the given value 35 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 36 | // If called multiple times, the Description field is set to the value of the last call. 37 | func (b *ExternalDocumentationApplyConfiguration) WithDescription(value string) *ExternalDocumentationApplyConfiguration { 38 | b.Description = &value 39 | return b 40 | } 41 | 42 | // WithURL sets the URL field in the declarative configuration to the given value 43 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 44 | // If called multiple times, the URL field is set to the value of the last call. 45 | func (b *ExternalDocumentationApplyConfiguration) WithURL(value string) *ExternalDocumentationApplyConfiguration { 46 | b.URL = &value 47 | return b 48 | } 49 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/apiextensions/v1beta1/selectablefield.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | // SelectableFieldApplyConfiguration represents a declarative configuration of the SelectableField type for use 22 | // with apply. 23 | type SelectableFieldApplyConfiguration struct { 24 | JSONPath *string `json:"jsonPath,omitempty"` 25 | } 26 | 27 | // SelectableFieldApplyConfiguration constructs a declarative configuration of the SelectableField type for use with 28 | // apply. 29 | func SelectableField() *SelectableFieldApplyConfiguration { 30 | return &SelectableFieldApplyConfiguration{} 31 | } 32 | 33 | // WithJSONPath sets the JSONPath field in the declarative configuration to the given value 34 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 35 | // If called multiple times, the JSONPath field is set to the value of the last call. 36 | func (b *SelectableFieldApplyConfiguration) WithJSONPath(value string) *SelectableFieldApplyConfiguration { 37 | b.JSONPath = &value 38 | return b 39 | } 40 | -------------------------------------------------------------------------------- /pkg/client/applyconfiguration/internal/internal.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by applyconfiguration-gen. DO NOT EDIT. 18 | 19 | package internal 20 | 21 | import ( 22 | fmt "fmt" 23 | sync "sync" 24 | 25 | typed "sigs.k8s.io/structured-merge-diff/v4/typed" 26 | ) 27 | 28 | func Parser() *typed.Parser { 29 | parserOnce.Do(func() { 30 | var err error 31 | parser, err = typed.NewParser(schemaYAML) 32 | if err != nil { 33 | panic(fmt.Sprintf("Failed to parse schema: %v", err)) 34 | } 35 | }) 36 | return parser 37 | } 38 | 39 | var parserOnce sync.Once 40 | var parser *typed.Parser 41 | var schemaYAML = typed.YAMLObject(`types: 42 | - name: __untyped_atomic_ 43 | scalar: untyped 44 | list: 45 | elementType: 46 | namedType: __untyped_atomic_ 47 | elementRelationship: atomic 48 | map: 49 | elementType: 50 | namedType: __untyped_atomic_ 51 | elementRelationship: atomic 52 | - name: __untyped_deduced_ 53 | scalar: untyped 54 | list: 55 | elementType: 56 | namedType: __untyped_atomic_ 57 | elementRelationship: atomic 58 | map: 59 | elementType: 60 | namedType: __untyped_deduced_ 61 | elementRelationship: separable 62 | `) 63 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/fake/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 23 | apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" 24 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | schema "k8s.io/apimachinery/pkg/runtime/schema" 27 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 28 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 29 | ) 30 | 31 | var scheme = runtime.NewScheme() 32 | var codecs = serializer.NewCodecFactory(scheme) 33 | 34 | var localSchemeBuilder = runtime.SchemeBuilder{ 35 | apiextensionsv1.AddToScheme, 36 | apiextensionsv1beta1.AddToScheme, 37 | } 38 | 39 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 40 | // of clientsets, like in: 41 | // 42 | // import ( 43 | // "k8s.io/client-go/kubernetes" 44 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 45 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 46 | // ) 47 | // 48 | // kclientset, _ := kubernetes.NewForConfig(c) 49 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 50 | // 51 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 52 | // correctly. 53 | var AddToScheme = localSchemeBuilder.AddToScheme 54 | 55 | func init() { 56 | v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) 57 | utilruntime.Must(AddToScheme(scheme)) 58 | } 59 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/scheme/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package scheme 20 | 21 | import ( 22 | apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 23 | apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" 24 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | schema "k8s.io/apimachinery/pkg/runtime/schema" 27 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 28 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 29 | ) 30 | 31 | var Scheme = runtime.NewScheme() 32 | var Codecs = serializer.NewCodecFactory(Scheme) 33 | var ParameterCodec = runtime.NewParameterCodec(Scheme) 34 | var localSchemeBuilder = runtime.SchemeBuilder{ 35 | apiextensionsv1.AddToScheme, 36 | apiextensionsv1beta1.AddToScheme, 37 | } 38 | 39 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 40 | // of clientsets, like in: 41 | // 42 | // import ( 43 | // "k8s.io/client-go/kubernetes" 44 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 45 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 46 | // ) 47 | // 48 | // kclientset, _ := kubernetes.NewForConfig(c) 49 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 50 | // 51 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 52 | // correctly. 53 | var AddToScheme = localSchemeBuilder.AddToScheme 54 | 55 | func init() { 56 | v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 57 | utilruntime.Must(AddToScheme(Scheme)) 58 | } 59 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1 21 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_apiextensions_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeApiextensionsV1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeApiextensionsV1) CustomResourceDefinitions() v1.CustomResourceDefinitionInterface { 32 | return newFakeCustomResourceDefinitions(c) 33 | } 34 | 35 | // RESTClient returns a RESTClient that is used to communicate 36 | // with API server by this client implementation. 37 | func (c *FakeApiextensionsV1) RESTClient() rest.Interface { 38 | var ret *rest.RESTClient 39 | return ret 40 | } 41 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_customresourcedefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 23 | apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration/apiextensions/v1" 24 | typedapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" 25 | gentype "k8s.io/client-go/gentype" 26 | ) 27 | 28 | // fakeCustomResourceDefinitions implements CustomResourceDefinitionInterface 29 | type fakeCustomResourceDefinitions struct { 30 | *gentype.FakeClientWithListAndApply[*v1.CustomResourceDefinition, *v1.CustomResourceDefinitionList, *apiextensionsv1.CustomResourceDefinitionApplyConfiguration] 31 | Fake *FakeApiextensionsV1 32 | } 33 | 34 | func newFakeCustomResourceDefinitions(fake *FakeApiextensionsV1) typedapiextensionsv1.CustomResourceDefinitionInterface { 35 | return &fakeCustomResourceDefinitions{ 36 | gentype.NewFakeClientWithListAndApply[*v1.CustomResourceDefinition, *v1.CustomResourceDefinitionList, *apiextensionsv1.CustomResourceDefinitionApplyConfiguration]( 37 | fake.Fake, 38 | "", 39 | v1.SchemeGroupVersion.WithResource("customresourcedefinitions"), 40 | v1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), 41 | func() *v1.CustomResourceDefinition { return &v1.CustomResourceDefinition{} }, 42 | func() *v1.CustomResourceDefinitionList { return &v1.CustomResourceDefinitionList{} }, 43 | func(dst, src *v1.CustomResourceDefinitionList) { dst.ListMeta = src.ListMeta }, 44 | func(list *v1.CustomResourceDefinitionList) []*v1.CustomResourceDefinition { 45 | return gentype.ToPointerSlice(list.Items) 46 | }, 47 | func(list *v1.CustomResourceDefinitionList, items []*v1.CustomResourceDefinition) { 48 | list.Items = gentype.FromPointerSlice(items) 49 | }, 50 | ), 51 | fake, 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | type CustomResourceDefinitionExpansion interface{} 22 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1beta1 21 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeApiextensionsV1beta1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeApiextensionsV1beta1) CustomResourceDefinitions() v1beta1.CustomResourceDefinitionInterface { 32 | return newFakeCustomResourceDefinitions(c) 33 | } 34 | 35 | // RESTClient returns a RESTClient that is used to communicate 36 | // with API server by this client implementation. 37 | func (c *FakeApiextensionsV1beta1) RESTClient() rest.Interface { 38 | var ret *rest.RESTClient 39 | return ret 40 | } 41 | -------------------------------------------------------------------------------- /pkg/client/clientset/clientset/typed/apiextensions/v1beta1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | type CustomResourceDefinitionExpansion interface{} 22 | -------------------------------------------------------------------------------- /pkg/client/informers/externalversions/apiextensions/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package apiextensions 20 | 21 | import ( 22 | v1 "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1" 23 | v1beta1 "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1" 24 | internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces" 25 | ) 26 | 27 | // Interface provides access to each of this group's versions. 28 | type Interface interface { 29 | // V1 provides access to shared informers for resources in V1. 30 | V1() v1.Interface 31 | // V1beta1 provides access to shared informers for resources in V1beta1. 32 | V1beta1() v1beta1.Interface 33 | } 34 | 35 | type group struct { 36 | factory internalinterfaces.SharedInformerFactory 37 | namespace string 38 | tweakListOptions internalinterfaces.TweakListOptionsFunc 39 | } 40 | 41 | // New returns a new Interface. 42 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 43 | return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 44 | } 45 | 46 | // V1 returns a new v1.Interface. 47 | func (g *group) V1() v1.Interface { 48 | return v1.New(g.factory, g.namespace, g.tweakListOptions) 49 | } 50 | 51 | // V1beta1 returns a new v1beta1.Interface. 52 | func (g *group) V1beta1() v1beta1.Interface { 53 | return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) 54 | } 55 | -------------------------------------------------------------------------------- /pkg/client/informers/externalversions/apiextensions/v1/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | import ( 22 | internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces" 23 | ) 24 | 25 | // Interface provides access to all the informers in this group version. 26 | type Interface interface { 27 | // CustomResourceDefinitions returns a CustomResourceDefinitionInformer. 28 | CustomResourceDefinitions() CustomResourceDefinitionInformer 29 | } 30 | 31 | type version struct { 32 | factory internalinterfaces.SharedInformerFactory 33 | namespace string 34 | tweakListOptions internalinterfaces.TweakListOptionsFunc 35 | } 36 | 37 | // New returns a new Interface. 38 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 39 | return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 40 | } 41 | 42 | // CustomResourceDefinitions returns a CustomResourceDefinitionInformer. 43 | func (v *version) CustomResourceDefinitions() CustomResourceDefinitionInformer { 44 | return &customResourceDefinitionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} 45 | } 46 | -------------------------------------------------------------------------------- /pkg/client/informers/externalversions/apiextensions/v1beta1/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | import ( 22 | internalinterfaces "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/internalinterfaces" 23 | ) 24 | 25 | // Interface provides access to all the informers in this group version. 26 | type Interface interface { 27 | // CustomResourceDefinitions returns a CustomResourceDefinitionInformer. 28 | CustomResourceDefinitions() CustomResourceDefinitionInformer 29 | } 30 | 31 | type version struct { 32 | factory internalinterfaces.SharedInformerFactory 33 | namespace string 34 | tweakListOptions internalinterfaces.TweakListOptionsFunc 35 | } 36 | 37 | // New returns a new Interface. 38 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 39 | return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 40 | } 41 | 42 | // CustomResourceDefinitions returns a CustomResourceDefinitionInformer. 43 | func (v *version) CustomResourceDefinitions() CustomResourceDefinitionInformer { 44 | return &customResourceDefinitionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} 45 | } 46 | -------------------------------------------------------------------------------- /pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package internalinterfaces 20 | 21 | import ( 22 | time "time" 23 | 24 | clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | runtime "k8s.io/apimachinery/pkg/runtime" 27 | cache "k8s.io/client-go/tools/cache" 28 | ) 29 | 30 | // NewInformerFunc takes clientset.Interface and time.Duration to return a SharedIndexInformer. 31 | type NewInformerFunc func(clientset.Interface, time.Duration) cache.SharedIndexInformer 32 | 33 | // SharedInformerFactory a small interface to allow for adding an informer without an import cycle 34 | type SharedInformerFactory interface { 35 | Start(stopCh <-chan struct{}) 36 | InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer 37 | } 38 | 39 | // TweakListOptionsFunc is a function that transforms a v1.ListOptions. 40 | type TweakListOptionsFunc func(*v1.ListOptions) 41 | -------------------------------------------------------------------------------- /pkg/client/listers/apiextensions/v1/customresourcedefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | import ( 22 | apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 23 | labels "k8s.io/apimachinery/pkg/labels" 24 | listers "k8s.io/client-go/listers" 25 | cache "k8s.io/client-go/tools/cache" 26 | ) 27 | 28 | // CustomResourceDefinitionLister helps list CustomResourceDefinitions. 29 | // All objects returned here must be treated as read-only. 30 | type CustomResourceDefinitionLister interface { 31 | // List lists all CustomResourceDefinitions in the indexer. 32 | // Objects returned here must be treated as read-only. 33 | List(selector labels.Selector) (ret []*apiextensionsv1.CustomResourceDefinition, err error) 34 | // Get retrieves the CustomResourceDefinition from the index for a given name. 35 | // Objects returned here must be treated as read-only. 36 | Get(name string) (*apiextensionsv1.CustomResourceDefinition, error) 37 | CustomResourceDefinitionListerExpansion 38 | } 39 | 40 | // customResourceDefinitionLister implements the CustomResourceDefinitionLister interface. 41 | type customResourceDefinitionLister struct { 42 | listers.ResourceIndexer[*apiextensionsv1.CustomResourceDefinition] 43 | } 44 | 45 | // NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister. 46 | func NewCustomResourceDefinitionLister(indexer cache.Indexer) CustomResourceDefinitionLister { 47 | return &customResourceDefinitionLister{listers.New[*apiextensionsv1.CustomResourceDefinition](indexer, apiextensionsv1.Resource("customresourcedefinition"))} 48 | } 49 | -------------------------------------------------------------------------------- /pkg/client/listers/apiextensions/v1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1 20 | 21 | // CustomResourceDefinitionListerExpansion allows custom methods to be added to 22 | // CustomResourceDefinitionLister. 23 | type CustomResourceDefinitionListerExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/client/listers/apiextensions/v1beta1/customresourcedefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | import ( 22 | apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" 23 | labels "k8s.io/apimachinery/pkg/labels" 24 | listers "k8s.io/client-go/listers" 25 | cache "k8s.io/client-go/tools/cache" 26 | ) 27 | 28 | // CustomResourceDefinitionLister helps list CustomResourceDefinitions. 29 | // All objects returned here must be treated as read-only. 30 | type CustomResourceDefinitionLister interface { 31 | // List lists all CustomResourceDefinitions in the indexer. 32 | // Objects returned here must be treated as read-only. 33 | List(selector labels.Selector) (ret []*apiextensionsv1beta1.CustomResourceDefinition, err error) 34 | // Get retrieves the CustomResourceDefinition from the index for a given name. 35 | // Objects returned here must be treated as read-only. 36 | Get(name string) (*apiextensionsv1beta1.CustomResourceDefinition, error) 37 | CustomResourceDefinitionListerExpansion 38 | } 39 | 40 | // customResourceDefinitionLister implements the CustomResourceDefinitionLister interface. 41 | type customResourceDefinitionLister struct { 42 | listers.ResourceIndexer[*apiextensionsv1beta1.CustomResourceDefinition] 43 | } 44 | 45 | // NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister. 46 | func NewCustomResourceDefinitionLister(indexer cache.Indexer) CustomResourceDefinitionLister { 47 | return &customResourceDefinitionLister{listers.New[*apiextensionsv1beta1.CustomResourceDefinition](indexer, apiextensionsv1beta1.Resource("customresourcedefinition"))} 48 | } 49 | -------------------------------------------------------------------------------- /pkg/client/listers/apiextensions/v1beta1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | // CustomResourceDefinitionListerExpansion allows custom methods to be added to 22 | // CustomResourceDefinitionLister. 23 | type CustomResourceDefinitionListerExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/cmd/server/server.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package server 18 | 19 | import ( 20 | "context" 21 | "io" 22 | 23 | "github.com/spf13/cobra" 24 | 25 | "k8s.io/apiextensions-apiserver/pkg/cmd/server/options" 26 | genericapiserver "k8s.io/apiserver/pkg/server" 27 | ) 28 | 29 | func NewServerCommand(ctx context.Context, out, errOut io.Writer) *cobra.Command { 30 | o := options.NewCustomResourceDefinitionsServerOptions(out, errOut) 31 | 32 | cmd := &cobra.Command{ 33 | Short: "Launch an API extensions API server", 34 | Long: "Launch an API extensions API server", 35 | PersistentPreRunE: func(*cobra.Command, []string) error { 36 | return o.ServerRunOptions.ComponentGlobalsRegistry.Set() 37 | }, 38 | RunE: func(c *cobra.Command, args []string) error { 39 | if err := o.Complete(); err != nil { 40 | return err 41 | } 42 | if err := o.Validate(); err != nil { 43 | return err 44 | } 45 | if err := Run(c.Context(), o); err != nil { 46 | return err 47 | } 48 | return nil 49 | }, 50 | } 51 | cmd.SetContext(ctx) 52 | 53 | fs := cmd.Flags() 54 | o.AddFlags(fs) 55 | return cmd 56 | } 57 | 58 | func Run(ctx context.Context, o *options.CustomResourceDefinitionsServerOptions) error { 59 | config, err := o.Config() 60 | if err != nil { 61 | return err 62 | } 63 | 64 | server, err := config.Complete().New(genericapiserver.NewEmptyDelegate()) 65 | if err != nil { 66 | return err 67 | } 68 | return server.GenericAPIServer.PrepareRun().RunWithContext(ctx) 69 | } 70 | -------------------------------------------------------------------------------- /pkg/cmd/server/testing/testdata/README.md: -------------------------------------------------------------------------------- 1 | Keys in this directory are generated for testing purposes only. 2 | -------------------------------------------------------------------------------- /pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDGjCCAgKgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdsb2Nh 3 | bGhvc3QtY2FAMTUzMTQ2ODA4NTAgFw0xODA3MTMwNjQ4MDVaGA8yMTE4MDYxOTA2 4 | NDgwNVowHzEdMBsGA1UEAwwUbG9jYWxob3N0QDE1MzE0NjgwODYwggEiMA0GCSqG 5 | SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDC9Qfx1YAEp+wrSIjbinWw3pWIDbf57Lut 6 | fXgS84ilZpc7M2zeu1QrPyhCedL/gPP0QxKbPS6AR5R/DibH4RWcujL6CU5FB0Y9 7 | on+IpN/Iml2XzgGiU82gTkJg185VgWwDaHOPKvUF9N1GpvxcSvRsNGoiBJ/LlE4N 8 | hxyUQ0V/lAalYxYybxgl8/xghWMkGnQc3YKWKqGmtBaaax3xvMzamxpWPphoLG07 9 | +YZfAf0Q7vslVMmlslRmx9OpJFvRnkelbXoHHx73umbMiFp28njY8NK2dqXwb6Z8 10 | 0BCezppCKYpbjnupOIDAAE0KvjzhhzSS68ZgukiBZOcUlnWLzL39AgMBAAGjXDBa 11 | MA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATAMBgNVHRMBAf8E 12 | AjAAMCUGA1UdEQQeMByCCWxvY2FsaG9zdIIJbG9jYWxob3N0hwR/AAABMA0GCSqG 13 | SIb3DQEBCwUAA4IBAQBm9Z15QxsRqoaRDh/ELA93eE9105gwrXrR3AK/iKuJyxIc 14 | /SXVbpAaYHArMrUzaZs0GXEzgW31tZn8D3dgFy8XdZxk1ztaFTm+QTnFRogMNB8A 15 | kvpq7jwTa44c7G0wuNO2nATMu2Ifi/nSdQadTxzmZacSrevN/zcjmvSoV4VFkKO5 16 | VBnr7e1ruffxAaVAzrRraplpZvuJzlcvqTYAME8fq8H9QidvaXF6yIbEPwwUHK67 17 | 8W4rXn9Zp6NDuQhH0eNPAGlEAaYuyCJvJZeM68ootMi7Uh6RJOTDw1HIdekYEr1/ 18 | FAg4+rH/9Gi+o/LXsBmYXabO+GjsOwfezv3THDnw 19 | -----END CERTIFICATE----- 20 | -----BEGIN CERTIFICATE----- 21 | MIIC5DCCAcygAwIBAgIBATANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdsb2Nh 22 | bGhvc3QtY2FAMTUzMTQ2ODA4NTAgFw0xODA3MTMwNjQ4MDVaGA8yMTE4MDYxOTA2 23 | NDgwNVowIjEgMB4GA1UEAwwXbG9jYWxob3N0LWNhQDE1MzE0NjgwODUwggEiMA0G 24 | CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDFDtkZLlseubpzPQr1IT3xE28/1cDM 25 | 3UB2vp+pbiwvkmHvfm9RxMmDZbYWqXL5beCG/ladHaJ0RW4f3sBPzxDzUP1zFM94 26 | iYDZmVA0f7ZvtijuiUrwc6TP21ctX5TlN2YYoh4Er+aZ6E5MQIMAxkP+w1lwyYmj 27 | oxopD1wf/4cmZgv9axZV1zR5MrpyVboQa4mQRUoMlLQFE0erMc0yIJsIVWXx9yS7 28 | 9dzhEXC2WPYnPHh6AYSQZBdzumj5HdZhOQhL/UOWq6AJGP1p7l0uXPArmDG0g9pS 29 | aFxAQx6IxtdSUOZFBlel/p+iOab3H8eoNkgCPMXmrM3WZLW7Uy5Onx6LAgMBAAGj 30 | IzAhMA4GA1UdDwEB/wQEAwICpDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB 31 | CwUAA4IBAQC0BaURRhpRbORaOiZJFeQR0gCD9goggXNj+cPh8yYol2GNBdLfed6x 32 | B6ZxGW2Y14pOjo2Ba5FdZyzfOenjhkqhUujQSMxKjkWxX03blLjPEvLo/Wi6TLnp 33 | H3Qmm/Gq1GAxmkZUaovcE71/zpZ/lJLWVVxz21wxcGQIA30DUKgdycfOvWdYkYGf 34 | tnsXpY4yIyHvKvfeIbxo8doBnoRvYd4a7QyY0zw/Q3qaCdINo9zKJYV0CnpSZhKy 35 | 5RLcrlfvXttEYryP57RWP9GYJMNmiovGcbls4pOwZMNueUx5qEzIbC9lsfyt13Bc 36 | oZ1lk1TqzwJERoALmgT0ccp7LRxIV90P 37 | -----END CERTIFICATE----- 38 | -------------------------------------------------------------------------------- /pkg/cmd/server/testing/testdata/localhost_127.0.0.1_localhost.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpgIBAAKCAQEAwvUH8dWABKfsK0iI24p1sN6ViA23+ey7rX14EvOIpWaXOzNs 3 | 3rtUKz8oQnnS/4Dz9EMSmz0ugEeUfw4mx+EVnLoy+glORQdGPaJ/iKTfyJpdl84B 4 | olPNoE5CYNfOVYFsA2hzjyr1BfTdRqb8XEr0bDRqIgSfy5RODYcclENFf5QGpWMW 5 | Mm8YJfP8YIVjJBp0HN2CliqhprQWmmsd8bzM2psaVj6YaCxtO/mGXwH9EO77JVTJ 6 | pbJUZsfTqSRb0Z5HpW16Bx8e97pmzIhadvJ42PDStnal8G+mfNAQns6aQimKW457 7 | qTiAwABNCr484Yc0kuvGYLpIgWTnFJZ1i8y9/QIDAQABAoIBAQC3rgioLpEI0fVO 8 | 6m4W+iLcWznjD5nQnNxOHrJsmIqb20aM/myKhVBN1pll2EWVeLdf4Xm8TS5sqgQc 9 | mQast0KXgU7aCL53ht0E4P7rjPtSky2vAubDO9W2PUWI3IqIQQG1TEnkD4L+868v 10 | C9EkW3JiKBf+qQCs27OWR0AD6EWoZfc9NT5AVnL1aTwKnLpSt80umXUMmR5c4ddT 11 | 58FO9JgZCzHbcoAyosf4v8fiz588zjBDRRienHourxmUnsKJrIyCMrygBpQ7wIcO 12 | R86e+PuQ+toeSbldq8EfN/XoY0POUvLL/zu6HkbZLhOEjEHQMkMRCMtmLCjuU+sy 13 | TwdRl0xBAoGBAOtC+kqh5eYgQAYtvPaW/XQwrang+G2xIYd/OTXzIlU2T3sTPrDo 14 | IEkwsXwAeKcJx+Z7XcipSG5l1s5QZbc+GIARmJ0DrAwLkDhlwz8RssxBY4q64Jtn 15 | FWRm6CBJkPDq4t16ZbXDdUleXAaqbvxTTnPZMz2o1XHEDpUcPG29MnF1AoGBANQk 16 | hh44qY3IUxRwp6ZoNHVRz7oJC2JLj1++QNoLXX/8LWTXd49RZpI7Byk2lEXl7clf 17 | 3rErBuWElrxxuikOahEdzkjKSZq4RSKj1lNpy14spBRo7O9Q+GrJgcr3tcuyT6ri 18 | sXOo6ET5bG72j+uVzv/QbuyCS8elZQHifBIi58FpAoGBAIXsQ8TWcqPUuf2KbeZF 19 | v5Qz3bg1y9XNnpOedbfjZyjw2L/sDaTxDuf7Ix2+uvADnlry4UlILGZD7MrXc3+j 20 | hpjo62J+Y6MbtgaUz1eIwKqLkpm3lgKA5OmZtwwiNLMgUvLXKS0WTh7s6yAUR0e2 21 | OJO0EfpIsPCpNc/mGfQyXpO9AoGBANEVblo63mGvHrL2lUWdTpaSm3lvkJjAf/6N 22 | NL2yleSeVt8cvemzALT/GH+2G00I4OOoaYOUNKfhle8E58WvPzq/daCoPwMOupT5 23 | hTORAa8/sDetclgsJaqaECJLIhIxG/QAmYS05LeWXRjASfiXHf1jIPBZOvb6PCMv 24 | Zbk6TdCBAoGBAIxT9W5FhHl+uUpuHIuFvCUg0AoERk9dUPXVEz1C1lqsYfetZ0uz 25 | wh9KtFq2puWrez+K4o04LoInXHFeb34Hx/9SRDCTawmMicuLxivbTm4yjG2RsShl 26 | nbq376nyawu9rcjM3F5ucYLiGHmQOPYWSOvGr2QhGgFgzXiBQ1RcAYdH 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /pkg/controller/nonstructuralschema/nonstructuralschema_controller_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package nonstructuralschema 18 | 19 | import ( 20 | "fmt" 21 | "reflect" 22 | "testing" 23 | 24 | apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 25 | "k8s.io/apimachinery/pkg/util/validation/field" 26 | ) 27 | 28 | func Test_calculateCondition(t *testing.T) { 29 | tests := []struct { 30 | name string 31 | args *apiextensionsv1.CustomResourceDefinition 32 | want *apiextensionsv1.CustomResourceDefinitionCondition 33 | }{ 34 | { 35 | name: "preserve unknown fields is false", 36 | args: &apiextensionsv1.CustomResourceDefinition{ 37 | Spec: apiextensionsv1.CustomResourceDefinitionSpec{ 38 | PreserveUnknownFields: false, 39 | }, 40 | }, 41 | }, 42 | { 43 | name: "preserve unknown fields is true", 44 | args: &apiextensionsv1.CustomResourceDefinition{ 45 | Spec: apiextensionsv1.CustomResourceDefinitionSpec{ 46 | PreserveUnknownFields: true, 47 | }, 48 | }, 49 | want: &apiextensionsv1.CustomResourceDefinitionCondition{ 50 | Type: apiextensionsv1.NonStructuralSchema, 51 | Status: apiextensionsv1.ConditionTrue, 52 | Reason: "Violations", 53 | Message: field.Invalid(field.NewPath("spec", "preserveUnknownFields"), 54 | true, 55 | fmt.Sprint("must be false")).Error(), 56 | }, 57 | }, 58 | } 59 | for _, tt := range tests { 60 | t.Run(tt.name, func(t *testing.T) { 61 | if got := calculateCondition(tt.args); !reflect.DeepEqual(got, tt.want) { 62 | t.Errorf("calculateCondition() = %v, want %v", got, tt.want) 63 | } 64 | }) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /pkg/controller/openapi/metrics.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package openapi 18 | 19 | import ( 20 | "k8s.io/component-base/metrics" 21 | "k8s.io/component-base/metrics/legacyregistry" 22 | ) 23 | 24 | var ( 25 | regenerationCounter = metrics.NewCounterVec( 26 | &metrics.CounterOpts{ 27 | Name: "apiextensions_openapi_v2_regeneration_count", 28 | Help: "Counter of OpenAPI v2 spec regeneration count broken down by causing CRD name and reason.", 29 | StabilityLevel: metrics.ALPHA, 30 | }, 31 | []string{"crd", "reason"}, 32 | ) 33 | ) 34 | 35 | func init() { 36 | legacyregistry.MustRegister(regenerationCounter) 37 | } 38 | -------------------------------------------------------------------------------- /pkg/controller/openapiv3/metrics.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package openapiv3 18 | 19 | import ( 20 | "k8s.io/component-base/metrics" 21 | "k8s.io/component-base/metrics/legacyregistry" 22 | ) 23 | 24 | var ( 25 | regenerationCounter = metrics.NewCounterVec( 26 | &metrics.CounterOpts{ 27 | Name: "apiextensions_openapi_v3_regeneration_count", 28 | Help: "Counter of OpenAPI v3 spec regeneration count broken down by group, version, causing CRD and reason.", 29 | StabilityLevel: metrics.ALPHA, 30 | }, 31 | []string{"group", "version", "crd", "reason"}, 32 | ) 33 | ) 34 | 35 | func init() { 36 | legacyregistry.MustRegister(regenerationCounter) 37 | } 38 | -------------------------------------------------------------------------------- /pkg/controller/openapiv3/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package openapiv3 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime/schema" 21 | ) 22 | 23 | func groupVersionToOpenAPIV3Path(gv schema.GroupVersion) string { 24 | return "apis/" + gv.Group + "/" + gv.Version 25 | } 26 | -------------------------------------------------------------------------------- /pkg/features/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - feature-approvers 5 | -------------------------------------------------------------------------------- /pkg/generated/openapi/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // openapi generated definitions. 18 | package openapi 19 | -------------------------------------------------------------------------------- /test/integration/apiserver.local.config/certificates/README.md: -------------------------------------------------------------------------------- 1 | Keys in this directory are generated for testing purposes only. 2 | -------------------------------------------------------------------------------- /test/integration/apiserver.local.config/certificates/apiserver.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDFTCCAf2gAwIBAgIBATANBgkqhkiG9w0BAQsFADAfMR0wGwYDVQQDDBRsb2Nh 3 | bGhvc3RAMTUxNTQ2MjIwNjAgFw0xODAxMDkwMTQzMjZaGA8yMTE4MDEwOTAxNDMy 4 | NlowHzEdMBsGA1UEAwwUbG9jYWxob3N0QDE1MTU0NjIyMDYwggEiMA0GCSqGSIb3 5 | DQEBAQUAA4IBDwAwggEKAoIBAQC2hIORzonehlNadYyI30v1Jj8lhhABuiWiTSkl 6 | KCLqZjwBfWfSC4w02zxi2SAH9ju20XCJrUauwPq1qXCp/CqXC/rVgZrzluDlpJpe 7 | gF9AilQvGOxhrZhV4kqpOjGVE78uOmpfxiOyNermoJ0OVE8ugh3s/LLTNK/qmCAX 8 | uEYTQccAvNEiPX3XPBCiaFlSCkUNS0zp12mJNP43+KF9y0CbtYs1gXKHmmJVSpjR 9 | YmcuJJUfHxNrV2YR3ek6O4IIJFIlnLxgpjRBseBPkTenAT3S2YY9MyQkkBrRSPBa 10 | vLM24al3KDvXYikYe3WpxeYNHGNcHIgR+hKlRTQ5VrWlfx9dAgMBAAGjWjBYMA4G 11 | A1UdDwEB/wQEAwICpDATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHRMBAf8EBTAD 12 | AQH/MCAGA1UdEQQZMBeCCWxvY2FsaG9zdIcEfwAAAYcEfwAAATANBgkqhkiG9w0B 13 | AQsFAAOCAQEAFhW8cVTraHPNsE+Jo0ZvcE2ic8lEzeOhWI2O/fpkrUJS5LptPKHS 14 | nTK+CPxA0zhIS/vlJznIabeddXwtq7Xb5SwlJMHYMnHD6f5qwpD22D2dxJJa5sma 15 | 3yrK/4CutuEae08qqSeakfgCjcHLL9p7FZWxujkV9/5CEH5lFWYLGumyIoS46Svf 16 | nSfDFKTrOj8P60ncCoWcSpMbdVQBDuKlIZuBMmz9CguC1CtuQWPDUmOGJuPs/+So 17 | yusHbBfj+ATUWDYTg1lLjOIOSJpHGUQkvS+8Bo47SThD/b4w2i6VC72ldxtBuxGf 18 | L7+jALMhMhiQD+Q4qsNuyvvNQLoYcTTFTw== 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /test/integration/apiserver.local.config/certificates/apiserver.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAtoSDkc6J3oZTWnWMiN9L9SY/JYYQAbolok0pJSgi6mY8AX1n 3 | 0guMNNs8YtkgB/Y7ttFwia1GrsD6talwqfwqlwv61YGa85bg5aSaXoBfQIpULxjs 4 | Ya2YVeJKqToxlRO/LjpqX8YjsjXq5qCdDlRPLoId7Pyy0zSv6pggF7hGE0HHALzR 5 | Ij191zwQomhZUgpFDUtM6ddpiTT+N/ihfctAm7WLNYFyh5piVUqY0WJnLiSVHx8T 6 | a1dmEd3pOjuCCCRSJZy8YKY0QbHgT5E3pwE90tmGPTMkJJAa0UjwWryzNuGpdyg7 7 | 12IpGHt1qcXmDRxjXByIEfoSpUU0OVa1pX8fXQIDAQABAoIBAERy2ezaqnXbpnLs 8 | VrIWHCRqHZBzAJnFN8vwaBfZP47snGBqqX7qecBw3+qqRwr1W1uqnCvl4fYzxVJP 9 | o0L8oPRYt89OddAYq2s0GfiK6C4KMpwfGrdfJRxAa4OfoWypJS+vFKmqY0S4V8n6 10 | Pixbjf6BKbvw4Re4UKkIODDtGMqrZFVKcFe8LCnd3D+7jvt0M/WjEhrepWxscJh3 11 | aHgDzsLzCv1DNjgZfoRZubkK3bdndMaL6NhaKNBz6S7CT9XmZsJaWkmBXs9zOoyr 12 | 0hKP0A11cm6a7LsmxX5h4uaQLh66KHUPbV4KjKgKiGkSS9cnZoXHFZLOplOfozje 13 | 1DKitAECgYEA2eWiRNByNIqqRPvBtD8ydavOLk6iLlLt+LkCpGupgELs53WS5fTT 14 | TxbyVq+897qeW2Klir7jZFWG3Q+EaBATxMYON+jb7QnIz8gX9lh1PpUlo88BiQzO 15 | hAIx2uV19KM0ftXYVTSAUh1N2cgoOWGUWLaeMPdxPOlJwvM25hSfp90CgYEA1m8W 16 | vWBO8X5LXM9g+fO1TFSlTnUJW1gWrnOw4VmU2+DbqNmtefpVrqDa5Iw2+mU+EBgA 17 | d3wdAHARXpc2MGcIRnRbHn+gXJVHA+gA7H9LSZ4Yi0qJZbNVAgRySs2iBYUcunsR 18 | AXkS7sPGQinfnjKh6vhYVErh5jA+cvS8CXZtnYECgYBmh61hYAw9OPqB100AebRO 19 | tncgRxP9ZDxiCvx5TcfGeLds+mATIK7FynBh5fOvRfr52WM39DafobcCEiklplsG 20 | /oL2P/YshaweSXMtEdapihjaCbAZQxNx/m5jKBHm+VzcSdev0DKJcQyO66Yxyf65 21 | 98RcGjMIjGWO/E7a2N1/aQKBgCPrY+HBGjg1saYQTuxPuJTasP4deL3GWbZLRtvY 22 | x6i1V9ZG8Fo4ZtXjuAcEvcjf4K+NdbaOIcWLAD3aEoe1GpvCrejD9DbOAqFS4aS8 23 | Bf6E7xOWHsHccmbuG78QBw3pqFBMgSLABz3bqYA3x2+Wh6z2gMVN7d1DQ5K6EC19 24 | mwsBAoGBAKZBgqRHRq1Ch3SWb5Q+SgUvNyQ+PAIwCve0vA4mMIK6EGqU/8wbU01B 25 | 5/UkCfT+ovDeDuyeaZbTWzwUC4Mrg4C9rThrK5WLc43Dig6G1HhfjdLA+gdKFOjh 26 | FpocOI2FEwbmj5Mka6n3TSFI8c55ubYdyXQu92DoFt4dTOJStUn2 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gateway/duplicate-listeners.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: duplicate-listeners 5 | spec: 6 | gatewayClassName: acme-lb 7 | listeners: 8 | - name: same 9 | protocol: HTTP 10 | port: 80 11 | - name: same 12 | protocol: HTTP 13 | port: 443 14 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gateway/hostname-tcp.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: hostname-tcp 5 | spec: 6 | gatewayClassName: acme-lb 7 | listeners: 8 | - name: example 9 | hostname: example.com 10 | protocol: TCP 11 | port: 80 12 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gateway/hostname-udp.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: hostname-udp 5 | spec: 6 | gatewayClassName: acme-lb 7 | listeners: 8 | - name: example 9 | hostname: example.com 10 | protocol: UDP 11 | port: 80 12 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gateway/invalid-addresses.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: invalid-addresses 5 | spec: 6 | gatewayClassName: acme-lb 7 | addresses: 8 | - value: 1200:0000:::AB00:1234:0000:2552:7777:1313 9 | - value: 21DA:D3:0:2F3B:2AY:FF:FE28:9C5A 10 | - value: "2001:db8:3c4d:15:0:d234:3eee:" 11 | - value: "2001:db8:3c4d:15:0:d234:3eee:::" 12 | - value: ":::1234::" 13 | - value: "1.1.1" 14 | - value: "1.a.3.4" 15 | - value: "foo.com" 16 | - type: IPAddress 17 | value: "256.255.255.255" 18 | - type: "Hostname" 19 | value: "foo.com:80" 20 | - type: "example.com/custom" 21 | value: "anything goes" 22 | listeners: 23 | - protocol: HTTP 24 | port: 80 25 | name: prod-web-gw 26 | allowedRoutes: 27 | namespaces: 28 | from: Same 29 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gateway/invalid-listener-name.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: invalid-listener-name 5 | spec: 6 | gatewayClassName: acme-lb 7 | listeners: 8 | - name: bad> 9 | protocol: HTTP 10 | port: 80 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gateway/invalid-listener-port.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: invalid-listener-port 5 | spec: 6 | gatewayClassName: acme-lb 7 | listeners: 8 | - name: foo 9 | protocol: HTTP 10 | port: 123456789 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gateway/tlsconfig-tcp.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: tlsconfig-tcp 5 | spec: 6 | gatewayClassName: acme-lb 7 | listeners: 8 | - name: example 9 | protocol: TCP 10 | port: 443 11 | tls: 12 | certificateRefs: 13 | - kind: Secret 14 | group: "" 15 | name: bar-example-com-cert 16 | 17 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/gatewayclass/invalid-controller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: GatewayClass 3 | metadata: 4 | name: invalid-controller 5 | spec: 6 | controllerName: example 7 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/duplicate-header-match.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: duplicate-header-match 5 | spec: 6 | rules: 7 | - matches: 8 | - headers: 9 | - name: foo 10 | value: bar 11 | - name: foo 12 | value: bar 13 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/duplicate-query-match.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: duplicate-query-match 5 | spec: 6 | rules: 7 | - matches: 8 | - queryParams: 9 | - name: foo 10 | value: bar 11 | - name: foo 12 | value: bar 13 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/httproute-portless-backend.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: portless-backend 5 | spec: 6 | parentRefs: 7 | - name: prod-web 8 | rules: 9 | - backendRefs: 10 | - name: foo 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/httproute-portless-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: portless-service 5 | spec: 6 | parentRefs: 7 | - name: prod-web 8 | rules: 9 | - backendRefs: 10 | - name: foo 11 | kind: Service 12 | group: "" 13 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-backend-group.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-backend-group 5 | spec: 6 | rules: 7 | - backendRefs: 8 | - group: "*" 9 | name: foo 10 | port: 80 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-backend-kind.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-backend-kind 5 | spec: 6 | rules: 7 | - backendRefs: 8 | - kind: "*" 9 | name: foo 10 | port: 80 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-backend-port.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-backend-port 5 | spec: 6 | rules: 7 | - backendRefs: 8 | - name: my-service1 9 | port: 800080 10 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-filter-duplicate-header.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-filter-duplicate-header 5 | spec: 6 | rules: 7 | - filters: 8 | - type: RequestHeaderModifier 9 | requestHeaderModifier: 10 | remove: 11 | - foo 12 | - foo 13 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-filter-duplicate.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-filter-duplicate 5 | spec: 6 | rules: 7 | - filters: 8 | - type: RequestHeaderModifier 9 | requestHeaderModifier: 10 | add: 11 | - name: my-header 12 | value: foo 13 | - type: RequestHeaderModifier 14 | requestHeaderModifier: 15 | add: 16 | - name: my-header 17 | value: bar 18 | 19 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-filter-empty.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-filter-empty 5 | spec: 6 | rules: 7 | - filters: 8 | - type: RequestHeaderModifier 9 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-filter-wrong-field.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-filter-wrong-field 5 | spec: 6 | rules: 7 | - filters: 8 | - type: RequestHeaderModifier 9 | requestRedirect: 10 | port: 443 11 | 12 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-header-name.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-header-name 5 | spec: 6 | rules: 7 | - matches: 8 | - headers: 9 | - type: Exact 10 | name: magic/ 11 | value: foo 12 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-hostname.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-hostname 5 | spec: 6 | hostnames: 7 | - http://a< 8 | rules: 9 | - backendRefs: 10 | - name: foo 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-httredirect-hostname.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-backend-port 5 | spec: 6 | rules: 7 | - backendRefs: 8 | - name: my-service 9 | port: 8080 10 | filters: 11 | - type: RequestRedirect 12 | requestRedirect: 13 | hostname: "*.gateway.networking.k8s.io" 14 | 15 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-method.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-method 5 | spec: 6 | rules: 7 | - matches: 8 | - method: NOTREAL 9 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-path-alphanum-specialchars-mix.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-path-alphanum-specialchars-mix 5 | spec: 6 | rules: 7 | - matches: 8 | - path: 9 | type: PathPrefix 10 | value: /my[/]path01 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-path-specialchars.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: invalid-path-specialchars 5 | spec: 6 | rules: 7 | - matches: 8 | - path: 9 | type: PathPrefix 10 | value: /[] 11 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/httproute/invalid-request-redirect-with-backendref.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: http-filter-rewrite 5 | spec: 6 | hostnames: 7 | - rewrite.example 8 | rules: 9 | - filters: 10 | - type: RequestRedirect 11 | requestRedirect: 12 | scheme: https 13 | statusCode: 301 14 | backendRefs: 15 | - name: example-svc 16 | port: 80 17 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/referencegrant/missing-from.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: ReferenceGrant 3 | metadata: 4 | name: missing-from 5 | spec: 6 | to: 7 | - group: "" 8 | kind: "Service" 9 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/referencegrant/missing-ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: ReferenceGrant 3 | metadata: 4 | name: missing-ns 5 | spec: 6 | to: 7 | - group: "" 8 | kind: "Service" 9 | from: 10 | - group: "gateway.networking.k8s.io" 11 | kind: "HTTPRoute" 12 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/invalid/referencegrant/missing-to.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: ReferenceGrant 3 | metadata: 4 | name: missing-to 5 | spec: 6 | from: 7 | - group: "" 8 | kind: "Service" 9 | namespace: "example" 10 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/0-namespaces.yaml: -------------------------------------------------------------------------------- 1 | # These namespaces can be used for examples without recreating them each time. 2 | --- 3 | apiVersion: v1 4 | kind: Namespace 5 | metadata: 6 | name: gateway-api-example-ns1 7 | --- 8 | apiVersion: v1 9 | kind: Namespace 10 | metadata: 11 | name: gateway-api-example-ns2 12 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/basic-http.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: GatewayClass 5 | metadata: 6 | name: acme-lb 7 | spec: 8 | controllerName: acme.io/gateway-controller 9 | parametersRef: 10 | name: acme-lb 11 | group: acme.io 12 | kind: Parameters 13 | --- 14 | apiVersion: gateway.networking.k8s.io/v1beta1 15 | kind: Gateway 16 | metadata: 17 | name: my-gateway 18 | spec: 19 | gatewayClassName: acme-lb 20 | listeners: # Use GatewayClass defaults for listener definition. 21 | - name: http 22 | protocol: HTTP 23 | port: 80 24 | --- 25 | apiVersion: gateway.networking.k8s.io/v1beta1 26 | kind: HTTPRoute 27 | metadata: 28 | name: http-app-1 29 | spec: 30 | parentRefs: 31 | - name: my-gateway 32 | hostnames: 33 | - "foo.com" 34 | rules: 35 | - matches: 36 | - path: 37 | type: PathPrefix 38 | value: /bar 39 | backendRefs: 40 | - name: my-service1 41 | port: 8080 42 | - matches: 43 | - headers: 44 | - type: Exact 45 | name: magic 46 | value: foo 47 | queryParams: 48 | - type: Exact 49 | name: great 50 | value: example 51 | path: 52 | type: PathPrefix 53 | value: /some/thing 54 | method: GET 55 | backendRefs: 56 | - name: my-service2 57 | port: 8080 58 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/cross-namespace-routing/0-namespaces.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/multiple-ns.md 3 | apiVersion: v1 4 | kind: Namespace 5 | metadata: 6 | name: infra-ns 7 | labels: 8 | shared-gateway-access: "true" 9 | --- 10 | apiVersion: v1 11 | kind: Namespace 12 | metadata: 13 | name: site-ns 14 | labels: 15 | shared-gateway-access: "true" 16 | --- 17 | apiVersion: v1 18 | kind: Namespace 19 | metadata: 20 | name: store-ns 21 | labels: 22 | shared-gateway-access: "true" 23 | --- 24 | apiVersion: v1 25 | kind: Namespace 26 | metadata: 27 | name: no-external-access 28 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/cross-namespace-routing/gateway.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/multiple-ns.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: Gateway 5 | metadata: 6 | name: shared-gateway 7 | namespace: infra-ns 8 | spec: 9 | gatewayClassName: shared-gateway-class 10 | listeners: 11 | - name: https 12 | hostname: "foo.example.com" 13 | protocol: HTTPS 14 | port: 443 15 | allowedRoutes: 16 | namespaces: 17 | from: Selector 18 | selector: 19 | matchLabels: 20 | shared-gateway-access: "true" 21 | tls: 22 | certificateRefs: 23 | - name: foo-example-com 24 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/cross-namespace-routing/site-route.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/multiple-ns.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: home 7 | namespace: site-ns 8 | spec: 9 | parentRefs: 10 | - name: shared-gateway 11 | namespace: infra-ns 12 | rules: 13 | - backendRefs: 14 | - name: home 15 | port: 8080 16 | --- 17 | apiVersion: gateway.networking.k8s.io/v1beta1 18 | kind: HTTPRoute 19 | metadata: 20 | name: login 21 | namespace: site-ns 22 | spec: 23 | parentRefs: 24 | - name: shared-gateway 25 | namespace: infra-ns 26 | rules: 27 | - matches: 28 | - path: 29 | value: /login 30 | backendRefs: 31 | - name: login-v1 32 | port: 8080 33 | weight: 90 34 | - name: login-v2 35 | port: 8080 36 | weight: 10 37 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/cross-namespace-routing/store-route.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/multiple-ns.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: store 7 | namespace: store-ns 8 | spec: 9 | parentRefs: 10 | - name: shared-gateway 11 | namespace: infra-ns 12 | rules: 13 | - matches: 14 | - path: 15 | value: /store 16 | backendRefs: 17 | - name: store 18 | port: 8080 19 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/default-match-http.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: GatewayClass 3 | metadata: 4 | name: default-match-example 5 | spec: 6 | controllerName: acme.io/gateway-controller 7 | --- 8 | apiVersion: gateway.networking.k8s.io/v1beta1 9 | kind: Gateway 10 | metadata: 11 | name: default-match-gw 12 | spec: 13 | gatewayClassName: default-match-example 14 | listeners: 15 | - name: http 16 | protocol: HTTP 17 | port: 80 18 | --- 19 | # This HTTPRoute demonstrates patch match defaulting. If no path match is 20 | # specified, CRD defaults adds a default PathPrefix match on the path "/". This 21 | # matches every HTTP request and ensures that route rules always have at 22 | # least one valid match. 23 | apiVersion: gateway.networking.k8s.io/v1beta1 24 | kind: HTTPRoute 25 | metadata: 26 | name: default-match-route 27 | labels: 28 | app: default-match 29 | spec: 30 | parentRefs: 31 | - name: default-match-gw 32 | hostnames: 33 | - default-match.com 34 | rules: 35 | - matches: 36 | - headers: 37 | - type: Exact 38 | name: magic 39 | value: default-match 40 | backendRefs: 41 | - group: acme.io 42 | kind: CustomBackend 43 | name: my-custom-resource 44 | port: 8080 45 | - matches: 46 | - path: 47 | type: Exact 48 | value: /example/exact 49 | backendRefs: 50 | - name: my-service-2 51 | port: 8080 52 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/gateway-addresses.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: gateway-addresses 5 | spec: 6 | gatewayClassName: acme-lb 7 | addresses: 8 | - value: 1200:0000:AB00:1234:0000:2552:7777:1313 9 | - value: 21DA:D3:0:2F3B:2AA:FF:FE28:9C5A 10 | - value: "2001:db8:3c4d:15:0:d234:3eee::" 11 | - value: "1234::" 12 | - value: "1.1.1.1" 13 | - value: "1.2.3.4" 14 | - value: "0.0.0.0" 15 | - value: "9.255.255.255" 16 | - value: "11.0.0.0" 17 | - type: IPAddress 18 | value: "255.255.255.255" 19 | - type: "Hostname" 20 | value: "example.com" 21 | listeners: 22 | - protocol: HTTP 23 | port: 80 24 | name: prod-web-gw 25 | allowedRoutes: 26 | namespaces: 27 | from: Same 28 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-filter.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: http-filter-1 7 | spec: 8 | hostnames: 9 | - my.filter.com 10 | rules: 11 | - filters: 12 | - type: RequestHeaderModifier 13 | requestHeaderModifier: 14 | add: 15 | - name: my-header 16 | value: foo 17 | backendRefs: 18 | - name: my-filter-svc1 19 | weight: 1 20 | port: 80 21 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect-path.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: http-filter-1 5 | namespace: gateway-api-example-ns1 6 | spec: 7 | parentRefs: 8 | - name: my-filter-gateway 9 | sectionName: http 10 | hostnames: 11 | - my-filter.example.com 12 | rules: 13 | - filters: 14 | - type: RequestRedirect 15 | requestRedirect: 16 | path: 17 | type: ReplaceFullPath 18 | replaceFullPath: /foo 19 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect-rewrite/httproute-redirect-full.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: http-filter-redirect 7 | spec: 8 | hostnames: 9 | - redirect.example 10 | rules: 11 | - matches: 12 | - path: 13 | type: PathPrefix 14 | value: /cayenne 15 | filters: 16 | - type: RequestRedirect 17 | requestRedirect: 18 | path: 19 | type: ReplaceFullPath 20 | replaceFullPath: /paprika 21 | statusCode: 302 22 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect-rewrite/httproute-redirect-https.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: http-filter-redirect 7 | spec: 8 | hostnames: 9 | - redirect.example 10 | rules: 11 | - filters: 12 | - type: RequestRedirect 13 | requestRedirect: 14 | scheme: https 15 | statusCode: 301 16 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect-rewrite/httproute-redirect-prefix.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: http-filter-redirect 7 | spec: 8 | hostnames: 9 | - redirect.example 10 | rules: 11 | - matches: 12 | - path: 13 | type: PathPrefix 14 | value: /cayenne 15 | filters: 16 | - type: RequestRedirect 17 | requestRedirect: 18 | path: 19 | type: ReplacePrefixMatch 20 | replacePrefixMatch: /paprika 21 | statusCode: 302 22 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect-rewrite/httproute-rewrite-path.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: http-filter-rewrite 7 | spec: 8 | hostnames: 9 | - rewrite.example 10 | rules: 11 | - matches: 12 | - path: 13 | type: PathPrefix 14 | value: /cardamom 15 | filters: 16 | - type: URLRewrite 17 | urlRewrite: 18 | hostname: elsewhere.example 19 | path: 20 | type: ReplaceFullPath 21 | replaceFullPath: /fennel 22 | backendRefs: 23 | - name: example-svc 24 | weight: 1 25 | port: 80 26 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect-rewrite/httproute-rewrite.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: http-filter-rewrite 7 | spec: 8 | hostnames: 9 | - rewrite.example 10 | rules: 11 | - filters: 12 | - type: URLRewrite 13 | urlRewrite: 14 | hostname: elsewhere.example 15 | backendRefs: 16 | - name: example-svc 17 | weight: 1 18 | port: 80 19 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect-rewrite/httproute-rewritepath.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/api-types/httproute.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: http-filter-rewrite 7 | spec: 8 | hostnames: 9 | - rewrite.example 10 | rules: 11 | - filters: 12 | - type: URLRewrite 13 | urlRewrite: 14 | hostname: elsewhere.example 15 | path: 16 | type: ReplacePrefixMatch 17 | replacePrefixMatch: /fennel 18 | backendRefs: 19 | - name: example-svc 20 | weight: 1 21 | port: 80 22 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-redirect.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: GatewayClass 3 | metadata: 4 | name: filter-lb 5 | spec: 6 | controllerName: acme.io/gateway-controller 7 | parametersRef: 8 | name: acme-lb 9 | group: acme.io 10 | kind: Parameters 11 | --- 12 | apiVersion: v1 13 | kind: Namespace 14 | metadata: 15 | name: gateway-api-example-ns1 16 | --- 17 | apiVersion: gateway.networking.k8s.io/v1beta1 18 | kind: Gateway 19 | metadata: 20 | name: my-filter-gateway 21 | namespace: gateway-api-example-ns1 22 | spec: 23 | gatewayClassName: filter-lb 24 | listeners: 25 | - name: http 26 | protocol: HTTP 27 | port: 80 28 | - name: https 29 | protocol: HTTPS 30 | port: 443 31 | tls: 32 | certificateRefs: 33 | - kind: Secret 34 | group: "" 35 | name: example-com-cert 36 | --- 37 | apiVersion: gateway.networking.k8s.io/v1beta1 38 | kind: HTTPRoute 39 | metadata: 40 | name: http-filter-1 41 | namespace: gateway-api-example-ns1 42 | spec: 43 | parentRefs: 44 | - name: my-filter-gateway 45 | sectionName: http 46 | hostnames: 47 | - my-filter.example.com 48 | rules: 49 | - filters: 50 | - type: RequestRedirect 51 | requestRedirect: 52 | scheme: https 53 | --- 54 | apiVersion: gateway.networking.k8s.io/v1beta1 55 | kind: HTTPRoute 56 | metadata: 57 | name: http-filter-2 58 | namespace: gateway-api-example-ns1 59 | spec: 60 | parentRefs: 61 | - name: my-filter-gateway 62 | sectionName: https 63 | hostnames: 64 | - my-filter.example.com 65 | rules: 66 | - matches: 67 | - path: 68 | type: PathPrefix 69 | value: / 70 | backendRefs: 71 | - name: my-filter-svc1 72 | weight: 1 73 | port: 80 74 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-request-header-add.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: header-http-echo 5 | spec: 6 | parentRefs: 7 | - name: acme-gw 8 | rules: 9 | - matches: 10 | - path: 11 | type: PathPrefix 12 | value: /add-a-request-header 13 | filters: 14 | - type: RequestHeaderModifier 15 | requestHeaderModifier: 16 | add: 17 | - name: my-header-name 18 | value: my-header-value 19 | backendRefs: 20 | - name: echo 21 | port: 8080 22 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-request-header-remove.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: header-http-echo 5 | spec: 6 | parentRefs: 7 | - name: acme-gw 8 | rules: 9 | - matches: 10 | - path: 11 | type: PathPrefix 12 | value: /remove-a-request-header 13 | filters: 14 | - type: RequestHeaderModifier 15 | requestHeaderModifier: 16 | remove: 17 | - x-request-id 18 | backendRefs: 19 | - name: echo 20 | port: 8080 21 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-request-header-set.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: header-http-echo 5 | spec: 6 | parentRefs: 7 | - name: acme-gw 8 | rules: 9 | - matches: 10 | - path: 11 | type: PathPrefix 12 | value: /edit-a-request-header 13 | filters: 14 | - type: RequestHeaderModifier 15 | requestHeaderModifier: 16 | set: 17 | - name: my-header-name 18 | value: my-new-header-value 19 | backendRefs: 20 | - name: echo 21 | port: 8080 22 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-rewrite.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: http-filter-1 5 | namespace: gateway-api-example-ns1 6 | spec: 7 | parentRefs: 8 | - name: my-filter-gateway 9 | sectionName: http 10 | hostnames: 11 | - my-filter.example.com 12 | rules: 13 | - filters: 14 | - type: URLRewrite 15 | urlRewrite: 16 | path: 17 | type: ReplaceFullPath 18 | replaceFullPath: /foo 19 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-route-attachment/gateway-namespaces.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/concepts/api-overview.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: Gateway 5 | metadata: 6 | name: prod-gateway 7 | namespace: gateway-api-example-ns1 8 | spec: 9 | gatewayClassName: foo-lb 10 | listeners: 11 | - name: prod-web 12 | port: 80 13 | protocol: HTTP 14 | allowedRoutes: 15 | kinds: 16 | - kind: HTTPRoute 17 | namespaces: 18 | from: Selector 19 | selector: 20 | matchLabels: 21 | expose-apps: "true" 22 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-route-attachment/gateway-strict.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/concepts/api-overview.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: Gateway 5 | metadata: 6 | name: foo-gateway 7 | namespace: gateway-api-example-ns1 8 | spec: 9 | gatewayClassName: foo-lb 10 | listeners: 11 | - name: prod-web 12 | port: 80 13 | protocol: HTTP 14 | allowedRoutes: 15 | kinds: 16 | - kind: HTTPRoute 17 | namespaces: 18 | from: Selector 19 | selector: 20 | matchLabels: 21 | # This label is added automatically as of K8s 1.22 22 | # to all namespaces 23 | kubernetes.io/metadata.name: gateway-api-example-ns2 24 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-route-attachment/httproute.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/concepts/api-overview.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: my-route 7 | namespace: gateway-api-example-ns2 8 | spec: 9 | parentRefs: 10 | - kind: Gateway 11 | name: foo-gateway 12 | namespace: gateway-api-example-ns1 13 | rules: 14 | - backendRefs: 15 | - name: foo-svc 16 | port: 8080 17 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-routing/bar-httproute.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/http-routing.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: bar-route 7 | spec: 8 | parentRefs: 9 | - name: example-gateway 10 | hostnames: 11 | - "bar.example.com" 12 | rules: 13 | - matches: 14 | - headers: 15 | - type: Exact 16 | name: env 17 | value: canary 18 | backendRefs: 19 | - name: bar-svc-canary 20 | port: 8080 21 | - backendRefs: 22 | - name: bar-svc 23 | port: 8080 24 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-routing/foo-httproute.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/http-routing.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: foo-route 7 | spec: 8 | parentRefs: 9 | - name: example-gateway 10 | hostnames: 11 | - "foo.example.com" 12 | rules: 13 | - matches: 14 | - path: 15 | type: PathPrefix 16 | value: /login 17 | backendRefs: 18 | - name: foo-svc 19 | port: 8080 20 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/http-routing/gateway.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/http-routing.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: Gateway 5 | metadata: 6 | name: example-gateway 7 | spec: 8 | gatewayClassName: example-gateway-class 9 | listeners: 10 | - name: http 11 | protocol: HTTP 12 | port: 80 13 | --- 14 | apiVersion: gateway.networking.k8s.io/v1beta1 15 | kind: HTTPRoute 16 | metadata: 17 | name: example-route 18 | spec: 19 | parentRefs: 20 | - name: example-gateway 21 | hostnames: 22 | - "example.com" 23 | rules: 24 | - backendRefs: 25 | - name: example-svc 26 | port: 80 27 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/httproute.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: my-app 5 | spec: 6 | rules: 7 | - matches: 8 | - path: 9 | type: PathPrefix 10 | value: /mypath 11 | backendRefs: 12 | - name: my-service-1 13 | port: 8080 14 | - matches: 15 | - path: 16 | type: PathPrefix 17 | value: /mypath-012 18 | backendRefs: 19 | - name: my-service-2 20 | port: 8080 21 | - matches: 22 | - path: 23 | type: PathPrefix 24 | value: /my%20path/123 25 | backendRefs: 26 | - name: my-service-3 27 | port: 8080 28 | 29 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/multicluster/0-namespaces.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: foo 5 | --- 6 | apiVersion: v1 7 | kind: Namespace 8 | metadata: 9 | name: bar 10 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/multicluster/httproute-gamma.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - geps/gep-1748.md 3 | kind: HTTPRoute 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | metadata: 6 | name: store 7 | spec: 8 | parentRefs: 9 | - group: multicluster.x-k8s.io 10 | kind: ServiceImport 11 | name: store 12 | rules: 13 | - matches: 14 | - path: 15 | value: "/cart" 16 | backendRefs: 17 | - group: multicluster.x-k8s.io 18 | kind: ServiceImport 19 | name: cart 20 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/multicluster/httproute-hybrid.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - geps/gep-1748.md 3 | kind: HTTPRoute 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | metadata: 6 | name: store 7 | spec: 8 | parentRefs: 9 | - name: external-http 10 | rules: 11 | - backendRefs: 12 | - kind: Service 13 | name: store 14 | port: 8080 15 | weight: 90 16 | - group: multicluster.x-k8s.io 17 | kind: ServiceImport 18 | name: store-global 19 | port: 8080 20 | weight: 10 21 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/multicluster/httproute-location.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - geps/gep-1748.md 3 | kind: HTTPRoute 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | metadata: 6 | name: store 7 | spec: 8 | parentRefs: 9 | - name: external-http 10 | rules: 11 | - matches: 12 | - path: 13 | type: PathPrefix 14 | value: /west 15 | backendRefs: 16 | - group: multicluster.x-k8s.io 17 | kind: ServiceImport 18 | name: store-west 19 | port: 8080 20 | - matches: 21 | - path: 22 | type: PathPrefix 23 | value: /east 24 | backendRefs: 25 | - group: multicluster.x-k8s.io 26 | kind: ServiceImport 27 | name: store-east 28 | port: 8080 29 | - backendRefs: 30 | - group: multicluster.x-k8s.io 31 | kind: ServiceImport 32 | name: store 33 | port: 8080 34 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/multicluster/httproute-method.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - geps/gep-1748.md 3 | kind: HTTPRoute 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | metadata: 6 | name: api 7 | spec: 8 | parentRefs: 9 | - name: api-gw 10 | rules: 11 | - matches: 12 | - method: POST 13 | - method: PUT 14 | - method: DELETE 15 | backendRefs: 16 | - group: multicluster.x-k8s.io 17 | kind: ServiceImport 18 | name: api-primary 19 | port: 8080 20 | - backendRefs: 21 | - group: multicluster.x-k8s.io 22 | kind: ServiceImport 23 | name: api-replicas 24 | port: 8080 25 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/multicluster/httproute-referencegrant.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - geps/gep-1748.md 3 | kind: HTTPRoute 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | metadata: 6 | name: foo 7 | namespace: foo 8 | spec: 9 | rules: 10 | - matches: 11 | - path: 12 | type: PathPrefix 13 | value: /bar 14 | backendRefs: 15 | - group: multicluster.x-k8s.io 16 | kind: ServiceImport 17 | name: bar 18 | namespace: bar 19 | --- 20 | kind: ReferenceGrant 21 | apiVersion: gateway.networking.k8s.io/v1beta1 22 | metadata: 23 | name: bar 24 | namespace: bar 25 | spec: 26 | from: 27 | - group: gateway.networking.k8s.io 28 | kind: HTTPRoute 29 | namespace: foo 30 | to: 31 | - group: multicluster.x-k8s.io 32 | kind: ServiceImport 33 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/multicluster/httproute-simple.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - geps/gep-1748.md 3 | kind: HTTPRoute 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | metadata: 6 | name: store 7 | spec: 8 | parentRefs: 9 | - name: external-http 10 | rules: 11 | - backendRefs: 12 | - group: multicluster.x-k8s.io 13 | kind: ServiceImport 14 | name: store 15 | port: 8080 16 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/reference-grant.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/concepts/security-model.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: ReferenceGrant 5 | metadata: 6 | name: allow-prod-traffic 7 | spec: 8 | from: 9 | - group: gateway.networking.k8s.io 10 | kind: HTTPRoute 11 | namespace: prod 12 | to: 13 | - group: "" 14 | kind: Service 15 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/simple-gateway/gateway.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/traffic-splitting.md 3 | #$ - site-src/guides/simple-gateway.md 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | kind: Gateway 6 | metadata: 7 | name: prod-web 8 | spec: 9 | gatewayClassName: acme-lb 10 | listeners: 11 | - protocol: HTTP 12 | port: 80 13 | name: prod-web-gw 14 | allowedRoutes: 15 | namespaces: 16 | from: Same 17 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/simple-gateway/httproute.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/simple-gateway.md 3 | #$ - site-src/blog/2021/introducing-v1beta1.md 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | kind: HTTPRoute 6 | metadata: 7 | name: foo 8 | spec: 9 | parentRefs: 10 | - name: prod-web 11 | rules: 12 | - backendRefs: 13 | - name: foo-svc 14 | port: 8080 15 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/simple-http-https/bar-route.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: bar 5 | spec: 6 | parentRefs: 7 | - name: example-gateway 8 | sectionName: https 9 | hostnames: 10 | - bar.example.com 11 | rules: 12 | - matches: 13 | - path: 14 | type: PathPrefix 15 | value: / 16 | backendRefs: 17 | - name: bar-app 18 | port: 80 19 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/simple-http-https/foo-route.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: foo 5 | spec: 6 | parentRefs: 7 | - name: example-gateway 8 | sectionName: https 9 | hostnames: 10 | - foo.example.com 11 | rules: 12 | - matches: 13 | - path: 14 | type: PathPrefix 15 | value: / 16 | backendRefs: 17 | - name: foo-app 18 | port: 80 19 | - matches: 20 | - path: 21 | type: PathPrefix 22 | value: /orders 23 | backendRefs: 24 | - name: foo-orders-app 25 | port: 80 26 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/simple-http-https/gateway.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: example-gateway 5 | spec: 6 | gatewayClassName: prod 7 | listeners: 8 | - name: http 9 | port: 80 10 | protocol: HTTP 11 | hostname: "*.example.com" 12 | - name: https 13 | port: 443 14 | protocol: HTTPS 15 | hostname: "*.example.com" 16 | tls: 17 | mode: Terminate 18 | certificateRefs: 19 | - kind: Secret 20 | name: example-com 21 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/simple-http-https/tls-redirect-route.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: tls-redirect 5 | spec: 6 | parentRefs: 7 | - name: example-gateway 8 | sectionName: http 9 | hostnames: 10 | - foo.example.com 11 | - bar.example.com 12 | rules: 13 | - filters: 14 | - type: RequestRedirect 15 | requestRedirect: 16 | scheme: https 17 | port: 443 18 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/tls-basic.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/tls.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: Gateway 5 | metadata: 6 | name: tls-basic 7 | spec: 8 | gatewayClassName: acme-lb 9 | listeners: 10 | - name: foo-https 11 | protocol: HTTPS 12 | port: 443 13 | hostname: foo.example.com 14 | tls: 15 | certificateRefs: 16 | - kind: Secret 17 | group: "" 18 | name: foo-example-com-cert 19 | - name: bar-https 20 | protocol: HTTPS 21 | port: 443 22 | hostname: bar.example.com 23 | tls: 24 | certificateRefs: 25 | - kind: Secret 26 | group: "" 27 | name: bar-example-com-cert 28 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/tls-cert-cross-namespace.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/v1alpha2/guides/tls.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: Gateway 5 | metadata: 6 | name: cross-namespace-tls-gateway 7 | namespace: gateway-api-example-ns1 8 | spec: 9 | gatewayClassName: acme-lb 10 | listeners: 11 | - name: https 12 | protocol: HTTPS 13 | port: 443 14 | hostname: "*.example.com" 15 | tls: 16 | certificateRefs: 17 | - kind: Secret 18 | group: "" 19 | name: wildcard-example-com-cert 20 | namespace: gateway-api-example-ns2 21 | --- 22 | apiVersion: gateway.networking.k8s.io/v1beta1 23 | kind: ReferenceGrant 24 | metadata: 25 | name: allow-ns1-gateways-to-ref-secrets 26 | namespace: gateway-api-example-ns2 27 | spec: 28 | from: 29 | - group: gateway.networking.k8s.io 30 | kind: Gateway 31 | namespace: gateway-api-example-ns1 32 | to: 33 | - group: "" 34 | kind: Secret 35 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/traffic-splitting/simple-split.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/traffic-splitting.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: simple-split 7 | spec: 8 | rules: 9 | - backendRefs: 10 | - name: foo-v1 11 | port: 8080 12 | weight: 90 13 | - name: foo-v2 14 | port: 8080 15 | weight: 10 16 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/traffic-splitting/traffic-split-1.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/traffic-splitting.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: foo-route 7 | labels: 8 | gateway: prod-web-gw 9 | spec: 10 | hostnames: 11 | - foo.example.com 12 | rules: 13 | - backendRefs: 14 | - name: foo-v1 15 | port: 8080 16 | - matches: 17 | - headers: 18 | - name: traffic 19 | value: test 20 | backendRefs: 21 | - name: foo-v2 22 | port: 8080 23 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/traffic-splitting/traffic-split-2.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/traffic-splitting.md 3 | #$ - site-src/api-types/httproute.md 4 | apiVersion: gateway.networking.k8s.io/v1beta1 5 | kind: HTTPRoute 6 | metadata: 7 | name: foo-route 8 | labels: 9 | gateway: prod-web-gw 10 | spec: 11 | hostnames: 12 | - foo.example.com 13 | rules: 14 | - backendRefs: 15 | - name: foo-v1 16 | port: 8080 17 | weight: 90 18 | - name: foo-v2 19 | port: 8080 20 | weight: 10 21 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/traffic-splitting/traffic-split-3.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/traffic-splitting.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: HTTPRoute 5 | metadata: 6 | name: foo-route 7 | labels: 8 | gateway: prod-web-gw 9 | spec: 10 | hostnames: 11 | - foo.example.com 12 | rules: 13 | - backendRefs: 14 | - name: foo-v1 15 | port: 8080 16 | weight: 0 17 | - name: foo-v2 18 | port: 8080 19 | weight: 1 20 | -------------------------------------------------------------------------------- /test/integration/ratcheting_test_cases/valid/wildcard-tls-gateway.yaml: -------------------------------------------------------------------------------- 1 | #$ Used in: 2 | #$ - site-src/guides/tls.md 3 | apiVersion: gateway.networking.k8s.io/v1beta1 4 | kind: Gateway 5 | metadata: 6 | name: wildcard-tls-gateway 7 | spec: 8 | gatewayClassName: acme-lb 9 | listeners: 10 | - name: foo-https 11 | protocol: HTTPS 12 | port: 443 13 | hostname: foo.example.com 14 | tls: 15 | certificateRefs: 16 | - kind: Secret 17 | group: "" 18 | name: foo-example-com-cert 19 | - name: wildcard-https 20 | protocol: HTTPS 21 | port: 443 22 | hostname: "*.example.com" 23 | tls: 24 | certificateRefs: 25 | - kind: Secret 26 | group: "" 27 | name: wildcard-example-com-cert 28 | --------------------------------------------------------------------------------