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
7a8fa181
Commit
7a8fa181
authored
Sep 21, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update generation scripts to share API group version constants
parent
db074337
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
79 additions
and
14 deletions
+79
-14
init.sh
hack/lib/init.sh
+25
-0
util.sh
hack/lib/util.sh
+5
-2
test-integration.sh
hack/make-rules/test-integration.sh
+2
-1
test.sh
hack/make-rules/test.sh
+3
-1
update-api-reference-docs.sh
hack/update-api-reference-docs.sh
+11
-4
update-codegen.sh
hack/update-codegen.sh
+27
-1
update-generated-swagger-docs.sh
hack/update-generated-swagger-docs.sh
+2
-1
update-swagger-spec.sh
hack/update-swagger-spec.sh
+1
-3
testapi.go
pkg/api/testapi/testapi.go
+3
-1
No files found.
hack/lib/init.sh
View file @
7a8fa181
...
...
@@ -44,6 +44,31 @@ source "${KUBE_ROOT}/hack/lib/etcd.sh"
KUBE_OUTPUT_HOSTBIN
=
"
${
KUBE_OUTPUT_BINPATH
}
/
$(
kube::util::host_platform
)
"
# list of all available group versions. This should be used when generated code
# or when starting an API server that you want to have everything.
# most preferred version for a group should appear first
KUBE_AVAILABLE_GROUP_VERSIONS
=
"
${
KUBE_AVAILABLE_GROUP_VERSIONS
:-
\
v1 \
apps/v1alpha1 \
authentication.k8s.io/v1beta1 \
authorization.k8s.io/v1beta1 \
autoscaling/v1 \
batch/v1 \
batch/v2alpha1 \
certificates.k8s.io/v1alpha1 \
extensions/v1beta1 \
imagepolicy.k8s.io/v1alpha1 \
policy/v1alpha1 \
rbac.authorization.k8s.io/v1alpha1 \
storage.k8s.io/v1beta1\
}
"
# not all group versions are exposed by the server. This list contains those
# which are not available so we don't generate clients or swagger for them
KUBE_NONSERVER_GROUP_VERSIONS
=
"
imagepolicy.k8s.io/v1alpha1
"
# This emulates "readlink -f" which is not available on MacOS X.
# Test:
# T=/tmp/$$.$RANDOM
...
...
hack/lib/util.sh
View file @
7a8fa181
...
...
@@ -312,10 +312,10 @@ kube::util::group-version-to-pkg-path() {
echo
"api/unversioned"
;;
*
.k8s.io
)
echo
"apis/
${
group_version
%.k8s.io
}
"
echo
"apis/
${
group_version
%.
*
k8s.io
}
"
;;
*
.k8s.io/
*
)
echo
"apis/
${
group_version
/.k8s.io/
}
"
echo
"apis/
${
group_version
/.
*
k8s.io/
}
"
;;
*
)
echo
"apis/
${
group_version
%__internal
}
"
...
...
@@ -347,6 +347,9 @@ kube::util::gv-to-swagger-name() {
# 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"
...
...
hack/make-rules/test-integration.sh
View file @
7a8fa181
...
...
@@ -27,7 +27,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
# KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,extensions/v1beta1"}
# FIXME: due to current implementation of a test client (see: pkg/api/testapi/testapi.go)
# ONLY the last version is tested in each group.
KUBE_TEST_API_VERSIONS
=
${
KUBE_TEST_API_VERSIONS
:-
"v1,authentication.k8s.io/v1beta1,authorization.k8s.io/v1beta1,autoscaling/v1,batch/v1,apps/v1alpha1,policy/v1alpha1,extensions/v1beta1,rbac.authorization.k8s.io/v1alpha1,certificates.k8s.io/v1alpha1,storage.k8s.io/v1beta1"
}
ALL_VERSIONS_CSV
=
$(
IFS
=
','
;
echo
"
${
KUBE_AVAILABLE_GROUP_VERSIONS
[*]// /,
}
"
;
IFS
=
$)
KUBE_TEST_API_VERSIONS
=
"
${
KUBE_TEST_API_VERSIONS
:-${
ALL_VERSIONS_CSV
}}
"
# Give integration tests longer to run
# TODO: allow a larger value to be passed in
...
...
hack/make-rules/test.sh
View file @
7a8fa181
...
...
@@ -66,7 +66,8 @@ KUBE_GOVERALLS_BIN=${KUBE_GOVERALLS_BIN:-}
# "v1,compute/v1alpha1,experimental/v1alpha2;v1,compute/v2,experimental/v1alpha3"
# FIXME: due to current implementation of a test client (see: pkg/api/testapi/testapi.go)
# ONLY the last version is tested in each group.
KUBE_TEST_API_VERSIONS
=
${
KUBE_TEST_API_VERSIONS
:-
"v1,apps/v1alpha1,authentication.k8s.io/v1beta1,authorization.k8s.io/v1beta1,autoscaling/v1,batch/v1,batch/v2alpha1,certificates.k8s.io/v1alpha1,extensions/v1beta1,federation/v1beta1,policy/v1alpha1,rbac.authorization.k8s.io/v1alpha1,imagepolicy.k8s.io/v1alpha1,storage.k8s.io/v1beta1"
}
ALL_VERSIONS_CSV
=
$(
IFS
=
','
;
echo
"
${
KUBE_AVAILABLE_GROUP_VERSIONS
[*]// /,
}
"
;
IFS
=
$)
,federation/v1beta1
KUBE_TEST_API_VERSIONS
=
"
${
KUBE_TEST_API_VERSIONS
:-${
ALL_VERSIONS_CSV
}}
"
# once we have multiple group supports
# Create a junit-style XML test report in this directory if set.
KUBE_JUNIT_REPORT_DIR
=
${
KUBE_JUNIT_REPORT_DIR
:-}
...
...
@@ -295,6 +296,7 @@ checkFDs() {
checkFDs
# Convert the CSVs to arrays.
IFS='
;
' read -a apiVersions <<< "${KUBE_TEST_API_VERSIONS}"
apiVersionsCount=${#apiVersions[@]}
...
...
hack/update-api-reference-docs.sh
View file @
7a8fa181
...
...
@@ -34,12 +34,19 @@ OUTPUT=${1:-${DEFAULT_OUTPUT}}
SWAGGER_SPEC_PATH
=
"
${
REPO_DIR
}
/api/swagger-spec"
GROUP_VERSIONS
=(
"v1"
"extensions/v1beta1"
"batch/v1"
"authentication.k8s.io/v1beta1"
"autoscaling/v1"
"certificates.k8s.io/v1alpha1"
)
ALL_GROUP_VERSIONS
=(
${
KUBE_AVAILABLE_GROUP_VERSIONS
}
)
INTERESTING_GROUP_VERSIONS
=()
GV_DIRS
=()
for
gv
in
"
${
GROUP_VERSIONS
[@]
}
"
;
do
GV_DIRS+
=(
"
${
REPO_DIR
}
/pkg/
$(
kube::util::group-version-to-pkg-path
"
${
gv
}
"
)
"
)
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
}
/pkg/
$(
kube::util::group-version-to-pkg-path
"
${
gv
}
"
)
"
)
done
GROUP_VERSIONS
=
"
${
GROUP_VERSIONS
[@]
}
"
GV_DIRS
=
"
${
GV_DIRS
[@]
}
"
kube::swagger::gen_api_ref_docs
"
${
SWAGGER_SPEC_PATH
}
"
"
${
OUTPUT
}
"
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
hack/update-codegen.sh
View file @
7a8fa181
...
...
@@ -35,11 +35,37 @@ setgen=$(kube::util::find-binary "set-gen")
# Please do not add any logic to this shell script. Add logic to the go code
# that generates the set-gen program.
#
GROUP_VERSIONS
=(
${
KUBE_AVAILABLE_GROUP_VERSIONS
}
)
GV_DIRS
=()
SEEN_GROUPS
=
","
for
gv
in
"
${
GROUP_VERSIONS
[@]
}
"
;
do
# add items, but strip off any leading apis/ you find to match command expectations
api_dir
=
$(
kube::util::group-version-to-pkg-path
"
${
gv
}
"
)
pkg_dir
=
${
api_dir
#apis/
}
# don't add a version for a group you've already seen
group
=
${
pkg_dir
%%/*
}
if
[[
"
${
SEEN_GROUPS
}
"
==
*
",
${
group
}
."
*
]]
;
then
continue
fi
SEEN_GROUPS
=
"
${
SEEN_GROUPS
}
,
${
group
}
."
# skip groups that aren't being served, clients for these don't matter
if
[[
"
${
KUBE_NONSERVER_GROUP_VERSIONS
}
"
==
*
"
${
gv
}
"
*
]]
;
then
continue
fi
GV_DIRS+
=(
"
${
pkg_dir
}
"
)
done
# delimit by commas for the command
GV_DIRS_CSV
=
$(
IFS
=
','
;
echo
"
${
GV_DIRS
[*]// /,
}
"
;
IFS
=
$)
# This can be called with one flag, --verify-only, so it works for both the
# update- and verify- scripts.
${
clientgen
}
"
$@
"
${
clientgen
}
-t
"
$@
"
${
clientgen
}
--clientset-name
=
"release_1_5"
--input
=
"
api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1,storage/v1beta1
"
"
$@
"
${
clientgen
}
--clientset-name
=
"release_1_5"
--input
=
"
${
GV_DIRS_CSV
}
"
"
$@
"
# Clientgen for federation clientset.
${
clientgen
}
--clientset-name
=
federation_internalclientset
--clientset-path
=
k8s.io/kubernetes/federation/client/clientset_generated
--input
=
"../../federation/apis/federation/"
,
"api/"
,
"extensions/"
--included-types-overrides
=
"api/Service,api/Namespace,extensions/ReplicaSet,api/Secret,extensions/Ingress,api/Event"
"
$@
"
${
clientgen
}
--clientset-name
=
federation_release_1_5
--clientset-path
=
k8s.io/kubernetes/federation/client/clientset_generated
--input
=
"../../federation/apis/federation/v1beta1"
,
"api/v1"
,
"extensions/v1beta1"
--included-types-overrides
=
"api/v1/Service,api/v1/Namespace,extensions/v1beta1/ReplicaSet,api/v1/Secret,extensions/v1beta1/Ingress,api/v1/Event"
"
$@
"
...
...
hack/update-generated-swagger-docs.sh
View file @
7a8fa181
...
...
@@ -28,7 +28,8 @@ source "${KUBE_ROOT}/hack/lib/swagger.sh"
kube::golang::setup_env
GROUP_VERSIONS
=(
unversioned v1 authentication/v1beta1 authorization/v1beta1 autoscaling/v1 batch/v1 batch/v2alpha1 extensions/v1beta1 apps/v1alpha1 policy/v1alpha1 rbac/v1alpha1 storage/v1beta1 certificates/v1alpha1
)
GROUP_VERSIONS
=(
unversioned
${
KUBE_AVAILABLE_GROUP_VERSIONS
}
)
# To avoid compile errors, remove the currently existing files.
for
group_version
in
"
${
GROUP_VERSIONS
[@]
}
"
;
do
rm
-f
"pkg/
$(
kube::util::group-version-to-pkg-path
"
${
group_version
}
"
)
/types_swagger_doc_generated.go"
...
...
hack/update-swagger-spec.sh
View file @
7a8fa181
...
...
@@ -73,12 +73,10 @@ APISERVER_PID=$!
kube::util::wait_for_url
"
${
API_HOST
}
:
${
API_PORT
}
/healthz"
"apiserver: "
SWAGGER_API_PATH
=
"
${
API_HOST
}
:
${
API_PORT
}
/swaggerapi/"
DEFAULT_GROUP_VERSIONS
=
"v1 apps/v1alpha1 authentication.k8s.io/v1beta1 authorization.k8s.io/v1beta1 autoscaling/v1 batch/v1 batch/v2alpha1 extensions/v1beta1 certificates.k8s.io/v1alpha1 policy/v1alpha1 rbac.authorization.k8s.io/v1alpha1 storage.k8s.io/v1beta1"
VERSIONS
=
${
VERSIONS
:-
$DEFAULT_GROUP_VERSIONS
}
kube::log::status
"Updating "
${
SWAGGER_ROOT_DIR
}
SWAGGER_API_PATH
=
"
${
SWAGGER_API_PATH
}
"
SWAGGER_ROOT_DIR
=
"
${
SWAGGER_ROOT_DIR
}
"
VERSIONS
=
"
${
VERSIONS
}
"
kube::util::fetch-swagger-spec
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"
...
...
pkg/api/testapi/testapi.go
View file @
7a8fa181
...
...
@@ -115,8 +115,10 @@ func init() {
kubeTestAPI
:=
os
.
Getenv
(
"KUBE_TEST_API"
)
if
len
(
kubeTestAPI
)
!=
0
{
// priority is "first in list preferred", so this has to run in reverse order
testGroupVersions
:=
strings
.
Split
(
kubeTestAPI
,
","
)
for
_
,
gvString
:=
range
testGroupVersions
{
for
i
:=
len
(
testGroupVersions
)
-
1
;
i
>=
0
;
i
--
{
gvString
:=
testGroupVersions
[
i
]
groupVersion
,
err
:=
unversioned
.
ParseGroupVersion
(
gvString
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"Error parsing groupversion %v: %v"
,
gvString
,
err
))
...
...
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