update-stable-metrics.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. # Copyright 2019 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
  19. BAZEL_OUT_DIR="$KUBE_ROOT/bazel-bin"
  20. BAZEL_GEN_DIR="$KUBE_ROOT/bazel-genfiles"
  21. METRICS_LIST_PATH="test/instrumentation/stable-metrics-list.yaml"
  22. bazel build //test/instrumentation:list_stable_metrics
  23. if [ -d "$BAZEL_OUT_DIR" ]; then
  24. cp "$BAZEL_OUT_DIR/$METRICS_LIST_PATH" "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml"
  25. else
  26. # Handle bazel < 0.25
  27. # https://github.com/bazelbuild/bazel/issues/6761
  28. echo "$BAZEL_OUT_DIR not found trying $BAZEL_GEN_DIR"
  29. cp "$BAZEL_GEN_DIR/$METRICS_LIST_PATH" "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml"
  30. fi