Merge pull request #35388 from mbohlool/co2
Automatic merge from submit-queue Add GroupVersion tags to OpenAPI spec and remove all specs except main one Tags are used as a grouping mechanism in OpenAPI. We generated one spec per GroupVersion before for this grouping but by adding those tags in this PR, those files have no use. We can always add them back if there were a use-case for them. **Release note**: ```release-note Deprecate OpenAPI spec for GroupVersion endpoints in favor of single spec /swagger.json ``` Reference: #13414
This commit is contained in:
@@ -387,60 +387,6 @@ kube::util::fetch-swagger-spec() {
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}logs" > "${SWAGGER_ROOT_DIR}/logs.json"
|
||||
}
|
||||
|
||||
# Takes a group/version and returns the openapi-spec file name.
|
||||
# default behavior: extensions/v1beta1 -> v1beta1.extensions
|
||||
# special case for v1: v1 -> v1
|
||||
kube::util::gv-to-openapi-name() {
|
||||
local group_version="$1"
|
||||
case "${group_version}" in
|
||||
v1)
|
||||
echo "v1"
|
||||
;;
|
||||
*)
|
||||
echo "${group_version#*/}.${group_version%/*}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# Fetches openapi spec from apiserver.
|
||||
# Assumed vars:
|
||||
# OPENAPI_API_PATH: Base path for openapi on apiserver. normally APIServer root. i.e., http://localhost:8080/
|
||||
# OPENAPI_ROOT_DIR: Root dir where we want to to save the fetched spec.
|
||||
# VERSIONS: Array of group versions to include in swagger spec.
|
||||
kube::util::fetch-openapi-spec() {
|
||||
for ver in ${VERSIONS}; do
|
||||
if [[ " ${KUBE_NONSERVER_GROUP_VERSIONS} " == *" ${ver} "* ]]; then
|
||||
continue
|
||||
fi
|
||||
# fetch the openapi spec for each group version.
|
||||
if [[ ${ver} == "v1" ]]; then
|
||||
SUBPATH="api"
|
||||
else
|
||||
SUBPATH="apis"
|
||||
fi
|
||||
SUBPATH="${SUBPATH}/${ver}"
|
||||
OPENAPI_JSON_NAME="$(kube::util::gv-to-openapi-name ${ver}).json"
|
||||
curl -w "\n" -fs "${OPENAPI_PATH}${SUBPATH}/swagger.json" > "${OPENAPI_ROOT_DIR}/${OPENAPI_JSON_NAME}"
|
||||
|
||||
# fetch the openapi spec for the discovery mechanism at group level.
|
||||
if [[ ${ver} == "v1" ]]; then
|
||||
continue
|
||||
fi
|
||||
SUBPATH="apis/"${ver%/*}
|
||||
OPENAPI_JSON_NAME="${ver%/*}.json"
|
||||
curl -w "\n" -fs "${OPENAPI_PATH}${SUBPATH}/swagger.json" > "${OPENAPI_ROOT_DIR}/${OPENAPI_JSON_NAME}"
|
||||
done
|
||||
|
||||
# fetch openapi specs for other discovery mechanism.
|
||||
curl -w "\n" -fs "${OPENAPI_PATH}swagger.json" > "${OPENAPI_ROOT_DIR}/root_swagger.json"
|
||||
curl -w "\n" -fs "${OPENAPI_PATH}version/swagger.json" > "${OPENAPI_ROOT_DIR}/version.json"
|
||||
curl -w "\n" -fs "${OPENAPI_PATH}api/swagger.json" > "${OPENAPI_ROOT_DIR}/api.json"
|
||||
curl -w "\n" -fs "${OPENAPI_PATH}apis/swagger.json" > "${OPENAPI_ROOT_DIR}/apis.json"
|
||||
curl -w "\n" -fs "${OPENAPI_PATH}logs/swagger.json" > "${OPENAPI_ROOT_DIR}/logs.json"
|
||||
}
|
||||
|
||||
|
||||
# Returns the name of the upstream remote repository name for the local git
|
||||
# repo, e.g. "upstream" or "origin".
|
||||
kube::util::git_upstream_remote_name() {
|
||||
|
@@ -60,18 +60,15 @@ kube::log::status "Starting federation-apiserver"
|
||||
--insecure-port="${API_PORT}" \
|
||||
--etcd-servers="http://${ETCD_HOST}:${ETCD_PORT}" \
|
||||
--advertise-address="10.10.10.10" \
|
||||
--cert-dir="${TMP_DIR}/certs" \
|
||||
--token-auth-file=$TMP_DIR/tokenauth.csv \
|
||||
--service-cluster-ip-range="10.0.0.0/24" >/tmp/openapi-federation-api-server.log 2>&1 &
|
||||
APISERVER_PID=$!
|
||||
kube::util::wait_for_url "${API_HOST}:${API_PORT}/" "apiserver: "
|
||||
|
||||
OPENAPI_PATH="${API_HOST}:${API_PORT}/"
|
||||
DEFAULT_GROUP_VERSIONS="v1 extensions/v1beta1 federation/v1beta1"
|
||||
VERSIONS=${VERSIONS:-$DEFAULT_GROUP_VERSIONS}
|
||||
|
||||
kube::log::status "Updating " ${OPENAPI_ROOT_DIR}
|
||||
|
||||
OPENAPI_PATH="${OPENAPI_PATH}" OPENAPI_ROOT_DIR="${OPENAPI_ROOT_DIR}" VERSIONS="${VERSIONS}" kube::util::fetch-openapi-spec
|
||||
curl -w "\n" -fs "${API_HOST}:${API_PORT}/swagger.json" > "${OPENAPI_ROOT_DIR}/swagger.json"
|
||||
|
||||
kube::log::status "SUCCESS"
|
||||
|
||||
|
@@ -71,7 +71,7 @@ kube::util::wait_for_url "${API_HOST}:${API_PORT}/healthz" "apiserver: "
|
||||
|
||||
kube::log::status "Updating " ${OPENAPI_ROOT_DIR}
|
||||
|
||||
OPENAPI_PATH="${API_HOST}:${API_PORT}/" OPENAPI_ROOT_DIR="${OPENAPI_ROOT_DIR}" VERSIONS="${KUBE_AVAILABLE_GROUP_VERSIONS}" KUBE_NONSERVER_GROUP_VERSIONS="${KUBE_NONSERVER_GROUP_VERSIONS}" kube::util::fetch-openapi-spec
|
||||
curl -w "\n" -fs "${API_HOST}:${API_PORT}/swagger.json" > "${OPENAPI_ROOT_DIR}/swagger.json"
|
||||
|
||||
kube::log::status "SUCCESS"
|
||||
|
||||
|
Reference in New Issue
Block a user