├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── OWNERS
├── README.md
├── SECURITY_CONTACTS
├── code-of-conduct.md
├── openapi
├── README.md
├── autoupdate.sh
├── c.sh
├── c.xml
├── csharp.sh
├── csharp.xml
├── custom_objects_spec.json
├── go.sh
├── go.xml
├── haskell-http-client.xml
├── haskell.sh
├── java-crd-cmd.sh
├── java.sh
├── java.xml
├── openapi-generator
│ ├── Dockerfile
│ ├── client-generator.sh
│ └── generate_client_in_container.sh
├── perl.sh
├── perl.xml
├── preprocess_spec.py
├── python-api_client.py.patch
├── python-asyncio.sh
├── python-asyncio.xml
├── python-crd-cmd.sh
├── python.sh
├── python.xml
├── ruby.sh
├── ruby.xml
├── rust.sh
├── rust.xml
├── typescript-fetch.sh
├── typescript-fetch.xml
├── typescript-jquery.sh
├── typescript-jquery.xml
├── typescript.sh
├── typescript.xml
└── update-templates.sh
└── proto
├── dependencies.sh
├── generate.sh
└── install.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | # Intellij IDEA files
2 | .idea/*
3 | *.iml
4 |
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Thanks for taking the time to join our community and start contributing!
4 |
5 | Please remember to read and observe the [Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
6 |
7 | This project accepts contribution via github [pull requests](https://help.github.com/articles/about-pull-requests/).
8 | This document outlines the process to help get your contribution accepted.
9 | Please also read the [Kubernetes contributor guide](https://github.com/kubernetes/community/blob/master/contributors/guide/README.md)
10 | which provides detailed instructions on how to get your ideas and bug fixes seen and accepted.
11 |
12 | ## Sign the Contributor License Agreement
13 | We'd love to accept your patches! Before we can accept them you need to sign Cloud Native Computing Foundation (CNCF) [CLA](https://github.com/kubernetes/community/blob/master/CLA.md).
14 |
15 | ## Reporting an issue
16 | If you have any problem with the package or any suggestions, please file an [issue](https://github.com/kubernetes-client/gen/issues).
17 |
18 | ## Contributing a Patch
19 | 1. Submit an issue describing your proposed change to the repo.
20 | 2. Fork this repo, develop and test your code changes.
21 | 3. Submit a pull request.
22 | 4. The bot will automatically assigns someone to review your PR. Check the full list of bot commands [here](https://prow.k8s.io/command-help).
23 |
24 | ### Contact
25 | You can reach the maintainers of this project at [SIG API Machinery](https://github.com/kubernetes/community/tree/master/sig-api-machinery) or on the [#kubernetes-client](https://kubernetes.slack.com/messages/kubernetes-client) channel on the Kubernetes slack.
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/OWNERS:
--------------------------------------------------------------------------------
1 | # See the OWNERS docs at https://go.k8s.io/owners
2 | approvers:
3 | - brendandburns
4 | - yue9944882
5 | - yliaog
6 | reviewers:
7 | - brendandburns
8 | - yue9944882
9 | - yliaog
10 | emeritus_approvers:
11 | - mbohlool
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # gen
2 | Common generator scripts for all client libraries
3 |
4 | # Badges
5 |
6 | [](https://github.com/kubernetes-client)
7 |
8 | [](https://github.com/kubernetes-client)
9 |
10 | [](https://github.com/kubernetes-client)
11 |
12 | # Generating a client
13 | To generate a client, first make sure the client generator exists. For any language other than
14 | go, check `openapi/` folder for a script with `${CLIENT_LANGUAGE}.sh` and run this command:
15 |
16 | ```bash
17 | ${CLIENT_LANGUAGE}.sh OUTPUT_DIR SETTING_FILE
18 | ```
19 |
20 | `SETTING_FILE` is a bash script exporting required setting to generate a client. These
21 | are normally:
22 |
23 | - `KUBERNETES_BRANCH`: The kubernetes branch to get OpenAPI spec from. e.g. "master"
24 | - `CLIENT_VERSION`: Client version string. e.g. "1.0.0b1"
25 | - `PACKAGE_NAME`: Package name for the generated client. e.g. "kubernetes"
26 |
27 | Example settings file for python-client:
28 |
29 | export KUBERNETES_BRANCH="master"
30 | export CLIENT_VERSION="8.0.0b1"
31 | export PACKAGE_NAME="client"
32 |
33 | Note: For generating the client for any language, the PACKAGE_NAME should be "client".
34 | You can use the latest version for the CLIENT_VERSION. It's displayed here for
35 | the python-client ( https://github.com/kubernetes-client/python ), and similarly
36 | for other language clients.
37 |
38 | Recommended structure is to generate client in a folder called `kubernetes` at the root of
39 | the client repo and put all settings in a file named `settings` at the root of the repo.
40 | If you followed these recommendations, you can simply run autoupdate script anywhere inside
41 | the client repo:
42 |
43 | ```bash
44 | cd ${CLIENT_ROOT}/...
45 | ${GEN_REPO_ROOT}/openapi/autoupdate.sh
46 | ```
47 |
48 | ## Contributing
49 |
50 | Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.
51 |
--------------------------------------------------------------------------------
/SECURITY_CONTACTS:
--------------------------------------------------------------------------------
1 | # Defined below are the security contacts for this repo.
2 | #
3 | # They are the contact point for the Product Security Team to reach out
4 | # to for triaging and handling of incoming issues.
5 | #
6 | # The below names agree to abide by the
7 | # [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
8 | # and will be removed and replaced if they violate that agreement.
9 | #
10 | # DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
11 | # INSTRUCTIONS AT https://kubernetes.io/security/
12 |
13 | brendandburns
14 | mbohlool
15 |
--------------------------------------------------------------------------------
/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | # Kubernetes Community Code of Conduct
2 |
3 | Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md)
4 |
--------------------------------------------------------------------------------
/openapi/README.md:
--------------------------------------------------------------------------------
1 | Share generator files for all OpenAPI based clients (non-go clients) such as python.
--------------------------------------------------------------------------------
/openapi/autoupdate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Script to fetch latest swagger spec.
18 | # Puts the updated spec at api/swagger-spec/
19 |
20 | set -o errexit
21 | set -o nounset
22 | set -o pipefail
23 |
24 | # Run this script on the root of the repo to automatically
25 | # detect the language and update its client. Assumptions are:
26 | # - the repo name is the language name.
27 | # - the output folder is named "kubernetes" at the root of the repo
28 | # - setting file is named "settings" at the root of the repo
29 |
30 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
31 | pushd "${SCRIPT_ROOT}" > /dev/null
32 | SCRIPT_ROOT=`pwd`
33 | popd > /dev/null
34 |
35 | REPO_NAME=$(basename `git rev-parse --show-toplevel`)
36 | REPO_ROOT=$(git rev-parse --show-toplevel)
37 |
38 | if [[ ! -f "${SCRIPT_ROOT}/${REPO_NAME}.sh" ]]; then
39 | echo "Repo name \"${REPO_NAME}\" is not a supported language."
40 | exit 1
41 | fi
42 |
43 | if [[ ! -d "${REPO_ROOT}/kubernetes" ]]; then
44 | echo "Expected folder named \"kubernetes\" at the root of the repo"
45 | exit 1
46 | fi
47 |
48 | if [[ ! -f "${REPO_ROOT}/settings" ]]; then
49 | echo "Expected setting file to be at the root of the repo"
50 | exit 1
51 | fi
52 |
53 | echo "Running command \"${SCRIPT_ROOT}/${REPO_NAME}.sh\" \"${REPO_ROOT}/kubernetes\" \"${REPO_ROOT}/settings\""
54 |
55 | "${SCRIPT_ROOT}/${REPO_NAME}.sh" "${REPO_ROOT}/kubernetes" "${REPO_ROOT}/settings"
56 |
57 |
58 |
--------------------------------------------------------------------------------
/openapi/c.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-master}" \
50 | CLIENT_LANGUAGE=c; \
51 | CLEANUP_DIRS=(pkg); \
52 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
53 |
54 | echo "---Done."
55 |
--------------------------------------------------------------------------------
/openapi/c.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-c
5 | 1.0-SNAPSHOT
6 | client-c
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | true
21 | ${generator.spec.path}
22 | c
23 | kubernetes-c
24 | c
25 |
26 | ${generator.package.name}
27 | ${generator.client.version}
28 |
29 |
30 | int-or-string=IntOrString
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | io.swagger
41 | swagger-annotations
42 | ${swagger-annotations-version}
43 |
44 |
45 |
46 | 1.5.0
47 | 1.0.0
48 |
49 |
50 | .
51 | swagger.json
52 | swagger_client
53 | unversioned
54 |
55 |
56 |
--------------------------------------------------------------------------------
/openapi/csharp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Script to fetch latest swagger spec.
18 | # Puts the updated spec at api/swagger-spec/
19 |
20 | set -o errexit
21 | set -o nounset
22 | set -o pipefail
23 |
24 | ARGC=$#
25 |
26 | if [ $# -ne 2 ]; then
27 | echo "Usage:"
28 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
29 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
30 | echo " Setting file can define an optional USERNAME if you're working on a fork"
31 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
32 | exit 1
33 | fi
34 |
35 |
36 | OUTPUT_DIR=$1
37 | SETTING_FILE=$2
38 | mkdir -p "${OUTPUT_DIR}"
39 |
40 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
41 | pushd "${SCRIPT_ROOT}" > /dev/null
42 | SCRIPT_ROOT=`pwd`
43 | popd > /dev/null
44 |
45 | pushd "${OUTPUT_DIR}" > /dev/null
46 | OUTPUT_DIR=`pwd`
47 | popd > /dev/null
48 |
49 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
50 | source "${SETTING_FILE}"
51 |
52 | # TODO(brendandburns): Update CLEANUP_DIRS
53 | CLIENT_LANGUAGE=csharp; CLEANUP_DIRS=(docs src target gradle); kubeclient::generator::generate_client "${OUTPUT_DIR}"
--------------------------------------------------------------------------------
/openapi/csharp.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | io.kubernetes
6 | client-csharp
7 | 1.0-SNAPSHOT
8 | client-net
9 | http://kubernetes.io
10 |
11 |
12 |
13 | org.codehaus.mojo
14 | exec-maven-plugin
15 | 1.1.1
16 |
17 |
18 | generate
19 | generate-sources
20 |
21 | exec
22 |
23 |
24 |
25 |
26 | true
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/openapi/go.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v3.3.4}" \
50 | CLIENT_LANGUAGE=go; \
51 | CLEANUP_DIRS=(pkg); \
52 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
53 |
54 | echo "---Done."
55 |
--------------------------------------------------------------------------------
/openapi/go.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-go
5 | 1.0-SNAPSHOT
6 | client-go
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | ${generator.spec.path}
21 | go
22 | kubernetes-client
23 | go
24 |
25 | ${generator.package.name}
26 | ${generator.client.version}
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | io.swagger
39 | swagger-annotations
40 | ${swagger-annotations-version}
41 |
42 |
43 |
44 | 1.5.0
45 | 1.0.0
46 |
47 |
48 | .
49 | swagger.json
50 | swagger_client
51 | unversioned
52 |
53 |
54 |
--------------------------------------------------------------------------------
/openapi/haskell-http-client.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-haskell
5 | 1.0-SNAPSHOT
6 | client-haskell
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | ${generator.spec.path}
21 | haskell-http-client
22 |
23 | true
24 | intstr.IntOrString=IntOrString,resource.Quantity=Quantity
25 | IntOrString=Kubernetes.OpenAPI.CustomTypes,Quantity=Kubernetes.OpenAPI.CustomTypes
26 |
27 | ${generator.package.name}
28 | ${generator.client.version}
29 | true
30 | kubernetes-client-core
31 | Kubernetes.OpenAPI
32 | KubernetesRequest
33 | KubernetesClientConfig
34 | CustomInstances
35 | %FT%T%6QZ
36 | %FT%T%QZ
37 | +
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/openapi/haskell.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | # Latest version as of Mar 15, 2019
50 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-a979fd8e13c86431831b0c769ba7b484e744afa5}"; \
51 | CLIENT_LANGUAGE=haskell-http-client; \
52 | CLEANUP_DIRS=(lib/Kubernetes/OpenAPI/API); \
53 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
54 |
55 | CABAL_OVERRIDES=(homepage https://github.com/kubernetes-client/haskell
56 | author "Auto Generated"
57 | maintainer "Shimin Guo , Akshay Mankar "
58 | license Apache-2.0)
59 |
60 | patch_cabal_file() {
61 | while [[ $# -gt 1 ]]; do
62 | sed -i 's|^\('$1':[[:space:]]*\).*|\1'"$2"'|' ${OUTPUT_DIR}/*.cabal
63 | shift 2
64 | done
65 | }
66 |
67 | patch_cabal_file "${CABAL_OVERRIDES[@]}"
68 |
69 | # Add license-file after license
70 | sed -i '/^license:/a license-file: LICENSE' ${OUTPUT_DIR}/*.cabal
71 |
72 | ln -sf ../LICENSE ${OUTPUT_DIR}/LICENSE
73 |
74 | sed -i '/^copyright:/d' ${OUTPUT_DIR}/*.cabal
75 | echo "---Done."
76 |
--------------------------------------------------------------------------------
/openapi/java-crd-cmd.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | PACKAGE_NAME=${PACKAGE_NAME:-io.kubernetes.client}
4 | CLIENT_VERSION=${CLIENT_VERSION:-5.0-SNAPSHOT}
5 | GENERATE_APIS=${GENERATE_APIS:-false}
6 | OUTPUT_DIR=${OUTPUT_DIR:-java}
7 | OPENAPI_MODEL_LENGTH=${OPENAPI_MODEL_LENGTH:-}
8 | HIDE_GENERATION_TIMESTAMP=${HIDE_GENERATION_TIMESTAMP:-false}
9 | LIBRARY=${LIBRARY:-okhttp-gson}
10 | OPENAPI_SKIP_BASE_INTERFACE=
11 | KUBERNETES_CRD_GROUP_PREFIX=
12 |
13 | print_usage() {
14 | echo "Usage: generate a java project using input openapi spec from stdin" >& 2
15 | echo " -c: project version of the generated java project." >& 2
16 | echo " -x: skips implementing kubernetes common interface (this is for backward compatibility w/ client-java lower than 9.0.0)" >& 2
17 | echo " -n: the prefix of the target CRD's api group to generate." >& 2
18 | echo " -g: generate crd apis." >& 2
19 | echo " -p: the base package name of the generated java project. " >& 2
20 | echo " -o: output directory of the generated java project. " >& 2
21 | echo " -l: keep the n last segments for the generated class name. " >& 2
22 | echo " -h: hide generation timestamp" >& 2
23 | echo " -i: client library" >& 2
24 | }
25 |
26 | while getopts 'c:g:h:i:n:l:p:o:x' flag; do
27 | case "${flag}" in
28 | c) CLIENT_VERSION="${CLIENT_VERSION}" ;;
29 | g) GENERATE_APIS="${OPTARG}" ;;
30 | h) HIDE_GENERATION_TIMESTAMP="${OPTARG}" ;;
31 | i) LIBRARY="${OPTARG}" ;;
32 | n) KUBERNETES_CRD_GROUP_PREFIX="${OPTARG}" ;;
33 | l) OPENAPI_MODEL_LENGTH="${OPTARG}" ;;
34 | p) PACKAGE_NAME="${OPTARG}" ;;
35 | o) OUTPUT_DIR="${OPTARG}" ;;
36 | x) OPENAPI_SKIP_BASE_INTERFACE=1 ;;
37 | *) print_usage
38 | exit 1 ;;
39 | esac
40 | done
41 |
42 | echo "KUBERNETES_CRD_GROUP_PREFIX: $KUBERNETES_CRD_GROUP_PREFIX" >& 2
43 | echo "OPENAPI_MODEL_LENGTH: $OPENAPI_MODEL_LENGTH" >& 2
44 | echo "PACKAGE_NAME: $PACKAGE_NAME" >& 2
45 | echo "GENERATE_APIS: $GENERATE_APIS" >& 2
46 | echo "CLIENT_VERSION: $CLIENT_VERSION" >& 2
47 | echo "OUTPUT_DIR: $OUTPUT_DIR" >& 2
48 | echo "HIDE_GENERATION_TIMESTAMP: $HIDE_GENERATION_TIMESTAMP" >& 2
49 | echo "LIBRARY: $LIBRARY" >& 2
50 | echo "" >& 2 # empty line
51 |
52 |
53 | mkdir -p "${OUTPUT_DIR}"
54 |
55 | echo 'rendering settings file to /tmp/settings' >& 2
56 | read -d '' settings << EOF
57 | export KUBERNETES_BRANCH="${KUBERNETES_BRANCH}"
58 |
59 | export CLIENT_VERSION="${CLIENT_VERSION}"
60 |
61 | export PACKAGE_NAME="${PACKAGE_NAME}"
62 | EOF
63 |
64 | echo ${settings} > /tmp/settings
65 |
66 | echo 'reading input openapi specs' >& 2
67 | cat > ${OUTPUT_DIR}/swagger.json.unprocessed
68 |
69 |
70 | source "/tmp/settings"
71 |
72 | KUBERNETES_CRD_MODE=true \
73 | GENERATE_APIS=${GENERATE_APIS} \
74 | OPENAPI_SKIP_FETCH_SPEC=true \
75 | OPENAPI_MODEL_LENGTH=${OPENAPI_MODEL_LENGTH} \
76 | KUBERNETES_CRD_GROUP_PREFIX=${KUBERNETES_CRD_GROUP_PREFIX} \
77 | OPENAPI_SKIP_BASE_INTERFACE=${OPENAPI_SKIP_BASE_INTERFACE} \
78 | HIDE_GENERATION_TIMESTAMP=${HIDE_GENERATION_TIMESTAMP} \
79 | LIBRARY=${LIBRARY} \
80 | $(pwd)/java.sh ${OUTPUT_DIR} /tmp/settings
81 |
--------------------------------------------------------------------------------
/openapi/java.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Script to fetch latest swagger spec.
18 | # Puts the updated spec at api/swagger-spec/
19 |
20 | set -o errexit
21 | set -o nounset
22 | set -o pipefail
23 |
24 | ARGC=$#
25 |
26 | if [ $# -ne 2 ]; then
27 | echo "Usage:"
28 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
29 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
30 | echo " Setting file can define an optional USERNAME if you're working on a fork"
31 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
32 | exit 1
33 | fi
34 |
35 |
36 | OUTPUT_DIR=$1
37 | SETTING_FILE=$2
38 | mkdir -p "${OUTPUT_DIR}"
39 |
40 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
41 | pushd "${SCRIPT_ROOT}" > /dev/null
42 | SCRIPT_ROOT=`pwd`
43 | popd > /dev/null
44 |
45 | pushd "${OUTPUT_DIR}" > /dev/null
46 | OUTPUT_DIR=`pwd`
47 | popd > /dev/null
48 |
49 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
50 | source "${SETTING_FILE}"
51 |
52 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v7.13.0}" \
53 | CLIENT_LANGUAGE=java; \
54 | CLEANUP_DIRS=(docs src/test/java/io/kubernetes/client/openapi/apis src/main/java/io/kubernetes/client/openapi/apis src/main/java/io/kubernetes/client/openapi/models src/main/java/io/kubernetes/client/openapi/auth gradle); \
55 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
56 |
--------------------------------------------------------------------------------
/openapi/java.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | io.kubernetes
6 | client-java-api
7 | ${generator.client.version}
8 | client-java-api
9 | http://kubernetes.io
10 |
11 |
12 | crd-mode
13 |
14 |
15 | env.KUBERNETES_CRD_MODE
16 | true
17 |
18 |
19 |
20 |
21 |
22 | org.openapitools
23 | openapi-generator-maven-plugin
24 |
25 |
26 |
27 | generate
28 |
29 |
30 | ${env.GENERATE_APIS}
31 | false
32 | SET_CONTAINER_TO_NULLABLE="array|map"
33 |
34 | V1ListMeta=io.kubernetes.client.openapi.models.V1ListMeta,
35 | V1ObjectMeta=io.kubernetes.client.openapi.models.V1ObjectMeta,
36 | V1ObjectMeta_v2=io.kubernetes.client.openapi.models.V1ObjectMeta,
37 | IntOrString=io.kubernetes.client.custom.IntOrString,
38 | Quantity=io.kubernetes.client.custom.Quantity,
39 | V1Patch=io.kubernetes.client.custom.V1Patch,
40 | V1DeleteOptions=io.kubernetes.client.openapi.models.V1DeleteOptions,
41 | V1DeleteOptions_v2=io.kubernetes.client.openapi.models.V1DeleteOptions,
42 | V1Status=io.kubernetes.client.openapi.models.V1Status,
43 | V1Status_v2=io.kubernetes.client.openapi.models.V1Status,
44 | V1Scale=io.kubernetes.client.openapi.models.V1Scale,
45 | V1Scale_v2=io.kubernetes.client.openapi.models.V1Scale,
46 |
47 |
48 | io.kubernetes.client.openapi
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | org.openapitools
62 | openapi-generator-maven-plugin
63 | ${openapi-generator-version}
64 |
65 |
66 |
67 | generate
68 |
69 |
70 | ${generator.spec.path}
71 | Kubernetes Java Client/${generator.client.version}
72 | java
73 | kubernetes-client
74 | client-java-api
75 | true
76 | false
77 | false
78 |
79 | Kubernetes Java Client API
80 | https://github.com/kubernetes-client/java
81 | scm:git:git@github.com:kubernetes-client/java.git
82 | scm:git:git@github.com:kubernetes-client/java.git
83 | io.kubernetes
84 | client-java-parent
85 | ${generator.client.version}
86 | kubernetes-java-client
87 | Java client API for Kubernetes.
88 | ${generator.client.version}
89 | Apache License 2.0
90 | https://github.com/kubernetes-client/java/blob/master/LICENSE
91 | true
92 | ${generator.package.name}.models
93 | ${generator.package.name}.apis
94 | ${generator.package.name}
95 | true
96 | io.kubernetes
97 | client-java-api
98 | ${generator.client.version}
99 | src/main/java
100 | false
101 | false
102 | false
103 | ${env.HIDE_GENERATION_TIMESTAMP}
104 | java8
105 | false
106 | true
107 | swagger1
108 | ${env.LIBRARY}
109 | ${use-single-parameter}
110 | false
111 |
112 | int-or-string=IntOrString,quantity=Quantity,patch=V1Patch
113 | IntOrString=io.kubernetes.client.custom.IntOrString,Quantity=io.kubernetes.client.custom.Quantity,V1Patch=io.kubernetes.client.custom.V1Patch
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | org.openapitools
125 | openapi-generator-maven-plugin
126 | ${openapi-generator-version}
127 |
128 |
129 | org.openapitools
130 | client-java-api-openapi-generator
131 | ${openapi-generator-version}
132 |
133 |
134 |
135 |
136 | .
137 | swagger.json
138 | client
139 | ${generator.client.version}
140 | true
141 |
142 |
143 |
--------------------------------------------------------------------------------
/openapi/openapi-generator/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copyright 2017 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | FROM maven:3.9.6-eclipse-temurin-11
16 |
17 | # Install preprocessing script requirements
18 | RUN apt-get update && apt-get -y install git python3-pip && pip install urllib3==1.24.2
19 |
20 | ARG OPENAPI_GENERATOR_COMMIT
21 | ARG GENERATION_XML_FILE
22 | ARG OPENAPI_GENERATOR_USER_ORG=OpenAPITools
23 |
24 | # Check out specific commit of openapi-generator
25 | RUN mkdir /source && \
26 | cd /source && \
27 | mkdir openapi-generator && \
28 | cd openapi-generator && \
29 | git init && \
30 | git remote add origin https://github.com/${OPENAPI_GENERATOR_USER_ORG}/openapi-generator.git && \
31 | git fetch --progress --depth=1 origin $OPENAPI_GENERATOR_COMMIT && \
32 | git checkout -b gen FETCH_HEAD && \
33 | git config --system --add safe.directory /source/openapi-generator
34 |
35 | # Build it and persist local repository
36 | RUN chmod -R go+rwx /root && umask 0 && cd /source/openapi-generator && \
37 | mvn install -DskipTests -Dmaven.test.skip=true -pl modules/openapi-generator-maven-plugin -am && \
38 | cp -r /root/.m2/* /usr/share/maven/ref
39 |
40 | # Copy required files
41 | COPY openapi-generator/generate_client_in_container.sh /generate_client.sh
42 | COPY preprocess_spec.py /
43 | COPY custom_objects_spec.json /
44 | COPY ${GENERATION_XML_FILE} /generation_params.xml
45 |
46 | ENTRYPOINT ["mvn-entrypoint.sh", "/generate_client.sh"]
47 |
--------------------------------------------------------------------------------
/openapi/openapi-generator/client-generator.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Script to fetch latest swagger spec.
18 | # Puts the updated spec at api/swagger-spec/
19 |
20 | set -o errexit
21 | set -o nounset
22 | set -o pipefail
23 |
24 | # Generates client.
25 | # Required env vars:
26 | # CLEANUP_DIRS: List of directories to cleanup before generation for this language
27 | # KUBERNETES_BRANCH: Kubernetes branch name to get the swagger spec from
28 | # CLIENT_VERSION: Client version. Will be used in the comment sections of the generated code
29 | # PACKAGE_NAME: Name of the client package.
30 | # CLIENT_LANGUAGE: Language of the client. ${CLIENT_LANGUAGE}.xml should exists.
31 | # Optional env vars:
32 | # OPENAPI_GENERATOR_USER_ORG: openapi-generator-user-org
33 | # OPENAPI_GENERATOR_COMMIT: openapi-generator-version
34 | # Input vars:
35 | # $1: output directory
36 | kubeclient::generator::generate_client() {
37 | : "${CLEANUP_DIRS?Must set CLEANUP_DIRS env var}"
38 | : "${KUBERNETES_BRANCH?Must set KUBERNETES_BRANCH env var}"
39 | : "${CLIENT_VERSION?Must set CLIENT_VERSION env var}"
40 | : "${PACKAGE_NAME?Must set PACKAGE_NAME env var}"
41 | : "${CLIENT_LANGUAGE?Must set CLIENT_LANGUAGE env var}"
42 |
43 | OPENAPI_GENERATOR_USER_ORG="${OPENAPI_GENERATOR_USER_ORG:-OpenAPITools}"
44 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v5.1.0}"
45 | OPENAPI_MODEL_LENGTH="${OPENAPI_MODEL_LENGTH:-}"
46 | OPENAPI_SKIP_FETCH_SPEC="${OPENAPI_SKIP_FETCH_SPEC:-}"
47 | OPENAPI_SKIP_BASE_INTERFACE="${OPENAPI_SKIP_BASE_INTERFACE:-}"
48 | KUBERNETES_CRD_MODE="${KUBERNETES_CRD_MODE:-}"
49 | KUBERNETES_CRD_GROUP_PREFIX="${KUBERNETES_CRD_GROUP_PREFIX:-}"
50 | GENERATE_APIS="${GENERATE_APIS:-true}"
51 | HIDE_GENERATION_TIMESTAMP="${HIDE_GENERATION_TIMESTAMP:-false}"
52 | USERNAME="${USERNAME:-kubernetes}"
53 | REPOSITORY="${REPOSITORY:-kubernetes}"
54 | CLIENT_VERSION="${CLIENT_VERSION}"
55 | # LIBRARY is used by Java client generation.
56 | LIBRARY="${LIBRARY:-okhttp-gson}"
57 |
58 | local output_dir=$1
59 | pushd "${output_dir}" > /dev/null
60 | local output_dir=`pwd`
61 | popd > /dev/null
62 | local SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
63 | pushd "${SCRIPT_ROOT}" > /dev/null
64 | local SCRIPT_ROOT=`pwd`
65 | popd > /dev/null
66 |
67 | mkdir -p "${output_dir}"
68 |
69 | if [ "${USERNAME}" != "kubernetes" ]; then
70 | image_name="${USERNAME}-${REPOSITORY}-${CLIENT_LANGUAGE}-client-gen-with-openapi-generator:v1"
71 | else
72 | image_name="${REPOSITORY}-${CLIENT_LANGUAGE}-client-gen-with-openapi-generator:v1"
73 | fi
74 |
75 | echo "--- Building docker image ${image_name}..."
76 | docker build "${SCRIPT_ROOT}"/../ -f "${SCRIPT_ROOT}/Dockerfile" -t "${image_name}" \
77 | --build-arg OPENAPI_GENERATOR_USER_ORG="${OPENAPI_GENERATOR_USER_ORG}" \
78 | --build-arg OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT}" \
79 | --build-arg GENERATION_XML_FILE="${CLIENT_LANGUAGE}.xml"
80 |
81 | # Docker does not support passing arrays, pass the string representation
82 | # of the array instead (space separated)
83 | CLEANUP_DIRS_STRING="${CLEANUP_DIRS[@]}"
84 |
85 | echo "--- Running generator inside container..."
86 | docker run --rm --security-opt="label=disable" -u $(id -u) \
87 | -e CLEANUP_DIRS="${CLEANUP_DIRS_STRING}" \
88 | -e KUBERNETES_BRANCH="${KUBERNETES_BRANCH}" \
89 | -e CLIENT_VERSION="${CLIENT_VERSION}" \
90 | -e CLIENT_LANGUAGE="${CLIENT_LANGUAGE}" \
91 | -e PACKAGE_NAME="${PACKAGE_NAME}" \
92 | -e OPENAPI_GENERATOR_USER_ORG="${OPENAPI_GENERATOR_USER_ORG}" \
93 | -e OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT}" \
94 | -e OPENAPI_MODEL_LENGTH="${OPENAPI_MODEL_LENGTH}" \
95 | -e OPENAPI_SKIP_FETCH_SPEC="${OPENAPI_SKIP_FETCH_SPEC}" \
96 | -e KUBERNETES_CRD_MODE="${KUBERNETES_CRD_MODE}" \
97 | -e KUBERNETES_CRD_GROUP_PREFIX="${KUBERNETES_CRD_GROUP_PREFIX}" \
98 | -e GENERATE_APIS="${GENERATE_APIS}" \
99 | -e OPENAPI_SKIP_BASE_INTERFACE="${OPENAPI_SKIP_BASE_INTERFACE}" \
100 | -e HIDE_GENERATION_TIMESTAMP="${HIDE_GENERATION_TIMESTAMP}" \
101 | -e LIBRARY="${LIBRARY}" \
102 | -e USERNAME="${USERNAME}" \
103 | -e REPOSITORY="${REPOSITORY}" \
104 | -e USE_SINGLE_PARAMETER="${USE_SINGLE_PARAMETER:-}" \
105 | -v "${output_dir}:/output_dir" \
106 | "${image_name}" "/output_dir"
107 |
108 | echo "---Done."
109 | }
110 |
--------------------------------------------------------------------------------
/openapi/openapi-generator/generate_client_in_container.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Script to fetch latest swagger spec.
18 | # Puts the updated spec at api/swagger-spec/
19 |
20 | set -o errexit
21 | set -o nounset
22 | set -o pipefail
23 |
24 | # Generates client.
25 | # Required env vars:
26 | # CLEANUP_DIRS: List of directories (string separated by space) to cleanup before generation for this language
27 | # KUBERNETES_BRANCH: Kubernetes branch name to get the swagger spec from
28 | # CLIENT_VERSION: Client version. Will be used in the comment sections of the generated code
29 | # PACKAGE_NAME: Name of the client package.
30 | # OPENAPI_GENERATOR_COMMIT: openapi-generator commit sha or tag/branch name. Will only be used as a reference in docs.
31 | # Input vars:
32 | # $1: output directory
33 | : "${CLEANUP_DIRS?Must set CLEANUP_DIRS env var}"
34 | : "${KUBERNETES_BRANCH?Must set KUBERNETES_BRANCH env var}"
35 | : "${CLIENT_VERSION?Must set CLIENT_VERSION env var}"
36 | : "${CLIENT_LANGUAGE?Must set CLIENT_LANGUAGE env var}"
37 | : "${PACKAGE_NAME?Must set PACKAGE_NAME env var}"
38 | : "${OPENAPI_GENERATOR_COMMIT?Must set OPENAPI_GENERATOR_COMMIT env var}"
39 |
40 | output_dir=$1
41 | pushd "${output_dir}" > /dev/null
42 | output_dir=`pwd`
43 | popd > /dev/null
44 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
45 | pushd "${SCRIPT_ROOT}" > /dev/null
46 | SCRIPT_ROOT=`pwd`
47 | popd > /dev/null
48 |
49 | if ! which mvn > /dev/null 2>&1; then
50 | echo "Maven is not installed."
51 | exit
52 | fi
53 |
54 | # There should be only one version of openapi-generator-maven-plugin.
55 | unset PLUGIN_VERSION
56 | shopt -s nullglob
57 | FOLDERS=(/root/.m2/repository/org/openapitools/openapi-generator-maven-plugin/*)
58 | for folder in "${FOLDERS[@]}"; do
59 | if [[ -d "${folder}" ]]; then
60 | folder=$(basename "${folder}")
61 | if [[ ! -z "${PLUGIN_VERSION:-}" ]]; then
62 | echo "Multiple openapi-generator-maven-plugin version exists: ${PLUGIN_VERSION} & ${folder}"
63 | exit 1
64 | fi
65 | PLUGIN_VERSION="${folder}"
66 | fi
67 | done
68 | if [[ -z "${PLUGIN_VERSION:-}" ]]; then
69 | echo "Cannot find openapi-generator-maven-plugin version"
70 | exit 1
71 | fi
72 | shopt -u nullglob
73 |
74 | # To make sure we can reproduce generation, we would also log code-gen exact commit
75 | pushd /source/openapi-generator
76 | OPENAPI_GENERATOR_COMMIT_ACTUAL=$(git rev-parse HEAD)
77 | popd
78 |
79 | mkdir -p "${output_dir}"
80 |
81 | echo "--- Downloading and pre-processing OpenAPI spec"
82 | python3 "${SCRIPT_ROOT}/preprocess_spec.py" "${CLIENT_LANGUAGE}" "${KUBERNETES_BRANCH}" "${output_dir}/swagger.json" "${USERNAME}" "${REPOSITORY}"
83 |
84 | echo "--- Cleaning up previously generated folders"
85 | for i in ${CLEANUP_DIRS}; do
86 | echo "--- Cleaning up ${output_dir}/${i}"
87 | rm -rf "${output_dir}/${i}"
88 | done
89 |
90 | echo "--- Generating client ..."
91 |
92 | mvn_args=(
93 | -Dgenerator.spec.path="${output_dir}/swagger.json"
94 | -Dgenerator.output.path="${output_dir}"
95 | -D=generator.client.version="${CLIENT_VERSION}"
96 | -D=generator.package.name="${PACKAGE_NAME}"
97 | -D=openapi-generator-version="${PLUGIN_VERSION}"
98 | -Duser.home=/root
99 | )
100 |
101 | if [ -n "${USE_SINGLE_PARAMETER:-}" ]; then
102 | mvn_args+=("-D=use-single-parameter=${USE_SINGLE_PARAMETER}")
103 | fi
104 |
105 | mvn -f "${SCRIPT_ROOT}/generation_params.xml" clean generate-sources "${mvn_args[@]}"
106 |
107 | mkdir -p "${output_dir}/.openapi-generator"
108 | echo "Requested Commit/Tag : ${OPENAPI_GENERATOR_COMMIT}" > "${output_dir}/.openapi-generator/COMMIT"
109 | echo "Actual Commit : ${OPENAPI_GENERATOR_COMMIT_ACTUAL}" >> "${output_dir}/.openapi-generator/COMMIT"
110 |
111 | echo "---Done."
112 |
--------------------------------------------------------------------------------
/openapi/perl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | CLIENT_LANGUAGE=perl; \
50 | CLEANUP_DIRS=(docs lib); \
51 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
52 |
--------------------------------------------------------------------------------
/openapi/perl.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-perl
5 | 1.0-SNAPSHOT
6 | client-perl
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | ${generator.spec.path}
21 | perl
22 | kubernetes-client
23 | perl
24 | false
25 | false
26 |
27 | kubernetes
28 | Kubernetes
29 | ${generator.client.version}
30 | Apache V2
31 | https://kubernetes.io
32 | Kubernetes perl client.
33 | Kubernetes official perl client to talk to kubernetes clusters.
34 | Kubernetes authors
35 | kubernetes-sig-api-machinery@googlegroups.com
36 | true
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | io.swagger
49 | swagger-annotations
50 | ${swagger-annotations-version}
51 |
52 |
53 |
54 | 1.5.0
55 | 1.0.0
56 |
57 |
58 | .
59 | swagger.json
60 | client
61 | 1.0-snapshot
62 |
63 |
64 |
--------------------------------------------------------------------------------
/openapi/preprocess_spec.py:
--------------------------------------------------------------------------------
1 | # Copyright 2016 The Kubernetes Authors.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | from __future__ import print_function
16 |
17 | import json
18 | import operator
19 | import os.path
20 | import sys
21 | import argparse
22 | from collections import OrderedDict
23 |
24 | import urllib3
25 |
26 | # these four constants are shown as part of this example in []:
27 | # "[watch]Pod[List]" is the deprecated version of "[list]Pod?[watch]=True"
28 | WATCH_OP_PREFIX = "watch"
29 | WATCH_OP_SUFFIX = "List"
30 | LIST_OP_PREFIX = "list"
31 | DELETECOLLECTION_OP_PREFIX = "deleteCollection"
32 | WATCH_QUERY_PARAM_NAME = "watch"
33 | ALLOW_WATCH_BOOKMARKS_QUERY_PARAM_NAME = "allowWatchBookmarks"
34 |
35 | CUSTOM_OBJECTS_SPEC_PATH = os.path.join(
36 | os.path.dirname(__file__),
37 | 'custom_objects_spec.json')
38 |
39 | _ops = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch']
40 |
41 |
42 | class PreprocessingException(Exception):
43 | pass
44 |
45 |
46 | def _title(s):
47 | if len(s) == 0:
48 | return s
49 | return s[0].upper() + s[1:]
50 |
51 |
52 | def _to_camel_case(s):
53 | return ''.join(_title(y) for y in s.split("_"))
54 |
55 |
56 | def apply_func_to_spec_operations(spec, func, *params):
57 | """Apply func to each operation in the spec.
58 |
59 | :param spec: The OpenAPI spec to apply func to.
60 | :param func: the function to apply to the spec's operations. It should be
61 | a func(operation, parent) where operation will be each
62 | operation of the spec and parent would be the parent object of
63 | the given operation.
64 | If the return value of the func is True, then the operation
65 | will be deleted from the spec.
66 | """
67 | for k, v in spec['paths'].items():
68 | for op in _ops:
69 | if op not in v:
70 | continue
71 | if func(v[op], v, *params):
72 | del v[op]
73 |
74 |
75 | def _has_property(prop_list, property_name):
76 | for prop in prop_list:
77 | if prop["name"] == property_name:
78 | return True
79 |
80 |
81 | def remove_watch_operations(op, parent, operation_ids):
82 | op_id = op['operationId']
83 | if not op_id.startswith(WATCH_OP_PREFIX):
84 | return
85 | list_id = (LIST_OP_PREFIX +
86 | op_id.replace(WATCH_OP_SUFFIX, "")[len(WATCH_OP_PREFIX):])
87 | if list_id not in operation_ids:
88 | raise PreprocessingException("Cannot find %s" % list_id)
89 | list_op = operation_ids[list_id]
90 | params = []
91 | if 'parameters' in list_op:
92 | params += list_op['parameters']
93 | if 'parameters' in parent:
94 | params += parent['parameters']
95 | if not _has_property(params, WATCH_QUERY_PARAM_NAME):
96 | raise PreprocessingException("%s has no watch query param" % list_id)
97 | return True
98 |
99 |
100 | def strip_delete_collection_operation_watch_params(op, parent):
101 | op_id = op['operationId']
102 | if not op_id.startswith(DELETECOLLECTION_OP_PREFIX):
103 | return
104 | params = []
105 | if 'parameters' in op:
106 | for i in range(len(op['parameters'])):
107 | paramName = op['parameters'][i].get('name', None)
108 | if paramName != WATCH_QUERY_PARAM_NAME and paramName != ALLOW_WATCH_BOOKMARKS_QUERY_PARAM_NAME:
109 | params.append(op['parameters'][i])
110 | op['parameters'] = params
111 | return False
112 |
113 |
114 | def strip_401_response(operation, _):
115 | if 'responses' in operation:
116 | operation['responses'].pop('401', None)
117 | if len(operation['responses']) == 0:
118 | operation['responses']['200'] = { 'description': 'OK' }
119 |
120 |
121 | def transform_to_csharp_stream_response(operation, _):
122 | if operation.get('operationId', None) == 'readNamespacedPodLog' or operation.get('x-kubernetes-action', None) == 'connect':
123 | operation['responses']['200']["schema"] = {
124 | "type": "object",
125 | "format": "file" ,
126 | }
127 |
128 | def transform_to_csharp_consume_json(operation, _):
129 | if operation.get('consumes', None) == ["*/*",] or operation.get('consumes', None) == "*/*":
130 | operation['consumes'] = ["application/json"]
131 |
132 | def transform_to_java_consume_json(operation, _):
133 | operation['consumes'] = ["application/json"]
134 |
135 | def strip_tags_from_operation_id(operation, _):
136 | operation_id = operation['operationId']
137 | if 'tags' in operation:
138 | for t in operation['tags']:
139 | operation_id = operation_id.replace(_to_camel_case(t), '')
140 | operation['operationId'] = operation_id
141 |
142 | def clean_crd_meta(spec):
143 | for k, v in spec['definitions'].items():
144 | if k.endswith('List'):
145 | print("Using built-in v1.ListMeta")
146 | v['properties']['metadata']['$ref'] = '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta'
147 | v['properties']['metadata'].pop('properties', None)
148 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta', '#/definitions/v1.ListMeta')
149 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta', '#/definitions/v1.ObjectMeta')
150 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta_v2', '#/definitions/v1.ObjectMeta')
151 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Status', '#/definitions/v1.Status')
152 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Status_v2', '#/definitions/v1.Status')
153 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Patch', '#/definitions/v1.Patch')
154 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions', '#/definitions/v1.DeleteOptions')
155 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions_v2', '#/definitions/v1.DeleteOptions')
156 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.api.autoscaling.v1.Scale', '#/definitions/v1.Scale')
157 | find_rename_ref_recursive(spec, '#/definitions/io.k8s.api.autoscaling.v1.Scale_v2', '#/definitions/v1.Scale')
158 |
159 |
160 | def add_custom_objects_spec(spec):
161 | with open(CUSTOM_OBJECTS_SPEC_PATH, 'r') as custom_objects_spec_file:
162 | custom_objects_spec = json.loads(custom_objects_spec_file.read())
163 | for path in custom_objects_spec.keys():
164 | if path not in spec['paths'].keys():
165 | spec['paths'][path] = custom_objects_spec[path]
166 | return spec
167 |
168 | def add_codegen_request_body(operation, _):
169 | if 'parameters' in operation and len(operation['parameters']) > 0:
170 | if operation['parameters'][0].get('in') == 'body':
171 | operation['x-codegen-request-body-name'] = 'body'
172 |
173 | def drop_paths(spec):
174 | paths = {}
175 | if (os.environ.get('GENERATE_APIS') or False):
176 | group_prefix = os.environ.get('KUBERNETES_CRD_GROUP_PREFIX')
177 | group_prefix_reversed = '.'.join(group_prefix.split('.')[::-1])
178 | for k, v in spec['paths'].items():
179 | if k.startswith('/apis/' + group_prefix_reversed):
180 | print("Adding Custom Resource api path %s" %k)
181 | paths[k] = v
182 | else:
183 | print("Ignoring non Custom Resource api path %s" %k)
184 | spec['paths'] = paths
185 |
186 | def fix_paths(spec):
187 | # see https://github.com/kubernetes/kubernetes/issues/117455
188 | paths = spec['paths']
189 | if '/.well-known/openid-configuration/' in paths:
190 | paths['/.well-known/openid-configuration'] = paths['/.well-known/openid-configuration/']
191 | del paths['/.well-known/openid-configuration/']
192 |
193 |
194 | if '/openid/v1/jwks/' in paths:
195 | paths['/openid/v1/jwks'] = paths['/openid/v1/jwks/']
196 | del paths['/openid/v1/jwks/']
197 |
198 | def expand_parameters(spec):
199 | if 'parameters' not in spec:
200 | return
201 | for path in spec['paths'].keys():
202 | if 'parameters' in spec['paths'][path]:
203 | for i in range(len(spec['paths'][path]['parameters'])):
204 | param = spec['paths'][path]['parameters'][i]
205 | if '$ref' in param:
206 | ref = param['$ref']
207 | param = spec['parameters'][ref.split('/')[-1]]
208 | spec['paths'][path]['parameters'][i] = param
209 | for method in spec['paths'][path].keys():
210 | if 'parameters' in spec['paths'][path][method]:
211 | for i in range(len(spec['paths'][path][method]['parameters'])):
212 | param = spec['paths'][path][method]['parameters'][i]
213 | if '$ref' in param:
214 | ref = param['$ref']
215 | param = spec['parameters'][ref.split('/')[-1]]
216 | spec['paths'][path][method]['parameters'][i] = param
217 | del spec['parameters']
218 |
219 | def process_swagger(spec, client_language, crd_mode=False):
220 | spec = add_custom_objects_spec(spec)
221 |
222 | if crd_mode:
223 | drop_paths(spec)
224 |
225 | fix_paths(spec)
226 |
227 | expand_parameters(spec)
228 |
229 | apply_func_to_spec_operations(spec, strip_tags_from_operation_id)
230 |
231 | if client_language == "csharp":
232 | # 401s in the spec block the csharp code generator from throwing on 401
233 | apply_func_to_spec_operations(spec, strip_401_response)
234 |
235 | # force to autorest to generate stream
236 | apply_func_to_spec_operations(spec, transform_to_csharp_stream_response)
237 | # force to consume json if */*
238 | apply_func_to_spec_operations(spec, transform_to_csharp_consume_json)
239 |
240 | if client_language == "java":
241 | # force to consume json, need this change due to https://github.com/OpenAPITools/openapi-generator/pull/10769
242 | apply_func_to_spec_operations(spec, transform_to_java_consume_json)
243 |
244 | apply_func_to_spec_operations(spec, strip_delete_collection_operation_watch_params)
245 |
246 | apply_func_to_spec_operations(spec, add_codegen_request_body)
247 |
248 | operation_ids = {}
249 | apply_func_to_spec_operations(spec, lambda op, _: operator.setitem(
250 | operation_ids, op['operationId'], op))
251 |
252 | try:
253 | apply_func_to_spec_operations(
254 | spec, remove_watch_operations, operation_ids)
255 | except PreprocessingException as e:
256 | print(e)
257 |
258 |
259 | if crd_mode:
260 | filter_api_group(spec)
261 | remove_model_prefixes(spec, crd_mode)
262 |
263 | inline_primitive_models(spec, preserved_primitives_for_language(client_language))
264 |
265 | remove_bad_descriptions(spec, bad_description_pattern_for_language(client_language))
266 |
267 | if crd_mode:
268 | clean_crd_meta(spec)
269 |
270 | add_custom_formatting(spec, format_for_language(client_language))
271 | add_custom_typing(spec, type_for_language(client_language))
272 |
273 | remove_models(spec, removed_models_for_language(client_language))
274 |
275 | add_openapi_codegen_x_implement_extension(spec, client_language)
276 |
277 | return spec
278 |
279 | def preserved_primitives_for_language(client_language):
280 | if client_language == "java":
281 | return ["intstr.IntOrString", "resource.Quantity", "v1.Patch"]
282 | elif client_language == "csharp":
283 | return ["intstr.IntOrString", "resource.Quantity", "v1.Patch"]
284 | elif client_language == "haskell-http-client":
285 | return ["intstr.IntOrString", "resource.Quantity"]
286 | elif client_language in ["typescript", "typescript-fetch"]:
287 | return ["intstr.IntOrString", "v1.MicroTime"]
288 | elif client_language == "c":
289 | return ["intstr.IntOrString"]
290 | else:
291 | return []
292 |
293 | def bad_description_pattern_for_language(client_language):
294 | if client_language == 'typescript-fetch':
295 | return '*/'
296 | return None
297 |
298 | def format_for_language(client_language):
299 | if client_language == "java":
300 | return {"resource.Quantity": "quantity", "v1.Patch": "patch"}
301 | else:
302 | return {}
303 |
304 | def type_for_language(client_language):
305 | if client_language == "java":
306 | return {"v1.Patch": { "type": "string"}}
307 | elif client_language == "typescript":
308 | return {"v1.MicroTime": { "type": "string", "format": "date-time-micro" }}
309 | elif client_language == "csharp":
310 | return {
311 | "v1.Patch": { "type": "object", "properties": {"content": { "type": "object"}} },
312 | "resource.Quantity": { "type": "object", "properties": {"value": { "type": "string"}} },
313 | "intstr.IntOrString" : { "type": "object", "properties": {"value": { "type": "string"}} },
314 | }
315 | else:
316 | return {}
317 |
318 | def removed_models_for_language(client_language):
319 | if client_language == "haskell-http-client":
320 | return ["intstr.IntOrString", "resource.Quantity"]
321 | else:
322 | return []
323 |
324 | def rename_model(spec, old_name, new_name):
325 | if new_name in spec['definitions']:
326 | raise PreprocessingException(
327 | "Cannot rename model %s. new name %s exists." %
328 | (old_name, new_name))
329 | find_rename_ref_recursive(spec,
330 | "#/definitions/" + old_name,
331 | "#/definitions/" + new_name)
332 | spec['definitions'][new_name] = spec['definitions'][old_name]
333 | del spec['definitions'][old_name]
334 |
335 |
336 | def find_rename_ref_recursive(root, old, new):
337 | if isinstance(root, list):
338 | for r in root:
339 | find_rename_ref_recursive(r, old, new)
340 | if isinstance(root, dict):
341 | if "$ref" in root:
342 | if root["$ref"] == old:
343 | root["$ref"] = new
344 | for k, v in root.items():
345 | find_rename_ref_recursive(v, old, new)
346 |
347 |
348 | def is_model_deprecated(m):
349 | """
350 | Check if a mode is deprecated model redirection.
351 |
352 | A deprecated mode redirecation has only two members with a
353 | description starts with "Deprecated." string.
354 | """
355 | if len(m) != 2:
356 | return False
357 | if "$ref" not in m or "description" not in m:
358 | return False
359 | return m["description"].startswith("Deprecated.")
360 |
361 | def filter_api_group(spec):
362 | models = {}
363 | for k, v in spec['definitions'].items():
364 | if k.startswith(os.environ.get('KUBERNETES_CRD_GROUP_PREFIX')):
365 | print("Adding Custom Resource by prefix %s" %k)
366 | models[k] = v
367 | elif k.startswith("io.k8s"):
368 | print("Removing builtin Kubernetes Resource %s" %k)
369 | else:
370 | print("Ignoring Custom Resource %s" %k)
371 | spec['definitions'] = models
372 |
373 | def remove_deprecated_models(spec):
374 | """
375 | In kubernetes 1.8 some of the models are renamed. Our remove_model_prefixes
376 | still creates the same model names but there are some models added to
377 | reference old model names to new names. These models broke remove_model_prefixes
378 | and need to be removed.
379 | """
380 | models = {}
381 | for k, v in spec['definitions'].items():
382 | if is_model_deprecated(v):
383 | print("Removing deprecated model %s" % k)
384 | else:
385 | models[k] = v
386 | spec['definitions'] = models
387 |
388 |
389 | def remove_model_prefixes(spec, crd_mode=False):
390 | """Remove full package name from OpenAPI model names.
391 |
392 | Starting kubernetes 1.6, all models has full package name. This is
393 | verbose and inconvenient in python client. This function tries to remove
394 | parts of the package name but will make sure there is no conflicting model
395 | names. This will keep most of the model names generated by previous client
396 | but will change some of them.
397 | """
398 |
399 | remove_deprecated_models(spec)
400 |
401 | models = {}
402 | for k, v in spec['definitions'].items():
403 | if k.startswith("io.k8s"):
404 | models[k] = {"split_n": 2}
405 | elif crd_mode and k.startswith(os.environ.get('KUBERNETES_CRD_GROUP_PREFIX')):
406 | if os.environ.get('OPENAPI_MODEL_LENGTH') or False:
407 | models[k] = {"split_n": int(os.environ.get('OPENAPI_MODEL_LENGTH'))}
408 |
409 | conflict = True
410 | while conflict:
411 | for k, v in models.items():
412 | splits = k.rsplit(".", v["split_n"])
413 | v["removed_prefix"] = splits.pop(0)
414 | v["new_name"] = ".".join(splits)
415 |
416 | conflict = False
417 | for k, v in models.items():
418 | for k2, v2 in models.items():
419 | if k != k2 and v["new_name"] == v2["new_name"]:
420 | v["conflict"] = True
421 | v2["conflict"] = True
422 | conflict = True
423 |
424 | if conflict:
425 | for k, v in models.items():
426 | if "conflict" in v:
427 | print("Resolving conflict for %s" % k)
428 | v["split_n"] += 1
429 | del v["conflict"]
430 |
431 | for k, v in models.items():
432 | if "new_name" not in v:
433 | raise PreprocessingException("Cannot rename model %s" % k)
434 | print("Removing prefix %s from %s...\n" % (v["removed_prefix"], k))
435 | rename_model(spec, k, v["new_name"])
436 |
437 |
438 | def find_replace_ref_recursive(root, ref_name, replace_map):
439 | if isinstance(root, list):
440 | for r in root:
441 | find_replace_ref_recursive(r, ref_name, replace_map)
442 | if isinstance(root, dict):
443 | if "$ref" in root:
444 | if root["$ref"] == ref_name:
445 | del root["$ref"]
446 | for k, v in replace_map.items():
447 | if k in root:
448 | if k != "description":
449 | raise PreprocessingException(
450 | "Cannot inline model %s because of "
451 | "conflicting key %s." % (ref_name, k))
452 | continue
453 | root[k] = v
454 | for k, v in root.items():
455 | find_replace_ref_recursive(v, ref_name, replace_map)
456 |
457 |
458 | def remove_models(spec, to_remove_models):
459 | for k in to_remove_models:
460 | print("Removing model `%s " % k)
461 | del spec['definitions'][k]
462 |
463 | def inline_primitive_models(spec, excluded_primitives):
464 | to_remove_models = []
465 | for k, v in spec['definitions'].items():
466 | if k in excluded_primitives:
467 | continue
468 | if "properties" not in v:
469 | if k == "intstr.IntOrString":
470 | v["type"] = "object"
471 | if "type" not in v:
472 | v["type"] = "object"
473 | print("Making model `%s` inline as %s..." % (k, v["type"]))
474 | find_replace_ref_recursive(spec, "#/definitions/" + k, v)
475 | to_remove_models.append(k)
476 |
477 | for k in to_remove_models:
478 | del spec['definitions'][k]
479 |
480 | def remove_bad_descriptions_recursively(model, pattern):
481 | desc = model.get('description', '')
482 | if desc.find(pattern) >= 0:
483 | model['description'] = ''
484 | if 'properties' not in model:
485 | return
486 | for prop in model['properties'].values():
487 | remove_bad_descriptions_recursively(prop, pattern)
488 |
489 | def remove_bad_descriptions(spec, pattern):
490 | if not pattern:
491 | return
492 | for model in spec['definitions'].values():
493 | remove_bad_descriptions_recursively(model, pattern)
494 |
495 | def add_custom_formatting(spec, custom_formats):
496 | for k, v in spec['definitions'].items():
497 | if k not in custom_formats:
498 | continue
499 | v["format"] = custom_formats[k]
500 |
501 | def add_custom_typing(spec, custom_types):
502 | for k, v in spec['definitions'].items():
503 | if k not in custom_types:
504 | continue
505 | v.update(custom_types[k])
506 |
507 | def add_openapi_codegen_x_implement_extension(spec, client_language):
508 | if client_language != "java":
509 | return
510 | if os.environ.get('OPENAPI_SKIP_BASE_INTERFACE') or False:
511 | return
512 | for k, v in spec['definitions'].items():
513 | if "x-kubernetes-group-version-kind" not in v:
514 | continue
515 | if k == "v1.Status":
516 | # Status is explicitly excluded because it's obviously not a list object,
517 | # but it has ListMeta.
518 | continue
519 | if not all(k in v['properties'] for k in ["metadata", "kind", "apiVersion"]) or "$ref" not in v['properties']['metadata']:
520 | continue # not a legitimate kubernetes api object (imperfect assumption)
521 | if v["properties"]["metadata"]["$ref"] == "#/definitions/v1.ListMeta":
522 | if "x-implements" not in v:
523 | v["x-implements"] = []
524 | v["x-implements"].append("io.kubernetes.client.common.KubernetesListObject")
525 | elif v["properties"]["metadata"]["$ref"] == "#/definitions/v1.ObjectMeta":
526 | if "x-implements" not in v:
527 | v["x-implements"] = []
528 | v["x-implements"].append("io.kubernetes.client.common.KubernetesObject")
529 |
530 |
531 |
532 | def write_json(filename, object):
533 | with open(filename, 'w') as out:
534 | json.dump(object, out, sort_keys=False, indent=2, separators=(',', ': '), ensure_ascii=True)
535 |
536 |
537 |
538 | def main():
539 | argparser = argparse.ArgumentParser()
540 | argparser.add_argument(
541 | 'client_language',
542 | help='Client language to setup spec for'
543 | )
544 | argparser.add_argument(
545 | 'kubernetes_branch',
546 | help='Branch/tag of github.com/kubernetes/kubernetes to get spec from'
547 | )
548 | argparser.add_argument(
549 | 'output_spec_path',
550 | help='Path to output spec file to'
551 | )
552 | argparser.add_argument(
553 | 'username',
554 | help='Optional username if working on forks',
555 | default='kubernetes'
556 | )
557 | argparser.add_argument(
558 | 'repository',
559 | help='Optional repository name if working with kubernetes ecosystem projects',
560 | default='kubernetes'
561 | )
562 | args = argparser.parse_args()
563 |
564 |
565 | unprocessed_spec = args.output_spec_path + ".unprocessed"
566 | in_spec = ""
567 | if os.environ.get("OPENAPI_SKIP_FETCH_SPEC") or False:
568 | with open(unprocessed_spec, 'r') as content:
569 | in_spec = json.load(content, object_pairs_hook=OrderedDict)
570 | else:
571 | pool = urllib3.PoolManager()
572 | spec_url = 'https://raw.githubusercontent.com/%s/%s/' \
573 | '%s/api/openapi-spec/swagger.json' % (args.username,
574 | args.repository,
575 | args.kubernetes_branch)
576 | with pool.request('GET', spec_url, preload_content=False) as response:
577 | if response.status != 200:
578 | print("Error downloading spec file %s. Reason: %s" % (spec_url, response.reason))
579 | return 1
580 | in_spec = json.load(response, object_pairs_hook=OrderedDict)
581 | write_json(unprocessed_spec, in_spec)
582 | # use version from branch/tag name if spec doesn't provide it
583 | if in_spec['info']['version'] == 'unversioned':
584 | in_spec['info']['version'] = args.kubernetes_branch
585 | crd_mode = os.environ.get('KUBERNETES_CRD_MODE') or False
586 | out_spec = process_swagger(in_spec, args.client_language, crd_mode)
587 | write_json(args.output_spec_path, out_spec)
588 | return 0
589 |
590 |
591 | if __name__ == '__main__':
592 | sys.exit(main())
593 |
--------------------------------------------------------------------------------
/openapi/python-api_client.py.patch:
--------------------------------------------------------------------------------
1 | --- a/kubernetes/client/api_client.py
2 | +++ b/kubernetes/client/api_client.py
3 | @@ -58,13 +58,15 @@ class ApiClient(object):
4 | 'datetime': datetime,
5 | 'object': object,
6 | }
7 | + _pool = None
8 |
9 | - def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None):
10 | + def __init__(self, configuration=None, header_name=None, header_value=None,
11 | + cookie=None, pool_threads=None):
12 | if configuration is None:
13 | configuration = Configuration()
14 | self.configuration = configuration
15 | + self.pool_threads = pool_threads
16 |
17 | - self.pool = ThreadPool()
18 | self.rest_client = RESTClientObject(configuration)
19 | self.default_headers = {}
20 | if header_name is not None:
21 | @@ -74,8 +76,19 @@ class ApiClient(object):
22 | self.user_agent = 'Swagger-Codegen/8.0.0-snapshot/python'
23 |
24 | def __del__(self):
25 | - self.pool.close()
26 | - self.pool.join()
27 | + if self._pool:
28 | + self._pool.close()
29 | + self._pool.join()
30 | + self._pool = None
31 | +
32 | + @property
33 | + def pool(self):
34 | + """Create thread pool on first request
35 | + avoids instantiating unused threadpool for blocking clients.
36 | + """
37 | + if self._pool is None:
38 | + self._pool = ThreadPool(self.pool_threads)
39 | + return self._pool
40 |
41 | @property
42 | def user_agent(self):
43 |
--------------------------------------------------------------------------------
/openapi/python-asyncio.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2018 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " python-asyncio.sh OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | exit 1
28 | fi
29 |
30 |
31 | OUTPUT_DIR=$1
32 | SETTING_FILE=$2
33 | mkdir -p "${OUTPUT_DIR}"
34 |
35 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
36 | pushd "${SCRIPT_ROOT}" > /dev/null
37 | SCRIPT_ROOT=`pwd`
38 | popd > /dev/null
39 |
40 | pushd "${OUTPUT_DIR}" > /dev/null
41 | OUTPUT_DIR=`pwd`
42 | popd > /dev/null
43 |
44 | source "${SETTING_FILE}"
45 |
46 | # use openapi-generator to generate library
47 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
48 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v5.4.0}"
49 |
50 | CLIENT_LANGUAGE=python-asyncio
51 | CLEANUP_DIRS=(client/apis client/models docs test)
52 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
53 |
54 | # Generic patches to the generated Python code, most notably renaming the library.
55 | echo "--- Patching generated code..."
56 |
57 | if [ ${PACKAGE_NAME} == "client" ]; then
58 |
59 | # Post-processing of the generated Python wrapper.
60 | find "${OUTPUT_DIR}/test" -type f -name \*.py -exec sed -i 's/\bclient/kubernetes_asyncio.client/g' {} +
61 | find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/\bclient/kubernetes_asyncio.client/g' {} +
62 | find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/kubernetes_asyncio.client-python/client-python/g' {} +
63 |
64 | # fix imports
65 | find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/import client\./import kubernetes_asyncio.client./g' {} +
66 | find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/from client/from kubernetes_asyncio.client/g' {} +
67 | find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/getattr(client\.models/getattr(kubernetes_asyncio.client.models/g' {} +
68 |
69 | else
70 |
71 | # Post-processing of the generated Python wrapper.
72 | find "${OUTPUT_DIR}/test" -type f -name \*.py -exec sed -i "s/\\bclient/${PACKAGE_NAME}.client/g" {} +
73 | find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i "s/\\bclient/${PACKAGE_NAME}.client/g" {} +
74 | find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i "s/${PACKAGE_NAME}.client-python/client-python/g" {} +
75 |
76 | fi
77 |
78 | echo "---Done."
79 |
--------------------------------------------------------------------------------
/openapi/python-asyncio.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-python
5 | 1.0-SNAPSHOT
6 | client-python
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | ${generator.spec.path}
21 | true
22 | python-legacy
23 | asyncio
24 | kubernetes-client
25 | python
26 |
27 | ${generator.package.name}
28 | ${generator.client.version}
29 | true
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.openapitools
42 | swagger-annotations
43 | ${swagger-annotations-version}
44 |
45 |
46 |
47 | 1.5.0
48 | 1.0.0
49 |
50 |
51 | .
52 | swagger.json
53 | swagger_client
54 | unversioned
55 |
56 |
57 |
--------------------------------------------------------------------------------
/openapi/python-crd-cmd.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | PACKAGE_NAME=${PACKAGE_NAME:-client}
4 | CLIENT_VERSION=${CLIENT_VERSION:-17.0.0-snapshot}
5 | GENERATE_APIS=${GENERATE_APIS:-false}
6 | OUTPUT_DIR=${OUTPUT_DIR:-python}
7 | OPENAPI_MODEL_LENGTH=${OPENAPI_MODEL_LENGTH:-}
8 | HIDE_GENERATION_TIMESTAMP=${HIDE_GENERATION_TIMESTAMP:-false}
9 | OPENAPI_SKIP_BASE_INTERFACE=
10 | KUBERNETES_CRD_GROUP_PREFIX=
11 |
12 | print_usage() {
13 | echo "Usage: generate a python project using input openapi spec from stdin" >& 2
14 | echo " -c: project version of the generated python project." >& 2
15 | echo " -n: the prefix of the target CRD's api group to generate." >& 2
16 | echo " -g: generate crd apis." >& 2
17 | echo " -p: the base package name of the generated python project. " >& 2
18 | echo " -o: output directory of the generated python project. " >& 2
19 | echo " -l: keep the n last segments for the generated class name. " >& 2
20 | echo " -h: hide generation timestamp" >& 2
21 | }
22 |
23 | while getopts 'c:g:h:n:l:p:o:' flag; do
24 | case "${flag}" in
25 | c) CLIENT_VERSION="${OPTARG}" ;;
26 | g) GENERATE_APIS="${OPTARG}" ;;
27 | h) HIDE_GENERATION_TIMESTAMP="${OPTARG}" ;;
28 | n) KUBERNETES_CRD_GROUP_PREFIX="${OPTARG}" ;;
29 | l) OPENAPI_MODEL_LENGTH="${OPTARG}" ;;
30 | p) PACKAGE_NAME="${OPTARG}" ;;
31 | o) OUTPUT_DIR="${OPTARG}" ;;
32 | *) print_usage
33 | exit 1 ;;
34 | esac
35 | done
36 |
37 | echo "KUBERNETES_CRD_GROUP_PREFIX: $KUBERNETES_CRD_GROUP_PREFIX" >& 2
38 | echo "OPENAPI_MODEL_LENGTH: $OPENAPI_MODEL_LENGTH" >& 2
39 | echo "PACKAGE_NAME: $PACKAGE_NAME" >& 2
40 | echo "GENERATE_APIS: $GENERATE_APIS" >& 2
41 | echo "CLIENT_VERSION: $CLIENT_VERSION" >& 2
42 | echo "OUTPUT_DIR: $OUTPUT_DIR" >& 2
43 | echo "HIDE_GENERATION_TIMESTAMP: $HIDE_GENERATION_TIMESTAMP" >& 2
44 | echo "" >& 2 # empty line
45 |
46 |
47 | mkdir -p "${OUTPUT_DIR}"
48 |
49 | echo 'rendering settings file to /tmp/settings' >& 2
50 | read -d '' settings << EOF
51 | export KUBERNETES_BRANCH="${KUBERNETES_BRANCH}"
52 | export CLIENT_VERSION="${CLIENT_VERSION}"
53 | export PACKAGE_NAME="${PACKAGE_NAME}"
54 | EOF
55 |
56 | echo ${settings} > /tmp/settings
57 |
58 | echo 'reading input openapi specs' >& 2
59 | cat swagger.json > ${OUTPUT_DIR}/swagger.json.unprocessed
60 |
61 | source "/tmp/settings"
62 |
63 | KUBERNETES_CRD_MODE=true \
64 | GENERATE_APIS=${GENERATE_APIS} \
65 | OPENAPI_SKIP_FETCH_SPEC=true \
66 | OPENAPI_MODEL_LENGTH=${OPENAPI_MODEL_LENGTH} \
67 | KUBERNETES_CRD_GROUP_PREFIX=${KUBERNETES_CRD_GROUP_PREFIX} \
68 | HIDE_GENERATION_TIMESTAMP=${HIDE_GENERATION_TIMESTAMP} \
69 | $(pwd)/python.sh ${OUTPUT_DIR} /tmp/settings
70 |
--------------------------------------------------------------------------------
/openapi/python.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v4.3.0}"
49 |
50 | CLIENT_LANGUAGE=python; \
51 | CLEANUP_DIRS=(client/api client/apis client/models docs test); \
52 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
53 |
54 | echo "--- Patching generated code..."
55 |
56 | # Post-processing of the generated Python wrapper.
57 | find "${OUTPUT_DIR}/test" -type f -name \*.py -exec sed -i 's/\bclient/kubernetes.client/g' {} +
58 | find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/\bclient/kubernetes.client/g' {} +
59 | find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/kubernetes.client-python/client-python/g' {} +
60 | find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/kubernetes-kubernetes.client/kubernetes-client/g' {} +
61 |
62 | # fix imports
63 | if [ "${PACKAGE_NAME}" = client ]; then
64 | find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/import client\./import kubernetes.client./g' {} +
65 | find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/from client/from kubernetes.client/g' {} +
66 | find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/getattr(client\.models/getattr(kubernetes.client.models/g' {} +
67 | fi
68 |
69 | echo "---Done."
70 |
--------------------------------------------------------------------------------
/openapi/python.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-python
5 | 1.0-SNAPSHOT
6 | client-python
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | ${generator.spec.path}
21 | python
22 | kubernetes-client
23 | python
24 | true
25 |
26 | ${generator.package.name}
27 | ${generator.client.version}
28 | true
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | org.openapitools
41 | swagger-annotations
42 | ${swagger-annotations-version}
43 |
44 |
45 |
46 | 1.5.0
47 | 1.0.0
48 |
49 |
50 | .
51 | swagger.json
52 | swagger_client
53 | unversioned
54 |
55 |
56 |
--------------------------------------------------------------------------------
/openapi/ruby.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | CLIENT_LANGUAGE=ruby; \
50 | CLEANUP_DIRS=(docs lib); \
51 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
52 |
--------------------------------------------------------------------------------
/openapi/ruby.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-ruby
5 | 1.0-SNAPSHOT
6 | client-ruby
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | ${generator.spec.path}
21 | ruby
22 | kubernetes-client
23 | ruby
24 | false
25 | false
26 |
27 | kubernetes
28 | Kubernetes
29 | ${generator.client.version}
30 | Apache V2
31 | https://kubernetes.io
32 | Kubernetes ruby client.
33 | Kubernetes official ruby client to talk to kubernetes clusters.
34 | Kubernetes authors
35 | kubernetes-sig-api-machinery@googlegroups.com
36 | true
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | io.swagger
49 | swagger-annotations
50 | ${swagger-annotations-version}
51 |
52 |
53 |
54 | 1.5.0
55 | 1.0.0
56 |
57 |
58 | .
59 | swagger.json
60 | client
61 | 1.0-snapshot
62 |
63 |
64 |
--------------------------------------------------------------------------------
/openapi/rust.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v7.10.0}" \
50 |
51 | CLIENT_LANGUAGE=rust; \
52 | CLEANUP_DIRS=(docs lib); \
53 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
54 |
--------------------------------------------------------------------------------
/openapi/rust.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | io.kubernetes
4 | client-rust
5 | 1.0-SNAPSHOT
6 | client-c
7 | http://kubernetes.io
8 |
9 |
10 |
11 | org.openapitools
12 | openapi-generator-maven-plugin
13 | ${openapi-generator-version}
14 |
15 |
16 |
17 | generate
18 |
19 |
20 | true
21 | ${generator.spec.path}
22 | rust
23 | kubernetes-client
24 | rust
25 | reqwest
26 |
27 | ${generator.package.name}
28 | ${generator.client.version}
29 | reqwest
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | io.swagger
42 | swagger-annotations
43 | ${swagger-annotations-version}
44 |
45 |
46 |
47 | 1.5.0
48 | 1.0.0
49 |
50 |
51 | .
52 | swagger.json
53 | swagger_client
54 | unversioned
55 |
56 |
57 |
--------------------------------------------------------------------------------
/openapi/typescript-fetch.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v5.2.0}"; \
50 | CLIENT_LANGUAGE=typescript-fetch; \
51 | CLEANUP_DIRS=(api model); \
52 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
53 |
--------------------------------------------------------------------------------
/openapi/typescript-fetch.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | io.kubernetes
6 | client-typescript-fetch
7 | 0.1-SNAPSHOT
8 | client-typescript-fetch
9 | http://kubernetes.io
10 |
11 |
12 |
13 | org.openapitools
14 | openapi-generator-maven-plugin
15 | ${openapi-generator-version}
16 |
17 |
18 |
19 | generate
20 |
21 |
22 | ${generator.spec.path}
23 | true
24 | typescript-fetch
25 |
26 |
27 | true
28 | true
29 | true
30 | true
31 | kubernetes-client-typescript-fetch
32 | ${generator.client.version}
33 | original
34 |
35 | int-or-string=IntOrString
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/openapi/typescript-jquery.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v4.0.3}"; \
50 | CLIENT_LANGUAGE=typescript-jquery; \
51 | CLEANUP_DIRS=(api model); \
52 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
53 |
--------------------------------------------------------------------------------
/openapi/typescript-jquery.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | io.kubernetes
6 | client-typescript-jquery
7 | 0.1-SNAPSHOT
8 | client-typescript-jquery
9 | http://kubernetes.io
10 |
11 |
12 |
13 | org.openapitools
14 | openapi-generator-maven-plugin
15 | ${openapi-generator-version}
16 |
17 |
18 |
19 | generate
20 |
21 |
22 | ${generator.spec.path}
23 | true
24 | typescript-jquery
25 |
26 |
27 | true
28 | true
29 | kubernetes-client-typescript-frontend
30 | ${generator.client.version}
31 | original
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/openapi/typescript.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2015 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 | set -o pipefail
20 |
21 | ARGC=$#
22 |
23 | if [ $# -ne 2 ]; then
24 | echo "Usage:"
25 | echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
26 | echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
27 | echo " Setting file can define an optional USERNAME if you're working on a fork"
28 | echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
29 | exit 1
30 | fi
31 |
32 |
33 | OUTPUT_DIR=$1
34 | SETTING_FILE=$2
35 | mkdir -p "${OUTPUT_DIR}"
36 |
37 | SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
38 | pushd "${SCRIPT_ROOT}" > /dev/null
39 | SCRIPT_ROOT=`pwd`
40 | popd > /dev/null
41 |
42 | pushd "${OUTPUT_DIR}" > /dev/null
43 | OUTPUT_DIR=`pwd`
44 | popd > /dev/null
45 |
46 | source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
47 | source "${SETTING_FILE}"
48 |
49 | OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v6.4.0}"; \
50 | CLIENT_LANGUAGE=typescript; \
51 | CLEANUP_DIRS=(api model); \
52 | kubeclient::generator::generate_client "${OUTPUT_DIR}"
53 |
--------------------------------------------------------------------------------
/openapi/typescript.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | io.kubernetes
6 | client-typescript
7 | 0.1-SNAPSHOT
8 | client-typescript
9 | http://kubernetes.io
10 |
11 |
12 |
13 | org.openapitools
14 | openapi-generator-maven-plugin
15 | ${openapi-generator-version}
16 |
17 |
18 |
19 | generate
20 |
21 |
22 | ${generator.spec.path}
23 | true
24 | typescript
25 |
26 | IntOrString=../../types,V1MicroTime=../../types
27 |
28 |
29 |
30 | true
31 | true
32 | true
33 | node
34 | fetch-api
35 | kubernetes-client-typescript
36 | ${generator.client.version}
37 | original
38 | .js
39 |
40 | int-or-string=IntOrString,date-time-micro=V1MicroTime
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/openapi/update-templates.sh:
--------------------------------------------------------------------------------
1 | echo "TODO!!!"
--------------------------------------------------------------------------------
/proto/dependencies.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | release=${1:-"master"}
18 |
19 | set -x
20 | curl_cmd="curl --fail -s"
21 |
22 | echo Downloading proto files for ${release}
23 |
24 | mkdir -p k8s.io/apimachinery/pkg/api/resource
25 | mkdir -p k8s.io/apimachinery/pkg/apis/meta/v1
26 | mkdir -p k8s.io/apimachinery/pkg/util/intstr
27 | mkdir -p k8s.io/apimachinery/pkg/runtime/schema
28 | mkdir -p k8s.io/apis/meta/v1
29 |
30 | mkdir -p k8s.io/api/rbac/v1alpha1
31 | mkdir -p k8s.io/api/rbac/v1
32 | mkdir -p k8s.io/api/rbac/v1beta1
33 | mkdir -p k8s.io/api/networking/v1
34 | mkdir -p k8s.io/api/admissionregistration/v1
35 | mkdir -p k8s.io/api/admissionregistration/v1beta1
36 | mkdir -p k8s.io/api/scheduling/v1
37 | mkdir -p k8s.io/api/scheduling/v1alpha1
38 | mkdir -p k8s.io/api/storage/v1
39 | mkdir -p k8s.io/api/storage/v1beta1
40 | mkdir -p k8s.io/api/batch/v1
41 | mkdir -p k8s.io/api/batch/v1beta1
42 | mkdir -p k8s.io/api/apps/v1beta2
43 | mkdir -p k8s.io/api/apps/v1
44 | mkdir -p k8s.io/api/apps/v1beta1
45 | mkdir -p k8s.io/api/authentication/v1
46 | mkdir -p k8s.io/api/authentication/v1beta1
47 | mkdir -p k8s.io/api/admission/v1
48 | mkdir -p k8s.io/api/admission/v1beta1
49 | mkdir -p k8s.io/api/policy/v1
50 | mkdir -p k8s.io/api/policy/v1beta1
51 | mkdir -p k8s.io/api/core/v1
52 | mkdir -p k8s.io/api/autoscaling/v1
53 | mkdir -p k8s.io/api/autoscaling/v2beta1
54 | mkdir -p k8s.io/api/autoscaling/v2beta2
55 | mkdir -p k8s.io/api/extensions/v1beta1
56 | mkdir -p k8s.io/api/certificates/v1
57 | mkdir -p k8s.io/api/certificates/v1beta1
58 | mkdir -p k8s.io/api/imagepolicy/v1alpha1
59 | mkdir -p k8s.io/api/authorization/v1
60 | mkdir -p k8s.io/api/authorization/v1beta1
61 | mkdir -p k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1
62 |
63 | base=https://raw.githubusercontent.com/kubernetes
64 | machinery_base=${base}/apimachinery/${release}
65 | $curl_cmd ${machinery_base}/pkg/api/resource/generated.proto \
66 | > k8s.io/apimachinery/pkg/api/resource/generated.proto
67 |
68 | $curl_cmd ${machinery_base}/pkg/apis/meta/v1/generated.proto \
69 | > k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto
70 |
71 | $curl_cmd ${machinery_base}/pkg/util/intstr/generated.proto \
72 | > k8s.io/apimachinery/pkg/util/intstr/generated.proto
73 |
74 | $curl_cmd ${machinery_base}/pkg/runtime/generated.proto \
75 | > k8s.io/apimachinery/pkg/runtime/generated.proto
76 |
77 | $curl_cmd ${machinery_base}/pkg/runtime/schema/generated.proto \
78 | > k8s.io/apimachinery/pkg/runtime/schema/generated.proto
79 |
80 | # There are currently no release branches for these files.
81 | $curl_cmd ${base}/api/master/rbac/v1alpha1/generated.proto > k8s.io/api/rbac/v1alpha1/generated.proto
82 | $curl_cmd ${base}/api/master/rbac/v1/generated.proto > k8s.io/api/rbac/v1/generated.proto
83 | $curl_cmd ${base}/api/master/rbac/v1beta1/generated.proto > k8s.io/api/rbac/v1beta1/generated.proto
84 | $curl_cmd ${base}/api/master/networking/v1/generated.proto > k8s.io/api/networking/v1/generated.proto
85 | $curl_cmd ${base}/api/master/admissionregistration/v1beta1/generated.proto > k8s.io/api/admissionregistration/v1beta1/generated.proto
86 | $curl_cmd ${base}/api/master/admissionregistration/v1/generated.proto > k8s.io/api/admissionregistration/v1/generated.proto
87 | $curl_cmd ${base}/api/master/scheduling/v1alpha1/generated.proto > k8s.io/api/scheduling/v1alpha1/generated.proto
88 | $curl_cmd ${base}/api/master/scheduling/v1/generated.proto > k8s.io/api/scheduling/v1/generated.proto
89 | $curl_cmd ${base}/api/master/storage/v1/generated.proto > k8s.io/api/storage/v1/generated.proto
90 | $curl_cmd ${base}/api/master/storage/v1beta1/generated.proto > k8s.io/api/storage/v1beta1/generated.proto
91 | $curl_cmd ${base}/api/master/batch/v1/generated.proto > k8s.io/api/batch/v1/generated.proto
92 | $curl_cmd ${base}/api/master/batch/v1beta1/generated.proto > k8s.io/api/batch/v1beta1/generated.proto
93 | $curl_cmd ${base}/api/master/apps/v1beta2/generated.proto > k8s.io/api/apps/v1beta2/generated.proto
94 | $curl_cmd ${base}/api/master/apps/v1/generated.proto > k8s.io/api/apps/v1/generated.proto
95 | $curl_cmd ${base}/api/master/apps/v1beta1/generated.proto > k8s.io/api/apps/v1beta1/generated.proto
96 | $curl_cmd ${base}/api/master/authentication/v1/generated.proto > k8s.io/api/authentication/v1/generated.proto
97 | $curl_cmd ${base}/api/master/authentication/v1beta1/generated.proto > k8s.io/api/authentication/v1beta1/generated.proto
98 | $curl_cmd ${base}/api/master/admission/v1beta1/generated.proto > k8s.io/api/admission/v1beta1/generated.proto
99 | $curl_cmd ${base}/api/master/admission/v1/generated.proto > k8s.io/api/admission/v1/generated.proto
100 | $curl_cmd ${base}/api/master/policy/v1/generated.proto > k8s.io/api/policy/v1/generated.proto
101 | $curl_cmd ${base}/api/master/policy/v1beta1/generated.proto > k8s.io/api/policy/v1beta1/generated.proto
102 | $curl_cmd ${base}/api/master/core/v1/generated.proto > k8s.io/api/core/v1/generated.proto
103 | $curl_cmd ${base}/api/master/autoscaling/v1/generated.proto > k8s.io/api/autoscaling/v1/generated.proto
104 | $curl_cmd ${base}/api/master/autoscaling/v2beta1/generated.proto > k8s.io/api/autoscaling/v2beta1/generated.proto
105 | $curl_cmd ${base}/api/master/autoscaling/v2beta2/generated.proto > k8s.io/api/autoscaling/v2beta2/generated.proto
106 | $curl_cmd ${base}/api/master/extensions/v1beta1/generated.proto > k8s.io/api/extensions/v1beta1/generated.proto
107 | $curl_cmd ${base}/api/master/certificates/v1/generated.proto > k8s.io/api/certificates/v1/generated.proto
108 | $curl_cmd ${base}/api/master/certificates/v1beta1/generated.proto > k8s.io/api/certificates/v1beta1/generated.proto
109 | $curl_cmd ${base}/api/master/imagepolicy/v1alpha1/generated.proto > k8s.io/api/imagepolicy/v1alpha1/generated.proto
110 | $curl_cmd ${base}/api/master/authorization/v1/generated.proto > k8s.io/api/authorization/v1/generated.proto
111 | $curl_cmd ${base}/api/master/authorization/v1beta1/generated.proto > k8s.io/api/authorization/v1beta1/generated.proto
112 | $curl_cmd ${base}/apiextensions-apiserver/master/pkg/apis/apiextensions/v1beta1/generated.proto > k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto
113 |
--------------------------------------------------------------------------------
/proto/generate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # usage: generate.sh $LANGUAGE $OUTPUT_DIR
18 | # current tested languages:
19 | # * java
20 |
21 | dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22 |
23 | if ! which protoc > /dev/null; then
24 | ${dir}/install.sh
25 | proto=./bin/protoc
26 | else
27 | proto=$(which protoc)
28 | fi
29 |
30 | ${dir}/dependencies.sh
31 |
32 | # The format here is ;
33 | files="k8s.io/apimachinery/pkg/api/resource/generated.proto;Resource \
34 | k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto;Meta \
35 | k8s.io/apimachinery/pkg/runtime/generated.proto;Runtime \
36 | k8s.io/apimachinery/pkg/runtime/schema/generated.proto;RuntimeSchema \
37 | k8s.io/apimachinery/pkg/util/intstr/generated.proto;IntStr \
38 | k8s.io/api/rbac/v1alpha1/generated.proto;V1alpha1Rbac \
39 | k8s.io/api/rbac/v1/generated.proto;V1Rbac \
40 | k8s.io/api/rbac/v1beta1/generated.proto;V1beta1Rbac \
41 | k8s.io/api/networking/v1/generated.proto;V1Networking \
42 | k8s.io/api/admissionregistration/v1beta1/generated.proto;V1beta1Admissionregistration \
43 | k8s.io/api/admissionregistration/v1/generated.proto;V1Admissionregistration \
44 | k8s.io/api/scheduling/v1alpha1/generated.proto;V1alpha1Scheduling \
45 | k8s.io/api/scheduling/v1/generated.proto;V1Scheduling \
46 | k8s.io/api/storage/v1/generated.proto;V1Storage \
47 | k8s.io/api/storage/v1beta1/generated.proto;V1beta1Storage \
48 | k8s.io/api/batch/v1/generated.proto;V1Batch \
49 | k8s.io/api/batch/v1beta1/generated.proto;V1beta1Batch \
50 | k8s.io/api/apps/v1beta2/generated.proto;V1beta2Apps \
51 | k8s.io/api/apps/v1/generated.proto;V1Apps \
52 | k8s.io/api/apps/v1beta1/generated.proto;V1beta1Apps \
53 | k8s.io/api/authentication/v1/generated.proto;V1Authentication \
54 | k8s.io/api/authentication/v1beta1/generated.proto;V1beta1Authentication \
55 | k8s.io/api/admission/v1/generated.proto;V1Admission \
56 | k8s.io/api/admission/v1beta1/generated.proto;V1beta1Admission \
57 | k8s.io/api/policy/v1/generated.proto;V1Policy \
58 | k8s.io/api/policy/v1beta1/generated.proto;V1beta1Policy \
59 | k8s.io/api/core/v1/generated.proto;V1 \
60 | k8s.io/api/autoscaling/v1/generated.proto;V1Autoscaling \
61 | k8s.io/api/autoscaling/v2beta1/generated.proto;V2beta1Autoscaling \
62 | k8s.io/api/autoscaling/v2beta2/generated.proto;V2beta2Autoscaling \
63 | k8s.io/api/extensions/v1beta1/generated.proto;V1beta1Extensions \
64 | k8s.io/api/certificates/v1/generated.proto;V1Certificates \
65 | k8s.io/api/certificates/v1beta1/generated.proto;V1beta1Certificates \
66 | k8s.io/api/imagepolicy/v1alpha1/generated.proto;V1alpha1Imagepolicy \
67 | k8s.io/api/authorization/v1/generated.proto;V1Authorization \
68 | k8s.io/api/authorization/v1beta1/generated.proto;V1beta1Authorization \
69 | k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/generated.proto;V1beta1Apiextensions"
70 |
71 | proto_files=""
72 |
73 | echo 'Munging proto file packages'
74 |
75 | # This is a little hacky, but we know the go_package directive is in the
76 | # right place, so add a marker, and then append more package declarations.
77 | # Sorry, I like perl.
78 | for info in ${files}; do
79 | file=$(echo ${info} | cut -d ";" -f 1)
80 | class=$(echo ${info} | cut -d ";" -f 2)
81 | proto_files="${file} ${proto_files}"
82 | perl -pi -e \
83 | 's/option go_package = "(.*)";/option go_package = "$1";\n\/\/ PKG/' \
84 | ${file}
85 | perl -pi -e \
86 | 's/\/\/ PKG/\/\/ PKG\noption java_package = "io.kubernetes.client.proto";/' \
87 | ${file}
88 | perl -pi -e \
89 | "s/\/\/ PKG/\/\/ PKG\noption java_outer_classname = \"${class}\";/" \
90 | ${file}
91 |
92 | # Other package declarations can go here.
93 | done
94 |
95 | echo "Generating code for $1"
96 | ${proto} -I${dir} ${proto_files} --${1}_out=${2}
97 |
--------------------------------------------------------------------------------
/proto/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2017 The Kubernetes Authors.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | echo 'Installing proto compiler'
18 |
19 | version=3.6.1
20 | platform="linux"
21 |
22 | if [[ "$OSTYPE" == "darwin"* ]]; then
23 | platform="osx"
24 | fi
25 |
26 | file=protoc-${version}-${platform}-x86_64.zip
27 |
28 | wget https://github.com/protocolbuffers/protobuf/releases/download/v${version}/${file}
29 | unzip ${file}
30 | rm ${file}
31 |
32 |
33 |
--------------------------------------------------------------------------------