Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
6aa23e4e
Commit
6aa23e4e
authored
Feb 08, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refacotr update-api-reference-docs.sh
parent
c70c7fde
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
24 deletions
+75
-24
extensions_v1beta1.json
api/swagger-spec/extensions_v1beta1.json
+0
-0
update-swagger-spec.sh
hack/after-build/update-swagger-spec.sh
+28
-7
gen-swagger-docs.sh
hack/gen-swagger-doc/gen-swagger-docs.sh
+9
-4
util.sh
hack/lib/util.sh
+15
-0
update-api-reference-docs.sh
hack/update-api-reference-docs.sh
+23
-13
No files found.
api/swagger-spec/v1beta1.json
→
api/swagger-spec/
extensions_
v1beta1.json
View file @
6aa23e4e
File moved
hack/after-build/update-swagger-spec.sh
View file @
6aa23e4e
...
@@ -64,15 +64,36 @@ APISERVER_PID=$!
...
@@ -64,15 +64,36 @@ APISERVER_PID=$!
kube::util::wait_for_url
"http://127.0.0.1:
${
API_PORT
}
/healthz"
"apiserver: "
kube::util::wait_for_url
"http://127.0.0.1:
${
API_PORT
}
/healthz"
"apiserver: "
SWAGGER_API_PATH
=
"http://127.0.0.1:
${
API_PORT
}
/swaggerapi/"
SWAGGER_API_PATH
=
"http://127.0.0.1:
${
API_PORT
}
/swaggerapi/"
DEFAULT_GROUP_VERSIONS
=
"v1 extensions/v1beta1"
VERSIONS
=
${
VERSIONS
:-
$DEFAULT_GROUP_VERSIONS
}
kube::log::status
"Updating "
${
SWAGGER_ROOT_DIR
}
kube::log::status
"Updating "
${
SWAGGER_ROOT_DIR
}
curl
-fs
${
SWAGGER_API_PATH
}
>
${
SWAGGER_ROOT_DIR
}
/resourceListing.json
curl
-fs
${
SWAGGER_API_PATH
}
version
>
${
SWAGGER_ROOT_DIR
}
/version.json
curl
-fs
${
SWAGGER_API_PATH
}
api
>
${
SWAGGER_ROOT_DIR
}
/api.json
curl
-fs
${
SWAGGER_API_PATH
}
api/v1
>
${
SWAGGER_ROOT_DIR
}
/v1.json
curl
-fs
${
SWAGGER_API_PATH
}
apis
>
${
SWAGGER_ROOT_DIR
}
/apis.json
curl
-fs
${
SWAGGER_API_PATH
}
apis/extensions
>
${
SWAGGER_ROOT_DIR
}
/extensions.json
curl
-fs
${
SWAGGER_API_PATH
}
apis/extensions/v1beta1
>
${
SWAGGER_ROOT_DIR
}
/v1beta1.json
for
ver
in
${
VERSIONS
}
;
do
# 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
-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
-fs
"
${
SWAGGER_API_PATH
}${
SUBPATH
}
"
>
"
${
SWAGGER_ROOT_DIR
}
/
${
SWAGGER_JSON_NAME
}
"
done
# fetch swagger specs for other discovery mechanism.
curl
-fs
"
${
SWAGGER_API_PATH
}
"
>
"
${
SWAGGER_ROOT_DIR
}
/resourceListing.json"
curl
-fs
"
${
SWAGGER_API_PATH
}
version"
>
"
${
SWAGGER_ROOT_DIR
}
/version.json"
curl
-fs
"
${
SWAGGER_API_PATH
}
api"
>
"
${
SWAGGER_ROOT_DIR
}
/api.json"
curl
-fs
"
${
SWAGGER_API_PATH
}
apis"
>
"
${
SWAGGER_ROOT_DIR
}
/apis.json"
kube::log::status
"SUCCESS"
kube::log::status
"SUCCESS"
# ex: ts=2 sw=2 et filetype=sh
# ex: ts=2 sw=2 et filetype=sh
hack/gen-swagger-doc/gen-swagger-docs.sh
View file @
6aa23e4e
...
@@ -33,6 +33,7 @@ for i in {1..3}; do
...
@@ -33,6 +33,7 @@ for i in {1..3}; do
done
done
# gendocs takes "input.json" as the input swagger spec.
# gendocs takes "input.json" as the input swagger spec.
# $1 is expected to be <group>_<version>
cp
/swagger-source/
"
$1
"
.json input.json
cp
/swagger-source/
"
$1
"
.json input.json
./gradle-2.5/bin/gradle gendocs
--info
./gradle-2.5/bin/gradle gendocs
--info
...
@@ -41,20 +42,24 @@ cp /swagger-source/"$1".json input.json
...
@@ -41,20 +42,24 @@ cp /swagger-source/"$1".json input.json
buf
=
"== Top Level API Objects
\n\n
"
buf
=
"== Top Level API Objects
\n\n
"
top_level_models
=
$(
grep
GetObjectKind ./register.go |
sed
's/func (obj \*\(.*\)) GetObjectKind(\(.*\)) .*/\1/g'
\
top_level_models
=
$(
grep
GetObjectKind ./register.go |
sed
's/func (obj \*\(.*\)) GetObjectKind(\(.*\)) .*/\1/g'
\
|
tr
-d
'()'
|
tr
-d
'{}'
|
tr
-d
' '
)
|
tr
-d
'()'
|
tr
-d
'{}'
|
tr
-d
' '
)
# check if the top level models exist in the definitions.adoc. If they exist,
# their name will be <version>.<model_name>
VERSION
=
"
${
1
#*_
}
"
for
m
in
$top_level_models
for
m
in
$top_level_models
do
do
if
grep
-xq
"===
$
1
.
$m
"
./definitions.adoc
if
grep
-xq
"===
$
{
VERSION
}
.
$m
"
./definitions.adoc
then
then
buf+
=
"* <<
$
1
."
$m
"
>>
\n
"
buf+
=
"* <<
$
{
VERSION
}
.
$m
>>
\n
"
fi
fi
done
done
sed
-i
"1i
$buf
"
./definitions.adoc
sed
-i
"1i
$buf
"
./definitions.adoc
#fix the links in .adoc, replace <<x.y>> with link:definitions.html#_x_y[x.y], and lowercase the _x_y part
#
fix the links in .adoc, replace <<x.y>> with link:definitions.html#_x_y[x.y], and lowercase the _x_y part
sed
-i
-e
's|<<\(.*\)\.\(.*\)>>|link:#_\L\1_\2\E[\1.\2]|g'
./definitions.adoc
sed
-i
-e
's|<<\(.*\)\.\(.*\)>>|link:#_\L\1_\2\E[\1.\2]|g'
./definitions.adoc
sed
-i
-e
's|<<\(.*\)\.\(.*\)>>|link:definitions.html#_\L\1_\2\E[\1.\2]|g'
./paths.adoc
sed
-i
-e
's|<<\(.*\)\.\(.*\)>>|link:definitions.html#_\L\1_\2\E[\1.\2]|g'
./paths.adoc
#fix the link to <<any>>
#
fix the link to <<any>>
sed
-i
-e
's|<<any>>|link:#_any[any]|g'
./definitions.adoc
sed
-i
-e
's|<<any>>|link:#_any[any]|g'
./definitions.adoc
sed
-i
-e
's|<<any>>|link:definitions.html#_any[any]|g'
./paths.adoc
sed
-i
-e
's|<<any>>|link:definitions.html#_any[any]|g'
./paths.adoc
...
...
hack/lib/util.sh
View file @
6aa23e4e
...
@@ -297,4 +297,19 @@ kube::util::group-version-to-pkg-path() {
...
@@ -297,4 +297,19 @@ kube::util::group-version-to-pkg-path() {
esac
esac
}
}
# Takes a group/version and returns the swagger-spec file name.
# default behavior: extensions/v1beta1 -> extensions_v1beta1
# special case for v1: v1 -> v1
kube::util::gv-to-swagger-name
()
{
local
group_version
=
"
$1
"
case
"
${
group_version
}
"
in
v1
)
echo
"v1"
;;
*
)
echo
"
${
group_version
%/*
}
_
${
group_version
#*/
}
"
;;
esac
}
# ex: ts=2 sw=2 et filetype=sh
# ex: ts=2 sw=2 et filetype=sh
hack/update-api-reference-docs.sh
View file @
6aa23e4e
...
@@ -40,12 +40,12 @@ OUTPUT_TMP="${KUBE_ROOT}/${TMP_SUBPATH}"
...
@@ -40,12 +40,12 @@ OUTPUT_TMP="${KUBE_ROOT}/${TMP_SUBPATH}"
echo
"Generating api reference docs at
${
OUTPUT_TMP
}
"
echo
"Generating api reference docs at
${
OUTPUT_TMP
}
"
V1_TMP_IN_HOST
=
"
${
OUTPUT_TMP_IN_HOST
}
/v1/
"
DEFAULT_GROUP_VERSIONS
=
"v1 extensions/v1beta1
"
V
1_TMP
=
"
${
OUTPUT_TMP
}
/v1/"
V
ERSIONS
=
${
VERSIONS
:-
$DEFAULT_GROUP_VERSIONS
}
mkdir
-p
${
V1_TMP
}
for
ver
in
$VERSIONS
;
do
V1BETA1_TMP_IN_HOST
=
"
${
OUTPUT_TMP_IN_HOST
}
/extensions/v1beta1/
"
mkdir
-p
"
${
OUTPUT_TMP
}
/
${
ver
}
"
V1BETA1_TMP
=
"
${
OUTPUT_TMP
}
/extensions/v1beta1/"
done
mkdir
-p
${
V1BETA1_TMP
}
SWAGGER_PATH
=
"
${
REPO_DIR
}
/api/swagger-spec/"
SWAGGER_PATH
=
"
${
REPO_DIR
}
/api/swagger-spec/"
echo
"Reading swagger spec from:
${
SWAGGER_PATH
}
"
echo
"Reading swagger spec from:
${
SWAGGER_PATH
}
"
...
@@ -56,13 +56,23 @@ if [[ $(uname) == "Darwin" ]]; then
...
@@ -56,13 +56,23 @@ if [[ $(uname) == "Darwin" ]]; then
user_flags
=
""
user_flags
=
""
fi
fi
docker run
${
user_flags
}
--rm
-v
$V1_TMP_IN_HOST
:/output:z
-v
${
SWAGGER_PATH
}
:/swagger-source:z gcr.io/google_containers/gen-swagger-docs:v4.2
\
for
ver
in
$VERSIONS
;
do
v1
\
TMP_IN_HOST
=
"
${
OUTPUT_TMP_IN_HOST
}
/
${
ver
}
"
https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg/api/v1/register.go
REGISTER_FILE_URL
=
"https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg"
if
[[
${
ver
}
==
"v1"
]]
;
then
REGISTER_FILE_URL
=
"
${
REGISTER_FILE_URL
}
/api/
${
ver
}
/register.go"
else
REGISTER_FILE_URL
=
"
${
REGISTER_FILE_URL
}
/apis/
${
ver
}
/register.go"
fi
SWAGGER_JSON_NAME
=
"
$(
kube::util::gv-to-swagger-name
"
${
ver
}
"
)
"
docker run
${
user_flags
}
--rm
-v
$V1BETA1_TMP_IN_HOST
:/output:z
-v
${
SWAGGER_PATH
}
:/swagger-source:z gcr.io/google_containers/gen-swagger-docs:v4.2
\
docker run
${
user_flags
}
\
v1beta1
\
--rm
-v
"
${
TMP_IN_HOST
}
"
:/output:z
\
https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg/apis/extensions/v1beta1/register.go
-v
"
${
SWAGGER_PATH
}
"
:/swagger-source:z
\
gcr.io/google_containers/gen-swagger-docs:v5
\
"
${
SWAGGER_JSON_NAME
}
"
\
"
${
REGISTER_FILE_URL
}
"
done
# Check if we actually changed anything
# Check if we actually changed anything
pushd
"
${
OUTPUT_TMP
}
"
>
/dev/null
pushd
"
${
OUTPUT_TMP
}
"
>
/dev/null
...
@@ -93,6 +103,6 @@ done <"${OUTPUT_TMP}/.generated_html"
...
@@ -93,6 +103,6 @@ done <"${OUTPUT_TMP}/.generated_html"
echo
"Moving api reference docs from
${
OUTPUT_TMP
}
to
${
OUTPUT
}
"
echo
"Moving api reference docs from
${
OUTPUT_TMP
}
to
${
OUTPUT
}
"
cp
-af
"
${
OUTPUT_TMP
}
"
/
*
"
${
OUTPUT
}
"
cp
-af
"
${
OUTPUT_TMP
}
"
/
*
"
${
OUTPUT
}
"
rm
-r
${
OUTPUT_TMP
}
rm
-r
"
${
OUTPUT_TMP
}
"
# ex: ts=2 sw=2 et filetype=sh
# ex: ts=2 sw=2 et filetype=sh
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment