mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Adding a script to verify api reference docs
This commit is contained in:
parent
034f7ccb1d
commit
24dcc9bfae
@ -14,14 +14,25 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Generates updated api-reference docs from the latest swagger spec.
|
||||||
|
# Usage: ./update-api-reference-docs.sh <absolute output path>
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
V1_PATH="$PWD/${KUBE_ROOT}/docs/api-reference/v1/"
|
DEFAULT_OUTPUT_PATH="$PWD/${KUBE_ROOT}/docs/api-reference"
|
||||||
V1BETA1_PATH="$PWD/${KUBE_ROOT}/docs/api-reference/extensions/v1beta1"
|
OUTPUT=${1:-${DEFAULT_OUTPUT_PATH}}
|
||||||
|
|
||||||
|
echo "Generating api reference docs at ${OUTPUT}"
|
||||||
|
|
||||||
|
V1_PATH="${OUTPUT}/v1/"
|
||||||
|
V1BETA1_PATH="${OUTPUT}/extensions/v1beta1"
|
||||||
SWAGGER_PATH="$PWD/${KUBE_ROOT}/api/swagger-spec/"
|
SWAGGER_PATH="$PWD/${KUBE_ROOT}/api/swagger-spec/"
|
||||||
|
|
||||||
|
echo "Reading swagger spec from: ${SWAGGER_PATH}"
|
||||||
|
|
||||||
mkdir -p $V1_PATH
|
mkdir -p $V1_PATH
|
||||||
mkdir -p $V1BETA1_PATH
|
mkdir -p $V1BETA1_PATH
|
||||||
|
|
||||||
@ -32,3 +43,5 @@ docker run -v $V1_PATH:/output -v ${SWAGGER_PATH}:/swagger-source gcr.io/google_
|
|||||||
docker run -v $V1BETA1_PATH:/output -v ${SWAGGER_PATH}:/swagger-source gcr.io/google_containers/gen-swagger-docs:v3 \
|
docker run -v $V1BETA1_PATH:/output -v ${SWAGGER_PATH}:/swagger-source gcr.io/google_containers/gen-swagger-docs:v3 \
|
||||||
v1beta1 \
|
v1beta1 \
|
||||||
https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg/apis/extensions/v1beta1/register.go
|
https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg/apis/extensions/v1beta1/register.go
|
||||||
|
|
||||||
|
# ex: ts=2 sw=2 et filetype=sh
|
47
hack/verify-api-reference-docs.sh
Executable file
47
hack/verify-api-reference-docs.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
# Verifies that api reference docs are upto date.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
API_REFERENCE_DOCS_ROOT="${KUBE_ROOT}/docs/api-reference"
|
||||||
|
TMP_OUTPUT_DIR="${KUBE_ROOT}/_tmp/api-reference"
|
||||||
|
TMP_ROOT="${KUBE_ROOT}/_tmp"
|
||||||
|
|
||||||
|
# Generate API reference docs in tmp.
|
||||||
|
"./hack/update-api-reference-docs.sh" "${TMP_OUTPUT_DIR}"
|
||||||
|
|
||||||
|
echo "diffing ${API_REFERENCE_DOCS_ROOT} against freshly generated docs"
|
||||||
|
ret=0
|
||||||
|
diff -Naupr -I 'Last update' --exclude=*.md "${API_REFERENCE_DOCS_ROOT}" "${TMP_OUTPUT_DIR}" || ret=$?
|
||||||
|
rm -rf "${TMP_ROOT}"
|
||||||
|
if [[ $ret -eq 0 ]]
|
||||||
|
then
|
||||||
|
echo "${API_REFERENCE_DOCS_ROOT} up to date."
|
||||||
|
else
|
||||||
|
echo "${API_REFERENCE_DOCS_ROOT} is out of date. Please run hack/update-api-reference-docs.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ex: ts=2 sw=2 et filetype=sh
|
Loading…
Reference in New Issue
Block a user