├── .github └── PULL_REQUEST_TEMPLATE.md ├── CONTRIBUTING.md ├── LICENSE ├── OWNERS ├── README.md ├── SECURITY_CONTACTS ├── artifacts ├── example │ ├── apiservice.yaml │ ├── auth-delegator.yaml │ ├── auth-reader.yaml │ ├── deployment.yaml │ ├── ns.yaml │ ├── rbac-bind.yaml │ ├── rbac.yaml │ ├── sa.yaml │ └── service.yaml ├── flunders │ └── 01-flunder.yaml └── simple-image │ └── Dockerfile ├── code-of-conduct.md ├── docs └── minikube-walkthrough.md ├── go.mod ├── go.sum ├── hack ├── boilerplate.go.txt ├── build-image.sh ├── custom-boilerplate.go.txt ├── godep-deps.sh ├── sync-from-kubernetes.sh ├── tools.go ├── update-codegen.sh └── verify-codegen.sh ├── main.go └── pkg ├── admission ├── plugin │ └── banflunder │ │ ├── admission.go │ │ └── admission_test.go └── wardleinitializer │ ├── interfaces.go │ ├── wardleinitializer.go │ └── wardleinitializer_test.go ├── apis └── wardle │ ├── doc.go │ ├── fuzzer │ └── fuzzer.go │ ├── install │ ├── install.go │ └── roundtrip_test.go │ ├── register.go │ ├── types.go │ ├── v1alpha1 │ ├── conversion.go │ ├── defaults.go │ ├── doc.go │ ├── register.go │ ├── types.go │ ├── zz_generated.conversion.go │ ├── zz_generated.deepcopy.go │ ├── zz_generated.defaults.go │ └── zz_generated.prerelease-lifecycle.go │ ├── v1beta1 │ ├── doc.go │ ├── register.go │ ├── types.go │ ├── zz_generated.conversion.go │ ├── zz_generated.deepcopy.go │ └── zz_generated.defaults.go │ ├── validation │ └── validation.go │ └── zz_generated.deepcopy.go ├── apiserver ├── apiserver.go └── scheme_test.go ├── cmd └── server │ ├── start.go │ └── start_test.go ├── generated ├── applyconfiguration │ ├── internal │ │ └── internal.go │ ├── utils.go │ └── wardle │ │ ├── v1alpha1 │ │ ├── fischer.go │ │ ├── flunder.go │ │ └── flunderspec.go │ │ └── v1beta1 │ │ ├── flunder.go │ │ └── flunderspec.go ├── clientset │ └── versioned │ │ ├── clientset.go │ │ ├── fake │ │ ├── clientset_generated.go │ │ ├── doc.go │ │ └── register.go │ │ ├── scheme │ │ ├── doc.go │ │ └── register.go │ │ └── typed │ │ └── wardle │ │ ├── v1alpha1 │ │ ├── doc.go │ │ ├── fake │ │ │ ├── doc.go │ │ │ ├── fake_fischer.go │ │ │ ├── fake_flunder.go │ │ │ └── fake_wardle_client.go │ │ ├── fischer.go │ │ ├── flunder.go │ │ ├── generated_expansion.go │ │ └── wardle_client.go │ │ └── v1beta1 │ │ ├── doc.go │ │ ├── fake │ │ ├── doc.go │ │ ├── fake_flunder.go │ │ └── fake_wardle_client.go │ │ ├── flunder.go │ │ ├── generated_expansion.go │ │ └── wardle_client.go ├── informers │ └── externalversions │ │ ├── factory.go │ │ ├── generic.go │ │ ├── internalinterfaces │ │ └── factory_interfaces.go │ │ └── wardle │ │ ├── interface.go │ │ ├── v1alpha1 │ │ ├── fischer.go │ │ ├── flunder.go │ │ └── interface.go │ │ └── v1beta1 │ │ ├── flunder.go │ │ └── interface.go ├── listers │ └── wardle │ │ ├── v1alpha1 │ │ ├── expansion_generated.go │ │ ├── fischer.go │ │ └── flunder.go │ │ └── v1beta1 │ │ ├── expansion_generated.go │ │ └── flunder.go └── openapi │ └── zz_generated.openapi.go └── registry ├── registry.go └── wardle ├── fischer ├── etcd.go └── strategy.go └── flunder ├── etcd.go └── strategy.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/sample-apiserver](https://git.k8s.io/kubernetes/staging/src/k8s.io/sample-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 | - smarterclayton 5 | - deads2k 6 | - sttts 7 | - liggitt 8 | - jpbetz 9 | reviewers: 10 | - smarterclayton 11 | - deads2k 12 | - sttts 13 | - liggitt 14 | - cheftako 15 | - jpbetz 16 | labels: 17 | - sig/api-machinery 18 | emeritus_approvers: 19 | - lavalamp 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sample-apiserver 2 | 3 | Demonstration of how to use the k8s.io/apiserver library to build a functional API server. 4 | 5 | **Note:** go-get or vendor this package as `k8s.io/sample-apiserver`. 6 | 7 | ## Purpose 8 | 9 | You may use this code if you want to build an Extension API Server to use with API Aggregation, or to build a stand-alone Kubernetes-style API server. 10 | 11 | However, consider two other options: 12 | * **CRDs**: if you just want to add a resource to your kubernetes cluster, then consider using Custom Resource Definition a.k.a CRDs. They require less coding and rebasing. Read about the differences between Custom Resource Definitions vs Extension API Servers [here](https://kubernetes.io/docs/concepts/api-extension/custom-resources). 13 | * **Apiserver-builder**: If you want to build an Extension API server, consider using [apiserver-builder](https://github.com/kubernetes-incubator/apiserver-builder) instead of this repo. The Apiserver-builder is a complete framework for generating the apiserver, client libraries, and the installation program. 14 | 15 | If you do decide to use this repository, then the recommended pattern is to fork this repository, modify it to add your types, and then periodically rebase your changes on top of this repo, to pick up improvements and bug fixes to the apiserver. 16 | 17 | 18 | ## Compatibility 19 | 20 | HEAD of this repo will match HEAD of k8s.io/apiserver, k8s.io/apimachinery, and k8s.io/client-go. 21 | 22 | ## Where does it come from? 23 | 24 | `sample-apiserver` is synced from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/sample-apiserver. 25 | Code changes are made in that location, merged into `k8s.io/kubernetes` and later synced here. 26 | 27 | ## Fetch sample-apiserver and its dependencies 28 | 29 | Issue the following commands --- starting in whatever working directory you 30 | like. 31 | 32 | ```sh 33 | git clone https://github.com/kubernetes/sample-apiserver 34 | cd sample-apiserver 35 | ``` 36 | 37 | ### When using Go modules 38 | 39 | Note, however, that if you intend to 40 | [generate code](#changes-to-the-types) then you will also need the 41 | code-generator repo to exist in an old-style location. One easy way 42 | to do this is to use the command `go mod vendor` to create and 43 | populate the `vendor` directory. 44 | 45 | ### A Note on kubernetes/kubernetes 46 | 47 | If you are developing Kubernetes according to 48 | https://github.com/kubernetes/community/blob/master/contributors/guide/github-workflow.md 49 | then you already have a copy of this demo in 50 | `kubernetes/staging/src/k8s.io/sample-apiserver` and its dependencies 51 | --- including the code generator --- are in usable locations. 52 | 53 | 54 | ## Normal Build and Deploy 55 | 56 | ### Changes to the Types 57 | 58 | If you change the API object type definitions in any of the 59 | `pkg/apis/.../types.go` files then you will need to update the files 60 | generated from the type definitions. To do this, first 61 | [create the vendor directory if necessary](#when-using-go-modules) 62 | and then invoke `hack/update-codegen.sh` with `sample-apiserver` as 63 | your current working directory; the script takes no arguments. 64 | 65 | ### Authentication plugins 66 | 67 | The normal build supports only a very spare selection of 68 | authentication methods. There is a much larger set available in 69 | https://github.com/kubernetes/client-go/tree/master/plugin/pkg/client/auth 70 | . If you want your server to support one of those, such as `oidc`, 71 | then add an import of the appropriate package to 72 | `sample-apiserver/main.go`. Here is an example: 73 | 74 | ``` go 75 | import _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" 76 | ``` 77 | 78 | Alternatively you could add support for all of them, with an import 79 | like this: 80 | 81 | ``` go 82 | import _ "k8s.io/client-go/plugin/pkg/client/auth" 83 | ``` 84 | 85 | ### Build the Binary 86 | 87 | With `sample-apiserver` as your current working directory, issue the 88 | following command: 89 | 90 | ``` 91 | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o artifacts/simple-image/kube-sample-apiserver 92 | ``` 93 | 94 | ### Build the Container Image 95 | 96 | With `sample-apiserver` as your current working directory, issue the 97 | following commands with `MYPREFIX` and `MYTAG` replaced by something 98 | suitable. 99 | 100 | ``` 101 | docker build -t MYPREFIX/kube-sample-apiserver:MYTAG ./artifacts/simple-image 102 | docker push MYPREFIX/kube-sample-apiserver:MYTAG 103 | ``` 104 | 105 | ### Deploy into a Kubernetes Cluster 106 | 107 | Edit `artifacts/example/deployment.yaml`, updating the pod template's image 108 | reference to match what you pushed and setting the `imagePullPolicy` 109 | to something suitable. Then call: 110 | 111 | ``` 112 | kubectl apply -f artifacts/example 113 | ``` 114 | 115 | ## Running it stand-alone 116 | 117 | During development it is helpful to run sample-apiserver stand-alone, i.e. without 118 | a Kubernetes API server for authn/authz and without aggregation. This is possible, but needs 119 | a couple of flags, keys and certs as described below. You will still need some kubeconfig, 120 | e.g. `~/.kube/config`, but the Kubernetes cluster is not used for authn/z. A minikube or 121 | hack/local-up-cluster.sh cluster will work. 122 | 123 | Instead of trusting the aggregator inside kube-apiserver, the described setup uses local 124 | client certificate based X.509 authentication and authorization. This means that the client 125 | certificate is trusted by a CA and the passed certificate contains the group membership 126 | to the `system:masters` group. As we disable delegated authorization with `--authorization-skip-lookup`, 127 | only this superuser group is authorized. 128 | 129 | 1. First we need a CA to later sign the client certificate: 130 | 131 | ``` shell 132 | openssl req -nodes -new -x509 -keyout ca.key -out ca.crt 133 | ``` 134 | 135 | 2. Then we create a client cert signed by this CA for the user `development` in the superuser group 136 | `system:masters`: 137 | 138 | ``` shell 139 | openssl req -out client.csr -new -newkey rsa:4096 -nodes -keyout client.key -subj "/CN=development/O=system:masters" 140 | openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -sha256 -out client.crt 141 | ``` 142 | 143 | 3. As curl requires client certificates in p12 format with password, do the conversion: 144 | 145 | ``` shell 146 | openssl pkcs12 -export -in ./client.crt -inkey ./client.key -out client.p12 -passout pass:password 147 | ``` 148 | 149 | 4. With these keys and certs in-place, we start the server: 150 | 151 | ``` shell 152 | etcd & 153 | sample-apiserver --secure-port 8443 --etcd-servers http://127.0.0.1:2379 --v=7 \ 154 | --client-ca-file ca.crt \ 155 | --kubeconfig ~/.kube/config \ 156 | --authentication-kubeconfig ~/.kube/config \ 157 | --authorization-kubeconfig ~/.kube/config 158 | ``` 159 | 160 | The first kubeconfig is used for the shared informers to access 161 | Kubernetes resources. The second kubeconfig passed to 162 | `--authentication-kubeconfig` is used to satisfy the delegated 163 | authenticator. The third kubeconfig passed to 164 | `--authorized-kubeconfig` is used to satisfy the delegated 165 | authorizer. Neither the authenticator, nor the authorizer will 166 | actually be used: due to `--client-ca-file`, our development X.509 167 | certificate is accepted and authenticates us as `system:masters` 168 | member. `system:masters` is the superuser group such that delegated 169 | authorization is skipped. 170 | 171 | 5. Use curl to access the server using the client certificate in p12 format for authentication: 172 | 173 | ``` shell 174 | curl -fv -k --cert-type P12 --cert client.p12:password \ 175 | https://localhost:8443/apis/wardle.example.com/v1alpha1/namespaces/default/flunders 176 | ``` 177 | 178 | Or use wget: 179 | ``` shell 180 | wget -O- --no-check-certificate \ 181 | --certificate client.crt --private-key client.key \ 182 | https://localhost:8443/apis/wardle.example.com/v1alpha1/namespaces/default/flunders 183 | ``` 184 | 185 | Note: Recent OSX versions broke client certs with curl. On Mac try `brew install httpie` and then: 186 | 187 | ``` shell 188 | http --verify=no --cert client.crt --cert-key client.key \ 189 | https://localhost:8443/apis/wardle.example.com/v1alpha1/namespaces/default/flunders 190 | ``` 191 | 192 | -------------------------------------------------------------------------------- /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/example/apiservice.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiregistration.k8s.io/v1 2 | kind: APIService 3 | metadata: 4 | name: v1alpha1.wardle.example.com 5 | spec: 6 | insecureSkipTLSVerify: true 7 | group: wardle.example.com 8 | groupPriorityMinimum: 1000 9 | versionPriority: 15 10 | service: 11 | name: api 12 | namespace: wardle 13 | version: v1alpha1 14 | -------------------------------------------------------------------------------- /artifacts/example/auth-delegator.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: wardle:system:auth-delegator 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: system:auth-delegator 9 | subjects: 10 | - kind: ServiceAccount 11 | name: apiserver 12 | namespace: wardle 13 | -------------------------------------------------------------------------------- /artifacts/example/auth-reader.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | name: wardle-auth-reader 5 | namespace: kube-system 6 | roleRef: 7 | apiGroup: rbac.authorization.k8s.io 8 | kind: Role 9 | name: extension-apiserver-authentication-reader 10 | subjects: 11 | - kind: ServiceAccount 12 | name: apiserver 13 | namespace: wardle 14 | -------------------------------------------------------------------------------- /artifacts/example/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: wardle-server 5 | namespace: wardle 6 | labels: 7 | apiserver: "true" 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | apiserver: "true" 13 | template: 14 | metadata: 15 | labels: 16 | apiserver: "true" 17 | spec: 18 | serviceAccountName: apiserver 19 | containers: 20 | - name: wardle-server 21 | # build from staging/src/k8s.io/sample-apiserver/artifacts/simple-image/Dockerfile 22 | # or 23 | # docker pull registry.k8s.io/e2e-test-images/sample-apiserver:1.17.4 24 | # docker tag registry.k8s.io/e2e-test-images/sample-apiserver:1.17.4 kube-sample-apiserver:latest 25 | image: kube-sample-apiserver:latest 26 | imagePullPolicy: Never 27 | args: [ "--etcd-servers=http://localhost:2379" ] 28 | - name: etcd 29 | image: gcr.io/etcd-development/etcd:v3.6.0 30 | -------------------------------------------------------------------------------- /artifacts/example/ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: wardle 5 | -------------------------------------------------------------------------------- /artifacts/example/rbac-bind.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: sample-apiserver-clusterrolebinding 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: aggregated-apiserver-clusterrole 9 | subjects: 10 | - kind: ServiceAccount 11 | name: apiserver 12 | namespace: wardle -------------------------------------------------------------------------------- /artifacts/example/rbac.yaml: -------------------------------------------------------------------------------- 1 | kind: ClusterRole 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | metadata: 4 | name: aggregated-apiserver-clusterrole 5 | rules: 6 | - apiGroups: [""] 7 | resources: ["namespaces"] 8 | verbs: ["get", "watch", "list"] 9 | - apiGroups: ["admissionregistration.k8s.io"] 10 | resources: ["mutatingwebhookconfigurations", "validatingwebhookconfigurations", "validatingadmissionpolicies", "validatingadmissionpolicybindings"] 11 | verbs: ["get", "watch", "list"] 12 | - apiGroups: ["flowcontrol.apiserver.k8s.io"] 13 | resources: ['prioritylevelconfigurations', 'flowschemas'] 14 | verbs: ['list', 'watch'] -------------------------------------------------------------------------------- /artifacts/example/sa.yaml: -------------------------------------------------------------------------------- 1 | kind: ServiceAccount 2 | apiVersion: v1 3 | metadata: 4 | name: apiserver 5 | namespace: wardle 6 | -------------------------------------------------------------------------------- /artifacts/example/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: api 5 | namespace: wardle 6 | spec: 7 | ports: 8 | - port: 443 9 | protocol: TCP 10 | targetPort: 443 11 | selector: 12 | apiserver: "true" 13 | -------------------------------------------------------------------------------- /artifacts/flunders/01-flunder.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: wardle.example.com/v1alpha1 2 | kind: Flunder 3 | metadata: 4 | name: my-first-flunder 5 | labels: 6 | sample-label: "true" 7 | -------------------------------------------------------------------------------- /artifacts/simple-image/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 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 fedora 16 | ADD kube-sample-apiserver / 17 | ENTRYPOINT ["/kube-sample-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 | -------------------------------------------------------------------------------- /docs/minikube-walkthrough.md: -------------------------------------------------------------------------------- 1 | # Minikube walkthrough 2 | 3 | This document will take you through setting up and trying the sample apiserver on a local minikube from a fresh clone of this repo. 4 | 5 | ## Pre requisites 6 | 7 | - Go 1.7.x or later installed and setup. More information can be found at [go installation](https://go.dev/doc/install) 8 | - Dockerhub account to push the image to [Dockerhub](https://hub.docker.com/) 9 | 10 | ## Install Minikube 11 | 12 | Minikube is a single node Kubernetes cluster that runs on your local machine. The Minikube docs have installation instructions for your OS. 13 | - [minikube installation](https://github.com/kubernetes/minikube#installation) 14 | 15 | 16 | ## Clone the repository 17 | 18 | In order to build the sample apiserver image we will need to build the apiserver binary. 19 | 20 | ``` 21 | cd $GOPATH/src 22 | mkdir -p k8s.io 23 | cd k8s.io 24 | git clone https://github.com/kubernetes/sample-apiserver.git 25 | ``` 26 | 27 | ## Build the binary 28 | 29 | Next we will want to create a new binary to both test we can build the server and to use for the container image. 30 | 31 | From the root of this repo, where ```main.go``` is located, run the following command: 32 | ``` 33 | export GOOS=linux; go build . 34 | ``` 35 | if everything went well, you should have a binary called ```sample-apiserver``` present in your current directory. 36 | 37 | ## Build the container image 38 | 39 | Using the binary we just built, we will now create a Docker image and push it to our Dockerhub registry so that we deploy it to our cluster. 40 | There is a sample ```Dockerfile``` located in ```artifacts/simple-image``` we will use this to build our own image. 41 | 42 | Again from the root of this repo run the following commands: 43 | ``` 44 | cp ./sample-apiserver ./artifacts/simple-image/kube-sample-apiserver 45 | docker build -t /kube-sample-apiserver:latest ./artifacts/simple-image 46 | docker push /kube-sample-apiserver 47 | ``` 48 | 49 | ## Modify the replication controller 50 | 51 | You need to modify the [artifacts/example/deployment.yaml](/artifacts/example/deployment.yaml) file to change the ```imagePullPolicy``` to ```Always``` or ```IfNotPresent```. 52 | 53 | You also need to change the image from ```kube-sample-apiserver:latest``` to ```/kube-sample-apiserver:latest```. For example: 54 | 55 | ```yaml 56 | ... 57 | containers: 58 | - name: wardle-server 59 | image: /kube-sample-apiserver:latest 60 | imagePullPolicy: Always 61 | ... 62 | ``` 63 | 64 | Save this file and we are then ready to deploy and try out the sample apiserver. 65 | 66 | ## Deploy to Minikube 67 | 68 | We will need to create several objects in order to setup the sample apiserver so you will need to ensure you have the ```kubectl``` tool installed. [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/). 69 | 70 | ``` 71 | # create the namespace to run the apiserver in 72 | kubectl create ns wardle 73 | 74 | # create the service account used to run the server 75 | kubectl create -f artifacts/example/sa.yaml -n wardle 76 | 77 | # create the rolebindings that allow the service account user to delegate authz back to the kubernetes master for incoming requests to the apiserver 78 | kubectl create -f artifacts/example/auth-delegator.yaml -n kube-system 79 | kubectl create -f artifacts/example/auth-reader.yaml -n kube-system 80 | 81 | # create rbac roles and clusterrolebinding that allow the service account user to use admission webhooks 82 | kubectl create -f artifacts/example/rbac.yaml 83 | kubectl create -f artifacts/example/rbac-bind.yaml 84 | 85 | # create the service and replication controller 86 | kubectl create -f artifacts/example/deployment.yaml -n wardle 87 | kubectl create -f artifacts/example/service.yaml -n wardle 88 | 89 | # create the apiservice object that tells kubernetes about your api extension and where in the cluster the server is located 90 | kubectl create -f artifacts/example/apiservice.yaml 91 | ``` 92 | 93 | ## Test that your setup has worked 94 | 95 | You should now be able to create the resource type ```Flunder``` which is the resource type registered by the sample apiserver. 96 | 97 | ``` 98 | kubectl create -f artifacts/flunders/01-flunder.yaml 99 | # outputs flunder "my-first-flunder" created 100 | ``` 101 | 102 | You can then get this resource by running: 103 | 104 | ``` 105 | kubectl get flunder my-first-flunder 106 | 107 | #outputs 108 | # NAME KIND 109 | # my-first-flunder Flunder.v1alpha1.wardle.example.com 110 | ``` 111 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | // This is a generated file. Do not edit directly. 2 | 3 | module k8s.io/sample-apiserver 4 | 5 | go 1.24.0 6 | 7 | godebug default=go1.24 8 | 9 | require ( 10 | github.com/spf13/cobra v1.8.1 11 | github.com/stretchr/testify v1.10.0 12 | k8s.io/apimachinery v0.0.0-20250527161416-09ff13941cda 13 | k8s.io/apiserver v0.0.0-20250527175757-73e127faf5f0 14 | k8s.io/client-go v0.0.0-20250526134158-e75871c73119 15 | k8s.io/code-generator v0.0.0-20250527174520-6a7575e38836 16 | k8s.io/component-base v0.0.0-20250527174749-7c0fc2b55ca1 17 | k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff 18 | k8s.io/utils v0.0.0-20250502105355-0f33e8f1c979 19 | sigs.k8s.io/randfill v1.0.0 20 | sigs.k8s.io/structured-merge-diff/v4 v4.7.0 21 | ) 22 | 23 | require ( 24 | cel.dev/expr v0.23.1 // indirect 25 | github.com/NYTimes/gziphandler v1.1.1 // indirect 26 | github.com/antlr4-go/antlr/v4 v4.13.0 // indirect 27 | github.com/beorn7/perks v1.0.1 // indirect 28 | github.com/blang/semver/v4 v4.0.0 // indirect 29 | github.com/cenkalti/backoff/v4 v4.3.0 // indirect 30 | github.com/cespare/xxhash/v2 v2.3.0 // indirect 31 | github.com/coreos/go-semver v0.3.1 // indirect 32 | github.com/coreos/go-systemd/v22 v22.5.0 // indirect 33 | github.com/davecgh/go-spew v1.1.1 // indirect 34 | github.com/emicklei/go-restful/v3 v3.11.0 // indirect 35 | github.com/felixge/httpsnoop v1.0.4 // indirect 36 | github.com/fsnotify/fsnotify v1.9.0 // indirect 37 | github.com/fxamacker/cbor/v2 v2.8.0 // indirect 38 | github.com/go-logr/logr v1.4.2 // indirect 39 | github.com/go-logr/stdr v1.2.2 // indirect 40 | github.com/go-openapi/jsonpointer v0.21.0 // indirect 41 | github.com/go-openapi/jsonreference v0.20.2 // indirect 42 | github.com/go-openapi/swag v0.23.0 // indirect 43 | github.com/gogo/protobuf v1.3.2 // indirect 44 | github.com/golang/protobuf v1.5.4 // indirect 45 | github.com/google/btree v1.1.3 // indirect 46 | github.com/google/cel-go v0.25.0 // indirect 47 | github.com/google/gnostic-models v0.6.9 // indirect 48 | github.com/google/go-cmp v0.7.0 // indirect 49 | github.com/google/uuid v1.6.0 // indirect 50 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect 51 | github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect 52 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 53 | github.com/josharian/intern v1.0.0 // indirect 54 | github.com/json-iterator/go v1.1.12 // indirect 55 | github.com/kylelemons/godebug v1.1.0 // indirect 56 | github.com/mailru/easyjson v0.7.7 // indirect 57 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 58 | github.com/modern-go/reflect2 v1.0.2 // indirect 59 | github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect 60 | github.com/pkg/errors v0.9.1 // indirect 61 | github.com/pmezard/go-difflib v1.0.0 // indirect 62 | github.com/prometheus/client_golang v1.22.0 // indirect 63 | github.com/prometheus/client_model v0.6.1 // indirect 64 | github.com/prometheus/common v0.62.0 // indirect 65 | github.com/prometheus/procfs v0.15.1 // indirect 66 | github.com/spf13/pflag v1.0.6 // indirect 67 | github.com/stoewer/go-strcase v1.3.0 // indirect 68 | github.com/x448/float16 v0.8.4 // indirect 69 | go.etcd.io/etcd/api/v3 v3.6.0 // indirect 70 | go.etcd.io/etcd/client/pkg/v3 v3.6.0 // indirect 71 | go.etcd.io/etcd/client/v3 v3.6.0 // indirect 72 | go.opentelemetry.io/auto/sdk v1.1.0 // indirect 73 | go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 // indirect 74 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect 75 | go.opentelemetry.io/otel v1.35.0 // indirect 76 | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect 77 | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 // indirect 78 | go.opentelemetry.io/otel/metric v1.35.0 // indirect 79 | go.opentelemetry.io/otel/sdk v1.34.0 // indirect 80 | go.opentelemetry.io/otel/trace v1.35.0 // indirect 81 | go.opentelemetry.io/proto/otlp v1.5.0 // indirect 82 | go.uber.org/multierr v1.11.0 // indirect 83 | go.uber.org/zap v1.27.0 // indirect 84 | golang.org/x/crypto v0.36.0 // indirect 85 | golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect 86 | golang.org/x/mod v0.21.0 // indirect 87 | golang.org/x/net v0.38.0 // indirect 88 | golang.org/x/oauth2 v0.27.0 // indirect 89 | golang.org/x/sync v0.12.0 // indirect 90 | golang.org/x/sys v0.31.0 // indirect 91 | golang.org/x/term v0.30.0 // indirect 92 | golang.org/x/text v0.23.0 // indirect 93 | golang.org/x/time v0.9.0 // indirect 94 | golang.org/x/tools v0.26.0 // indirect 95 | google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect 96 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect 97 | google.golang.org/grpc v1.72.1 // indirect 98 | google.golang.org/protobuf v1.36.5 // indirect 99 | gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect 100 | gopkg.in/inf.v0 v0.9.1 // indirect 101 | gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect 102 | gopkg.in/yaml.v3 v3.0.1 // indirect 103 | k8s.io/api v0.0.0-20250527173755-16b0005a085f // indirect 104 | k8s.io/gengo/v2 v2.0.0-20250207200755-1244d31929d7 // indirect 105 | k8s.io/klog/v2 v2.130.1 // indirect 106 | k8s.io/kms v0.0.0-20250527175117-e6cd4d7331a4 // indirect 107 | sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect 108 | sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect 109 | sigs.k8s.io/yaml v1.4.0 // indirect 110 | ) 111 | -------------------------------------------------------------------------------- /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 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 | 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/sample-apiserver/artifacts/simple-image/kube-sample-apiserver" 27 | } 28 | trap cleanup EXIT 29 | 30 | pushd "${KUBE_ROOT}/staging/src/k8s.io/sample-apiserver" 31 | cp -v ../../../../_output/local/bin/linux/amd64/sample-apiserver ./artifacts/simple-image/kube-sample-apiserver 32 | docker build -t kube-sample-apiserver:latest ./artifacts/simple-image 33 | popd 34 | -------------------------------------------------------------------------------- /hack/custom-boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright YEAR The Kubernetes sample-apiserver 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/godep-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/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 | 18 | # overall flow 19 | # 1. make a clean gopath 20 | # 2. get client-go 21 | # 3. flatten client-go's vendored deps 22 | # 4. go get extra deps we need 23 | # 5. remove old vendoring data 24 | # 6. vendor packages we need 25 | # 7. copy new vendored packages and save them 26 | 27 | set -o errexit 28 | set -o nounset 29 | set -o pipefail 30 | 31 | goPath=$(mktemp -d "${TMPDIR:-/tmp/}$(basename 0).XXXXXXXXXXXX") 32 | echo ${goPath} 33 | 34 | export GOPATH=${goPath} 35 | 36 | mkdir -p ${goPath}/src/k8s.io/sample-apiserver 37 | cp -R . ${goPath}/src/k8s.io/sample-apiserver 38 | 39 | pushd ${goPath}/src/k8s.io/sample-apiserver 40 | rm -rf vendor || true 41 | 42 | # restore what we have in our new manifest that we've sync 43 | godep restore 44 | 45 | # the manifest doesn't include any levels of k8s.io dependencies so load them using the go get 46 | # assume you sync all the repos at the same time, the leves you get will be correct 47 | go get -d ./... || true 48 | 49 | # save the new levels of dependencies 50 | rm -rf vendor || true 51 | rm -rf Godeps || true 52 | godep save ./... 53 | popd 54 | 55 | # remove the vendor dir we have and move the one we just made 56 | rm -rf vendor || true 57 | rm -rf Godeps || true 58 | git rm -rf vendor || true 59 | git rm -rf Godeps || true 60 | mv ${goPath}/src/k8s.io/sample-apiserver/vendor . 61 | mv ${goPath}/src/k8s.io/sample-apiserver/Godeps . 62 | git add vendor 63 | git add Godeps 64 | git commit -m "sync: resync vendor folder" 65 | 66 | -------------------------------------------------------------------------------- /hack/sync-from-kubernetes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/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 | 18 | # overall flow 19 | # 1. fetch the current level of k8s.io/kubernetes 20 | # 2. check out the k8s.io/kubernetes HEAD into a separate branch 21 | # 3. rewrite the history on that branch to *only* include staging/src/k8s.io/sample-apiserver 22 | # 4. locate all commits between the last time we sync'ed and now 23 | # 5. switch back to the starting branch 24 | # 6. for each commit, cherry-pick it (which will keep authorship) into current branch 25 | # 7. update metadata files indicating which commits we've sync'ed to 26 | 27 | set -e 28 | 29 | ROOT=$(dirname "${BASH_SOURCE}")/.. 30 | dir=$(mktemp -d "${TMPDIR:-/tmp/}$(basename 0).XXXXXXXXXXXX") 31 | 32 | git remote add upstream-kube git@github.com:kubernetes/kubernetes.git || true 33 | git fetch upstream-kube 34 | 35 | currBranch=$(git rev-parse --abbrev-ref HEAD) 36 | previousKubeSHA=$(cat kubernetes-sha) 37 | previousBranchSHA=$(cat filter-branch-sha) 38 | 39 | git branch -D kube-sync || true 40 | git checkout upstream-kube/master -b kube-sync 41 | git reset --hard upstream-kube/master 42 | newKubeSHA=$(git log --oneline --format='%H' kube-sync -1) 43 | 44 | # this command rewrite git history to *only* include staging/src/k8s.io/sample-apiserver 45 | git filter-branch -f --subdirectory-filter staging/src/k8s.io/sample-apiserver HEAD 46 | 47 | newBranchSHA=$(git log --oneline --format='%H' kube-sync -1) 48 | git log --no-merges --format='%H' --reverse ${previousBranchSHA}..HEAD > ${dir}/commits 49 | 50 | git checkout ${currBranch} 51 | 52 | # we must reset Godeps.json to what it looked like BEFORE the last vendor sync so that any 53 | # new Godep.json changes from k8s.io/kubernetes will apply cleanly. Since its always auto-generated 54 | # it doesn't matter that we're removing it 55 | lastResyncCommit=$(git rev-list -n 1 --grep "sync: resync vendor folder" HEAD) 56 | cleanGodepJsonCommit=$(git rev-list -n 1 ${lastResyncCommit}^) 57 | git checkout ${cleanGodepJsonCommit} Godeps/Godeps.json 58 | git commit -m "sync: reset Godeps.json" -- Godeps/Godeps.json 59 | 60 | while read commitSHA; do 61 | echo "working ${commitSHA}" 62 | git cherry-pick ${commitSHA} 63 | done <${dir}/commits 64 | 65 | # update the vendored godeps 66 | ${ROOT}/hack/godep-deps.sh 67 | 68 | # track the k8s.io/kubernetes commit SHA so we can always determine which level of kube this repo matches 69 | # track the filtered branch commit SHA so that we can determine which commits need to be picked 70 | echo ${newKubeSHA} > kubernetes-sha 71 | echo ${newBranchSHA} > filter-branch-sha 72 | git commit -m "sync(k8s.io/kubernetes): ${newKubeSHA}" -- kubernetes-sha filter-branch-sha 73 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/sample-apiserver" 27 | 28 | kube::codegen::gen_helpers \ 29 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 30 | "${SCRIPT_ROOT}/pkg/apis" 31 | 32 | if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then 33 | report_filename="${API_KNOWN_VIOLATIONS_DIR}/sample_apiserver_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 | --output-dir "${SCRIPT_ROOT}/pkg/generated/openapi" \ 41 | --output-pkg "${THIS_PKG}/pkg/generated/openapi" \ 42 | --report-filename "${report_filename:-"/dev/null"}" \ 43 | ${update_report:+"${update_report}"} \ 44 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 45 | "${SCRIPT_ROOT}/pkg/apis" 46 | 47 | kube::codegen::gen_client \ 48 | --with-watch \ 49 | --with-applyconfig \ 50 | --output-dir "${SCRIPT_ROOT}/pkg/generated" \ 51 | --output-pkg "${THIS_PKG}/pkg/generated" \ 52 | --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ 53 | "${SCRIPT_ROOT}/pkg/apis" 54 | -------------------------------------------------------------------------------- /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 2016 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 | genericapiserver "k8s.io/apiserver/pkg/server" 23 | "k8s.io/component-base/cli" 24 | "k8s.io/sample-apiserver/pkg/cmd/server" 25 | ) 26 | 27 | func main() { 28 | ctx := genericapiserver.SetupSignalContext() 29 | options := server.NewWardleServerOptions(os.Stdout, os.Stderr) 30 | cmd := server.NewCommandStartWardleServer(ctx, options, false) 31 | code := cli.Run(cmd) 32 | os.Exit(code) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/admission/plugin/banflunder/admission.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 banflunder 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "io" 23 | 24 | "k8s.io/apimachinery/pkg/api/errors" 25 | "k8s.io/apimachinery/pkg/api/meta" 26 | "k8s.io/apimachinery/pkg/labels" 27 | "k8s.io/apiserver/pkg/admission" 28 | "k8s.io/sample-apiserver/pkg/admission/wardleinitializer" 29 | "k8s.io/sample-apiserver/pkg/apis/wardle" 30 | informers "k8s.io/sample-apiserver/pkg/generated/informers/externalversions" 31 | listers "k8s.io/sample-apiserver/pkg/generated/listers/wardle/v1alpha1" 32 | ) 33 | 34 | // Register registers a plugin 35 | func Register(plugins *admission.Plugins) { 36 | plugins.Register("BanFlunder", func(config io.Reader) (admission.Interface, error) { 37 | return New() 38 | }) 39 | } 40 | 41 | // DisallowFlunder is a ban flunder admission plugin 42 | type DisallowFlunder struct { 43 | *admission.Handler 44 | lister listers.FischerLister 45 | } 46 | 47 | var _ = wardleinitializer.WantsInternalWardleInformerFactory(&DisallowFlunder{}) 48 | 49 | // Admit ensures that the object in-flight is of kind Flunder. 50 | // In addition checks that the Name is not on the banned list. 51 | // The list is stored in Fischers API objects. 52 | func (d *DisallowFlunder) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error { 53 | // we are only interested in flunders 54 | if a.GetKind().GroupKind() != wardle.Kind("Flunder") { 55 | return nil 56 | } 57 | 58 | if !d.WaitForReady() { 59 | return admission.NewForbidden(a, fmt.Errorf("not yet ready to handle request")) 60 | } 61 | 62 | metaAccessor, err := meta.Accessor(a.GetObject()) 63 | if err != nil { 64 | return err 65 | } 66 | flunderName := metaAccessor.GetName() 67 | 68 | fischers, err := d.lister.List(labels.Everything()) 69 | if err != nil { 70 | return err 71 | } 72 | 73 | for _, fischer := range fischers { 74 | for _, disallowedFlunder := range fischer.DisallowedFlunders { 75 | if flunderName == disallowedFlunder { 76 | return errors.NewForbidden( 77 | a.GetResource().GroupResource(), 78 | a.GetName(), 79 | fmt.Errorf("this name may not be used, please change the resource name"), 80 | ) 81 | } 82 | } 83 | } 84 | return nil 85 | } 86 | 87 | // SetInternalWardleInformerFactory gets Lister from SharedInformerFactory. 88 | // The lister knows how to lists Fischers. 89 | func (d *DisallowFlunder) SetInternalWardleInformerFactory(f informers.SharedInformerFactory) { 90 | d.lister = f.Wardle().V1alpha1().Fischers().Lister() 91 | d.SetReadyFunc(f.Wardle().V1alpha1().Fischers().Informer().HasSynced) 92 | } 93 | 94 | // ValidateInitialization checks whether the plugin was correctly initialized. 95 | func (d *DisallowFlunder) ValidateInitialization() error { 96 | if d.lister == nil { 97 | return fmt.Errorf("missing fischer lister") 98 | } 99 | return nil 100 | } 101 | 102 | // New creates a new ban flunder admission plugin 103 | func New() (*DisallowFlunder, error) { 104 | return &DisallowFlunder{ 105 | Handler: admission.NewHandler(admission.Create), 106 | }, nil 107 | } 108 | -------------------------------------------------------------------------------- /pkg/admission/plugin/banflunder/admission_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 banflunder_test 18 | 19 | import ( 20 | "context" 21 | "testing" 22 | "time" 23 | 24 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | "k8s.io/apimachinery/pkg/runtime" 26 | "k8s.io/apimachinery/pkg/runtime/schema" 27 | "k8s.io/apiserver/pkg/admission" 28 | clienttesting "k8s.io/client-go/testing" 29 | "k8s.io/sample-apiserver/pkg/admission/plugin/banflunder" 30 | "k8s.io/sample-apiserver/pkg/admission/wardleinitializer" 31 | wardle "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 32 | "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/fake" 33 | informers "k8s.io/sample-apiserver/pkg/generated/informers/externalversions" 34 | ) 35 | 36 | // TestBanfluderAdmissionPlugin tests various test cases against 37 | // ban flunder admission plugin 38 | func TestBanflunderAdmissionPlugin(t *testing.T) { 39 | var scenarios = []struct { 40 | informersOutput wardle.FischerList 41 | admissionInput wardle.Flunder 42 | admissionInputKind schema.GroupVersionKind 43 | admissionInputResource schema.GroupVersionResource 44 | admissionMustFail bool 45 | }{ 46 | // scenario 1: 47 | // a flunder with a name that appears on a list of disallowed flunders must be banned 48 | { 49 | informersOutput: wardle.FischerList{ 50 | Items: []wardle.Fischer{ 51 | {DisallowedFlunders: []string{"badname"}}, 52 | }, 53 | }, 54 | admissionInput: wardle.Flunder{ 55 | ObjectMeta: metav1.ObjectMeta{ 56 | Name: "badname", 57 | Namespace: "", 58 | }, 59 | }, 60 | admissionInputKind: wardle.SchemeGroupVersion.WithKind("Flunder").GroupKind().WithVersion("version"), 61 | admissionInputResource: wardle.Resource("flunders").WithVersion("version"), 62 | admissionMustFail: true, 63 | }, 64 | // scenario 2: 65 | // a flunder with a name that does not appear on a list of disallowed flunders must be admitted 66 | { 67 | informersOutput: wardle.FischerList{ 68 | Items: []wardle.Fischer{ 69 | {DisallowedFlunders: []string{"badname"}}, 70 | }, 71 | }, 72 | admissionInput: wardle.Flunder{ 73 | ObjectMeta: metav1.ObjectMeta{ 74 | Name: "goodname", 75 | Namespace: "", 76 | }, 77 | }, 78 | admissionInputKind: wardle.SchemeGroupVersion.WithKind("Flunder").GroupKind().WithVersion("version"), 79 | admissionInputResource: wardle.Resource("flunders").WithVersion("version"), 80 | admissionMustFail: false, 81 | }, 82 | // scenario 3: 83 | // a flunder with a name that appears on a list of disallowed flunders would be banned 84 | // but the kind passed in is not a flunder thus the whole request is accepted 85 | { 86 | informersOutput: wardle.FischerList{ 87 | Items: []wardle.Fischer{ 88 | {DisallowedFlunders: []string{"badname"}}, 89 | }, 90 | }, 91 | admissionInput: wardle.Flunder{ 92 | ObjectMeta: metav1.ObjectMeta{ 93 | Name: "badname", 94 | Namespace: "", 95 | }, 96 | }, 97 | admissionInputKind: wardle.SchemeGroupVersion.WithKind("NotFlunder").GroupKind().WithVersion("version"), 98 | admissionInputResource: wardle.Resource("notflunders").WithVersion("version"), 99 | admissionMustFail: false, 100 | }, 101 | } 102 | 103 | for index, scenario := range scenarios { 104 | func() { 105 | // prepare 106 | cs := &fake.Clientset{} 107 | cs.AddReactor("list", "fischers", func(action clienttesting.Action) (bool, runtime.Object, error) { 108 | return true, &scenario.informersOutput, nil 109 | }) 110 | informersFactory := informers.NewSharedInformerFactory(cs, 5*time.Minute) 111 | 112 | target, err := banflunder.New() 113 | if err != nil { 114 | t.Fatalf("scenario %d: failed to create banflunder admission plugin due to = %v", index, err) 115 | } 116 | 117 | targetInitializer := wardleinitializer.New(informersFactory) 118 | targetInitializer.Initialize(target) 119 | 120 | err = admission.ValidateInitialization(target) 121 | if err != nil { 122 | t.Fatalf("scenario %d: failed to initialize banflunder admission plugin due to =%v", index, err) 123 | } 124 | 125 | stop := make(chan struct{}) 126 | defer close(stop) 127 | informersFactory.Start(stop) 128 | informersFactory.WaitForCacheSync(stop) 129 | 130 | // act 131 | err = target.Admit(context.TODO(), admission.NewAttributesRecord( 132 | &scenario.admissionInput, 133 | nil, 134 | scenario.admissionInputKind, 135 | scenario.admissionInput.ObjectMeta.Namespace, 136 | "", 137 | scenario.admissionInputResource, 138 | "", 139 | admission.Create, 140 | &metav1.CreateOptions{}, 141 | false, 142 | nil), 143 | nil, 144 | ) 145 | 146 | // validate 147 | if scenario.admissionMustFail && err == nil { 148 | t.Errorf("scenario %d: expected an error but got nothing", index) 149 | } 150 | 151 | if !scenario.admissionMustFail && err != nil { 152 | t.Errorf("scenario %d: banflunder admission plugin returned unexpected error = %v", index, err) 153 | } 154 | }() 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /pkg/admission/wardleinitializer/interfaces.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 wardleinitializer 18 | 19 | import ( 20 | "k8s.io/apiserver/pkg/admission" 21 | informers "k8s.io/sample-apiserver/pkg/generated/informers/externalversions" 22 | ) 23 | 24 | // WantsInternalWardleInformerFactory defines a function which sets InformerFactory for admission plugins that need it 25 | type WantsInternalWardleInformerFactory interface { 26 | SetInternalWardleInformerFactory(informers.SharedInformerFactory) 27 | admission.InitializationValidator 28 | } 29 | -------------------------------------------------------------------------------- /pkg/admission/wardleinitializer/wardleinitializer.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 wardleinitializer 18 | 19 | import ( 20 | "k8s.io/apiserver/pkg/admission" 21 | informers "k8s.io/sample-apiserver/pkg/generated/informers/externalversions" 22 | ) 23 | 24 | type pluginInitializer struct { 25 | informers informers.SharedInformerFactory 26 | } 27 | 28 | var _ admission.PluginInitializer = pluginInitializer{} 29 | 30 | // New creates an instance of wardle admission plugins initializer. 31 | func New(informers informers.SharedInformerFactory) pluginInitializer { 32 | return pluginInitializer{ 33 | informers: informers, 34 | } 35 | } 36 | 37 | // Initialize checks the initialization interfaces implemented by a plugin 38 | // and provide the appropriate initialization data 39 | func (i pluginInitializer) Initialize(plugin admission.Interface) { 40 | if wants, ok := plugin.(WantsInternalWardleInformerFactory); ok { 41 | wants.SetInternalWardleInformerFactory(i.informers) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pkg/admission/wardleinitializer/wardleinitializer_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 wardleinitializer_test 18 | 19 | import ( 20 | "context" 21 | "testing" 22 | "time" 23 | 24 | "k8s.io/apiserver/pkg/admission" 25 | "k8s.io/sample-apiserver/pkg/admission/wardleinitializer" 26 | "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/fake" 27 | informers "k8s.io/sample-apiserver/pkg/generated/informers/externalversions" 28 | ) 29 | 30 | // TestWantsInternalWardleInformerFactory ensures that the informer factory is injected 31 | // when the WantsInternalWardleInformerFactory interface is implemented by a plugin. 32 | func TestWantsInternalWardleInformerFactory(t *testing.T) { 33 | cs := &fake.Clientset{} 34 | sf := informers.NewSharedInformerFactory(cs, time.Duration(1)*time.Second) 35 | target := wardleinitializer.New(sf) 36 | 37 | wantWardleInformerFactory := &wantInternalWardleInformerFactory{} 38 | target.Initialize(wantWardleInformerFactory) 39 | if wantWardleInformerFactory.sf != sf { 40 | t.Errorf("expected informer factory to be initialized") 41 | } 42 | } 43 | 44 | // wantInternalWardleInformerFactory is a test stub that fulfills the WantsInternalWardleInformerFactory interface 45 | type wantInternalWardleInformerFactory struct { 46 | sf informers.SharedInformerFactory 47 | } 48 | 49 | func (f *wantInternalWardleInformerFactory) SetInternalWardleInformerFactory(sf informers.SharedInformerFactory) { 50 | f.sf = sf 51 | } 52 | func (f *wantInternalWardleInformerFactory) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error { 53 | return nil 54 | } 55 | func (f *wantInternalWardleInformerFactory) Handles(o admission.Operation) bool { return false } 56 | func (f *wantInternalWardleInformerFactory) ValidateInitialization() error { return nil } 57 | 58 | var _ admission.Interface = &wantInternalWardleInformerFactory{} 59 | var _ wardleinitializer.WantsInternalWardleInformerFactory = &wantInternalWardleInformerFactory{} 60 | -------------------------------------------------------------------------------- /pkg/apis/wardle/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=wardle.example.com 19 | 20 | // Package wardle is the internal version of the API. 21 | package wardle 22 | -------------------------------------------------------------------------------- /pkg/apis/wardle/fuzzer/fuzzer.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 fuzzer 18 | 19 | import ( 20 | "k8s.io/sample-apiserver/pkg/apis/wardle" 21 | "sigs.k8s.io/randfill" 22 | 23 | runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" 24 | ) 25 | 26 | // Funcs returns the fuzzer functions for the apps api group. 27 | var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { 28 | return []interface{}{ 29 | func(s *wardle.FlunderSpec, c randfill.Continue) { 30 | c.FillNoCustom(s) // fuzz self without calling this function again 31 | 32 | if len(s.FlunderReference) != 0 && len(s.FischerReference) != 0 { 33 | s.FischerReference = "" 34 | } 35 | if len(s.FlunderReference) != 0 { 36 | s.ReferenceType = wardle.FlunderReferenceType 37 | } else if len(s.FischerReference) != 0 { 38 | s.ReferenceType = wardle.FischerReferenceType 39 | } else { 40 | s.ReferenceType = "" 41 | } 42 | }, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /pkg/apis/wardle/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/apimachinery/pkg/runtime" 21 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 22 | "k8s.io/sample-apiserver/pkg/apis/wardle" 23 | "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 24 | "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 25 | ) 26 | 27 | // Install registers the API group and adds types to a scheme 28 | func Install(scheme *runtime.Scheme) { 29 | utilruntime.Must(wardle.AddToScheme(scheme)) 30 | utilruntime.Must(v1beta1.AddToScheme(scheme)) 31 | utilruntime.Must(v1alpha1.AddToScheme(scheme)) 32 | utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1alpha1.SchemeGroupVersion)) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/apis/wardle/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 | "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" 23 | wardlefuzzer "k8s.io/sample-apiserver/pkg/apis/wardle/fuzzer" 24 | ) 25 | 26 | func TestRoundTripTypes(t *testing.T) { 27 | roundtrip.RoundTripTestForAPIGroup(t, Install, wardlefuzzer.Funcs) 28 | // TODO: enable protobuf generation for the sample-apiserver 29 | // roundtrip.RoundTripProtobufTestForAPIGroup(t, Install, wardlefuzzer.Funcs) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/apis/wardle/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 wardle 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "k8s.io/apimachinery/pkg/runtime/schema" 22 | ) 23 | 24 | // GroupName is the group name used in this package 25 | const GroupName = "wardle.example.com" 26 | 27 | // SchemeGroupVersion is group version used to register these objects 28 | var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} 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 is the scheme builder with scheme init functions to run for this API package 42 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 43 | // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme 44 | AddToScheme = SchemeBuilder.AddToScheme 45 | ) 46 | 47 | // Adds the list of known types to the given scheme. 48 | func addKnownTypes(scheme *runtime.Scheme) error { 49 | scheme.AddKnownTypes(SchemeGroupVersion, 50 | &Flunder{}, 51 | &FlunderList{}, 52 | &Fischer{}, 53 | &FischerList{}, 54 | ) 55 | return nil 56 | } 57 | -------------------------------------------------------------------------------- /pkg/apis/wardle/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 wardle 18 | 19 | import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 20 | 21 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 22 | 23 | // FlunderList is a list of Flunder objects. 24 | type FlunderList struct { 25 | metav1.TypeMeta 26 | metav1.ListMeta 27 | 28 | Items []Flunder 29 | } 30 | 31 | // ReferenceType defines the type of an object reference. 32 | type ReferenceType string 33 | 34 | const ( 35 | // FlunderReferenceType is used for Flunder references. 36 | FlunderReferenceType = ReferenceType("Flunder") 37 | // FischerReferenceType is used for Fischer references. 38 | FischerReferenceType = ReferenceType("Fischer") 39 | ) 40 | 41 | // FlunderSpec is the specification of a Flunder. 42 | type FlunderSpec struct { 43 | // A name of another flunder, mutually exclusive to the FischerReference. 44 | FlunderReference string 45 | // A name of a fischer, mutually exclusive to the FlunderReference. 46 | FischerReference string 47 | // The reference type. 48 | ReferenceType ReferenceType 49 | } 50 | 51 | // FlunderStatus is the status of a Flunder. 52 | type FlunderStatus struct { 53 | } 54 | 55 | // +genclient 56 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 57 | 58 | // Flunder is an example type with a spec and a status. 59 | type Flunder struct { 60 | metav1.TypeMeta 61 | metav1.ObjectMeta 62 | 63 | Spec FlunderSpec 64 | Status FlunderStatus 65 | } 66 | 67 | // +genclient 68 | // +genclient:nonNamespaced 69 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 70 | 71 | // Fischer is an example type with a list of disallowed Flunder.Names 72 | type Fischer struct { 73 | metav1.TypeMeta 74 | metav1.ObjectMeta 75 | 76 | // DisallowedFlunders holds a list of Flunder.Names that are disallowed. 77 | DisallowedFlunders []string 78 | } 79 | 80 | // +genclient:nonNamespaced 81 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 82 | 83 | // FischerList is a list of Fischer objects. 84 | type FischerList struct { 85 | metav1.TypeMeta 86 | metav1.ListMeta 87 | 88 | // Items is a list of Fischers 89 | Items []Fischer 90 | } 91 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/conversion.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 v1alpha1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/conversion" 21 | "k8s.io/sample-apiserver/pkg/apis/wardle" 22 | ) 23 | 24 | // Convert_v1alpha1_FlunderSpec_To_wardle_FlunderSpec is an autogenerated conversion function. 25 | func Convert_v1alpha1_FlunderSpec_To_wardle_FlunderSpec(in *FlunderSpec, out *wardle.FlunderSpec, s conversion.Scope) error { 26 | if in.ReferenceType != nil { 27 | // assume that ReferenceType is defaulted 28 | switch *in.ReferenceType { 29 | case FlunderReferenceType: 30 | out.ReferenceType = wardle.FlunderReferenceType 31 | out.FlunderReference = in.Reference 32 | case FischerReferenceType: 33 | out.ReferenceType = wardle.FischerReferenceType 34 | out.FischerReference = in.Reference 35 | } 36 | } 37 | 38 | return nil 39 | } 40 | 41 | // Convert_wardle_FlunderSpec_To_v1alpha1_FlunderSpec is an autogenerated conversion function. 42 | func Convert_wardle_FlunderSpec_To_v1alpha1_FlunderSpec(in *wardle.FlunderSpec, out *FlunderSpec, s conversion.Scope) error { 43 | switch in.ReferenceType { 44 | case wardle.FlunderReferenceType: 45 | t := FlunderReferenceType 46 | out.ReferenceType = &t 47 | out.Reference = in.FlunderReference 48 | case wardle.FischerReferenceType: 49 | t := FischerReferenceType 50 | out.ReferenceType = &t 51 | out.Reference = in.FischerReference 52 | } 53 | 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/defaults.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 v1alpha1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | 27 | // SetDefaults_FlunderSpec sets defaults for Flunder spec 28 | func SetDefaults_FlunderSpec(obj *FlunderSpec) { 29 | if (obj.ReferenceType == nil || len(*obj.ReferenceType) == 0) && len(obj.Reference) != 0 { 30 | t := FlunderReferenceType 31 | obj.ReferenceType = &t 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/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:openapi-gen=true 18 | // +k8s:deepcopy-gen=package 19 | // +k8s:conversion-gen=k8s.io/sample-apiserver/pkg/apis/wardle 20 | // +k8s:defaulter-gen=TypeMeta 21 | // +k8s:prerelease-lifecycle-gen=true 22 | // +groupName=wardle.example.com 23 | 24 | // Package v1alpha1 is the v1alpha1 version of the API. 25 | package v1alpha1 26 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 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 v1alpha1 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 | // GroupName is the group name used in this package 26 | const GroupName = "wardle.example.com" 27 | 28 | // SchemeGroupVersion is group version used to register these objects 29 | var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} 30 | 31 | var ( 32 | // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. 33 | // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. 34 | // SchemeBuilder is the scheme builder with scheme init functions to run for this API package 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme 38 | AddToScheme = localSchemeBuilder.AddToScheme 39 | ) 40 | 41 | func init() { 42 | // We only register manually written functions here. The registration of the 43 | // generated functions takes place in the generated files. The separation 44 | // makes the code compile even when the generated files are missing. 45 | localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs) 46 | } 47 | 48 | // Adds the list of known types to the given scheme. 49 | func addKnownTypes(scheme *runtime.Scheme) error { 50 | scheme.AddKnownTypes(SchemeGroupVersion, 51 | &Flunder{}, 52 | &FlunderList{}, 53 | &Fischer{}, 54 | &FischerList{}, 55 | ) 56 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 57 | return nil 58 | } 59 | 60 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 61 | func Resource(resource string) schema.GroupResource { 62 | return SchemeGroupVersion.WithResource(resource).GroupResource() 63 | } 64 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/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 v1alpha1 18 | 19 | import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 20 | 21 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 22 | // +k8s:prerelease-lifecycle-gen:introduced=1.0 23 | // +k8s:prerelease-lifecycle-gen:removed=1.10 24 | 25 | // FlunderList is a list of Flunder objects. 26 | type FlunderList struct { 27 | metav1.TypeMeta `json:",inline"` 28 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 29 | 30 | Items []Flunder `json:"items" protobuf:"bytes,2,rep,name=items"` 31 | } 32 | 33 | type ReferenceType string 34 | 35 | const ( 36 | FlunderReferenceType = ReferenceType("Flunder") 37 | FischerReferenceType = ReferenceType("Fischer") 38 | ) 39 | 40 | type FlunderSpec struct { 41 | // A name of another flunder or fischer, depending on the reference type. 42 | Reference string `json:"reference,omitempty" protobuf:"bytes,1,opt,name=reference"` 43 | // The reference type, defaults to "Flunder" if reference is set. 44 | ReferenceType *ReferenceType `json:"referenceType,omitempty" protobuf:"bytes,2,opt,name=referenceType"` 45 | } 46 | 47 | type FlunderStatus struct { 48 | } 49 | 50 | // +genclient 51 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 52 | // +k8s:prerelease-lifecycle-gen:introduced=1.0 53 | // +k8s:prerelease-lifecycle-gen:removed=1.10 54 | 55 | type Flunder struct { 56 | metav1.TypeMeta `json:",inline"` 57 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 58 | 59 | Spec FlunderSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 60 | Status FlunderStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 61 | } 62 | 63 | // +genclient 64 | // +genclient:nonNamespaced 65 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 66 | // +k8s:prerelease-lifecycle-gen:introduced=1.0 67 | // +k8s:prerelease-lifecycle-gen:removed=1.10 68 | 69 | type Fischer struct { 70 | metav1.TypeMeta `json:",inline"` 71 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 72 | 73 | // DisallowedFlunders holds a list of Flunder.Names that are disallowed. 74 | // +listType=atomic 75 | DisallowedFlunders []string `json:"disallowedFlunders,omitempty" protobuf:"bytes,2,rep,name=disallowedFlunders"` 76 | } 77 | 78 | // +genclient:nonNamespaced 79 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 80 | // +k8s:prerelease-lifecycle-gen:introduced=1.0 81 | // +k8s:prerelease-lifecycle-gen:removed=1.10 82 | 83 | // FischerList is a list of Fischer objects. 84 | type FischerList struct { 85 | metav1.TypeMeta `json:",inline"` 86 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 87 | 88 | Items []Fischer `json:"items" protobuf:"bytes,2,rep,name=items"` 89 | } 90 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/zz_generated.deepcopy.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 deepcopy-gen. DO NOT EDIT. 21 | 22 | package v1alpha1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 29 | func (in *Fischer) DeepCopyInto(out *Fischer) { 30 | *out = *in 31 | out.TypeMeta = in.TypeMeta 32 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 33 | if in.DisallowedFlunders != nil { 34 | in, out := &in.DisallowedFlunders, &out.DisallowedFlunders 35 | *out = make([]string, len(*in)) 36 | copy(*out, *in) 37 | } 38 | return 39 | } 40 | 41 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Fischer. 42 | func (in *Fischer) DeepCopy() *Fischer { 43 | if in == nil { 44 | return nil 45 | } 46 | out := new(Fischer) 47 | in.DeepCopyInto(out) 48 | return out 49 | } 50 | 51 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 52 | func (in *Fischer) DeepCopyObject() runtime.Object { 53 | if c := in.DeepCopy(); c != nil { 54 | return c 55 | } 56 | return nil 57 | } 58 | 59 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 60 | func (in *FischerList) DeepCopyInto(out *FischerList) { 61 | *out = *in 62 | out.TypeMeta = in.TypeMeta 63 | in.ListMeta.DeepCopyInto(&out.ListMeta) 64 | if in.Items != nil { 65 | in, out := &in.Items, &out.Items 66 | *out = make([]Fischer, len(*in)) 67 | for i := range *in { 68 | (*in)[i].DeepCopyInto(&(*out)[i]) 69 | } 70 | } 71 | return 72 | } 73 | 74 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FischerList. 75 | func (in *FischerList) DeepCopy() *FischerList { 76 | if in == nil { 77 | return nil 78 | } 79 | out := new(FischerList) 80 | in.DeepCopyInto(out) 81 | return out 82 | } 83 | 84 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 85 | func (in *FischerList) DeepCopyObject() runtime.Object { 86 | if c := in.DeepCopy(); c != nil { 87 | return c 88 | } 89 | return nil 90 | } 91 | 92 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 93 | func (in *Flunder) DeepCopyInto(out *Flunder) { 94 | *out = *in 95 | out.TypeMeta = in.TypeMeta 96 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 97 | in.Spec.DeepCopyInto(&out.Spec) 98 | out.Status = in.Status 99 | return 100 | } 101 | 102 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Flunder. 103 | func (in *Flunder) DeepCopy() *Flunder { 104 | if in == nil { 105 | return nil 106 | } 107 | out := new(Flunder) 108 | in.DeepCopyInto(out) 109 | return out 110 | } 111 | 112 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 113 | func (in *Flunder) DeepCopyObject() runtime.Object { 114 | if c := in.DeepCopy(); c != nil { 115 | return c 116 | } 117 | return nil 118 | } 119 | 120 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 121 | func (in *FlunderList) DeepCopyInto(out *FlunderList) { 122 | *out = *in 123 | out.TypeMeta = in.TypeMeta 124 | in.ListMeta.DeepCopyInto(&out.ListMeta) 125 | if in.Items != nil { 126 | in, out := &in.Items, &out.Items 127 | *out = make([]Flunder, len(*in)) 128 | for i := range *in { 129 | (*in)[i].DeepCopyInto(&(*out)[i]) 130 | } 131 | } 132 | return 133 | } 134 | 135 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderList. 136 | func (in *FlunderList) DeepCopy() *FlunderList { 137 | if in == nil { 138 | return nil 139 | } 140 | out := new(FlunderList) 141 | in.DeepCopyInto(out) 142 | return out 143 | } 144 | 145 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 146 | func (in *FlunderList) DeepCopyObject() runtime.Object { 147 | if c := in.DeepCopy(); c != nil { 148 | return c 149 | } 150 | return nil 151 | } 152 | 153 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 154 | func (in *FlunderSpec) DeepCopyInto(out *FlunderSpec) { 155 | *out = *in 156 | if in.ReferenceType != nil { 157 | in, out := &in.ReferenceType, &out.ReferenceType 158 | *out = new(ReferenceType) 159 | **out = **in 160 | } 161 | return 162 | } 163 | 164 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderSpec. 165 | func (in *FlunderSpec) DeepCopy() *FlunderSpec { 166 | if in == nil { 167 | return nil 168 | } 169 | out := new(FlunderSpec) 170 | in.DeepCopyInto(out) 171 | return out 172 | } 173 | 174 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 175 | func (in *FlunderStatus) DeepCopyInto(out *FlunderStatus) { 176 | *out = *in 177 | return 178 | } 179 | 180 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderStatus. 181 | func (in *FlunderStatus) DeepCopy() *FlunderStatus { 182 | if in == nil { 183 | return nil 184 | } 185 | out := new(FlunderStatus) 186 | in.DeepCopyInto(out) 187 | return out 188 | } 189 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/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 v1alpha1 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(&Flunder{}, func(obj interface{}) { SetObjectDefaults_Flunder(obj.(*Flunder)) }) 33 | scheme.AddTypeDefaultingFunc(&FlunderList{}, func(obj interface{}) { SetObjectDefaults_FlunderList(obj.(*FlunderList)) }) 34 | return nil 35 | } 36 | 37 | func SetObjectDefaults_Flunder(in *Flunder) { 38 | SetDefaults_FlunderSpec(&in.Spec) 39 | } 40 | 41 | func SetObjectDefaults_FlunderList(in *FlunderList) { 42 | for i := range in.Items { 43 | a := &in.Items[i] 44 | SetObjectDefaults_Flunder(a) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1alpha1/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 v1alpha1 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 *Fischer) APILifecycleIntroduced() (major, minor int) { 27 | return 1, 0 28 | } 29 | 30 | // APILifecycleDeprecated is an autogenerated function, returning the release in which the API struct was or will be deprecated as int versions of major and minor for comparison. 31 | // It is controlled by "k8s:prerelease-lifecycle-gen:deprecated" tags in types.go or "k8s:prerelease-lifecycle-gen:introduced" plus three minor. 32 | func (in *Fischer) APILifecycleDeprecated() (major, minor int) { 33 | return 1, 3 34 | } 35 | 36 | // APILifecycleRemoved is an autogenerated function, returning the release in which the API is no longer served as int versions of major and minor for comparison. 37 | // It is controlled by "k8s:prerelease-lifecycle-gen:removed" tags in types.go or "k8s:prerelease-lifecycle-gen:deprecated" plus three minor. 38 | func (in *Fischer) APILifecycleRemoved() (major, minor int) { 39 | return 1, 10 40 | } 41 | 42 | // APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison. 43 | // It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go. 44 | func (in *FischerList) APILifecycleIntroduced() (major, minor int) { 45 | return 1, 0 46 | } 47 | 48 | // APILifecycleDeprecated is an autogenerated function, returning the release in which the API struct was or will be deprecated as int versions of major and minor for comparison. 49 | // It is controlled by "k8s:prerelease-lifecycle-gen:deprecated" tags in types.go or "k8s:prerelease-lifecycle-gen:introduced" plus three minor. 50 | func (in *FischerList) APILifecycleDeprecated() (major, minor int) { 51 | return 1, 3 52 | } 53 | 54 | // APILifecycleRemoved is an autogenerated function, returning the release in which the API is no longer served as int versions of major and minor for comparison. 55 | // It is controlled by "k8s:prerelease-lifecycle-gen:removed" tags in types.go or "k8s:prerelease-lifecycle-gen:deprecated" plus three minor. 56 | func (in *FischerList) APILifecycleRemoved() (major, minor int) { 57 | return 1, 10 58 | } 59 | 60 | // APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison. 61 | // It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go. 62 | func (in *Flunder) APILifecycleIntroduced() (major, minor int) { 63 | return 1, 0 64 | } 65 | 66 | // APILifecycleDeprecated is an autogenerated function, returning the release in which the API struct was or will be deprecated as int versions of major and minor for comparison. 67 | // It is controlled by "k8s:prerelease-lifecycle-gen:deprecated" tags in types.go or "k8s:prerelease-lifecycle-gen:introduced" plus three minor. 68 | func (in *Flunder) APILifecycleDeprecated() (major, minor int) { 69 | return 1, 3 70 | } 71 | 72 | // APILifecycleRemoved is an autogenerated function, returning the release in which the API is no longer served as int versions of major and minor for comparison. 73 | // It is controlled by "k8s:prerelease-lifecycle-gen:removed" tags in types.go or "k8s:prerelease-lifecycle-gen:deprecated" plus three minor. 74 | func (in *Flunder) APILifecycleRemoved() (major, minor int) { 75 | return 1, 10 76 | } 77 | 78 | // APILifecycleIntroduced is an autogenerated function, returning the release in which the API struct was introduced as int versions of major and minor for comparison. 79 | // It is controlled by "k8s:prerelease-lifecycle-gen:introduced" tags in types.go. 80 | func (in *FlunderList) APILifecycleIntroduced() (major, minor int) { 81 | return 1, 0 82 | } 83 | 84 | // APILifecycleDeprecated is an autogenerated function, returning the release in which the API struct was or will be deprecated as int versions of major and minor for comparison. 85 | // It is controlled by "k8s:prerelease-lifecycle-gen:deprecated" tags in types.go or "k8s:prerelease-lifecycle-gen:introduced" plus three minor. 86 | func (in *FlunderList) APILifecycleDeprecated() (major, minor int) { 87 | return 1, 3 88 | } 89 | 90 | // APILifecycleRemoved is an autogenerated function, returning the release in which the API is no longer served as int versions of major and minor for comparison. 91 | // It is controlled by "k8s:prerelease-lifecycle-gen:removed" tags in types.go or "k8s:prerelease-lifecycle-gen:deprecated" plus three minor. 92 | func (in *FlunderList) APILifecycleRemoved() (major, minor int) { 93 | return 1, 10 94 | } 95 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1beta1/doc.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 | // +k8s:openapi-gen=true 18 | // +k8s:deepcopy-gen=package 19 | // +k8s:conversion-gen=k8s.io/sample-apiserver/pkg/apis/wardle 20 | // +k8s:defaulter-gen=TypeMeta 21 | // +groupName=wardle.example.com 22 | 23 | // Package v1beta1 is the v1beta1 version of the API. 24 | package v1beta1 25 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1beta1/register.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 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 | // GroupName holds the API group name. 26 | const GroupName = "wardle.example.com" 27 | 28 | // SchemeGroupVersion is group version used to register these objects 29 | var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} 30 | 31 | var ( 32 | // SchemeBuilder allows to add this group to a scheme. 33 | // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. 34 | // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | 38 | // AddToScheme adds this group to a scheme. 39 | AddToScheme = localSchemeBuilder.AddToScheme 40 | ) 41 | 42 | func init() { 43 | // We only register manually written functions here. The registration of the 44 | // generated functions takes place in the generated files. The separation 45 | // makes the code compile even when the generated files are missing. 46 | localSchemeBuilder.Register(addKnownTypes) 47 | } 48 | 49 | // Adds the list of known types to the given scheme. 50 | func addKnownTypes(scheme *runtime.Scheme) error { 51 | scheme.AddKnownTypes(SchemeGroupVersion, 52 | &Flunder{}, 53 | &FlunderList{}, 54 | ) 55 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 56 | return nil 57 | } 58 | 59 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 60 | func Resource(resource string) schema.GroupResource { 61 | return SchemeGroupVersion.WithResource(resource).GroupResource() 62 | } 63 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1beta1/types.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 v1beta1 18 | 19 | import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 20 | 21 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 22 | 23 | // FlunderList is a list of Flunder objects. 24 | type FlunderList struct { 25 | metav1.TypeMeta `json:",inline"` 26 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 27 | 28 | Items []Flunder `json:"items" protobuf:"bytes,2,rep,name=items"` 29 | } 30 | 31 | // ReferenceType defines the type of an object reference. 32 | type ReferenceType string 33 | 34 | const ( 35 | // FlunderReferenceType is used for Flunder references. 36 | FlunderReferenceType = ReferenceType("Flunder") 37 | // FischerReferenceType is used for Fischer references. 38 | FischerReferenceType = ReferenceType("Fischer") 39 | ) 40 | 41 | // FlunderSpec is the specification of a Flunder. 42 | type FlunderSpec struct { 43 | // A name of another flunder, mutually exclusive to the FischerReference. 44 | FlunderReference string `json:"flunderReference,omitempty" protobuf:"bytes,1,opt,name=flunderReference"` 45 | // A name of a fischer, mutually exclusive to the FlunderReference. 46 | FischerReference string `json:"fischerReference,omitempty" protobuf:"bytes,2,opt,name=fischerReference"` 47 | // The reference type. 48 | ReferenceType ReferenceType `json:"referenceType,omitempty" protobuf:"bytes,3,opt,name=referenceType"` 49 | } 50 | 51 | // FlunderStatus is the status of a Flunder. 52 | type FlunderStatus struct { 53 | } 54 | 55 | // +genclient 56 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 57 | 58 | // Flunder is an example type with a spec and a status. 59 | type Flunder struct { 60 | metav1.TypeMeta `json:",inline"` 61 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 62 | 63 | Spec FlunderSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 64 | Status FlunderStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 65 | } 66 | -------------------------------------------------------------------------------- /pkg/apis/wardle/v1beta1/zz_generated.deepcopy.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 deepcopy-gen. DO NOT EDIT. 21 | 22 | package v1beta1 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 29 | func (in *Flunder) DeepCopyInto(out *Flunder) { 30 | *out = *in 31 | out.TypeMeta = in.TypeMeta 32 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 33 | out.Spec = in.Spec 34 | out.Status = in.Status 35 | return 36 | } 37 | 38 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Flunder. 39 | func (in *Flunder) DeepCopy() *Flunder { 40 | if in == nil { 41 | return nil 42 | } 43 | out := new(Flunder) 44 | in.DeepCopyInto(out) 45 | return out 46 | } 47 | 48 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 49 | func (in *Flunder) DeepCopyObject() runtime.Object { 50 | if c := in.DeepCopy(); c != nil { 51 | return c 52 | } 53 | return nil 54 | } 55 | 56 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 57 | func (in *FlunderList) DeepCopyInto(out *FlunderList) { 58 | *out = *in 59 | out.TypeMeta = in.TypeMeta 60 | in.ListMeta.DeepCopyInto(&out.ListMeta) 61 | if in.Items != nil { 62 | in, out := &in.Items, &out.Items 63 | *out = make([]Flunder, len(*in)) 64 | for i := range *in { 65 | (*in)[i].DeepCopyInto(&(*out)[i]) 66 | } 67 | } 68 | return 69 | } 70 | 71 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderList. 72 | func (in *FlunderList) DeepCopy() *FlunderList { 73 | if in == nil { 74 | return nil 75 | } 76 | out := new(FlunderList) 77 | in.DeepCopyInto(out) 78 | return out 79 | } 80 | 81 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 82 | func (in *FlunderList) DeepCopyObject() runtime.Object { 83 | if c := in.DeepCopy(); c != nil { 84 | return c 85 | } 86 | return nil 87 | } 88 | 89 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 90 | func (in *FlunderSpec) DeepCopyInto(out *FlunderSpec) { 91 | *out = *in 92 | return 93 | } 94 | 95 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderSpec. 96 | func (in *FlunderSpec) DeepCopy() *FlunderSpec { 97 | if in == nil { 98 | return nil 99 | } 100 | out := new(FlunderSpec) 101 | in.DeepCopyInto(out) 102 | return out 103 | } 104 | 105 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 106 | func (in *FlunderStatus) DeepCopyInto(out *FlunderStatus) { 107 | *out = *in 108 | return 109 | } 110 | 111 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderStatus. 112 | func (in *FlunderStatus) DeepCopy() *FlunderStatus { 113 | if in == nil { 114 | return nil 115 | } 116 | out := new(FlunderStatus) 117 | in.DeepCopyInto(out) 118 | return out 119 | } 120 | -------------------------------------------------------------------------------- /pkg/apis/wardle/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 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /pkg/apis/wardle/validation/validation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 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 | "k8s.io/apimachinery/pkg/util/validation/field" 21 | "k8s.io/sample-apiserver/pkg/apis/wardle" 22 | ) 23 | 24 | // ValidateFlunder validates a Flunder. 25 | func ValidateFlunder(f *wardle.Flunder) field.ErrorList { 26 | allErrs := field.ErrorList{} 27 | 28 | allErrs = append(allErrs, ValidateFlunderSpec(&f.Spec, field.NewPath("spec"))...) 29 | 30 | return allErrs 31 | } 32 | 33 | // ValidateFlunderSpec validates a FlunderSpec. 34 | func ValidateFlunderSpec(s *wardle.FlunderSpec, fldPath *field.Path) field.ErrorList { 35 | allErrs := field.ErrorList{} 36 | 37 | if len(s.FlunderReference) != 0 && len(s.FischerReference) != 0 { 38 | allErrs = append(allErrs, field.Invalid(fldPath.Child("fischerReference"), s.FischerReference, "cannot be set with flunderReference at the same time")) 39 | } else if len(s.FlunderReference) != 0 && s.ReferenceType != wardle.FlunderReferenceType { 40 | allErrs = append(allErrs, field.Invalid(fldPath.Child("flunderReference"), s.FlunderReference, "cannot be set if referenceType is not Flunder")) 41 | } else if len(s.FischerReference) != 0 && s.ReferenceType != wardle.FischerReferenceType { 42 | allErrs = append(allErrs, field.Invalid(fldPath.Child("fischerReference"), s.FischerReference, "cannot be set if referenceType is not Fischer")) 43 | } else if len(s.FischerReference) == 0 && s.ReferenceType == wardle.FischerReferenceType { 44 | allErrs = append(allErrs, field.Invalid(fldPath.Child("fischerReference"), s.FischerReference, "cannot be empty if referenceType is Fischer")) 45 | } else if len(s.FlunderReference) == 0 && s.ReferenceType == wardle.FlunderReferenceType { 46 | allErrs = append(allErrs, field.Invalid(fldPath.Child("flunderReference"), s.FlunderReference, "cannot be empty if referenceType is Flunder")) 47 | } 48 | 49 | if len(s.ReferenceType) != 0 && s.ReferenceType != wardle.FischerReferenceType && s.ReferenceType != wardle.FlunderReferenceType { 50 | allErrs = append(allErrs, field.Invalid(fldPath.Child("referenceType"), s.ReferenceType, "must be Flunder or Fischer")) 51 | } 52 | 53 | return allErrs 54 | } 55 | -------------------------------------------------------------------------------- /pkg/apis/wardle/zz_generated.deepcopy.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 deepcopy-gen. DO NOT EDIT. 21 | 22 | package wardle 23 | 24 | import ( 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | ) 27 | 28 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 29 | func (in *Fischer) DeepCopyInto(out *Fischer) { 30 | *out = *in 31 | out.TypeMeta = in.TypeMeta 32 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 33 | if in.DisallowedFlunders != nil { 34 | in, out := &in.DisallowedFlunders, &out.DisallowedFlunders 35 | *out = make([]string, len(*in)) 36 | copy(*out, *in) 37 | } 38 | return 39 | } 40 | 41 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Fischer. 42 | func (in *Fischer) DeepCopy() *Fischer { 43 | if in == nil { 44 | return nil 45 | } 46 | out := new(Fischer) 47 | in.DeepCopyInto(out) 48 | return out 49 | } 50 | 51 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 52 | func (in *Fischer) DeepCopyObject() runtime.Object { 53 | if c := in.DeepCopy(); c != nil { 54 | return c 55 | } 56 | return nil 57 | } 58 | 59 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 60 | func (in *FischerList) DeepCopyInto(out *FischerList) { 61 | *out = *in 62 | out.TypeMeta = in.TypeMeta 63 | in.ListMeta.DeepCopyInto(&out.ListMeta) 64 | if in.Items != nil { 65 | in, out := &in.Items, &out.Items 66 | *out = make([]Fischer, len(*in)) 67 | for i := range *in { 68 | (*in)[i].DeepCopyInto(&(*out)[i]) 69 | } 70 | } 71 | return 72 | } 73 | 74 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FischerList. 75 | func (in *FischerList) DeepCopy() *FischerList { 76 | if in == nil { 77 | return nil 78 | } 79 | out := new(FischerList) 80 | in.DeepCopyInto(out) 81 | return out 82 | } 83 | 84 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 85 | func (in *FischerList) DeepCopyObject() runtime.Object { 86 | if c := in.DeepCopy(); c != nil { 87 | return c 88 | } 89 | return nil 90 | } 91 | 92 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 93 | func (in *Flunder) DeepCopyInto(out *Flunder) { 94 | *out = *in 95 | out.TypeMeta = in.TypeMeta 96 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 97 | out.Spec = in.Spec 98 | out.Status = in.Status 99 | return 100 | } 101 | 102 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Flunder. 103 | func (in *Flunder) DeepCopy() *Flunder { 104 | if in == nil { 105 | return nil 106 | } 107 | out := new(Flunder) 108 | in.DeepCopyInto(out) 109 | return out 110 | } 111 | 112 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 113 | func (in *Flunder) DeepCopyObject() runtime.Object { 114 | if c := in.DeepCopy(); c != nil { 115 | return c 116 | } 117 | return nil 118 | } 119 | 120 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 121 | func (in *FlunderList) DeepCopyInto(out *FlunderList) { 122 | *out = *in 123 | out.TypeMeta = in.TypeMeta 124 | in.ListMeta.DeepCopyInto(&out.ListMeta) 125 | if in.Items != nil { 126 | in, out := &in.Items, &out.Items 127 | *out = make([]Flunder, len(*in)) 128 | for i := range *in { 129 | (*in)[i].DeepCopyInto(&(*out)[i]) 130 | } 131 | } 132 | return 133 | } 134 | 135 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderList. 136 | func (in *FlunderList) DeepCopy() *FlunderList { 137 | if in == nil { 138 | return nil 139 | } 140 | out := new(FlunderList) 141 | in.DeepCopyInto(out) 142 | return out 143 | } 144 | 145 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 146 | func (in *FlunderList) DeepCopyObject() runtime.Object { 147 | if c := in.DeepCopy(); c != nil { 148 | return c 149 | } 150 | return nil 151 | } 152 | 153 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 154 | func (in *FlunderSpec) DeepCopyInto(out *FlunderSpec) { 155 | *out = *in 156 | return 157 | } 158 | 159 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderSpec. 160 | func (in *FlunderSpec) DeepCopy() *FlunderSpec { 161 | if in == nil { 162 | return nil 163 | } 164 | out := new(FlunderSpec) 165 | in.DeepCopyInto(out) 166 | return out 167 | } 168 | 169 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 170 | func (in *FlunderStatus) DeepCopyInto(out *FlunderStatus) { 171 | *out = *in 172 | return 173 | } 174 | 175 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlunderStatus. 176 | func (in *FlunderStatus) DeepCopy() *FlunderStatus { 177 | if in == nil { 178 | return nil 179 | } 180 | out := new(FlunderStatus) 181 | in.DeepCopyInto(out) 182 | return out 183 | } 184 | -------------------------------------------------------------------------------- /pkg/apiserver/apiserver.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 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 apiserver 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 | "k8s.io/apimachinery/pkg/runtime/serializer" 24 | "k8s.io/apiserver/pkg/registry/rest" 25 | genericapiserver "k8s.io/apiserver/pkg/server" 26 | 27 | "k8s.io/sample-apiserver/pkg/apis/wardle" 28 | "k8s.io/sample-apiserver/pkg/apis/wardle/install" 29 | wardleregistry "k8s.io/sample-apiserver/pkg/registry" 30 | fischerstorage "k8s.io/sample-apiserver/pkg/registry/wardle/fischer" 31 | flunderstorage "k8s.io/sample-apiserver/pkg/registry/wardle/flunder" 32 | ) 33 | 34 | var ( 35 | // Scheme defines methods for serializing and deserializing API objects. 36 | Scheme = runtime.NewScheme() 37 | // Codecs provides methods for retrieving codecs and serializers for specific 38 | // versions and content types. 39 | Codecs = serializer.NewCodecFactory(Scheme) 40 | WardleComponentName = "wardle" 41 | ) 42 | 43 | func init() { 44 | install.Install(Scheme) 45 | 46 | // we need to add the options to empty v1 47 | // TODO fix the server code to avoid this 48 | metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 49 | 50 | // TODO: keep the generic API server from wanting this 51 | unversioned := schema.GroupVersion{Group: "", Version: "v1"} 52 | Scheme.AddUnversionedTypes(unversioned, 53 | &metav1.Status{}, 54 | &metav1.APIVersions{}, 55 | &metav1.APIGroupList{}, 56 | &metav1.APIGroup{}, 57 | &metav1.APIResourceList{}, 58 | ) 59 | } 60 | 61 | // ExtraConfig holds custom apiserver config 62 | type ExtraConfig struct { 63 | // Place you custom config here. 64 | } 65 | 66 | // Config defines the config for the apiserver 67 | type Config struct { 68 | GenericConfig *genericapiserver.RecommendedConfig 69 | ExtraConfig ExtraConfig 70 | } 71 | 72 | // WardleServer contains state for a Kubernetes cluster master/api server. 73 | type WardleServer struct { 74 | GenericAPIServer *genericapiserver.GenericAPIServer 75 | } 76 | 77 | type completedConfig struct { 78 | GenericConfig genericapiserver.CompletedConfig 79 | ExtraConfig *ExtraConfig 80 | } 81 | 82 | // CompletedConfig embeds a private pointer that cannot be instantiated outside of this package. 83 | type CompletedConfig struct { 84 | *completedConfig 85 | } 86 | 87 | // Complete fills in any fields not set that are required to have valid data. It's mutating the receiver. 88 | func (cfg *Config) Complete() CompletedConfig { 89 | c := completedConfig{ 90 | cfg.GenericConfig.Complete(), 91 | &cfg.ExtraConfig, 92 | } 93 | 94 | return CompletedConfig{&c} 95 | } 96 | 97 | // New returns a new instance of WardleServer from the given config. 98 | func (c completedConfig) New() (*WardleServer, error) { 99 | genericServer, err := c.GenericConfig.New("sample-apiserver", genericapiserver.NewEmptyDelegate()) 100 | if err != nil { 101 | return nil, err 102 | } 103 | 104 | s := &WardleServer{ 105 | GenericAPIServer: genericServer, 106 | } 107 | 108 | apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(wardle.GroupName, Scheme, metav1.ParameterCodec, Codecs) 109 | 110 | v1alpha1storage := map[string]rest.Storage{} 111 | v1alpha1storage["flunders"] = wardleregistry.RESTInPeace(flunderstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) 112 | v1alpha1storage["fischers"] = wardleregistry.RESTInPeace(fischerstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) 113 | apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage 114 | 115 | v1beta1storage := map[string]rest.Storage{} 116 | v1beta1storage["flunders"] = wardleregistry.RESTInPeace(flunderstorage.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)) 117 | apiGroupInfo.VersionedResourcesStorageMap["v1beta1"] = v1beta1storage 118 | 119 | if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil { 120 | return nil, err 121 | } 122 | 123 | return s, nil 124 | } 125 | -------------------------------------------------------------------------------- /pkg/apiserver/scheme_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 apiserver 18 | 19 | import ( 20 | "testing" 21 | 22 | "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" 23 | wardlefuzzer "k8s.io/sample-apiserver/pkg/apis/wardle/fuzzer" 24 | ) 25 | 26 | func TestRoundTripTypes(t *testing.T) { 27 | roundtrip.RoundTripTestForScheme(t, Scheme, wardlefuzzer.Funcs) 28 | } 29 | -------------------------------------------------------------------------------- /pkg/cmd/server/start_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 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 | "testing" 21 | 22 | "k8s.io/apimachinery/pkg/util/version" 23 | "k8s.io/apiserver/pkg/util/compatibility" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestWardleEmulationVersionToKubeEmulationVersion(t *testing.T) { 29 | defaultKubeEffectiveVersion := compatibility.DefaultKubeEffectiveVersionForTest() 30 | 31 | testCases := []struct { 32 | desc string 33 | wardleEmulationVer *version.Version 34 | expectedKubeEmulationVer *version.Version 35 | }{ 36 | { 37 | desc: "same version as than kube binary", 38 | wardleEmulationVer: version.MajorMinor(1, 2), 39 | expectedKubeEmulationVer: defaultKubeEffectiveVersion.BinaryVersion(), 40 | }, 41 | { 42 | desc: "1 version lower than kube binary", 43 | wardleEmulationVer: version.MajorMinor(1, 1), 44 | expectedKubeEmulationVer: defaultKubeEffectiveVersion.BinaryVersion().OffsetMinor(-1), 45 | }, 46 | { 47 | desc: "2 versions lower than kube binary", 48 | wardleEmulationVer: version.MajorMinor(1, 0), 49 | expectedKubeEmulationVer: defaultKubeEffectiveVersion.BinaryVersion().OffsetMinor(-2), 50 | }, 51 | { 52 | desc: "capped at kube binary", 53 | wardleEmulationVer: version.MajorMinor(1, 3), 54 | expectedKubeEmulationVer: defaultKubeEffectiveVersion.BinaryVersion(), 55 | }, 56 | { 57 | desc: "no mapping", 58 | wardleEmulationVer: version.MajorMinor(2, 10), 59 | }, 60 | } 61 | 62 | for _, tc := range testCases { 63 | t.Run(tc.desc, func(t *testing.T) { 64 | mappedKubeEmulationVer := WardleVersionToKubeVersion(tc.wardleEmulationVer) 65 | assert.True(t, mappedKubeEmulationVer.EqualTo(tc.expectedKubeEmulationVer)) 66 | }) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pkg/generated/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/generated/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 | runtime "k8s.io/apimachinery/pkg/runtime" 23 | schema "k8s.io/apimachinery/pkg/runtime/schema" 24 | managedfields "k8s.io/apimachinery/pkg/util/managedfields" 25 | v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 26 | v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 27 | internal "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal" 28 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" 29 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1" 30 | ) 31 | 32 | // ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no 33 | // apply configuration type exists for the given GroupVersionKind. 34 | func ForKind(kind schema.GroupVersionKind) interface{} { 35 | switch kind { 36 | // Group=wardle.example.com, Version=v1alpha1 37 | case v1alpha1.SchemeGroupVersion.WithKind("Fischer"): 38 | return &wardlev1alpha1.FischerApplyConfiguration{} 39 | case v1alpha1.SchemeGroupVersion.WithKind("Flunder"): 40 | return &wardlev1alpha1.FlunderApplyConfiguration{} 41 | case v1alpha1.SchemeGroupVersion.WithKind("FlunderSpec"): 42 | return &wardlev1alpha1.FlunderSpecApplyConfiguration{} 43 | 44 | // Group=wardle.example.com, Version=v1beta1 45 | case v1beta1.SchemeGroupVersion.WithKind("Flunder"): 46 | return &wardlev1beta1.FlunderApplyConfiguration{} 47 | case v1beta1.SchemeGroupVersion.WithKind("FlunderSpec"): 48 | return &wardlev1beta1.FlunderSpecApplyConfiguration{} 49 | 50 | } 51 | return nil 52 | } 53 | 54 | func NewTypeConverter(scheme *runtime.Scheme) managedfields.TypeConverter { 55 | return managedfields.NewSchemeTypeConverter(scheme, internal.Parser()) 56 | } 57 | -------------------------------------------------------------------------------- /pkg/generated/applyconfiguration/wardle/v1alpha1/flunderspec.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 v1alpha1 20 | 21 | import ( 22 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 23 | ) 24 | 25 | // FlunderSpecApplyConfiguration represents a declarative configuration of the FlunderSpec type for use 26 | // with apply. 27 | type FlunderSpecApplyConfiguration struct { 28 | Reference *string `json:"reference,omitempty"` 29 | ReferenceType *wardlev1alpha1.ReferenceType `json:"referenceType,omitempty"` 30 | } 31 | 32 | // FlunderSpecApplyConfiguration constructs a declarative configuration of the FlunderSpec type for use with 33 | // apply. 34 | func FlunderSpec() *FlunderSpecApplyConfiguration { 35 | return &FlunderSpecApplyConfiguration{} 36 | } 37 | 38 | // WithReference sets the Reference 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 Reference field is set to the value of the last call. 41 | func (b *FlunderSpecApplyConfiguration) WithReference(value string) *FlunderSpecApplyConfiguration { 42 | b.Reference = &value 43 | return b 44 | } 45 | 46 | // WithReferenceType sets the ReferenceType 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 ReferenceType field is set to the value of the last call. 49 | func (b *FlunderSpecApplyConfiguration) WithReferenceType(value wardlev1alpha1.ReferenceType) *FlunderSpecApplyConfiguration { 50 | b.ReferenceType = &value 51 | return b 52 | } 53 | -------------------------------------------------------------------------------- /pkg/generated/applyconfiguration/wardle/v1beta1/flunderspec.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 | import ( 22 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 23 | ) 24 | 25 | // FlunderSpecApplyConfiguration represents a declarative configuration of the FlunderSpec type for use 26 | // with apply. 27 | type FlunderSpecApplyConfiguration struct { 28 | FlunderReference *string `json:"flunderReference,omitempty"` 29 | FischerReference *string `json:"fischerReference,omitempty"` 30 | ReferenceType *wardlev1beta1.ReferenceType `json:"referenceType,omitempty"` 31 | } 32 | 33 | // FlunderSpecApplyConfiguration constructs a declarative configuration of the FlunderSpec type for use with 34 | // apply. 35 | func FlunderSpec() *FlunderSpecApplyConfiguration { 36 | return &FlunderSpecApplyConfiguration{} 37 | } 38 | 39 | // WithFlunderReference sets the FlunderReference field in the declarative configuration to the given value 40 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 41 | // If called multiple times, the FlunderReference field is set to the value of the last call. 42 | func (b *FlunderSpecApplyConfiguration) WithFlunderReference(value string) *FlunderSpecApplyConfiguration { 43 | b.FlunderReference = &value 44 | return b 45 | } 46 | 47 | // WithFischerReference sets the FischerReference field in the declarative configuration to the given value 48 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 49 | // If called multiple times, the FischerReference field is set to the value of the last call. 50 | func (b *FlunderSpecApplyConfiguration) WithFischerReference(value string) *FlunderSpecApplyConfiguration { 51 | b.FischerReference = &value 52 | return b 53 | } 54 | 55 | // WithReferenceType sets the ReferenceType field in the declarative configuration to the given value 56 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 57 | // If called multiple times, the ReferenceType field is set to the value of the last call. 58 | func (b *FlunderSpecApplyConfiguration) WithReferenceType(value wardlev1beta1.ReferenceType) *FlunderSpecApplyConfiguration { 59 | b.ReferenceType = &value 60 | return b 61 | } 62 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/clientset.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 versioned 20 | 21 | import ( 22 | fmt "fmt" 23 | http "net/http" 24 | 25 | discovery "k8s.io/client-go/discovery" 26 | rest "k8s.io/client-go/rest" 27 | flowcontrol "k8s.io/client-go/util/flowcontrol" 28 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1" 29 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1" 30 | ) 31 | 32 | type Interface interface { 33 | Discovery() discovery.DiscoveryInterface 34 | WardleV1alpha1() wardlev1alpha1.WardleV1alpha1Interface 35 | WardleV1beta1() wardlev1beta1.WardleV1beta1Interface 36 | } 37 | 38 | // Clientset contains the clients for groups. 39 | type Clientset struct { 40 | *discovery.DiscoveryClient 41 | wardleV1alpha1 *wardlev1alpha1.WardleV1alpha1Client 42 | wardleV1beta1 *wardlev1beta1.WardleV1beta1Client 43 | } 44 | 45 | // WardleV1alpha1 retrieves the WardleV1alpha1Client 46 | func (c *Clientset) WardleV1alpha1() wardlev1alpha1.WardleV1alpha1Interface { 47 | return c.wardleV1alpha1 48 | } 49 | 50 | // WardleV1beta1 retrieves the WardleV1beta1Client 51 | func (c *Clientset) WardleV1beta1() wardlev1beta1.WardleV1beta1Interface { 52 | return c.wardleV1beta1 53 | } 54 | 55 | // Discovery retrieves the DiscoveryClient 56 | func (c *Clientset) Discovery() discovery.DiscoveryInterface { 57 | if c == nil { 58 | return nil 59 | } 60 | return c.DiscoveryClient 61 | } 62 | 63 | // NewForConfig creates a new Clientset for the given config. 64 | // If config's RateLimiter is not set and QPS and Burst are acceptable, 65 | // NewForConfig will generate a rate-limiter in configShallowCopy. 66 | // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 67 | // where httpClient was generated with rest.HTTPClientFor(c). 68 | func NewForConfig(c *rest.Config) (*Clientset, error) { 69 | configShallowCopy := *c 70 | 71 | if configShallowCopy.UserAgent == "" { 72 | configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() 73 | } 74 | 75 | // share the transport between all clients 76 | httpClient, err := rest.HTTPClientFor(&configShallowCopy) 77 | if err != nil { 78 | return nil, err 79 | } 80 | 81 | return NewForConfigAndClient(&configShallowCopy, httpClient) 82 | } 83 | 84 | // NewForConfigAndClient creates a new Clientset for the given config and http client. 85 | // Note the http client provided takes precedence over the configured transport values. 86 | // If config's RateLimiter is not set and QPS and Burst are acceptable, 87 | // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 88 | func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 89 | configShallowCopy := *c 90 | if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 91 | if configShallowCopy.Burst <= 0 { 92 | return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") 93 | } 94 | configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 95 | } 96 | 97 | var cs Clientset 98 | var err error 99 | cs.wardleV1alpha1, err = wardlev1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 100 | if err != nil { 101 | return nil, err 102 | } 103 | cs.wardleV1beta1, err = wardlev1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) 104 | if err != nil { 105 | return nil, err 106 | } 107 | 108 | cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) 109 | if err != nil { 110 | return nil, err 111 | } 112 | return &cs, nil 113 | } 114 | 115 | // NewForConfigOrDie creates a new Clientset for the given config and 116 | // panics if there is an error in the config. 117 | func NewForConfigOrDie(c *rest.Config) *Clientset { 118 | cs, err := NewForConfig(c) 119 | if err != nil { 120 | panic(err) 121 | } 122 | return cs 123 | } 124 | 125 | // New creates a new Clientset for the given RESTClient. 126 | func New(c rest.Interface) *Clientset { 127 | var cs Clientset 128 | cs.wardleV1alpha1 = wardlev1alpha1.New(c) 129 | cs.wardleV1beta1 = wardlev1beta1.New(c) 130 | 131 | cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 132 | return &cs 133 | } 134 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/fake/clientset_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 client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | "k8s.io/apimachinery/pkg/runtime" 24 | "k8s.io/apimachinery/pkg/watch" 25 | "k8s.io/client-go/discovery" 26 | fakediscovery "k8s.io/client-go/discovery/fake" 27 | "k8s.io/client-go/testing" 28 | applyconfiguration "k8s.io/sample-apiserver/pkg/generated/applyconfiguration" 29 | clientset "k8s.io/sample-apiserver/pkg/generated/clientset/versioned" 30 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1" 31 | fakewardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake" 32 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1" 33 | fakewardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/fake" 34 | ) 35 | 36 | // NewSimpleClientset returns a clientset that will respond with the provided objects. 37 | // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, 38 | // without applying any field management, validations and/or defaults. It shouldn't be considered a replacement 39 | // for a real clientset and is mostly useful in simple unit tests. 40 | // 41 | // DEPRECATED: NewClientset replaces this with support for field management, which significantly improves 42 | // server side apply testing. NewClientset is only available when apply configurations are generated (e.g. 43 | // via --with-applyconfig). 44 | func NewSimpleClientset(objects ...runtime.Object) *Clientset { 45 | o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) 46 | for _, obj := range objects { 47 | if err := o.Add(obj); err != nil { 48 | panic(err) 49 | } 50 | } 51 | 52 | cs := &Clientset{tracker: o} 53 | cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} 54 | cs.AddReactor("*", "*", testing.ObjectReaction(o)) 55 | cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { 56 | var opts metav1.ListOptions 57 | if watchActcion, ok := action.(testing.WatchActionImpl); ok { 58 | opts = watchActcion.ListOptions 59 | } 60 | gvr := action.GetResource() 61 | ns := action.GetNamespace() 62 | watch, err := o.Watch(gvr, ns, opts) 63 | if err != nil { 64 | return false, nil, err 65 | } 66 | return true, watch, nil 67 | }) 68 | 69 | return cs 70 | } 71 | 72 | // Clientset implements clientset.Interface. Meant to be embedded into a 73 | // struct to get a default implementation. This makes faking out just the method 74 | // you want to test easier. 75 | type Clientset struct { 76 | testing.Fake 77 | discovery *fakediscovery.FakeDiscovery 78 | tracker testing.ObjectTracker 79 | } 80 | 81 | func (c *Clientset) Discovery() discovery.DiscoveryInterface { 82 | return c.discovery 83 | } 84 | 85 | func (c *Clientset) Tracker() testing.ObjectTracker { 86 | return c.tracker 87 | } 88 | 89 | // NewClientset returns a clientset that will respond with the provided objects. 90 | // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, 91 | // without applying any validations and/or defaults. It shouldn't be considered a replacement 92 | // for a real clientset and is mostly useful in simple unit tests. 93 | func NewClientset(objects ...runtime.Object) *Clientset { 94 | o := testing.NewFieldManagedObjectTracker( 95 | scheme, 96 | codecs.UniversalDecoder(), 97 | applyconfiguration.NewTypeConverter(scheme), 98 | ) 99 | for _, obj := range objects { 100 | if err := o.Add(obj); err != nil { 101 | panic(err) 102 | } 103 | } 104 | 105 | cs := &Clientset{tracker: o} 106 | cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} 107 | cs.AddReactor("*", "*", testing.ObjectReaction(o)) 108 | cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { 109 | var opts metav1.ListOptions 110 | if watchActcion, ok := action.(testing.WatchActionImpl); ok { 111 | opts = watchActcion.ListOptions 112 | } 113 | gvr := action.GetResource() 114 | ns := action.GetNamespace() 115 | watch, err := o.Watch(gvr, ns, opts) 116 | if err != nil { 117 | return false, nil, err 118 | } 119 | return true, watch, nil 120 | }) 121 | 122 | return cs 123 | } 124 | 125 | var ( 126 | _ clientset.Interface = &Clientset{} 127 | _ testing.FakeClient = &Clientset{} 128 | ) 129 | 130 | // WardleV1alpha1 retrieves the WardleV1alpha1Client 131 | func (c *Clientset) WardleV1alpha1() wardlev1alpha1.WardleV1alpha1Interface { 132 | return &fakewardlev1alpha1.FakeWardleV1alpha1{Fake: &c.Fake} 133 | } 134 | 135 | // WardleV1beta1 retrieves the WardleV1beta1Client 136 | func (c *Clientset) WardleV1beta1() wardlev1beta1.WardleV1beta1Interface { 137 | return &fakewardlev1beta1.FakeWardleV1beta1{Fake: &c.Fake} 138 | } 139 | -------------------------------------------------------------------------------- /pkg/generated/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 | -------------------------------------------------------------------------------- /pkg/generated/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 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | runtime "k8s.io/apimachinery/pkg/runtime" 24 | schema "k8s.io/apimachinery/pkg/runtime/schema" 25 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 26 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 27 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 28 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 29 | ) 30 | 31 | var scheme = runtime.NewScheme() 32 | var codecs = serializer.NewCodecFactory(scheme) 33 | 34 | var localSchemeBuilder = runtime.SchemeBuilder{ 35 | wardlev1alpha1.AddToScheme, 36 | wardlev1beta1.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/generated/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 | -------------------------------------------------------------------------------- /pkg/generated/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 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | runtime "k8s.io/apimachinery/pkg/runtime" 24 | schema "k8s.io/apimachinery/pkg/runtime/schema" 25 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 26 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 27 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 28 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 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 | wardlev1alpha1.AddToScheme, 36 | wardlev1beta1.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/generated/clientset/versioned/typed/wardle/v1alpha1/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 v1alpha1 21 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1alpha1/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/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_fischer.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 | gentype "k8s.io/client-go/gentype" 23 | v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 24 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" 25 | typedwardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1" 26 | ) 27 | 28 | // fakeFischers implements FischerInterface 29 | type fakeFischers struct { 30 | *gentype.FakeClientWithListAndApply[*v1alpha1.Fischer, *v1alpha1.FischerList, *wardlev1alpha1.FischerApplyConfiguration] 31 | Fake *FakeWardleV1alpha1 32 | } 33 | 34 | func newFakeFischers(fake *FakeWardleV1alpha1) typedwardlev1alpha1.FischerInterface { 35 | return &fakeFischers{ 36 | gentype.NewFakeClientWithListAndApply[*v1alpha1.Fischer, *v1alpha1.FischerList, *wardlev1alpha1.FischerApplyConfiguration]( 37 | fake.Fake, 38 | "", 39 | v1alpha1.SchemeGroupVersion.WithResource("fischers"), 40 | v1alpha1.SchemeGroupVersion.WithKind("Fischer"), 41 | func() *v1alpha1.Fischer { return &v1alpha1.Fischer{} }, 42 | func() *v1alpha1.FischerList { return &v1alpha1.FischerList{} }, 43 | func(dst, src *v1alpha1.FischerList) { dst.ListMeta = src.ListMeta }, 44 | func(list *v1alpha1.FischerList) []*v1alpha1.Fischer { return gentype.ToPointerSlice(list.Items) }, 45 | func(list *v1alpha1.FischerList, items []*v1alpha1.Fischer) { 46 | list.Items = gentype.FromPointerSlice(items) 47 | }, 48 | ), 49 | fake, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_flunder.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 | gentype "k8s.io/client-go/gentype" 23 | v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 24 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" 25 | typedwardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1" 26 | ) 27 | 28 | // fakeFlunders implements FlunderInterface 29 | type fakeFlunders struct { 30 | *gentype.FakeClientWithListAndApply[*v1alpha1.Flunder, *v1alpha1.FlunderList, *wardlev1alpha1.FlunderApplyConfiguration] 31 | Fake *FakeWardleV1alpha1 32 | } 33 | 34 | func newFakeFlunders(fake *FakeWardleV1alpha1, namespace string) typedwardlev1alpha1.FlunderInterface { 35 | return &fakeFlunders{ 36 | gentype.NewFakeClientWithListAndApply[*v1alpha1.Flunder, *v1alpha1.FlunderList, *wardlev1alpha1.FlunderApplyConfiguration]( 37 | fake.Fake, 38 | namespace, 39 | v1alpha1.SchemeGroupVersion.WithResource("flunders"), 40 | v1alpha1.SchemeGroupVersion.WithKind("Flunder"), 41 | func() *v1alpha1.Flunder { return &v1alpha1.Flunder{} }, 42 | func() *v1alpha1.FlunderList { return &v1alpha1.FlunderList{} }, 43 | func(dst, src *v1alpha1.FlunderList) { dst.ListMeta = src.ListMeta }, 44 | func(list *v1alpha1.FlunderList) []*v1alpha1.Flunder { return gentype.ToPointerSlice(list.Items) }, 45 | func(list *v1alpha1.FlunderList, items []*v1alpha1.Flunder) { 46 | list.Items = gentype.FromPointerSlice(items) 47 | }, 48 | ), 49 | fake, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fake/fake_wardle_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 | rest "k8s.io/client-go/rest" 23 | testing "k8s.io/client-go/testing" 24 | v1alpha1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1" 25 | ) 26 | 27 | type FakeWardleV1alpha1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeWardleV1alpha1) Fischers() v1alpha1.FischerInterface { 32 | return newFakeFischers(c) 33 | } 34 | 35 | func (c *FakeWardleV1alpha1) Flunders(namespace string) v1alpha1.FlunderInterface { 36 | return newFakeFlunders(c, namespace) 37 | } 38 | 39 | // RESTClient returns a RESTClient that is used to communicate 40 | // with API server by this client implementation. 41 | func (c *FakeWardleV1alpha1) RESTClient() rest.Interface { 42 | var ret *rest.RESTClient 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.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 v1alpha1 20 | 21 | import ( 22 | context "context" 23 | 24 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | types "k8s.io/apimachinery/pkg/types" 26 | watch "k8s.io/apimachinery/pkg/watch" 27 | gentype "k8s.io/client-go/gentype" 28 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 29 | applyconfigurationwardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" 30 | scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" 31 | ) 32 | 33 | // FischersGetter has a method to return a FischerInterface. 34 | // A group's client should implement this interface. 35 | type FischersGetter interface { 36 | Fischers() FischerInterface 37 | } 38 | 39 | // FischerInterface has methods to work with Fischer resources. 40 | type FischerInterface interface { 41 | Create(ctx context.Context, fischer *wardlev1alpha1.Fischer, opts v1.CreateOptions) (*wardlev1alpha1.Fischer, error) 42 | Update(ctx context.Context, fischer *wardlev1alpha1.Fischer, opts v1.UpdateOptions) (*wardlev1alpha1.Fischer, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*wardlev1alpha1.Fischer, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*wardlev1alpha1.FischerList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *wardlev1alpha1.Fischer, err error) 49 | Apply(ctx context.Context, fischer *applyconfigurationwardlev1alpha1.FischerApplyConfiguration, opts v1.ApplyOptions) (result *wardlev1alpha1.Fischer, err error) 50 | FischerExpansion 51 | } 52 | 53 | // fischers implements FischerInterface 54 | type fischers struct { 55 | *gentype.ClientWithListAndApply[*wardlev1alpha1.Fischer, *wardlev1alpha1.FischerList, *applyconfigurationwardlev1alpha1.FischerApplyConfiguration] 56 | } 57 | 58 | // newFischers returns a Fischers 59 | func newFischers(c *WardleV1alpha1Client) *fischers { 60 | return &fischers{ 61 | gentype.NewClientWithListAndApply[*wardlev1alpha1.Fischer, *wardlev1alpha1.FischerList, *applyconfigurationwardlev1alpha1.FischerApplyConfiguration]( 62 | "fischers", 63 | c.RESTClient(), 64 | scheme.ParameterCodec, 65 | "", 66 | func() *wardlev1alpha1.Fischer { return &wardlev1alpha1.Fischer{} }, 67 | func() *wardlev1alpha1.FischerList { return &wardlev1alpha1.FischerList{} }, 68 | ), 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.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 v1alpha1 20 | 21 | import ( 22 | context "context" 23 | 24 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | types "k8s.io/apimachinery/pkg/types" 26 | watch "k8s.io/apimachinery/pkg/watch" 27 | gentype "k8s.io/client-go/gentype" 28 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 29 | applyconfigurationwardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" 30 | scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" 31 | ) 32 | 33 | // FlundersGetter has a method to return a FlunderInterface. 34 | // A group's client should implement this interface. 35 | type FlundersGetter interface { 36 | Flunders(namespace string) FlunderInterface 37 | } 38 | 39 | // FlunderInterface has methods to work with Flunder resources. 40 | type FlunderInterface interface { 41 | Create(ctx context.Context, flunder *wardlev1alpha1.Flunder, opts v1.CreateOptions) (*wardlev1alpha1.Flunder, error) 42 | Update(ctx context.Context, flunder *wardlev1alpha1.Flunder, opts v1.UpdateOptions) (*wardlev1alpha1.Flunder, error) 43 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 44 | UpdateStatus(ctx context.Context, flunder *wardlev1alpha1.Flunder, opts v1.UpdateOptions) (*wardlev1alpha1.Flunder, error) 45 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 46 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 47 | Get(ctx context.Context, name string, opts v1.GetOptions) (*wardlev1alpha1.Flunder, error) 48 | List(ctx context.Context, opts v1.ListOptions) (*wardlev1alpha1.FlunderList, error) 49 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 50 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *wardlev1alpha1.Flunder, err error) 51 | Apply(ctx context.Context, flunder *applyconfigurationwardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *wardlev1alpha1.Flunder, err error) 52 | // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). 53 | ApplyStatus(ctx context.Context, flunder *applyconfigurationwardlev1alpha1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *wardlev1alpha1.Flunder, err error) 54 | FlunderExpansion 55 | } 56 | 57 | // flunders implements FlunderInterface 58 | type flunders struct { 59 | *gentype.ClientWithListAndApply[*wardlev1alpha1.Flunder, *wardlev1alpha1.FlunderList, *applyconfigurationwardlev1alpha1.FlunderApplyConfiguration] 60 | } 61 | 62 | // newFlunders returns a Flunders 63 | func newFlunders(c *WardleV1alpha1Client, namespace string) *flunders { 64 | return &flunders{ 65 | gentype.NewClientWithListAndApply[*wardlev1alpha1.Flunder, *wardlev1alpha1.FlunderList, *applyconfigurationwardlev1alpha1.FlunderApplyConfiguration]( 66 | "flunders", 67 | c.RESTClient(), 68 | scheme.ParameterCodec, 69 | namespace, 70 | func() *wardlev1alpha1.Flunder { return &wardlev1alpha1.Flunder{} }, 71 | func() *wardlev1alpha1.FlunderList { return &wardlev1alpha1.FlunderList{} }, 72 | ), 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1alpha1/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 v1alpha1 20 | 21 | type FischerExpansion interface{} 22 | 23 | type FlunderExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1alpha1/wardle_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 v1alpha1 20 | 21 | import ( 22 | http "net/http" 23 | 24 | rest "k8s.io/client-go/rest" 25 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 26 | scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" 27 | ) 28 | 29 | type WardleV1alpha1Interface interface { 30 | RESTClient() rest.Interface 31 | FischersGetter 32 | FlundersGetter 33 | } 34 | 35 | // WardleV1alpha1Client is used to interact with features provided by the wardle.example.com group. 36 | type WardleV1alpha1Client struct { 37 | restClient rest.Interface 38 | } 39 | 40 | func (c *WardleV1alpha1Client) Fischers() FischerInterface { 41 | return newFischers(c) 42 | } 43 | 44 | func (c *WardleV1alpha1Client) Flunders(namespace string) FlunderInterface { 45 | return newFlunders(c, namespace) 46 | } 47 | 48 | // NewForConfig creates a new WardleV1alpha1Client for the given config. 49 | // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 50 | // where httpClient was generated with rest.HTTPClientFor(c). 51 | func NewForConfig(c *rest.Config) (*WardleV1alpha1Client, error) { 52 | config := *c 53 | setConfigDefaults(&config) 54 | httpClient, err := rest.HTTPClientFor(&config) 55 | if err != nil { 56 | return nil, err 57 | } 58 | return NewForConfigAndClient(&config, httpClient) 59 | } 60 | 61 | // NewForConfigAndClient creates a new WardleV1alpha1Client for the given config and http client. 62 | // Note the http client provided takes precedence over the configured transport values. 63 | func NewForConfigAndClient(c *rest.Config, h *http.Client) (*WardleV1alpha1Client, error) { 64 | config := *c 65 | setConfigDefaults(&config) 66 | client, err := rest.RESTClientForConfigAndClient(&config, h) 67 | if err != nil { 68 | return nil, err 69 | } 70 | return &WardleV1alpha1Client{client}, nil 71 | } 72 | 73 | // NewForConfigOrDie creates a new WardleV1alpha1Client for the given config and 74 | // panics if there is an error in the config. 75 | func NewForConfigOrDie(c *rest.Config) *WardleV1alpha1Client { 76 | client, err := NewForConfig(c) 77 | if err != nil { 78 | panic(err) 79 | } 80 | return client 81 | } 82 | 83 | // New creates a new WardleV1alpha1Client for the given RESTClient. 84 | func New(c rest.Interface) *WardleV1alpha1Client { 85 | return &WardleV1alpha1Client{c} 86 | } 87 | 88 | func setConfigDefaults(config *rest.Config) { 89 | gv := wardlev1alpha1.SchemeGroupVersion 90 | config.GroupVersion = &gv 91 | config.APIPath = "/apis" 92 | config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() 93 | 94 | if config.UserAgent == "" { 95 | config.UserAgent = rest.DefaultKubernetesUserAgent() 96 | } 97 | } 98 | 99 | // RESTClient returns a RESTClient that is used to communicate 100 | // with API server by this client implementation. 101 | func (c *WardleV1alpha1Client) RESTClient() rest.Interface { 102 | if c == nil { 103 | return nil 104 | } 105 | return c.restClient 106 | } 107 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/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/generated/clientset/versioned/typed/wardle/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/generated/clientset/versioned/typed/wardle/v1beta1/fake/fake_flunder.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 | gentype "k8s.io/client-go/gentype" 23 | v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 24 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1" 25 | typedwardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1" 26 | ) 27 | 28 | // fakeFlunders implements FlunderInterface 29 | type fakeFlunders struct { 30 | *gentype.FakeClientWithListAndApply[*v1beta1.Flunder, *v1beta1.FlunderList, *wardlev1beta1.FlunderApplyConfiguration] 31 | Fake *FakeWardleV1beta1 32 | } 33 | 34 | func newFakeFlunders(fake *FakeWardleV1beta1, namespace string) typedwardlev1beta1.FlunderInterface { 35 | return &fakeFlunders{ 36 | gentype.NewFakeClientWithListAndApply[*v1beta1.Flunder, *v1beta1.FlunderList, *wardlev1beta1.FlunderApplyConfiguration]( 37 | fake.Fake, 38 | namespace, 39 | v1beta1.SchemeGroupVersion.WithResource("flunders"), 40 | v1beta1.SchemeGroupVersion.WithKind("Flunder"), 41 | func() *v1beta1.Flunder { return &v1beta1.Flunder{} }, 42 | func() *v1beta1.FlunderList { return &v1beta1.FlunderList{} }, 43 | func(dst, src *v1beta1.FlunderList) { dst.ListMeta = src.ListMeta }, 44 | func(list *v1beta1.FlunderList) []*v1beta1.Flunder { return gentype.ToPointerSlice(list.Items) }, 45 | func(list *v1beta1.FlunderList, items []*v1beta1.Flunder) { 46 | list.Items = gentype.FromPointerSlice(items) 47 | }, 48 | ), 49 | fake, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1beta1/fake/fake_wardle_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 | rest "k8s.io/client-go/rest" 23 | testing "k8s.io/client-go/testing" 24 | v1beta1 "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1" 25 | ) 26 | 27 | type FakeWardleV1beta1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeWardleV1beta1) Flunders(namespace string) v1beta1.FlunderInterface { 32 | return newFakeFlunders(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 *FakeWardleV1beta1) RESTClient() rest.Interface { 38 | var ret *rest.RESTClient 39 | return ret 40 | } 41 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.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 | import ( 22 | context "context" 23 | 24 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | types "k8s.io/apimachinery/pkg/types" 26 | watch "k8s.io/apimachinery/pkg/watch" 27 | gentype "k8s.io/client-go/gentype" 28 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 29 | applyconfigurationwardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1" 30 | scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" 31 | ) 32 | 33 | // FlundersGetter has a method to return a FlunderInterface. 34 | // A group's client should implement this interface. 35 | type FlundersGetter interface { 36 | Flunders(namespace string) FlunderInterface 37 | } 38 | 39 | // FlunderInterface has methods to work with Flunder resources. 40 | type FlunderInterface interface { 41 | Create(ctx context.Context, flunder *wardlev1beta1.Flunder, opts v1.CreateOptions) (*wardlev1beta1.Flunder, error) 42 | Update(ctx context.Context, flunder *wardlev1beta1.Flunder, opts v1.UpdateOptions) (*wardlev1beta1.Flunder, error) 43 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 44 | UpdateStatus(ctx context.Context, flunder *wardlev1beta1.Flunder, opts v1.UpdateOptions) (*wardlev1beta1.Flunder, error) 45 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 46 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 47 | Get(ctx context.Context, name string, opts v1.GetOptions) (*wardlev1beta1.Flunder, error) 48 | List(ctx context.Context, opts v1.ListOptions) (*wardlev1beta1.FlunderList, error) 49 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 50 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *wardlev1beta1.Flunder, err error) 51 | Apply(ctx context.Context, flunder *applyconfigurationwardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *wardlev1beta1.Flunder, err error) 52 | // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). 53 | ApplyStatus(ctx context.Context, flunder *applyconfigurationwardlev1beta1.FlunderApplyConfiguration, opts v1.ApplyOptions) (result *wardlev1beta1.Flunder, err error) 54 | FlunderExpansion 55 | } 56 | 57 | // flunders implements FlunderInterface 58 | type flunders struct { 59 | *gentype.ClientWithListAndApply[*wardlev1beta1.Flunder, *wardlev1beta1.FlunderList, *applyconfigurationwardlev1beta1.FlunderApplyConfiguration] 60 | } 61 | 62 | // newFlunders returns a Flunders 63 | func newFlunders(c *WardleV1beta1Client, namespace string) *flunders { 64 | return &flunders{ 65 | gentype.NewClientWithListAndApply[*wardlev1beta1.Flunder, *wardlev1beta1.FlunderList, *applyconfigurationwardlev1beta1.FlunderApplyConfiguration]( 66 | "flunders", 67 | c.RESTClient(), 68 | scheme.ParameterCodec, 69 | namespace, 70 | func() *wardlev1beta1.Flunder { return &wardlev1beta1.Flunder{} }, 71 | func() *wardlev1beta1.FlunderList { return &wardlev1beta1.FlunderList{} }, 72 | ), 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/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 FlunderExpansion interface{} 22 | -------------------------------------------------------------------------------- /pkg/generated/clientset/versioned/typed/wardle/v1beta1/wardle_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 v1beta1 20 | 21 | import ( 22 | http "net/http" 23 | 24 | rest "k8s.io/client-go/rest" 25 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 26 | scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" 27 | ) 28 | 29 | type WardleV1beta1Interface interface { 30 | RESTClient() rest.Interface 31 | FlundersGetter 32 | } 33 | 34 | // WardleV1beta1Client is used to interact with features provided by the wardle.example.com group. 35 | type WardleV1beta1Client struct { 36 | restClient rest.Interface 37 | } 38 | 39 | func (c *WardleV1beta1Client) Flunders(namespace string) FlunderInterface { 40 | return newFlunders(c, namespace) 41 | } 42 | 43 | // NewForConfig creates a new WardleV1beta1Client for the given config. 44 | // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 45 | // where httpClient was generated with rest.HTTPClientFor(c). 46 | func NewForConfig(c *rest.Config) (*WardleV1beta1Client, error) { 47 | config := *c 48 | setConfigDefaults(&config) 49 | httpClient, err := rest.HTTPClientFor(&config) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return NewForConfigAndClient(&config, httpClient) 54 | } 55 | 56 | // NewForConfigAndClient creates a new WardleV1beta1Client for the given config and http client. 57 | // Note the http client provided takes precedence over the configured transport values. 58 | func NewForConfigAndClient(c *rest.Config, h *http.Client) (*WardleV1beta1Client, error) { 59 | config := *c 60 | setConfigDefaults(&config) 61 | client, err := rest.RESTClientForConfigAndClient(&config, h) 62 | if err != nil { 63 | return nil, err 64 | } 65 | return &WardleV1beta1Client{client}, nil 66 | } 67 | 68 | // NewForConfigOrDie creates a new WardleV1beta1Client for the given config and 69 | // panics if there is an error in the config. 70 | func NewForConfigOrDie(c *rest.Config) *WardleV1beta1Client { 71 | client, err := NewForConfig(c) 72 | if err != nil { 73 | panic(err) 74 | } 75 | return client 76 | } 77 | 78 | // New creates a new WardleV1beta1Client for the given RESTClient. 79 | func New(c rest.Interface) *WardleV1beta1Client { 80 | return &WardleV1beta1Client{c} 81 | } 82 | 83 | func setConfigDefaults(config *rest.Config) { 84 | gv := wardlev1beta1.SchemeGroupVersion 85 | config.GroupVersion = &gv 86 | config.APIPath = "/apis" 87 | config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() 88 | 89 | if config.UserAgent == "" { 90 | config.UserAgent = rest.DefaultKubernetesUserAgent() 91 | } 92 | } 93 | 94 | // RESTClient returns a RESTClient that is used to communicate 95 | // with API server by this client implementation. 96 | func (c *WardleV1beta1Client) RESTClient() rest.Interface { 97 | if c == nil { 98 | return nil 99 | } 100 | return c.restClient 101 | } 102 | -------------------------------------------------------------------------------- /pkg/generated/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 | schema "k8s.io/apimachinery/pkg/runtime/schema" 25 | cache "k8s.io/client-go/tools/cache" 26 | v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 27 | v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 28 | ) 29 | 30 | // GenericInformer is type of SharedIndexInformer which will locate and delegate to other 31 | // sharedInformers based on type 32 | type GenericInformer interface { 33 | Informer() cache.SharedIndexInformer 34 | Lister() cache.GenericLister 35 | } 36 | 37 | type genericInformer struct { 38 | informer cache.SharedIndexInformer 39 | resource schema.GroupResource 40 | } 41 | 42 | // Informer returns the SharedIndexInformer. 43 | func (f *genericInformer) Informer() cache.SharedIndexInformer { 44 | return f.informer 45 | } 46 | 47 | // Lister returns the GenericLister. 48 | func (f *genericInformer) Lister() cache.GenericLister { 49 | return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 50 | } 51 | 52 | // ForResource gives generic access to a shared informer of the matching type 53 | // TODO extend this to unknown resources with a client pool 54 | func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 55 | switch resource { 56 | // Group=wardle.example.com, Version=v1alpha1 57 | case v1alpha1.SchemeGroupVersion.WithResource("fischers"): 58 | return &genericInformer{resource: resource.GroupResource(), informer: f.Wardle().V1alpha1().Fischers().Informer()}, nil 59 | case v1alpha1.SchemeGroupVersion.WithResource("flunders"): 60 | return &genericInformer{resource: resource.GroupResource(), informer: f.Wardle().V1alpha1().Flunders().Informer()}, nil 61 | 62 | // Group=wardle.example.com, Version=v1beta1 63 | case v1beta1.SchemeGroupVersion.WithResource("flunders"): 64 | return &genericInformer{resource: resource.GroupResource(), informer: f.Wardle().V1beta1().Flunders().Informer()}, nil 65 | 66 | } 67 | 68 | return nil, fmt.Errorf("no informer found for %v", resource) 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/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 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | cache "k8s.io/client-go/tools/cache" 27 | versioned "k8s.io/sample-apiserver/pkg/generated/clientset/versioned" 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 | -------------------------------------------------------------------------------- /pkg/generated/informers/externalversions/wardle/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 wardle 20 | 21 | import ( 22 | internalinterfaces "k8s.io/sample-apiserver/pkg/generated/informers/externalversions/internalinterfaces" 23 | v1alpha1 "k8s.io/sample-apiserver/pkg/generated/informers/externalversions/wardle/v1alpha1" 24 | v1beta1 "k8s.io/sample-apiserver/pkg/generated/informers/externalversions/wardle/v1beta1" 25 | ) 26 | 27 | // Interface provides access to each of this group's versions. 28 | type Interface interface { 29 | // V1alpha1 provides access to shared informers for resources in V1alpha1. 30 | V1alpha1() v1alpha1.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 | // V1alpha1 returns a new v1alpha1.Interface. 47 | func (g *group) V1alpha1() v1alpha1.Interface { 48 | return v1alpha1.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/generated/informers/externalversions/wardle/v1alpha1/fischer.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 v1alpha1 20 | 21 | import ( 22 | context "context" 23 | time "time" 24 | 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | runtime "k8s.io/apimachinery/pkg/runtime" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | cache "k8s.io/client-go/tools/cache" 29 | apiswardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 30 | versioned "k8s.io/sample-apiserver/pkg/generated/clientset/versioned" 31 | internalinterfaces "k8s.io/sample-apiserver/pkg/generated/informers/externalversions/internalinterfaces" 32 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/listers/wardle/v1alpha1" 33 | ) 34 | 35 | // FischerInformer provides access to a shared informer and lister for 36 | // Fischers. 37 | type FischerInformer interface { 38 | Informer() cache.SharedIndexInformer 39 | Lister() wardlev1alpha1.FischerLister 40 | } 41 | 42 | type fischerInformer struct { 43 | factory internalinterfaces.SharedInformerFactory 44 | tweakListOptions internalinterfaces.TweakListOptionsFunc 45 | } 46 | 47 | // NewFischerInformer constructs a new informer for Fischer type. 48 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 49 | // one. This reduces memory footprint and number of connections to the server. 50 | func NewFischerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredFischerInformer(client, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredFischerInformer constructs a new informer for Fischer type. 55 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 56 | // one. This reduces memory footprint and number of connections to the server. 57 | func NewFilteredFischerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 58 | return cache.NewSharedIndexInformer( 59 | &cache.ListWatch{ 60 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 61 | if tweakListOptions != nil { 62 | tweakListOptions(&options) 63 | } 64 | return client.WardleV1alpha1().Fischers().List(context.Background(), options) 65 | }, 66 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 67 | if tweakListOptions != nil { 68 | tweakListOptions(&options) 69 | } 70 | return client.WardleV1alpha1().Fischers().Watch(context.Background(), options) 71 | }, 72 | ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { 73 | if tweakListOptions != nil { 74 | tweakListOptions(&options) 75 | } 76 | return client.WardleV1alpha1().Fischers().List(ctx, options) 77 | }, 78 | WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { 79 | if tweakListOptions != nil { 80 | tweakListOptions(&options) 81 | } 82 | return client.WardleV1alpha1().Fischers().Watch(ctx, options) 83 | }, 84 | }, 85 | &apiswardlev1alpha1.Fischer{}, 86 | resyncPeriod, 87 | indexers, 88 | ) 89 | } 90 | 91 | func (f *fischerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 92 | return NewFilteredFischerInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 93 | } 94 | 95 | func (f *fischerInformer) Informer() cache.SharedIndexInformer { 96 | return f.factory.InformerFor(&apiswardlev1alpha1.Fischer{}, f.defaultInformer) 97 | } 98 | 99 | func (f *fischerInformer) Lister() wardlev1alpha1.FischerLister { 100 | return wardlev1alpha1.NewFischerLister(f.Informer().GetIndexer()) 101 | } 102 | -------------------------------------------------------------------------------- /pkg/generated/informers/externalversions/wardle/v1alpha1/flunder.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 v1alpha1 20 | 21 | import ( 22 | context "context" 23 | time "time" 24 | 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | runtime "k8s.io/apimachinery/pkg/runtime" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | cache "k8s.io/client-go/tools/cache" 29 | apiswardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 30 | versioned "k8s.io/sample-apiserver/pkg/generated/clientset/versioned" 31 | internalinterfaces "k8s.io/sample-apiserver/pkg/generated/informers/externalversions/internalinterfaces" 32 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/listers/wardle/v1alpha1" 33 | ) 34 | 35 | // FlunderInformer provides access to a shared informer and lister for 36 | // Flunders. 37 | type FlunderInformer interface { 38 | Informer() cache.SharedIndexInformer 39 | Lister() wardlev1alpha1.FlunderLister 40 | } 41 | 42 | type flunderInformer struct { 43 | factory internalinterfaces.SharedInformerFactory 44 | tweakListOptions internalinterfaces.TweakListOptionsFunc 45 | namespace string 46 | } 47 | 48 | // NewFlunderInformer constructs a new informer for Flunder type. 49 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 50 | // one. This reduces memory footprint and number of connections to the server. 51 | func NewFlunderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 52 | return NewFilteredFlunderInformer(client, namespace, resyncPeriod, indexers, nil) 53 | } 54 | 55 | // NewFilteredFlunderInformer constructs a new informer for Flunder type. 56 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 57 | // one. This reduces memory footprint and number of connections to the server. 58 | func NewFilteredFlunderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 59 | return cache.NewSharedIndexInformer( 60 | &cache.ListWatch{ 61 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 62 | if tweakListOptions != nil { 63 | tweakListOptions(&options) 64 | } 65 | return client.WardleV1alpha1().Flunders(namespace).List(context.Background(), options) 66 | }, 67 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 68 | if tweakListOptions != nil { 69 | tweakListOptions(&options) 70 | } 71 | return client.WardleV1alpha1().Flunders(namespace).Watch(context.Background(), options) 72 | }, 73 | ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { 74 | if tweakListOptions != nil { 75 | tweakListOptions(&options) 76 | } 77 | return client.WardleV1alpha1().Flunders(namespace).List(ctx, options) 78 | }, 79 | WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { 80 | if tweakListOptions != nil { 81 | tweakListOptions(&options) 82 | } 83 | return client.WardleV1alpha1().Flunders(namespace).Watch(ctx, options) 84 | }, 85 | }, 86 | &apiswardlev1alpha1.Flunder{}, 87 | resyncPeriod, 88 | indexers, 89 | ) 90 | } 91 | 92 | func (f *flunderInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 93 | return NewFilteredFlunderInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 94 | } 95 | 96 | func (f *flunderInformer) Informer() cache.SharedIndexInformer { 97 | return f.factory.InformerFor(&apiswardlev1alpha1.Flunder{}, f.defaultInformer) 98 | } 99 | 100 | func (f *flunderInformer) Lister() wardlev1alpha1.FlunderLister { 101 | return wardlev1alpha1.NewFlunderLister(f.Informer().GetIndexer()) 102 | } 103 | -------------------------------------------------------------------------------- /pkg/generated/informers/externalversions/wardle/v1alpha1/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 v1alpha1 20 | 21 | import ( 22 | internalinterfaces "k8s.io/sample-apiserver/pkg/generated/informers/externalversions/internalinterfaces" 23 | ) 24 | 25 | // Interface provides access to all the informers in this group version. 26 | type Interface interface { 27 | // Fischers returns a FischerInformer. 28 | Fischers() FischerInformer 29 | // Flunders returns a FlunderInformer. 30 | Flunders() FlunderInformer 31 | } 32 | 33 | type version struct { 34 | factory internalinterfaces.SharedInformerFactory 35 | namespace string 36 | tweakListOptions internalinterfaces.TweakListOptionsFunc 37 | } 38 | 39 | // New returns a new Interface. 40 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 41 | return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 42 | } 43 | 44 | // Fischers returns a FischerInformer. 45 | func (v *version) Fischers() FischerInformer { 46 | return &fischerInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} 47 | } 48 | 49 | // Flunders returns a FlunderInformer. 50 | func (v *version) Flunders() FlunderInformer { 51 | return &flunderInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} 52 | } 53 | -------------------------------------------------------------------------------- /pkg/generated/informers/externalversions/wardle/v1beta1/flunder.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 | context "context" 23 | time "time" 24 | 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | runtime "k8s.io/apimachinery/pkg/runtime" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | cache "k8s.io/client-go/tools/cache" 29 | apiswardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 30 | versioned "k8s.io/sample-apiserver/pkg/generated/clientset/versioned" 31 | internalinterfaces "k8s.io/sample-apiserver/pkg/generated/informers/externalversions/internalinterfaces" 32 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/listers/wardle/v1beta1" 33 | ) 34 | 35 | // FlunderInformer provides access to a shared informer and lister for 36 | // Flunders. 37 | type FlunderInformer interface { 38 | Informer() cache.SharedIndexInformer 39 | Lister() wardlev1beta1.FlunderLister 40 | } 41 | 42 | type flunderInformer struct { 43 | factory internalinterfaces.SharedInformerFactory 44 | tweakListOptions internalinterfaces.TweakListOptionsFunc 45 | namespace string 46 | } 47 | 48 | // NewFlunderInformer constructs a new informer for Flunder type. 49 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 50 | // one. This reduces memory footprint and number of connections to the server. 51 | func NewFlunderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 52 | return NewFilteredFlunderInformer(client, namespace, resyncPeriod, indexers, nil) 53 | } 54 | 55 | // NewFilteredFlunderInformer constructs a new informer for Flunder type. 56 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 57 | // one. This reduces memory footprint and number of connections to the server. 58 | func NewFilteredFlunderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 59 | return cache.NewSharedIndexInformer( 60 | &cache.ListWatch{ 61 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 62 | if tweakListOptions != nil { 63 | tweakListOptions(&options) 64 | } 65 | return client.WardleV1beta1().Flunders(namespace).List(context.Background(), options) 66 | }, 67 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 68 | if tweakListOptions != nil { 69 | tweakListOptions(&options) 70 | } 71 | return client.WardleV1beta1().Flunders(namespace).Watch(context.Background(), options) 72 | }, 73 | ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { 74 | if tweakListOptions != nil { 75 | tweakListOptions(&options) 76 | } 77 | return client.WardleV1beta1().Flunders(namespace).List(ctx, options) 78 | }, 79 | WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { 80 | if tweakListOptions != nil { 81 | tweakListOptions(&options) 82 | } 83 | return client.WardleV1beta1().Flunders(namespace).Watch(ctx, options) 84 | }, 85 | }, 86 | &apiswardlev1beta1.Flunder{}, 87 | resyncPeriod, 88 | indexers, 89 | ) 90 | } 91 | 92 | func (f *flunderInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 93 | return NewFilteredFlunderInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 94 | } 95 | 96 | func (f *flunderInformer) Informer() cache.SharedIndexInformer { 97 | return f.factory.InformerFor(&apiswardlev1beta1.Flunder{}, f.defaultInformer) 98 | } 99 | 100 | func (f *flunderInformer) Lister() wardlev1beta1.FlunderLister { 101 | return wardlev1beta1.NewFlunderLister(f.Informer().GetIndexer()) 102 | } 103 | -------------------------------------------------------------------------------- /pkg/generated/informers/externalversions/wardle/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/sample-apiserver/pkg/generated/informers/externalversions/internalinterfaces" 23 | ) 24 | 25 | // Interface provides access to all the informers in this group version. 26 | type Interface interface { 27 | // Flunders returns a FlunderInformer. 28 | Flunders() FlunderInformer 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 | // Flunders returns a FlunderInformer. 43 | func (v *version) Flunders() FlunderInformer { 44 | return &flunderInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} 45 | } 46 | -------------------------------------------------------------------------------- /pkg/generated/listers/wardle/v1alpha1/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 v1alpha1 20 | 21 | // FischerListerExpansion allows custom methods to be added to 22 | // FischerLister. 23 | type FischerListerExpansion interface{} 24 | 25 | // FlunderListerExpansion allows custom methods to be added to 26 | // FlunderLister. 27 | type FlunderListerExpansion interface{} 28 | 29 | // FlunderNamespaceListerExpansion allows custom methods to be added to 30 | // FlunderNamespaceLister. 31 | type FlunderNamespaceListerExpansion interface{} 32 | -------------------------------------------------------------------------------- /pkg/generated/listers/wardle/v1alpha1/fischer.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 v1alpha1 20 | 21 | import ( 22 | labels "k8s.io/apimachinery/pkg/labels" 23 | listers "k8s.io/client-go/listers" 24 | cache "k8s.io/client-go/tools/cache" 25 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 26 | ) 27 | 28 | // FischerLister helps list Fischers. 29 | // All objects returned here must be treated as read-only. 30 | type FischerLister interface { 31 | // List lists all Fischers in the indexer. 32 | // Objects returned here must be treated as read-only. 33 | List(selector labels.Selector) (ret []*wardlev1alpha1.Fischer, err error) 34 | // Get retrieves the Fischer from the index for a given name. 35 | // Objects returned here must be treated as read-only. 36 | Get(name string) (*wardlev1alpha1.Fischer, error) 37 | FischerListerExpansion 38 | } 39 | 40 | // fischerLister implements the FischerLister interface. 41 | type fischerLister struct { 42 | listers.ResourceIndexer[*wardlev1alpha1.Fischer] 43 | } 44 | 45 | // NewFischerLister returns a new FischerLister. 46 | func NewFischerLister(indexer cache.Indexer) FischerLister { 47 | return &fischerLister{listers.New[*wardlev1alpha1.Fischer](indexer, wardlev1alpha1.Resource("fischer"))} 48 | } 49 | -------------------------------------------------------------------------------- /pkg/generated/listers/wardle/v1alpha1/flunder.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 v1alpha1 20 | 21 | import ( 22 | labels "k8s.io/apimachinery/pkg/labels" 23 | listers "k8s.io/client-go/listers" 24 | cache "k8s.io/client-go/tools/cache" 25 | wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" 26 | ) 27 | 28 | // FlunderLister helps list Flunders. 29 | // All objects returned here must be treated as read-only. 30 | type FlunderLister interface { 31 | // List lists all Flunders in the indexer. 32 | // Objects returned here must be treated as read-only. 33 | List(selector labels.Selector) (ret []*wardlev1alpha1.Flunder, err error) 34 | // Flunders returns an object that can list and get Flunders. 35 | Flunders(namespace string) FlunderNamespaceLister 36 | FlunderListerExpansion 37 | } 38 | 39 | // flunderLister implements the FlunderLister interface. 40 | type flunderLister struct { 41 | listers.ResourceIndexer[*wardlev1alpha1.Flunder] 42 | } 43 | 44 | // NewFlunderLister returns a new FlunderLister. 45 | func NewFlunderLister(indexer cache.Indexer) FlunderLister { 46 | return &flunderLister{listers.New[*wardlev1alpha1.Flunder](indexer, wardlev1alpha1.Resource("flunder"))} 47 | } 48 | 49 | // Flunders returns an object that can list and get Flunders. 50 | func (s *flunderLister) Flunders(namespace string) FlunderNamespaceLister { 51 | return flunderNamespaceLister{listers.NewNamespaced[*wardlev1alpha1.Flunder](s.ResourceIndexer, namespace)} 52 | } 53 | 54 | // FlunderNamespaceLister helps list and get Flunders. 55 | // All objects returned here must be treated as read-only. 56 | type FlunderNamespaceLister interface { 57 | // List lists all Flunders in the indexer for a given namespace. 58 | // Objects returned here must be treated as read-only. 59 | List(selector labels.Selector) (ret []*wardlev1alpha1.Flunder, err error) 60 | // Get retrieves the Flunder from the indexer for a given namespace and name. 61 | // Objects returned here must be treated as read-only. 62 | Get(name string) (*wardlev1alpha1.Flunder, error) 63 | FlunderNamespaceListerExpansion 64 | } 65 | 66 | // flunderNamespaceLister implements the FlunderNamespaceLister 67 | // interface. 68 | type flunderNamespaceLister struct { 69 | listers.ResourceIndexer[*wardlev1alpha1.Flunder] 70 | } 71 | -------------------------------------------------------------------------------- /pkg/generated/listers/wardle/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 | // FlunderListerExpansion allows custom methods to be added to 22 | // FlunderLister. 23 | type FlunderListerExpansion interface{} 24 | 25 | // FlunderNamespaceListerExpansion allows custom methods to be added to 26 | // FlunderNamespaceLister. 27 | type FlunderNamespaceListerExpansion interface{} 28 | -------------------------------------------------------------------------------- /pkg/generated/listers/wardle/v1beta1/flunder.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 | labels "k8s.io/apimachinery/pkg/labels" 23 | listers "k8s.io/client-go/listers" 24 | cache "k8s.io/client-go/tools/cache" 25 | wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" 26 | ) 27 | 28 | // FlunderLister helps list Flunders. 29 | // All objects returned here must be treated as read-only. 30 | type FlunderLister interface { 31 | // List lists all Flunders in the indexer. 32 | // Objects returned here must be treated as read-only. 33 | List(selector labels.Selector) (ret []*wardlev1beta1.Flunder, err error) 34 | // Flunders returns an object that can list and get Flunders. 35 | Flunders(namespace string) FlunderNamespaceLister 36 | FlunderListerExpansion 37 | } 38 | 39 | // flunderLister implements the FlunderLister interface. 40 | type flunderLister struct { 41 | listers.ResourceIndexer[*wardlev1beta1.Flunder] 42 | } 43 | 44 | // NewFlunderLister returns a new FlunderLister. 45 | func NewFlunderLister(indexer cache.Indexer) FlunderLister { 46 | return &flunderLister{listers.New[*wardlev1beta1.Flunder](indexer, wardlev1beta1.Resource("flunder"))} 47 | } 48 | 49 | // Flunders returns an object that can list and get Flunders. 50 | func (s *flunderLister) Flunders(namespace string) FlunderNamespaceLister { 51 | return flunderNamespaceLister{listers.NewNamespaced[*wardlev1beta1.Flunder](s.ResourceIndexer, namespace)} 52 | } 53 | 54 | // FlunderNamespaceLister helps list and get Flunders. 55 | // All objects returned here must be treated as read-only. 56 | type FlunderNamespaceLister interface { 57 | // List lists all Flunders in the indexer for a given namespace. 58 | // Objects returned here must be treated as read-only. 59 | List(selector labels.Selector) (ret []*wardlev1beta1.Flunder, err error) 60 | // Get retrieves the Flunder from the indexer for a given namespace and name. 61 | // Objects returned here must be treated as read-only. 62 | Get(name string) (*wardlev1beta1.Flunder, error) 63 | FlunderNamespaceListerExpansion 64 | } 65 | 66 | // flunderNamespaceLister implements the FlunderNamespaceLister 67 | // interface. 68 | type flunderNamespaceLister struct { 69 | listers.ResourceIndexer[*wardlev1beta1.Flunder] 70 | } 71 | -------------------------------------------------------------------------------- /pkg/registry/registry.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 registry 18 | 19 | import ( 20 | "fmt" 21 | 22 | genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" 23 | ) 24 | 25 | // REST implements a RESTStorage for API services against etcd 26 | type REST struct { 27 | *genericregistry.Store 28 | } 29 | 30 | // RESTInPeace is just a simple function that panics on error. 31 | // Otherwise returns the given storage object. It is meant to be 32 | // a wrapper for wardle registries. 33 | func RESTInPeace(storage *REST, err error) *REST { 34 | if err != nil { 35 | err = fmt.Errorf("unable to create REST storage for a resource due to %v, will die", err) 36 | panic(err) 37 | } 38 | return storage 39 | } 40 | -------------------------------------------------------------------------------- /pkg/registry/wardle/fischer/etcd.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 fischer 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "k8s.io/apiserver/pkg/registry/generic" 22 | genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" 23 | "k8s.io/apiserver/pkg/registry/rest" 24 | "k8s.io/sample-apiserver/pkg/apis/wardle" 25 | "k8s.io/sample-apiserver/pkg/registry" 26 | ) 27 | 28 | // NewREST returns a RESTStorage object that will work against API services. 29 | func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*registry.REST, error) { 30 | strategy := NewStrategy(scheme) 31 | 32 | store := &genericregistry.Store{ 33 | NewFunc: func() runtime.Object { return &wardle.Fischer{} }, 34 | NewListFunc: func() runtime.Object { return &wardle.FischerList{} }, 35 | PredicateFunc: MatchFischer, 36 | DefaultQualifiedResource: wardle.Resource("fischers"), 37 | SingularQualifiedResource: wardle.Resource("fischer"), 38 | 39 | CreateStrategy: strategy, 40 | UpdateStrategy: strategy, 41 | DeleteStrategy: strategy, 42 | 43 | // TODO: define table converter that exposes more than name/creation timestamp 44 | TableConvertor: rest.NewDefaultTableConvertor(wardle.Resource("fischers")), 45 | } 46 | options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} 47 | if err := store.CompleteWithOptions(options); err != nil { 48 | return nil, err 49 | } 50 | return ®istry.REST{Store: store}, nil 51 | } 52 | -------------------------------------------------------------------------------- /pkg/registry/wardle/fischer/strategy.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 fischer 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | 23 | "k8s.io/apimachinery/pkg/fields" 24 | "k8s.io/apimachinery/pkg/labels" 25 | "k8s.io/apimachinery/pkg/runtime" 26 | "k8s.io/apimachinery/pkg/util/validation/field" 27 | "k8s.io/apiserver/pkg/registry/generic" 28 | "k8s.io/apiserver/pkg/storage" 29 | "k8s.io/apiserver/pkg/storage/names" 30 | 31 | "k8s.io/sample-apiserver/pkg/apis/wardle" 32 | ) 33 | 34 | // NewStrategy creates and returns a fischerStrategy instance 35 | func NewStrategy(typer runtime.ObjectTyper) fischerStrategy { 36 | return fischerStrategy{typer, names.SimpleNameGenerator} 37 | } 38 | 39 | // GetAttrs returns labels.Set, fields.Set, and error in case the given runtime.Object is not a Fischer 40 | func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { 41 | apiserver, ok := obj.(*wardle.Fischer) 42 | if !ok { 43 | return nil, nil, fmt.Errorf("given object is not a Fischer") 44 | } 45 | return labels.Set(apiserver.ObjectMeta.Labels), SelectableFields(apiserver), nil 46 | } 47 | 48 | // MatchFischer is the filter used by the generic etcd backend to watch events 49 | // from etcd to clients of the apiserver only interested in specific labels/fields. 50 | func MatchFischer(label labels.Selector, field fields.Selector) storage.SelectionPredicate { 51 | return storage.SelectionPredicate{ 52 | Label: label, 53 | Field: field, 54 | GetAttrs: GetAttrs, 55 | } 56 | } 57 | 58 | // SelectableFields returns a field set that represents the object. 59 | func SelectableFields(obj *wardle.Fischer) fields.Set { 60 | return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true) 61 | } 62 | 63 | type fischerStrategy struct { 64 | runtime.ObjectTyper 65 | names.NameGenerator 66 | } 67 | 68 | func (fischerStrategy) NamespaceScoped() bool { 69 | return false 70 | } 71 | 72 | func (fischerStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { 73 | } 74 | 75 | func (fischerStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { 76 | } 77 | 78 | func (fischerStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { 79 | return field.ErrorList{} 80 | } 81 | 82 | // WarningsOnCreate returns warnings for the creation of the given object. 83 | func (fischerStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil } 84 | 85 | func (fischerStrategy) AllowCreateOnUpdate() bool { 86 | return false 87 | } 88 | 89 | func (fischerStrategy) AllowUnconditionalUpdate() bool { 90 | return false 91 | } 92 | 93 | func (fischerStrategy) Canonicalize(obj runtime.Object) { 94 | } 95 | 96 | func (fischerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { 97 | return field.ErrorList{} 98 | } 99 | 100 | // WarningsOnUpdate returns warnings for the given update. 101 | func (fischerStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { 102 | return nil 103 | } 104 | -------------------------------------------------------------------------------- /pkg/registry/wardle/flunder/etcd.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 flunder 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "k8s.io/apiserver/pkg/registry/generic" 22 | genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" 23 | "k8s.io/apiserver/pkg/registry/rest" 24 | "k8s.io/sample-apiserver/pkg/apis/wardle" 25 | "k8s.io/sample-apiserver/pkg/registry" 26 | ) 27 | 28 | // NewREST returns a RESTStorage object that will work against API services. 29 | func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*registry.REST, error) { 30 | strategy := NewStrategy(scheme) 31 | 32 | store := &genericregistry.Store{ 33 | NewFunc: func() runtime.Object { return &wardle.Flunder{} }, 34 | NewListFunc: func() runtime.Object { return &wardle.FlunderList{} }, 35 | PredicateFunc: MatchFlunder, 36 | DefaultQualifiedResource: wardle.Resource("flunders"), 37 | SingularQualifiedResource: wardle.Resource("flunder"), 38 | 39 | CreateStrategy: strategy, 40 | UpdateStrategy: strategy, 41 | DeleteStrategy: strategy, 42 | 43 | // TODO: define table converter that exposes more than name/creation timestamp 44 | TableConvertor: rest.NewDefaultTableConvertor(wardle.Resource("flunders")), 45 | } 46 | options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs} 47 | if err := store.CompleteWithOptions(options); err != nil { 48 | return nil, err 49 | } 50 | return ®istry.REST{Store: store}, nil 51 | } 52 | -------------------------------------------------------------------------------- /pkg/registry/wardle/flunder/strategy.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 flunder 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | 23 | "k8s.io/apimachinery/pkg/fields" 24 | "k8s.io/apimachinery/pkg/labels" 25 | "k8s.io/apimachinery/pkg/runtime" 26 | "k8s.io/apimachinery/pkg/util/validation/field" 27 | "k8s.io/apiserver/pkg/registry/generic" 28 | "k8s.io/apiserver/pkg/storage" 29 | "k8s.io/apiserver/pkg/storage/names" 30 | "k8s.io/sample-apiserver/pkg/apis/wardle/validation" 31 | 32 | "k8s.io/sample-apiserver/pkg/apis/wardle" 33 | ) 34 | 35 | // NewStrategy creates and returns a flunderStrategy instance 36 | func NewStrategy(typer runtime.ObjectTyper) flunderStrategy { 37 | return flunderStrategy{typer, names.SimpleNameGenerator} 38 | } 39 | 40 | // GetAttrs returns labels.Set, fields.Set, and error in case the given runtime.Object is not a Flunder 41 | func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) { 42 | apiserver, ok := obj.(*wardle.Flunder) 43 | if !ok { 44 | return nil, nil, fmt.Errorf("given object is not a Flunder") 45 | } 46 | return labels.Set(apiserver.ObjectMeta.Labels), SelectableFields(apiserver), nil 47 | } 48 | 49 | // MatchFlunder is the filter used by the generic etcd backend to watch events 50 | // from etcd to clients of the apiserver only interested in specific labels/fields. 51 | func MatchFlunder(label labels.Selector, field fields.Selector) storage.SelectionPredicate { 52 | return storage.SelectionPredicate{ 53 | Label: label, 54 | Field: field, 55 | GetAttrs: GetAttrs, 56 | } 57 | } 58 | 59 | // SelectableFields returns a field set that represents the object. 60 | func SelectableFields(obj *wardle.Flunder) fields.Set { 61 | return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true) 62 | } 63 | 64 | type flunderStrategy struct { 65 | runtime.ObjectTyper 66 | names.NameGenerator 67 | } 68 | 69 | func (flunderStrategy) NamespaceScoped() bool { 70 | return true 71 | } 72 | 73 | func (flunderStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { 74 | } 75 | 76 | func (flunderStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) { 77 | } 78 | 79 | func (flunderStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList { 80 | flunder := obj.(*wardle.Flunder) 81 | return validation.ValidateFlunder(flunder) 82 | } 83 | 84 | // WarningsOnCreate returns warnings for the creation of the given object. 85 | func (flunderStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil } 86 | 87 | func (flunderStrategy) AllowCreateOnUpdate() bool { 88 | return false 89 | } 90 | 91 | func (flunderStrategy) AllowUnconditionalUpdate() bool { 92 | return false 93 | } 94 | 95 | func (flunderStrategy) Canonicalize(obj runtime.Object) { 96 | } 97 | 98 | func (flunderStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList { 99 | return field.ErrorList{} 100 | } 101 | 102 | // WarningsOnUpdate returns warnings for the given update. 103 | func (flunderStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { 104 | return nil 105 | } 106 | --------------------------------------------------------------------------------