mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Remove build/verify scripts for swagger 1.2 API docs, API server swagger ui / swagger 1.2 config
This commit is contained in:
parent
c3871e69ff
commit
9229399bd6
@ -24,7 +24,6 @@ file-name types_swagger_doc_generated.go
|
||||
|
||||
path-prefix Godeps/
|
||||
path-prefix vendor/
|
||||
path-prefix api/swagger-spec/
|
||||
path-prefix pkg/generated/
|
||||
|
||||
paths-from-repo docs/.generated_docs
|
||||
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -6,6 +6,4 @@ test/test_owners.csv merge=union
|
||||
**/generated.pb.go linguist-generated=true
|
||||
**/generated.proto
|
||||
**/types_swagger_doc_generated.go linguist-generated=true
|
||||
docs/api-reference/** linguist-generated=true
|
||||
api/swagger-spec/*.json linguist-generated=true
|
||||
api/openapi-spec/*.json linguist-generated=true
|
||||
|
@ -73,10 +73,6 @@ func createAggregatorConfig(
|
||||
aggregatorscheme.Scheme,
|
||||
pluginInitializers...)
|
||||
|
||||
// the aggregator doesn't wire these up. It just delegates them to the kubeapiserver
|
||||
genericConfig.EnableSwaggerUI = false
|
||||
genericConfig.SwaggerConfig = nil
|
||||
|
||||
// copy the etcd options so we don't mutate originals.
|
||||
etcdOptions := *commandOptions.Etcd
|
||||
etcdOptions.StorageConfig.Paging = utilfeature.DefaultFeatureGate.Enabled(features.APIListChunking)
|
||||
|
@ -96,7 +96,6 @@ func TestAddFlags(t *testing.T) {
|
||||
"--contention-profiling=true",
|
||||
"--enable-aggregator-routing=true",
|
||||
"--enable-logs-handler=false",
|
||||
"--enable-swagger-ui=true",
|
||||
"--endpoint-reconciler-type=" + string(reconcilers.LeaseEndpointReconcilerType),
|
||||
"--etcd-keyfile=/var/run/kubernetes/etcd.key",
|
||||
"--etcd-certfile=/var/run/kubernetes/etcdce.crt",
|
||||
@ -245,7 +244,6 @@ func TestAddFlags(t *testing.T) {
|
||||
PolicyFile: "/policy",
|
||||
},
|
||||
Features: &apiserveroptions.FeatureOptions{
|
||||
EnableSwaggerUI: true,
|
||||
EnableProfiling: true,
|
||||
EnableContentionProfiling: true,
|
||||
},
|
||||
|
@ -405,7 +405,6 @@ func buildGenericConfig(
|
||||
genericConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(legacyscheme.Scheme, extensionsapiserver.Scheme, aggregatorscheme.Scheme))
|
||||
genericConfig.OpenAPIConfig.PostProcessSpec = postProcessOpenAPISpecForBackwardCompatibility
|
||||
genericConfig.OpenAPIConfig.Info.Title = "Kubernetes"
|
||||
genericConfig.SwaggerConfig = genericapiserver.DefaultSwaggerConfig()
|
||||
genericConfig.LongRunningFunc = filters.BasicLongRunningRequestCheck(
|
||||
sets.NewString("watch", "proxy"),
|
||||
sets.NewString("attach", "exec", "proxy", "log", "portforward"),
|
||||
|
@ -568,7 +568,6 @@ staging/src/k8s.io/apiserver/pkg/server
|
||||
staging/src/k8s.io/apiserver/pkg/server/healthz
|
||||
staging/src/k8s.io/apiserver/pkg/server/httplog
|
||||
staging/src/k8s.io/apiserver/pkg/server/options
|
||||
staging/src/k8s.io/apiserver/pkg/server/routes/data/swagger
|
||||
staging/src/k8s.io/apiserver/pkg/server/storage
|
||||
staging/src/k8s.io/apiserver/pkg/storage
|
||||
staging/src/k8s.io/apiserver/pkg/storage/errors
|
||||
|
@ -69,7 +69,6 @@
|
||||
./hack/benchmark-go.sh
|
||||
./hack/build-cross.sh
|
||||
./hack/build-go.sh
|
||||
./hack/build-ui.sh
|
||||
./hack/cherry_pick_pull.sh
|
||||
./hack/dev-build-and-push.sh
|
||||
./hack/dev-build-and-up.sh
|
||||
@ -125,7 +124,6 @@
|
||||
./hack/test-integration.sh
|
||||
./hack/test-update-storage-objects.sh
|
||||
./hack/update-all.sh
|
||||
./hack/update-api-reference-docs.sh
|
||||
./hack/update-bazel.sh
|
||||
./hack/update-codegen.sh
|
||||
./hack/update-generated-device-plugin-dockerized.sh
|
||||
@ -147,12 +145,10 @@
|
||||
./hack/update-openapi-spec.sh
|
||||
./hack/update-staging-godeps-dockerized.sh
|
||||
./hack/update-staging-godeps.sh
|
||||
./hack/update-swagger-spec.sh
|
||||
./hack/update-translations.sh
|
||||
./hack/update-workspace-mirror.sh
|
||||
./hack/verify-all.sh
|
||||
./hack/verify-api-groups.sh
|
||||
./hack/verify-api-reference-docs.sh
|
||||
./hack/verify-bazel.sh
|
||||
./hack/verify-boilerplate.sh
|
||||
./hack/verify-cli-conventions.sh
|
||||
@ -183,7 +179,6 @@
|
||||
./hack/verify-spelling.sh
|
||||
./hack/verify-staging-godeps.sh
|
||||
./hack/verify-staging-meta-files.sh
|
||||
./hack/verify-swagger-spec.sh
|
||||
./hack/verify-symbols.sh
|
||||
./hack/verify-test-featuregates.sh
|
||||
./hack/verify-test-images.sh
|
||||
|
@ -3,7 +3,6 @@ CHANGELOG
|
||||
OWNERS
|
||||
api.pb.go
|
||||
api.proto
|
||||
docs/api-reference
|
||||
docs/man
|
||||
docs/user-guide
|
||||
generated.pb.go
|
||||
|
@ -152,8 +152,7 @@ skipped_dirs = ['Godeps', 'third_party', '_gopath', '_output', '.git', 'cluster/
|
||||
"pkg/kubectl/generated/bindata.go"]
|
||||
|
||||
# list all the files contain 'DO NOT EDIT', but are not generated
|
||||
skipped_ungenerated_files = ['hack/build-ui.sh', 'hack/lib/swagger.sh',
|
||||
'hack/boilerplate/boilerplate.py']
|
||||
skipped_ungenerated_files = ['hack/lib/swagger.sh', 'hack/boilerplate/boilerplate.py']
|
||||
|
||||
def normalize_files(files):
|
||||
newfiles = []
|
||||
|
@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2014 The Kubernetes Authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# This script builds ui assets into a single go datafile
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
if ! which go-bindata > /dev/null 2>&1 ; then
|
||||
echo "Cannot find go-bindata. Install with \"go get github.com/jteeuwen/go-bindata/...\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kube::util::ensure-temp-dir
|
||||
readonly TMP_DATAFILE="${KUBE_TEMP}/datafile.go"
|
||||
readonly SWAGGER_SRC="third_party/swagger-ui/..."
|
||||
readonly SWAGGER_PKG="swagger"
|
||||
|
||||
function kube::hack::build_ui() {
|
||||
local pkg="$1"
|
||||
local src="$2"
|
||||
local output_file="staging/src/k8s.io/apiserver/pkg/server/routes/data/${pkg}/datafile.go"
|
||||
|
||||
go-bindata -nocompress -o "${output_file}" -prefix ${PWD} -pkg "${pkg}" "${src}"
|
||||
|
||||
local year=$(date +%Y)
|
||||
cat hack/boilerplate/boilerplate.generatego.txt > "${TMP_DATAFILE}"
|
||||
echo -e "// generated by hack/build-ui.sh; DO NOT EDIT\n" >> "${TMP_DATAFILE}"
|
||||
cat "${output_file}" >> "${TMP_DATAFILE}"
|
||||
|
||||
gofmt -s -w "${TMP_DATAFILE}"
|
||||
|
||||
mv "${TMP_DATAFILE}" "${output_file}"
|
||||
}
|
||||
|
||||
kube::hack::build_ui "${SWAGGER_PKG}" "${SWAGGER_SRC}"
|
@ -1,45 +0,0 @@
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
FROM java:7-jre
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
asciidoctor \
|
||||
unzip \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install gradle
|
||||
RUN wget -O /tmp/gradle.zip https://services.gradle.org/distributions/gradle-2.5-bin.zip \
|
||||
&& mkdir -p build/ \
|
||||
&& unzip /tmp/gradle.zip -d build/ \
|
||||
&& rm /tmp/gradle.zip \
|
||||
&& mkdir -p gradle-cache/
|
||||
|
||||
ENV GRADLE_USER_HOME=/gradle-cache
|
||||
|
||||
COPY build.gradle build/
|
||||
COPY gen-swagger-docs.sh build/
|
||||
|
||||
# Run the script once to download the dependent java libraries into the image
|
||||
RUN mkdir -p /output /swagger-source \
|
||||
&& wget https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/swagger-spec/v1.json -O /swagger-source/v1.json \
|
||||
&& wget https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg/api/v1/register.go -O /register.go \
|
||||
&& build/gen-swagger-docs.sh v1 \
|
||||
&& rm -rf /output/* /swagger-source/* /register.go
|
||||
|
||||
RUN chmod -R 777 build/ \
|
||||
&& chmod -R 777 gradle-cache/
|
||||
|
||||
ENTRYPOINT ["build/gen-swagger-docs.sh"]
|
@ -1,18 +0,0 @@
|
||||
This folder contains the sources needed to build the gen-swagger-doc container.
|
||||
|
||||
To build the container image,
|
||||
|
||||
```
|
||||
$ sudo docker build -t k8s.gcr.io/gen-swagger-docs:v1 .
|
||||
```
|
||||
|
||||
To generate the html docs,
|
||||
|
||||
```
|
||||
$ ./gen-swagger-docs.sh <API version> <absolute output path, default to PWD>
|
||||
```
|
||||
|
||||
The generated definitions.html and operations.html will be stored in output paths.
|
||||
|
||||
|
||||
[]()
|
@ -1,18 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'io.github.robwin:swagger2markup:0.6.0'
|
||||
}
|
||||
}
|
||||
|
||||
task gendocs << {
|
||||
io.github.robwin.swagger2markup.Swagger2MarkupConverter
|
||||
.from("./input.json")
|
||||
.build()
|
||||
.intoFolder("./");
|
||||
println '*** generating docs to ./'
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -61,95 +61,3 @@ EOF
|
||||
gofmt -w -s "$TMPFILE"
|
||||
mv "$TMPFILE" ""${gv_dir}"/types_swagger_doc_generated.go"
|
||||
}
|
||||
|
||||
# Generates API reference docs for the given API group versions.
|
||||
# Required env vars:
|
||||
# GROUP_VERSIONS: Array of group versions to be included in the reference
|
||||
# docs.
|
||||
# GV_DIRS: Array of root directories for those group versions.
|
||||
# Input vars:
|
||||
# $1: Root directory path for swagger spec
|
||||
# $2: Root directory path where the reference docs should be generated.
|
||||
kube::swagger::gen_api_ref_docs() {
|
||||
: "${GROUP_VERSIONS?Must set GROUP_VERSIONS env var}"
|
||||
: "${GV_DIRS?Must set GV_DIRS env var}"
|
||||
|
||||
echo "Generating API reference docs for group versions: ${GROUP_VERSIONS[@]}, at dirs: ${GV_DIRS[@]}"
|
||||
GROUP_VERSIONS=(${GROUP_VERSIONS[@]})
|
||||
GV_DIRS=(${GV_DIRS[@]})
|
||||
local swagger_spec_path=${1}
|
||||
local output_dir=${2}
|
||||
echo "Reading swagger spec from: ${swagger_spec_path}"
|
||||
echo "Generating the docs at: ${output_dir}"
|
||||
|
||||
# Use REPO_DIR if provided so we can set it to the host-resolvable path
|
||||
# to the repo root if we are running this script from a container with
|
||||
# docker mounted in as a volume.
|
||||
# We pass the host output dir as the source dir to `docker run -v`, but use
|
||||
# the regular one to compute diff (they will be the same if running this
|
||||
# test on the host, potentially different if running in a container).
|
||||
local repo_dir=${REPO_DIR:-"${KUBE_ROOT}"}
|
||||
local tmp_subpath="_output/generated_html"
|
||||
local output_tmp_in_host="${repo_dir}/${tmp_subpath}"
|
||||
local output_tmp="${KUBE_ROOT}/${tmp_subpath}"
|
||||
|
||||
echo "Generating api reference docs at ${output_tmp}"
|
||||
|
||||
for ver in "${GROUP_VERSIONS[@]}"; do
|
||||
mkdir -p "${output_tmp}/${ver}"
|
||||
done
|
||||
|
||||
user_flags="-u $(id -u)"
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
# mapping in a uid from OS X doesn't make any sense
|
||||
user_flags=""
|
||||
fi
|
||||
|
||||
for i in "${!GROUP_VERSIONS[@]}"; do
|
||||
local ver=${GROUP_VERSIONS[i]}
|
||||
local dir=${GV_DIRS[i]}
|
||||
local tmp_in_host="${output_tmp_in_host}/${ver}"
|
||||
local register_file="${dir}/register.go"
|
||||
local swagger_json_name="$(kube::util::gv-to-swagger-name "${ver}")"
|
||||
|
||||
docker run ${user_flags} \
|
||||
--rm -v "${tmp_in_host}":/output:z \
|
||||
-v "${swagger_spec_path}":/swagger-source:z \
|
||||
-v "${register_file}":/register.go:z \
|
||||
--net=host -e "https_proxy=${KUBERNETES_HTTPS_PROXY:-}" \
|
||||
k8s.gcr.io/gen-swagger-docs:v8 \
|
||||
"${swagger_json_name}"
|
||||
done
|
||||
|
||||
# Check if we actually changed anything
|
||||
pushd "${output_tmp}" > /dev/null
|
||||
touch .generated_html
|
||||
find . -type f | cut -sd / -f 2- | LC_ALL=C sort > .generated_html
|
||||
popd > /dev/null
|
||||
|
||||
kube::util::ensure-gnu-sed
|
||||
|
||||
while read file; do
|
||||
if [[ -e "${output_dir}/${file}" && -e "${output_tmp}/${file}" ]]; then
|
||||
echo "comparing ${output_dir}/${file} with ${output_tmp}/${file}"
|
||||
|
||||
# Remove the timestamp to reduce conflicts in PR(s)
|
||||
${SED} -i 's/^Last updated.*$//' "${output_tmp}/${file}"
|
||||
|
||||
# By now, the contents should be normalized and stripped of any
|
||||
# auto-managed content.
|
||||
if diff -NauprB "${output_dir}/${file}" "${output_tmp}/${file}" >/dev/null; then
|
||||
# actual contents same, overwrite generated with original.
|
||||
cp "${output_dir}/${file}" "${output_tmp}/${file}"
|
||||
fi
|
||||
fi
|
||||
done <"${output_tmp}/.generated_html"
|
||||
|
||||
echo "Moving api reference docs from ${output_tmp} to ${output_dir}"
|
||||
|
||||
# Create output_dir if doesn't exist. Prevents error on copy.
|
||||
mkdir -p "${output_dir}"
|
||||
|
||||
cp -af "${output_tmp}"/* "${output_dir}"
|
||||
rm -r "${output_tmp}"
|
||||
}
|
||||
|
@ -317,45 +317,6 @@ kube::util::gv-to-swagger-name() {
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# Fetches swagger spec from apiserver.
|
||||
# Assumed vars:
|
||||
# SWAGGER_API_PATH: Base path for swaggerapi on apiserver. Ex:
|
||||
# http://localhost:8080/swaggerapi.
|
||||
# SWAGGER_ROOT_DIR: Root dir where we want to save the fetched spec.
|
||||
# VERSIONS: Array of group versions to include in swagger spec.
|
||||
kube::util::fetch-swagger-spec() {
|
||||
for ver in ${VERSIONS}; do
|
||||
if [[ " ${KUBE_NONSERVER_GROUP_VERSIONS} " == *" ${ver} "* ]]; then
|
||||
continue
|
||||
fi
|
||||
# fetch the swagger spec for each group version.
|
||||
if [[ ${ver} == "v1" ]]; then
|
||||
SUBPATH="api"
|
||||
else
|
||||
SUBPATH="apis"
|
||||
fi
|
||||
SUBPATH="${SUBPATH}/${ver}"
|
||||
SWAGGER_JSON_NAME="$(kube::util::gv-to-swagger-name ${ver}).json"
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}${SUBPATH}" > "${SWAGGER_ROOT_DIR}/${SWAGGER_JSON_NAME}"
|
||||
|
||||
# fetch the swagger spec for the discovery mechanism at group level.
|
||||
if [[ ${ver} == "v1" ]]; then
|
||||
continue
|
||||
fi
|
||||
SUBPATH="apis/"${ver%/*}
|
||||
SWAGGER_JSON_NAME="${ver%/*}.json"
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}${SUBPATH}" > "${SWAGGER_ROOT_DIR}/${SWAGGER_JSON_NAME}"
|
||||
done
|
||||
|
||||
# fetch swagger specs for other discovery mechanism.
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}" > "${SWAGGER_ROOT_DIR}/resourceListing.json"
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}version" > "${SWAGGER_ROOT_DIR}/version.json"
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}api" > "${SWAGGER_ROOT_DIR}/api.json"
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}apis" > "${SWAGGER_ROOT_DIR}/apis.json"
|
||||
curl -w "\n" -fs "${SWAGGER_API_PATH}logs" > "${SWAGGER_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() {
|
||||
|
@ -80,8 +80,6 @@ FEATURE_GATES=${FEATURE_GATES:-"AllAlpha=false"}
|
||||
STORAGE_BACKEND=${STORAGE_BACKEND:-"etcd3"}
|
||||
# preserve etcd data. you also need to set ETCD_DIR.
|
||||
PRESERVE_ETCD="${PRESERVE_ETCD:-false}"
|
||||
# enable swagger ui
|
||||
ENABLE_SWAGGER_UI=${ENABLE_SWAGGER_UI:-false}
|
||||
# enable Pod priority and preemption
|
||||
ENABLE_POD_PRIORITY_PREEMPTION=${ENABLE_POD_PRIORITY_PREEMPTION:-""}
|
||||
|
||||
@ -515,11 +513,6 @@ function start_apiserver {
|
||||
# Append security_admission plugin
|
||||
ENABLE_ADMISSION_PLUGINS="${ENABLE_ADMISSION_PLUGINS}${security_admission}"
|
||||
|
||||
swagger_arg=""
|
||||
if [[ "${ENABLE_SWAGGER_UI}" = true ]]; then
|
||||
swagger_arg="--enable-swagger-ui=true "
|
||||
fi
|
||||
|
||||
authorizer_arg=""
|
||||
if [[ -n "${AUTHORIZATION_MODE}" ]]; then
|
||||
authorizer_arg="--authorization-mode=${AUTHORIZATION_MODE} "
|
||||
@ -566,7 +559,7 @@ function start_apiserver {
|
||||
fi
|
||||
|
||||
APISERVER_LOG=${LOG_DIR}/kube-apiserver.log
|
||||
${CONTROLPLANE_SUDO} "${GO_OUT}/hyperkube" apiserver ${swagger_arg} ${authorizer_arg} ${priv_arg} ${runtime_config} \
|
||||
${CONTROLPLANE_SUDO} "${GO_OUT}/hyperkube" apiserver ${authorizer_arg} ${priv_arg} ${runtime_config} \
|
||||
${cloud_config_arg} \
|
||||
${advertise_address} \
|
||||
${node_port_range} \
|
||||
|
@ -56,9 +56,7 @@ BASH_TARGETS="
|
||||
update-generated-device-plugin
|
||||
update-generated-docs
|
||||
update-generated-swagger-docs
|
||||
update-swagger-spec
|
||||
update-openapi-spec
|
||||
update-api-reference-docs
|
||||
update-staging-godeps
|
||||
update-bazel"
|
||||
|
||||
|
@ -1,52 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Generates updated api-reference docs from the latest swagger spec.
|
||||
# Usage: ./update-api-reference-docs.sh <absolute output path>
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
echo "Note: This assumes that swagger spec has been updated. Please run hack/update-swagger-spec.sh to ensure that."
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
source "${KUBE_ROOT}/hack/lib/swagger.sh"
|
||||
kube::golang::setup_env
|
||||
|
||||
REPO_DIR=${REPO_DIR:-"${KUBE_ROOT}"}
|
||||
DEFAULT_OUTPUT="${REPO_DIR}/docs/api-reference"
|
||||
OUTPUT=${1:-${DEFAULT_OUTPUT}}
|
||||
|
||||
SWAGGER_SPEC_PATH="${REPO_DIR}/api/swagger-spec"
|
||||
|
||||
ALL_GROUP_VERSIONS=(${KUBE_AVAILABLE_GROUP_VERSIONS})
|
||||
INTERESTING_GROUP_VERSIONS=()
|
||||
GV_DIRS=()
|
||||
for gv in "${ALL_GROUP_VERSIONS[@]}"; do
|
||||
# skip groups that aren't being served, clients for these don't matter
|
||||
if [[ " ${KUBE_NONSERVER_GROUP_VERSIONS} " == *" ${gv} "* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
INTERESTING_GROUP_VERSIONS+=(${gv})
|
||||
GV_DIRS+=("${REPO_DIR}/$(kube::util::group-version-to-pkg-path "${gv}")")
|
||||
done
|
||||
|
||||
GROUP_VERSIONS="${INTERESTING_GROUP_VERSIONS[@]}" GV_DIRS="${GV_DIRS[@]}" kube::swagger::gen_api_ref_docs "${SWAGGER_SPEC_PATH}" "${OUTPUT}"
|
||||
|
||||
# ex: ts=2 sw=2 et filetype=sh
|
@ -1,96 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Script to fetch latest swagger spec.
|
||||
# Puts the updated spec at api/swagger-spec/
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
cat << __EOF__
|
||||
Note: This assumes that the 'types_swagger_doc_generated.go' file has been
|
||||
updated for all API group versions. If you are unsure, please run
|
||||
hack/update-generated-swagger-docs.sh first.
|
||||
__EOF__
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
SWAGGER_ROOT_DIR="${KUBE_ROOT}/api/swagger-spec"
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
kube::golang::setup_env
|
||||
|
||||
make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
if [[ -n "${APISERVER_PID-}" ]]; then
|
||||
kill "${APISERVER_PID}" &>/dev/null || :
|
||||
wait "${APISERVER_PID}" &>/dev/null || :
|
||||
fi
|
||||
|
||||
kube::etcd::cleanup
|
||||
|
||||
kube::log::status "Clean up complete"
|
||||
}
|
||||
|
||||
kube::util::trap_add cleanup EXIT
|
||||
|
||||
kube::golang::setup_env
|
||||
|
||||
apiserver=$(kube::util::find-binary "kube-apiserver")
|
||||
|
||||
TMP_DIR=$(mktemp -d /tmp/update-swagger-spec.XXXX)
|
||||
ETCD_HOST=${ETCD_HOST:-127.0.0.1}
|
||||
ETCD_PORT=${ETCD_PORT:-2379}
|
||||
API_PORT=${API_PORT:-8050}
|
||||
API_HOST=${API_HOST:-127.0.0.1}
|
||||
API_LOGFILE=${API_LOGFILE:-/tmp/swagger-api-server.log}
|
||||
|
||||
kube::etcd::start
|
||||
|
||||
|
||||
# Start kube-apiserver, with alpha api versions on so we can harvest their swagger docs
|
||||
# Set --runtime-config to all versions in KUBE_AVAILABLE_GROUP_VERSIONS to enable alpha features.
|
||||
kube::log::status "Starting kube-apiserver"
|
||||
"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
|
||||
--insecure-bind-address="${API_HOST}" \
|
||||
--bind-address="${API_HOST}" \
|
||||
--insecure-port="${API_PORT}" \
|
||||
--etcd-servers="http://${ETCD_HOST}:${ETCD_PORT}" \
|
||||
--advertise-address="10.10.10.10" \
|
||||
--cert-dir="${TMP_DIR}/certs" \
|
||||
--runtime-config=$(echo "${KUBE_AVAILABLE_GROUP_VERSIONS}" | sed -E 's|[[:blank:]]+|,|g') \
|
||||
--service-cluster-ip-range="10.0.0.0/24" >"${API_LOGFILE}" 2>&1 &
|
||||
APISERVER_PID=$!
|
||||
|
||||
if ! kube::util::wait_for_url "${API_HOST}:${API_PORT}/healthz" "apiserver: "; then
|
||||
kube::log::error "Here are the last 10 lines from kube-apiserver (${API_LOGFILE})"
|
||||
kube::log::error "=== BEGIN OF LOG ==="
|
||||
tail -10 "${API_LOGFILE}" || :
|
||||
kube::log::error "=== END OF LOG ==="
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SWAGGER_API_PATH="${API_HOST}:${API_PORT}/swaggerapi/"
|
||||
|
||||
kube::log::status "Updating " ${SWAGGER_ROOT_DIR}
|
||||
|
||||
SWAGGER_API_PATH="${SWAGGER_API_PATH}" SWAGGER_ROOT_DIR="${SWAGGER_ROOT_DIR}" VERSIONS="${KUBE_AVAILABLE_GROUP_VERSIONS}" KUBE_NONSERVER_GROUP_VERSIONS="${KUBE_NONSERVER_GROUP_VERSIONS}" kube::util::fetch-swagger-spec
|
||||
|
||||
kube::log::status "SUCCESS"
|
||||
|
||||
# ex: ts=2 sw=2 et filetype=sh
|
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors.
|
||||
#
|
||||
# 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 up to 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"
|
||||
OUTPUT_DIR="${KUBE_ROOT}/_tmp/api-reference"
|
||||
mkdir -p ${OUTPUT_DIR}
|
||||
TMP_ROOT="${KUBE_ROOT}/_tmp"
|
||||
trap "rm -rf ${TMP_ROOT}" EXIT SIGINT
|
||||
|
||||
# Generate API reference docs in tmp.
|
||||
"./hack/update-api-reference-docs.sh" "${OUTPUT_DIR}"
|
||||
|
||||
echo "diffing ${API_REFERENCE_DOCS_ROOT} against freshly generated docs"
|
||||
ret=0
|
||||
diff -NauprB -I 'Last update' --exclude=*.md --exclude=OWNERS "${API_REFERENCE_DOCS_ROOT}" "${OUTPUT_DIR}" || ret=$?
|
||||
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
|
@ -1,52 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors.
|
||||
#
|
||||
# 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
|
||||
kube::etcd::install
|
||||
|
||||
make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
|
||||
|
||||
apiserver=$(kube::util::find-binary "kube-apiserver")
|
||||
|
||||
SPECROOT="${KUBE_ROOT}/api/swagger-spec"
|
||||
TMP_SPECROOT="${KUBE_ROOT}/_tmp/swagger-spec"
|
||||
_tmp="${KUBE_ROOT}/_tmp"
|
||||
|
||||
mkdir -p "${_tmp}"
|
||||
trap "rm -rf ${_tmp}" EXIT SIGINT
|
||||
cp -a "${SPECROOT}" "${TMP_SPECROOT}"
|
||||
|
||||
"${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"
|
||||
if [[ $ret -eq 0 ]]
|
||||
then
|
||||
echo "${SPECROOT} up to date."
|
||||
else
|
||||
echo "${SPECROOT} is out of date. Please run hack/update-swagger-spec.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ex: ts=2 sw=2 et filetype=sh
|
@ -73,9 +73,7 @@ var (
|
||||
patchLong = templates.LongDesc(i18n.T(`
|
||||
Update field(s) of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
|
||||
|
||||
JSON and YAML formats are accepted.
|
||||
|
||||
Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`))
|
||||
JSON and YAML formats are accepted.`))
|
||||
|
||||
patchExample = templates.Examples(i18n.T(`
|
||||
# Partially update a node using a strategic merge patch. Specify the patch as JSON.
|
||||
|
@ -48,9 +48,7 @@ var (
|
||||
JSON and YAML formats are accepted. If replacing an existing resource, the
|
||||
complete resource spec must be provided. This can be obtained by
|
||||
|
||||
$ kubectl get TYPE NAME -o yaml
|
||||
|
||||
Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`))
|
||||
$ kubectl get TYPE NAME -o yaml`))
|
||||
|
||||
replaceExample = templates.Examples(i18n.T(`
|
||||
# Replace a pod using the data in pod.json.
|
||||
|
@ -52,7 +52,6 @@ func TestValidOpenAPISpec(t *testing.T) {
|
||||
Version: "unversioned",
|
||||
},
|
||||
}
|
||||
config.GenericConfig.SwaggerConfig = genericapiserver.DefaultSwaggerConfig()
|
||||
|
||||
master, err := config.Complete().New(genericapiserver.NewEmptyDelegate())
|
||||
if err != nil {
|
||||
|
@ -199,8 +199,6 @@ func ClusterRoles() []rbacv1.ClusterRole {
|
||||
Rules: []rbacv1.PolicyRule{
|
||||
rbacv1helpers.NewRule("get").URLs(
|
||||
"/healthz", "/version", "/version/",
|
||||
// remove once swagger 1.2 support is removed
|
||||
"/swaggerapi", "/swaggerapi/*",
|
||||
// do not expand this pattern for openapi discovery docs
|
||||
// move to a single openapi endpoint that takes accept/accept-encoding headers
|
||||
"/swagger.json", "/swagger-2.0.0.pb-v1",
|
||||
|
@ -552,8 +552,6 @@ items:
|
||||
- /openapi/*
|
||||
- /swagger-2.0.0.pb-v1
|
||||
- /swagger.json
|
||||
- /swaggerapi
|
||||
- /swaggerapi/*
|
||||
- /version
|
||||
- /version/
|
||||
verbs:
|
||||
|
@ -56,7 +56,7 @@ type Attributes interface {
|
||||
GetAPIVersion() string
|
||||
|
||||
// IsResourceRequest returns true for requests to API resources, like /api/v1/nodes,
|
||||
// and false for non-resource endpoints like /api, /healthz, and /swaggerapi
|
||||
// and false for non-resource endpoints like /api, /healthz
|
||||
IsResourceRequest() bool
|
||||
|
||||
// GetPath returns the path of the request
|
||||
|
@ -28,7 +28,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
"github.com/go-openapi/spec"
|
||||
"github.com/pborman/uuid"
|
||||
"k8s.io/klog"
|
||||
@ -101,7 +100,6 @@ type Config struct {
|
||||
AdmissionControl admission.Interface
|
||||
CorsAllowedOriginList []string
|
||||
|
||||
EnableSwaggerUI bool
|
||||
EnableIndex bool
|
||||
EnableProfiling bool
|
||||
EnableDiscovery bool
|
||||
@ -145,8 +143,6 @@ type Config struct {
|
||||
Serializer runtime.NegotiatedSerializer
|
||||
// OpenAPIConfig will be used in generating OpenAPI spec. This is nil by default. Use DefaultOpenAPIConfig for "working" defaults.
|
||||
OpenAPIConfig *openapicommon.Config
|
||||
// SwaggerConfig will be used in generating Swagger spec. This is nil by default. Use DefaultSwaggerConfig for "working" defaults.
|
||||
SwaggerConfig *swagger.Config
|
||||
|
||||
// RESTOptionsGetter is used to construct RESTStorage types via the generic registry.
|
||||
RESTOptionsGetter genericregistry.RESTOptionsGetter
|
||||
@ -279,7 +275,7 @@ func NewRecommendedConfig(codecs serializer.CodecFactory) *RecommendedConfig {
|
||||
func DefaultOpenAPIConfig(getDefinitions openapicommon.GetOpenAPIDefinitions, defNamer *apiopenapi.DefinitionNamer) *openapicommon.Config {
|
||||
return &openapicommon.Config{
|
||||
ProtocolList: []string{"https"},
|
||||
IgnorePrefixes: []string{"/swaggerapi"},
|
||||
IgnorePrefixes: []string{},
|
||||
Info: &spec.Info{
|
||||
InfoProps: spec.InfoProps{
|
||||
Title: "Generic API Server",
|
||||
@ -296,23 +292,6 @@ func DefaultOpenAPIConfig(getDefinitions openapicommon.GetOpenAPIDefinitions, de
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultSwaggerConfig returns a default configuration without WebServiceURL and
|
||||
// WebServices set.
|
||||
func DefaultSwaggerConfig() *swagger.Config {
|
||||
return &swagger.Config{
|
||||
ApiPath: "/swaggerapi",
|
||||
SwaggerPath: "/swaggerui/",
|
||||
SwaggerFilePath: "/swagger-ui/",
|
||||
SchemaFormatHandler: func(typeName string) string {
|
||||
switch typeName {
|
||||
case "metav1.Time", "*metav1.Time":
|
||||
return "date-time"
|
||||
}
|
||||
return ""
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AuthenticationInfo) ApplyClientCert(clientCAFile string, servingInfo *SecureServingInfo) error {
|
||||
if servingInfo != nil {
|
||||
if len(clientCAFile) > 0 {
|
||||
@ -403,13 +382,6 @@ func (c *Config) Complete(informers informers.SharedInformerFactory) CompletedCo
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.SwaggerConfig != nil && len(c.SwaggerConfig.WebServicesUrl) == 0 {
|
||||
if c.SecureServing != nil {
|
||||
c.SwaggerConfig.WebServicesUrl = "https://" + c.ExternalAddress
|
||||
} else {
|
||||
c.SwaggerConfig.WebServicesUrl = "http://" + c.ExternalAddress
|
||||
}
|
||||
}
|
||||
if c.DiscoveryAddresses == nil {
|
||||
c.DiscoveryAddresses = discovery.DefaultAddresses{DefaultAddress: c.ExternalAddress}
|
||||
}
|
||||
@ -466,7 +438,6 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
||||
|
||||
listedPathProvider: apiServerHandler,
|
||||
|
||||
swaggerConfig: c.SwaggerConfig,
|
||||
openAPIConfig: c.OpenAPIConfig,
|
||||
|
||||
postStartHooks: map[string]postStartHookEntry{},
|
||||
@ -550,9 +521,6 @@ func installAPI(s *GenericAPIServer, c *Config) {
|
||||
if c.EnableIndex {
|
||||
routes.Index{}.Install(s.listedPathProvider, s.Handler.NonGoRestfulMux)
|
||||
}
|
||||
if c.SwaggerConfig != nil && c.EnableSwaggerUI {
|
||||
routes.SwaggerUI{}.Install(s.Handler.NonGoRestfulMux)
|
||||
}
|
||||
if c.EnableProfiling {
|
||||
routes.Profiling{}.Install(s.Handler.NonGoRestfulMux)
|
||||
if c.EnableContentionProfiling {
|
||||
|
@ -38,7 +38,6 @@ func TestNewWithDelegate(t *testing.T) {
|
||||
delegateConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
||||
delegateConfig.LegacyAPIGroupPrefixes = sets.NewString("/api")
|
||||
delegateConfig.LoopbackClientConfig = &rest.Config{}
|
||||
delegateConfig.SwaggerConfig = DefaultSwaggerConfig()
|
||||
clientset := fake.NewSimpleClientset()
|
||||
if clientset == nil {
|
||||
t.Fatal("unable to create fake client set")
|
||||
@ -69,7 +68,6 @@ func TestNewWithDelegate(t *testing.T) {
|
||||
wrappingConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
||||
wrappingConfig.LegacyAPIGroupPrefixes = sets.NewString("/api")
|
||||
wrappingConfig.LoopbackClientConfig = &rest.Config{}
|
||||
wrappingConfig.SwaggerConfig = DefaultSwaggerConfig()
|
||||
|
||||
wrappingConfig.HealthzChecks = append(wrappingConfig.HealthzChecks, healthz.NamedCheck("wrapping-health", func(r *http.Request) error {
|
||||
return fmt.Errorf("wrapping failed healthcheck")
|
||||
@ -109,8 +107,7 @@ func TestNewWithDelegate(t *testing.T) {
|
||||
"/healthz/poststarthook/generic-apiserver-start-informers",
|
||||
"/healthz/poststarthook/wrapping-post-start-hook",
|
||||
"/healthz/wrapping-health",
|
||||
"/metrics",
|
||||
"/swaggerapi"
|
||||
"/metrics"
|
||||
]
|
||||
}`, t)
|
||||
checkPath(server.URL+"/healthz", http.StatusInternalServerError, `[+]ping ok
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"time"
|
||||
|
||||
systemd "github.com/coreos/go-systemd/daemon"
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
@ -121,7 +120,6 @@ type GenericAPIServer struct {
|
||||
DiscoveryGroupManager discovery.GroupManager
|
||||
|
||||
// Enable swagger and/or OpenAPI if these configs are non-nil.
|
||||
swaggerConfig *swagger.Config
|
||||
openAPIConfig *openapicommon.Config
|
||||
|
||||
// PostStartHooks are each called after the server has started listening, in a separate go func for each
|
||||
@ -236,9 +234,6 @@ type preparedGenericAPIServer struct {
|
||||
|
||||
// PrepareRun does post API installation setup steps.
|
||||
func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer {
|
||||
if s.swaggerConfig != nil {
|
||||
routes.Swagger{Config: s.swaggerConfig}.Install(s.Handler.GoRestfulContainer)
|
||||
}
|
||||
if s.openAPIConfig != nil {
|
||||
routes.OpenAPI{
|
||||
Config: s.openAPIConfig,
|
||||
|
@ -137,7 +137,6 @@ func setUp(t *testing.T) (Config, *assert.Assertions) {
|
||||
|
||||
config.OpenAPIConfig = DefaultOpenAPIConfig(testGetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(runtime.NewScheme()))
|
||||
config.OpenAPIConfig.Info.Version = "unversioned"
|
||||
config.SwaggerConfig = DefaultSwaggerConfig()
|
||||
sharedInformers := informers.NewSharedInformerFactory(clientset, config.LoopbackClientConfig.Timeout)
|
||||
config.Complete(sharedInformers)
|
||||
|
||||
@ -162,11 +161,6 @@ func TestNew(t *testing.T) {
|
||||
// Verify many of the variables match their config counterparts
|
||||
assert.Equal(s.legacyAPIGroupPrefixes, config.LegacyAPIGroupPrefixes)
|
||||
assert.Equal(s.admissionControl, config.AdmissionControl)
|
||||
|
||||
// these values get defaulted
|
||||
assert.Equal(net.JoinHostPort(config.PublicAddress.String(), "443"), s.ExternalAddress)
|
||||
assert.NotNil(s.swaggerConfig)
|
||||
assert.Equal("http://"+s.ExternalAddress, s.swaggerConfig.WebServicesUrl)
|
||||
}
|
||||
|
||||
// Verifies that AddGroupVersions works as expected.
|
||||
@ -321,7 +315,7 @@ func TestInstallAPIGroups(t *testing.T) {
|
||||
func TestPrepareRun(t *testing.T) {
|
||||
s, config, assert := newMaster(t)
|
||||
|
||||
assert.NotNil(config.SwaggerConfig)
|
||||
assert.NotNil(config.OpenAPIConfig)
|
||||
|
||||
server := httptest.NewServer(s.Handler.Director)
|
||||
defer server.Close()
|
||||
@ -330,8 +324,8 @@ func TestPrepareRun(t *testing.T) {
|
||||
s.PrepareRun()
|
||||
s.RunPostStartHooks(done)
|
||||
|
||||
// swagger is installed in PrepareRun
|
||||
resp, err := http.Get(server.URL + "/swaggerapi/")
|
||||
// openapi is installed in PrepareRun
|
||||
resp, err := http.Get(server.URL + "/openapi/v2")
|
||||
assert.NoError(err)
|
||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||
|
||||
@ -406,10 +400,8 @@ func TestNotRestRoutesHaveAuth(t *testing.T) {
|
||||
config.LegacyAPIGroupPrefixes = sets.NewString("/apiPrefix")
|
||||
config.Authorization.Authorizer = &authz
|
||||
|
||||
config.EnableSwaggerUI = true
|
||||
config.EnableIndex = true
|
||||
config.EnableProfiling = true
|
||||
config.SwaggerConfig = DefaultSwaggerConfig()
|
||||
|
||||
kubeVersion := fakeVersion()
|
||||
config.Version = &kubeVersion
|
||||
@ -423,7 +415,6 @@ func TestNotRestRoutesHaveAuth(t *testing.T) {
|
||||
route string
|
||||
}{
|
||||
{"/"},
|
||||
{"/swagger-ui/"},
|
||||
{"/debug/pprof/"},
|
||||
{"/debug/flags/"},
|
||||
{"/version"},
|
||||
|
@ -26,7 +26,6 @@ import (
|
||||
type FeatureOptions struct {
|
||||
EnableProfiling bool
|
||||
EnableContentionProfiling bool
|
||||
EnableSwaggerUI bool
|
||||
}
|
||||
|
||||
func NewFeatureOptions() *FeatureOptions {
|
||||
@ -35,7 +34,6 @@ func NewFeatureOptions() *FeatureOptions {
|
||||
return &FeatureOptions{
|
||||
EnableProfiling: defaults.EnableProfiling,
|
||||
EnableContentionProfiling: defaults.EnableContentionProfiling,
|
||||
EnableSwaggerUI: defaults.EnableSwaggerUI,
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,8 +46,9 @@ func (o *FeatureOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
"Enable profiling via web interface host:port/debug/pprof/")
|
||||
fs.BoolVar(&o.EnableContentionProfiling, "contention-profiling", o.EnableContentionProfiling,
|
||||
"Enable lock contention profiling, if profiling is enabled")
|
||||
fs.BoolVar(&o.EnableSwaggerUI, "enable-swagger-ui", o.EnableSwaggerUI,
|
||||
"Enables swagger ui on the apiserver at /swagger-ui")
|
||||
dummy := false
|
||||
fs.BoolVar(&dummy, "enable-swagger-ui", dummy, "Enables swagger ui on the apiserver at /swagger-ui")
|
||||
fs.MarkDeprecated("enable-swagger-ui", "swagger 1.2 support has been removed")
|
||||
}
|
||||
|
||||
func (o *FeatureOptions) ApplyTo(c *server.Config) error {
|
||||
@ -59,7 +58,6 @@ func (o *FeatureOptions) ApplyTo(c *server.Config) error {
|
||||
|
||||
c.EnableProfiling = o.EnableProfiling
|
||||
c.EnableContentionProfiling = o.EnableContentionProfiling
|
||||
c.EnableSwaggerUI = o.EnableSwaggerUI
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
The datafiles contained in these directories were generated by the script
|
||||
```sh
|
||||
hack/build-ui.sh
|
||||
```
|
||||
|
||||
Do not edit by hand.
|
||||
|
||||
|
||||
[]()
|
||||
|
||||
|
||||
[]()
|
@ -1,26 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["datafile.go"],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/server/routes/data/swagger",
|
||||
importpath = "k8s.io/apiserver/pkg/server/routes/data/swagger",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
File diff suppressed because one or more lines are too long
@ -1,36 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/emicklei/go-restful"
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
)
|
||||
|
||||
// Swagger installs the /swaggerapi/ endpoint to allow schema discovery
|
||||
// and traversal. It is optional to allow consumers of the Kubernetes GenericAPIServer to
|
||||
// register their own web services into the Kubernetes mux prior to initialization
|
||||
// of swagger, so that other resource types show up in the documentation.
|
||||
type Swagger struct {
|
||||
Config *swagger.Config
|
||||
}
|
||||
|
||||
// Install adds the SwaggerUI webservice to the given mux.
|
||||
func (s Swagger) Install(c *restful.Container) {
|
||||
s.Config.WebServices = c.RegisteredWebServices()
|
||||
swagger.RegisterSwaggerService(*s.Config, c)
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
assetfs "github.com/elazarl/go-bindata-assetfs"
|
||||
|
||||
"k8s.io/apiserver/pkg/server/mux"
|
||||
"k8s.io/apiserver/pkg/server/routes/data/swagger"
|
||||
)
|
||||
|
||||
// SwaggerUI exposes files in third_party/swagger-ui/ under /swagger-ui.
|
||||
type SwaggerUI struct{}
|
||||
|
||||
// Install adds the SwaggerUI webservice to the given mux.
|
||||
func (l SwaggerUI) Install(c *mux.PathRecorderMux) {
|
||||
fileServer := http.FileServer(&assetfs.AssetFS{
|
||||
Asset: swagger.Asset,
|
||||
AssetDir: swagger.AssetDir,
|
||||
Prefix: "third_party/swagger-ui",
|
||||
})
|
||||
prefix := "/swagger-ui/"
|
||||
c.HandlePrefix(prefix, http.StripPrefix(prefix, fileServer))
|
||||
}
|
@ -119,8 +119,8 @@ run_swagger_tests() {
|
||||
kube::log::status "Testing swagger"
|
||||
|
||||
# Verify schema
|
||||
file="${KUBE_TEMP}/schema-v1.json"
|
||||
curl -s "http://127.0.0.1:${API_PORT}/swaggerapi/api/v1" > "${file}"
|
||||
file="${KUBE_TEMP}/schema.json"
|
||||
curl -s "http://127.0.0.1:${API_PORT}/openapi/v2" > "${file}"
|
||||
[[ "$(grep "list of returned" "${file}")" ]]
|
||||
[[ "$(grep "List of services" "${file}")" ]]
|
||||
[[ "$(grep "Watch for changes to the described resources" "${file}")" ]]
|
||||
|
@ -66,7 +66,7 @@ var _ = SIGDescribe("Networking", func() {
|
||||
{path: "/api"},
|
||||
{path: "/apis"},
|
||||
{path: "/metrics"},
|
||||
{path: "/swaggerapi"},
|
||||
{path: "/openapi/v2"},
|
||||
{path: "/version"},
|
||||
// TODO: test proxy links here
|
||||
}
|
||||
|
@ -151,7 +151,6 @@ func startMasterOrDie(masterConfig *master.Config, incomingServer *httptest.Serv
|
||||
},
|
||||
}
|
||||
masterConfig.GenericConfig.OpenAPIConfig.GetDefinitions = openapi.GetOpenAPIDefinitions
|
||||
masterConfig.GenericConfig.SwaggerConfig = genericapiserver.DefaultSwaggerConfig()
|
||||
}
|
||||
|
||||
// set the loopback client config
|
||||
|
Loading…
Reference in New Issue
Block a user