Skip to content

Commit c1a65ad

Browse files
committed
Generate codes
Signed-off-by: Yuki Iwai <[email protected]>
1 parent 0fe6cae commit c1a65ad

File tree

154 files changed

+19796
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+19796
-702
lines changed

deploy/v2beta1/mpi-operator.yaml

Lines changed: 501 additions & 60 deletions
Large diffs are not rendered by default.

hack/python-sdk/gen-sdk.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ if [ -z "${GOPATH:-}" ]; then
2828
export GOPATH=$(go env GOPATH)
2929
fi
3030

31-
# Backup existing v2 openapi_generated.go
32-
cp pkg/apis/kubeflow/v2beta1/openapi_generated.go pkg/apis/kubeflow/v2beta1/openapi_generated.go.backup
33-
34-
CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1)
35-
GOBIN="${PWD}/bin" go install "k8s.io/code-generator/cmd/openapi-gen@${CODEGEN_VERSION}"
36-
echo "Generating V2 OpenAPI specification ..."
37-
"${PWD}/bin/openapi-gen" --input-dirs github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --output-package github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --go-header-file hack/boilerplate/boilerplate.go.txt
38-
3931
echo "Generating V2 swagger file ..."
4032
go run hack/python-sdk/main.go v2beta1 > ${SWAGGER_V2_CODEGEN_FILE}
4133

@@ -47,7 +39,7 @@ fi
4739
echo "Generating V2 Python SDK for Kubeflow MPI-Operator ..."
4840
java -jar ${SWAGGER_CODEGEN_JAR} generate -i ${SWAGGER_V2_CODEGEN_FILE} -g python-legacy -o ${SDK_OUTPUT_PATH}/v2beta1 -c ${SWAGGER_CODEGEN_CONF}
4941

50-
# Rollback the current V2 openapi_generated.go
51-
mv pkg/apis/kubeflow/v2beta1/openapi_generated.go.backup pkg/apis/kubeflow/v2beta1/openapi_generated.go
42+
# Rollback the current V2 zz_generated.openapi.go
43+
mv pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go.backup pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go
5244

5345
echo "Kubeflow MPI-Operator Python SDK is generated successfully to folder ${SDK_OUTPUT_PATH}/."

hack/update-codegen.sh

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,34 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22-
pushd "${SCRIPT_ROOT}"
23-
SCRIPT_ROOT=$(pwd)
24-
popd
25-
26-
# Note that we use code-generator from `${GOPATH}/pkg/mod/` because we cannot vendor it
27-
# via `go mod vendor` to the project's /vendor directory.
28-
# Reference: https://github.com/kubernetes/code-generator/issues/57
29-
CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1)
30-
CODEGEN_PKG=$(echo `go env GOPATH`"/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}")
31-
chmod +x "${CODEGEN_PKG}/generate-groups.sh"
32-
chmod +x "${CODEGEN_PKG}/generate-internal-groups.sh"
33-
34-
"${CODEGEN_PKG}/generate-groups.sh" "deepcopy,client,informer,lister,applyconfiguration" \
35-
github.com/kubeflow/mpi-operator/pkg/client github.com/kubeflow/mpi-operator/pkg/apis \
36-
kubeflow:v2beta1 --go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt"
21+
CURRENT_DIR=$(dirname "${BASH_SOURCE[0]}")
22+
MPI_OPERATOR_ROOT=$(realpath "${CURRENT_DIR}/..")
23+
MPI_OPERATOR_PKG="github.com/kubeflow/mpi-operator"
24+
CODEGEN_PKG=$(go list -m -mod=readonly -f "{{.Dir}}" k8s.io/code-generator)
25+
26+
cd "${CURRENT_DIR}/.."
27+
28+
source "${CODEGEN_PKG}/kube_codegen.sh"
29+
30+
kube::codegen::gen_helpers \
31+
--boilerplate "${MPI_OPERATOR_ROOT}/hack/custom-boilerplate.go.txt" \
32+
"${MPI_OPERATOR_ROOT}/pkg/apis"
33+
34+
# Generating OpenAPI
35+
cp "${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go" \
36+
"${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1/zz_generated.openapi.go.backup"
37+
38+
kube::codegen::gen_openapi \
39+
--boilerplate "${MPI_OPERATOR_ROOT}/hack/custom-boilerplate.go.txt" \
40+
--output-dir "${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1" \
41+
--output-pkg "${MPI_OPERATOR_PKG}/pkg/apis/kubeflow/v2beta1" \
42+
--update-report \
43+
"${MPI_OPERATOR_ROOT}/pkg/apis/kubeflow/v2beta1"
44+
45+
kube::codegen::gen_client \
46+
--with-watch \
47+
--with-applyconfig \
48+
--output-dir "${MPI_OPERATOR_ROOT}/pkg/client" \
49+
--output-pkg "${MPI_OPERATOR_PKG}/pkg/client" \
50+
--boilerplate "${MPI_OPERATOR_ROOT}/hack/custom-boilerplate.go.txt" \
51+
"${MPI_OPERATOR_ROOT}/pkg/apis"

manifests/base/kubeflow.org_mpijobs.yaml

Lines changed: 501 additions & 60 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)