Skip to content

Commit

Permalink
Adding a script to verify that swagger spec is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiljindal committed Jun 8, 2015
1 parent 0f1c4c2 commit a89d2da
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions api/swagger-spec/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -12053,4 +12053,4 @@
}
}
}
}
}
6 changes: 3 additions & 3 deletions api/swagger-spec/v1beta3.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -12059,4 +12059,4 @@
}
}
}
}
}
48 changes: 48 additions & 0 deletions hack/verify-swagger-spec.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a89d2da

Please sign in to comment.