|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2017 The Kubernetes Authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# Script to fetch latest swagger spec. |
| 18 | +# Puts the updated spec at api/swagger-spec/ |
| 19 | + |
| 20 | +set -o errexit |
| 21 | +set -o nounset |
| 22 | +set -o pipefail |
| 23 | + |
| 24 | +if ! which mvn > /dev/null 2>&1; then |
| 25 | + echo "Maven is not installed." |
| 26 | + exit |
| 27 | +fi |
| 28 | + |
| 29 | +SCRIPT_ROOT=$(dirname "${BASH_SOURCE}") |
| 30 | +CLIENT_ROOT="${SCRIPT_ROOT}/../kubernetes" |
| 31 | + |
| 32 | +pushd "${SCRIPT_ROOT}" > /dev/null |
| 33 | +SCRIPT_ROOT=`pwd` |
| 34 | +popd > /dev/null |
| 35 | + |
| 36 | +pushd "${CLIENT_ROOT}" > /dev/null |
| 37 | +CLIENT_ROOT=`pwd` |
| 38 | +popd > /dev/null |
| 39 | + |
| 40 | +TEMP_FOLDER=$(mktemp -d) |
| 41 | +trap "rm -rf ${TEMP_FOLDER}" EXIT SIGINT |
| 42 | + |
| 43 | +if [[ -z ${GEN_ROOT:-} ]]; then |
| 44 | + GEN_ROOT="${TEMP_FOLDER}/gen" |
| 45 | + echo ">>> Cloning gen repo" |
| 46 | + git clone --recursive https://github.com/kubernetes-client/gen.git "${GEN_ROOT}" |
| 47 | +else |
| 48 | + echo ">>> Reusing gen repo at ${GEN_ROOT}" |
| 49 | +fi |
| 50 | + |
| 51 | +echo ">>> Running java generator from the gen repo" |
| 52 | +"${GEN_ROOT}/openapi/java.sh" "${CLIENT_ROOT}" "${SCRIPT_ROOT}/../settings" |
| 53 | + |
| 54 | +echo ">>> Done." |
0 commit comments