verify-generated-device-plugin.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env bash
  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. # This script checks whether updating of device plugin API is needed or not. We
  16. # should run `hack/update-generated-device-plugin.sh` if device plugin API is
  17. # out of date.
  18. # Usage: `hack/verify-generated-device-plugin.sh`.
  19. set -o errexit
  20. set -o nounset
  21. set -o pipefail
  22. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
  23. ERROR="Device plugin api is out of date. Please run hack/update-generated-device-plugin.sh"
  24. DEVICE_PLUGIN_ALPHA="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1alpha/"
  25. DEVICE_PLUGIN_V1BETA1="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/"
  26. source "${KUBE_ROOT}/hack/lib/protoc.sh"
  27. kube::golang::setup_env
  28. function cleanup {
  29. rm -rf "${DEVICE_PLUGIN_ALPHA}/_tmp/"
  30. rm -rf "${DEVICE_PLUGIN_V1BETA1}/_tmp/"
  31. }
  32. trap cleanup EXIT
  33. mkdir -p "${DEVICE_PLUGIN_ALPHA}/_tmp"
  34. cp "${DEVICE_PLUGIN_ALPHA}/api.pb.go" "${DEVICE_PLUGIN_ALPHA}/_tmp/"
  35. mkdir -p "${DEVICE_PLUGIN_V1BETA1}/_tmp"
  36. cp "${DEVICE_PLUGIN_V1BETA1}/api.pb.go" "${DEVICE_PLUGIN_V1BETA1}/_tmp/"
  37. KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-device-plugin.sh"
  38. kube::protoc::diff "${DEVICE_PLUGIN_ALPHA}/api.pb.go" "${DEVICE_PLUGIN_ALPHA}/_tmp/api.pb.go" "${ERROR}"
  39. echo "Generated device plugin alpha api is up to date."
  40. kube::protoc::diff "${DEVICE_PLUGIN_V1BETA1}/api.pb.go" "${DEVICE_PLUGIN_V1BETA1}/_tmp/api.pb.go" "${ERROR}"
  41. echo "Generated device plugin beta api is up to date."