mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 02:08:13 +00:00 
			
		
		
		
	Enable client-gen for k8s.io/metrics
This commit turns on client-gen for k8s.io/metrics. Clients are generated for `k8s.io/metrics/pkg/apis/metrics` (both internal and v1alpha1). `k8s.io/metrics/pkg/apis/custom_metrics` uses a bespoke client due to the unique nature of its paths.
This commit is contained in:
		| @@ -104,3 +104,4 @@ ${informergen} \ | ||||
| vendor/k8s.io/kube-aggregator/hack/update-codegen.sh | ||||
| vendor/k8s.io/sample-apiserver/hack/update-codegen.sh | ||||
| vendor/k8s.io/kube-apiextensions-server/hack/update-codegen.sh | ||||
| vendor/k8s.io/metrics/hack/update-codegen.sh | ||||
|   | ||||
| @@ -27,6 +27,7 @@ kube::golang::setup_env | ||||
| vendor/k8s.io/kube-aggregator/hack/verify-codegen.sh | ||||
| vendor/k8s.io/sample-apiserver/hack/verify-codegen.sh | ||||
| vendor/k8s.io/kube-apiextensions-server/hack/verify-codegen.sh | ||||
| vendor/k8s.io/metrics/hack/verify-codegen.sh | ||||
|  | ||||
| "${KUBE_ROOT}/hack/update-codegen.sh" --verify-only | ||||
|  | ||||
|   | ||||
							
								
								
									
										42
									
								
								staging/src/k8s.io/metrics/hack/update-codegen.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										42
									
								
								staging/src/k8s.io/metrics/hack/update-codegen.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Copyright 2017 The Kubernetes Authors. | ||||
| # | ||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| # you may not use this file except in compliance with the License. | ||||
| # You may obtain a copy of the License at | ||||
| # | ||||
| #     http://www.apache.org/licenses/LICENSE-2.0 | ||||
| # | ||||
| # Unless required by applicable law or agreed to in writing, software | ||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| # See the License for the specific language governing permissions and | ||||
| # limitations under the License. | ||||
|  | ||||
| set -o errexit | ||||
| set -o nounset | ||||
| set -o pipefail | ||||
|  | ||||
| KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../../../.. | ||||
| METRICS_ROOT=$(dirname "${BASH_SOURCE}")/.. | ||||
| source "${KUBE_ROOT}/hack/lib/init.sh" | ||||
|  | ||||
| # Register function to be called on EXIT to remove generated binary. | ||||
| function cleanup { | ||||
|   rm -f "${CLIENTGEN:-}" | ||||
| } | ||||
| trap cleanup EXIT | ||||
|  | ||||
| echo "Building client-gen" | ||||
| CLIENTGEN="${PWD}/client-gen-binary" | ||||
| go build -o "${CLIENTGEN}" ./cmd/libs/go2idl/client-gen | ||||
|  | ||||
| PREFIX=k8s.io/metrics/pkg/apis | ||||
| INPUT_BASE="--input-base ${PREFIX}" | ||||
| CLIENTSET_PATH="--clientset-path k8s.io/metrics/pkg/client/clientset_generated" | ||||
|  | ||||
| ${CLIENTGEN} --clientset-name="clientset" ${INPUT_BASE} --input metrics/v1alpha1 ${CLIENTSET_PATH} --output-base ${KUBE_ROOT}/vendor | ||||
|  | ||||
| # we skip informers and listers for metrics, because we don't quite support the requisite operations yet | ||||
| # we skip generating the internal clientset as it's not really needed | ||||
							
								
								
									
										51
									
								
								staging/src/k8s.io/metrics/hack/verify-codegen.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										51
									
								
								staging/src/k8s.io/metrics/hack/verify-codegen.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Copyright 2017 The Kubernetes Authors. | ||||
| # | ||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| # you may not use this file except in compliance with the License. | ||||
| # You may obtain a copy of the License at | ||||
| # | ||||
| #     http://www.apache.org/licenses/LICENSE-2.0 | ||||
| # | ||||
| # Unless required by applicable law or agreed to in writing, software | ||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| # See the License for the specific language governing permissions and | ||||
| # limitations under the License. | ||||
|  | ||||
| set -o errexit | ||||
| set -o nounset | ||||
| set -o pipefail | ||||
|  | ||||
| KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../../../.. | ||||
| METRICS_ROOT=$(dirname "${BASH_SOURCE}")/.. | ||||
| source "${KUBE_ROOT}/hack/lib/init.sh" | ||||
|  | ||||
| DIFFROOT="${METRICS_ROOT}/pkg" | ||||
| TMP_DIFFROOT="${METRICS_ROOT}/_tmp/pkg" | ||||
| _tmp="${METRICS_ROOT}/_tmp" | ||||
|  | ||||
| cleanup() { | ||||
|   rm -rf "${_tmp}" | ||||
| } | ||||
| trap "cleanup" EXIT SIGINT | ||||
|  | ||||
| cleanup | ||||
|  | ||||
| mkdir -p "${TMP_DIFFROOT}" | ||||
| cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" | ||||
|  | ||||
| "${METRICS_ROOT}/hack/update-codegen.sh" | ||||
| echo "diffing ${DIFFROOT} against freshly generated codegen" | ||||
| ret=0 | ||||
| diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? | ||||
| cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" | ||||
| if [[ $ret -eq 0 ]] | ||||
| then | ||||
|   echo "${DIFFROOT} up to date." | ||||
| else | ||||
|   echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Solly Ross
					Solly Ross