From 2393799e2efc05a1940e9f623d1309eecea0994d Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Tue, 5 Feb 2019 17:36:35 +0100 Subject: [PATCH] hack/update-openapi-spec.sh: normalize indention of spec through jq --- hack/lib/util.sh | 20 ++++++++++++++------ hack/update-openapi-spec.sh | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 0415f3a9d8..9d058c205e 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -339,10 +339,9 @@ kube::util::create-fake-git-tree() { kube::util::godep_restored() { local -r godeps_json=${1:-Godeps/Godeps.json} local -r gopath=${2:-${GOPATH%:*}} - if ! which jq &>/dev/null; then - echo "jq not found. Please install." 1>&2 - return 1 - fi + + kube::util::require-jq + local root local old_rev="" while read path rev; do @@ -461,7 +460,7 @@ kube::util::base_ref() { fi full_branch="$(kube::util::git_upstream_remote_name)/${git_branch}" - + # make sure the branch is valid, otherwise the check will pass erroneously. if ! git describe "${full_branch}" >/dev/null; then # abort! @@ -479,7 +478,7 @@ kube::util::has_changes() { local -r git_branch=$1 local -r pattern=$2 local -r not_pattern=${3:-totallyimpossiblepattern} - + local base_ref=$(kube::util::base_ref "${git_branch}") echo "Checking for '${pattern}' changes against '${base_ref}'" @@ -792,6 +791,15 @@ function kube::util::check-file-in-alphabetical-order { fi } +# kube::util::require-jq +# Checks whether jq is installed. +function kube::util::require-jq { + if ! which jq &>/dev/null; then + echo "jq not found. Please install." 1>&2 + return 1 + fi +} + # Some useful colors. if [[ -z "${color_start-}" ]]; then declare -r color_start="\033[" diff --git a/hack/update-openapi-spec.sh b/hack/update-openapi-spec.sh index 9fd67e960d..2127910c1c 100755 --- a/hack/update-openapi-spec.sh +++ b/hack/update-openapi-spec.sh @@ -25,6 +25,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. OPENAPI_ROOT_DIR="${KUBE_ROOT}/api/openapi-spec" source "${KUBE_ROOT}/hack/lib/init.sh" +kube::util::require-jq kube::golang::setup_env make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver @@ -83,7 +84,7 @@ fi kube::log::status "Updating " ${OPENAPI_ROOT_DIR} -curl -w "\n" -fs "${API_HOST}:${API_PORT}/openapi/v2" > "${OPENAPI_ROOT_DIR}/swagger.json" +curl -w "\n" -fs "${API_HOST}:${API_PORT}/openapi/v2" | jq -S . > "${OPENAPI_ROOT_DIR}/swagger.json" kube::log::status "SUCCESS"