summaryrefslogtreecommitdiff
path: root/hack
diff options
context:
space:
mode:
authorzhu733756 <talonzhu@yunify.com>2021-10-08 11:20:35 +0800
committerzhu733756 <talonzhu@yunify.com>2021-10-08 13:05:29 +0800
commitbc3cc88b39784e8981b9223b675787ff37f0bea7 (patch)
tree8fd9cfce8f5de5e5405718d67e4a0eaccafba867 /hack
parentbetter code style (diff)
downloadkubeedge-bc3cc88b39784e8981b9223b675787ff37f0bea7.tar.gz
Add kubebuilder comments to support enum and subresource
Signed-off-by: zhu733756 <talonzhu@yunify.com>
Diffstat (limited to 'hack')
-rwxr-xr-xhack/generate-crds.sh17
-rwxr-xr-xhack/verify-crds.sh66
2 files changed, 46 insertions, 37 deletions
diff --git a/hack/generate-crds.sh b/hack/generate-crds.sh
index f60fcbe09..009a6a27f 100755
--- a/hack/generate-crds.sh
+++ b/hack/generate-crds.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright 2020 The KubeEdge Authors
+# Copyright 2021 The KubeEdge Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -49,11 +49,11 @@ while [ $# -gt 0 ]; do
shift
done
-function :prepare:install: {
+function :pre:install: {
# install controller-gen tool if not exsit
- if [ $(which controller-gen) == "" ]; then
+ if [ "$(which controller-gen)" == "" ]; then
echo "Start to install controller-gen tool"
- GO111MODULE=on go get -v sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2
+ GO111MODULE=on go install -v sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2
fi
}
@@ -62,7 +62,7 @@ function :gen:crds: {
$(which controller-gen) paths="./..." ${_crdOptions} output:crd:artifacts:config=${_tmpdir}
}
-function :copy:to:targets {
+function :copy:to:destination {
# rename files, copy files
mkdir -p ${CRD_OUTPUTS}/devices
mkdir -p ${CRD_OUTPUTS}/reliablesyncs
@@ -92,7 +92,10 @@ function cleanup {
rm -rf "${_tmpdir}"
}
-:prepare:install:
+:pre:install:
+
:gen:crds:
-:copy:to:targets
+
+:copy:to:destination
+
cleanup \ No newline at end of file
diff --git a/hack/verify-crds.sh b/hack/verify-crds.sh
index 2aeab65ca..1460879b8 100755
--- a/hack/verify-crds.sh
+++ b/hack/verify-crds.sh
@@ -1,43 +1,49 @@
-#!/usr/bin/env bash
+#!/bin/bash
-###
-#Copyright 2021 The KubeEdge Authors.
+# Copyright 2021 The KubeEdge Authors.
#
-#Licensed under the Apache License, Version 2.0 (the "License");
-#you may not use this file except in compliance with the License.
-#You may obtain a copy of the License at
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
-#Unless required by applicable law or agreed to in writing, software
-#distributed under the License is distributed on an "AS IS" BASIS,
-#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#See the License for the specific language governing permissions and
-#limitations under the License.
-###
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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
-# The root of the build/dist directory
-KUBEEDGE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
-CRD_OUTPUTS="${KUBEEDGE_ROOT}/build/crds"
-REQUIRED_VERSION="v1"
+SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
-echo "Start to check CRDs version..."
+DIFFROOT="${SCRIPT_ROOT}/build/crds"
+TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/build/crds"
+_tmp="${SCRIPT_ROOT}/_tmp"
-for entry in `ls ${CRD_OUTPUTS}/*/*.yaml`; do
- CRD_NAME=`echo ${entry} | awk -F '/' '{print $NF}'`
- if [ "$CRD_NAME" != "devices_v1alpha1_device.yaml" ] && [ "$CRD_NAME" != "devices_v1alpha1_devicemodel.yaml" ]; then
- echo "checking CRD ${CRD_NAME}..."
- version=`cat $entry | grep "apiVersion" | head -1 | awk -F '/' '{print $2}'`
- if [ "$version" != "${REQUIRED_VERSION}" ]; then
- echo "CRD ${CRD_NAME} version does not equal v1"
- exit 1
- fi
- fi
-done
+cleanup() {
+ rm -rf "${_tmp}"
+}
+trap "cleanup" EXIT SIGINT
-echo "Finished, all CRDs version sucessfully..."
+cleanup
+
+mkdir -p "${TMP_DIFFROOT}"
+cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
+
+"${SCRIPT_ROOT}/hack/generate-crds.sh"
+echo "diffing ${DIFFROOT} against freshly generated crds"
+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/generate-crds.sh"
+ exit 1
+fi