From be807639b0bf0d8589f4566896b3eb4114724b37 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 9 Nov 2016 13:21:58 -0500 Subject: [PATCH] Add validate/swagger-gen Signed-off-by: Daniel Nephin --- hack/validate/default | 1 + hack/validate/swagger-gen | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 hack/validate/swagger-gen diff --git a/hack/validate/default b/hack/validate/default index 198f73066f..29b96ca9a3 100755 --- a/hack/validate/default +++ b/hack/validate/default @@ -10,6 +10,7 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" . $SCRIPTDIR/lint . $SCRIPTDIR/pkg-imports . $SCRIPTDIR/swagger +. $SCRIPTDIR/swagger-gen . $SCRIPTDIR/test-imports . $SCRIPTDIR/toml . $SCRIPTDIR/vet diff --git a/hack/validate/swagger-gen b/hack/validate/swagger-gen new file mode 100755 index 0000000000..5d6fadb6aa --- /dev/null +++ b/hack/validate/swagger-gen @@ -0,0 +1,30 @@ +#!/bin/bash + +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" + +IFS=$'\n' +files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' || true) ) +unset IFS + +if [ ${#files[@]} -gt 0 ]; then + # We run vndr to and see if we have a diff afterwards + ${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null + # Let see if the working directory is clean + diffs="$(git status --porcelain -- api/types/ 2>/dev/null)" + if [ "$diffs" ]; then + { + echo 'The result of hack/geneate-swagger-api.sh differs' + echo + echo "$diffs" + echo + echo 'Please update api/swagger.yaml with any api changes, then ' + echo 'run `hack/geneate-swagger-api.sh`.' + } >&2 + false + else + echo 'Congratulations! All api changes are done the right way.' + fi +else + echo 'No api/types/ changes in diff.' +fi