From a89d2da249aa82de99e8bdb36da24125c085dde6 Mon Sep 17 00:00:00 2001 From: nikhiljindal Date: Mon, 8 Jun 2015 01:38:08 -0700 Subject: [PATCH] Adding a script to verify that swagger spec is updated --- .travis.yml | 1 + api/swagger-spec/v1.json | 6 ++--- api/swagger-spec/v1beta3.json | 6 ++--- hack/verify-swagger-spec.sh | 48 +++++++++++++++++++++++++++++++++++ hooks/pre-commit | 12 +++++++++ shippable.yml | 1 + 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100755 hack/verify-swagger-spec.sh diff --git a/.travis.yml b/.travis.yml index 5d873d451d5..06a1ef828eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ install: - ./hack/build-go.sh - GOPATH=$PWD/Godeps/_workspace:$GOPATH go install ./... - PATH=$HOME/gopath/bin:./third_party/etcd:$PATH ./hack/verify-gendocs.sh + - PATH=$HOME/gopath/bin:./third_party/etcd:$PATH ./hack/verify-swagger-spec.sh before_script: - npm install karma karma-junit-reporter karma-phantomjs-launcher karma-jasmine diff --git a/api/swagger-spec/v1.json b/api/swagger-spec/v1.json index 52b0a3d1f6c..365021e3628 100644 --- a/api/swagger-spec/v1.json +++ b/api/swagger-spec/v1.json @@ -10606,7 +10606,7 @@ }, "persistentVolumeReclaimPolicy": { "type": "string", - "description": "persistentVolumeReclaimPolicy is what happens to a volume when released from its claim; Default is Retain." + "description": "what happens to a volume when released from its claim; Valid options are Retain (default) and Recycle. Recyling must be supported by the volume plugin underlying this persistent volume." } } }, @@ -10818,7 +10818,7 @@ }, "reason": { "type": "string", - "description": "(brief) reason the volume is not is not available, such as failed recycling" + "description": "(brief) reason the volume is not is not available" } } }, @@ -12053,4 +12053,4 @@ } } } - } + } \ No newline at end of file diff --git a/api/swagger-spec/v1beta3.json b/api/swagger-spec/v1beta3.json index 055242aaacd..7408a8a17a7 100644 --- a/api/swagger-spec/v1beta3.json +++ b/api/swagger-spec/v1beta3.json @@ -10603,7 +10603,7 @@ }, "persistentVolumeReclaimPolicy": { "type": "string", - "description": "persistentVolumeReclaimPolicy is what happens to a volume when released from its claim; Default is Retain." + "description": "what happens to a volume when released from its claim; Valid options are Retain (default) and Recycle. Recyling must be supported by the volume plugin underlying this persistent volume." } } }, @@ -10815,7 +10815,7 @@ }, "reason": { "type": "string", - "description": "(brief) reason the volume is not is not available, such as failed recycling" + "description": "(brief) reason the volume is not is not available" } } }, @@ -12059,4 +12059,4 @@ } } } - } + } \ No newline at end of file diff --git a/hack/verify-swagger-spec.sh b/hack/verify-swagger-spec.sh new file mode 100755 index 00000000000..7e92929a2b5 --- /dev/null +++ b/hack/verify-swagger-spec.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# 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}")/.. +source "${KUBE_ROOT}/hack/lib/init.sh" + +kube::golang::setup_env + +SPECROOT="${KUBE_ROOT}/api/swagger-spec" +TMP_SPECROOT="${KUBE_ROOT}/_tmp/swagger-spec" +_tmp="${KUBE_ROOT}/_tmp" + +mkdir -p "${_tmp}" +cp -a "${SPECROOT}" "${TMP_SPECROOT}" + +"${KUBE_ROOT}/hack/build-go.sh" +"${KUBE_ROOT}/hack/update-swagger-spec.sh" +echo "diffing ${SPECROOT} against freshly generated swagger spec" +ret=0 +diff -Naupr -I 'Auto generated by' "${SPECROOT}" "${TMP_SPECROOT}" || ret=$? +cp -a ${TMP_SPECROOT} "${KUBE_ROOT}/api" +rm -rf "${_tmp}" +if [[ $ret -eq 0 ]] +then + echo "${SPECROOT} up to date." +else + echo "${SPECROOT} is out of date. Please run hack/update-swagger-spec.sh" + exit 1 +fi + +# ex: ts=2 sw=2 et filetype=sh diff --git a/hooks/pre-commit b/hooks/pre-commit index a9855c5480e..14663691fba 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -123,4 +123,16 @@ else fi echo "${reset}" +echo -ne "Checking for swagger spec that need updating... " +if ! hack/verify-swagger-spec.sh > /dev/null; then + echo "${red}ERROR!" + echo "Swagger spec needs to be updated." + echo "To regenerate the spec, run:" + echo " hack/update-swagger-spec.sh" + exit_code=1 +else + echo "${green}OK" +fi +echo "${reset}" + exit $exit_code diff --git a/shippable.yml b/shippable.yml index daa67e624f0..36393000de7 100644 --- a/shippable.yml +++ b/shippable.yml @@ -31,6 +31,7 @@ install: - ./hack/build-go.sh - GOPATH=$PWD/Godeps/_workspace:$GOPATH go install ./... - PATH=$HOME/gopath/bin:./third_party/etcd:$PATH ./hack/verify-gendocs.sh + - PATH=$HOME/gopath/bin:./third_party/etcd:$PATH ./hack/verify-swagger-spec.sh script: - KUBE_RACE="-race" KUBE_COVER="y" KUBE_GOVERALLS_BIN="$HOME/gopath/bin/goveralls" KUBE_TIMEOUT='-timeout 300s' KUBE_COVERPROCS=8 KUBE_TEST_ETCD_PREFIXES="${KUBE_TEST_ETCD_PREFIXES}" KUBE_TEST_API_VERSIONS="${KUBE_TEST_API_VERSIONS}" ./hack/test-go.sh -- -p=2