Skip to content

Commit

Permalink
Merge pull request kubernetes-client#330 from silasbw/gen0
Browse files Browse the repository at this point in the history
Script for generating client code
  • Loading branch information
k8s-ci-robot authored Aug 20, 2019
2 parents 4d72a14 + 1d89fcd commit 0a0dcbf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ npm install
## (re) Generating code

```console
cd ../
git clone https://github.com/kubernetes-client/gen
cd javascript
../gen/openapi/typescript.sh src/gen settings
npm run generate
```

## Formatting
Expand Down
25 changes: 25 additions & 0 deletions generate-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

. settings

if [[ -z ${GEN_ROOT:-} ]]; then
: "${GEN_COMMIT?Need to set GEN_COMMIT to kubernetes-client/gen commit}"
TEMP_FOLDER=$(mktemp -d)
trap "rm -rf ${TEMP_FOLDER}" EXIT SIGINT

GEN_ROOT="${TEMP_FOLDER}/gen"
echo ">>> Cloning gen repo"
git clone --recursive https://github.com/kubernetes-client/gen.git "${GEN_ROOT}"
(cd ${GEN_ROOT} && git checkout ${GEN_COMMIT})
else
echo ">>> Reusing gen repo at ${GEN_ROOT}"
fi

TYPESCRIPT="${GEN_ROOT}/openapi/typescript.sh"
echo ">>> Running ${TYPESCRIPT}"
${TYPESCRIPT} src/gen settings
echo ">>> Done."
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lint": "tslint --project \".\" && prettier --check './src/**/*.ts' && tslint --project \"./examples/typescript\"",
"clean": "rm -Rf node_modules/ dist/",
"build": "tsc",
"generate": "./generate-client.sh",
"watch": "tsc --watch",
"test": "nyc mocha",
"prepare": "npm run build"
Expand Down
6 changes: 6 additions & 0 deletions settings
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# kubernetes-client/gen commit to use for code generation.
export GEN_COMMIT=7959939

# GitHub username/organization to clone kubernetes repo from.
export USERNAME=kubernetes

# Kubernetes branch to get the OpenAPI spec from.
export KUBERNETES_BRANCH="release-1.13"

Expand Down

0 comments on commit 0a0dcbf

Please sign in to comment.