https://github.com/kubeflow/katib
Raw File
Tip revision: de80d638b14cfc1e05282f52af84031ddc15f654 authored by avelichk on 03 September 2020, 19:47:30 UTC
Add newline
Tip revision: de80d63
update-openapigen.sh
#!/bin/bash

# Copyright 2019 The Kubeflow Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

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

if [[ -z "${GOPATH:-}" ]]; then
    export GOPATH=$(go env GOPATH)
fi

PROJECT_ROOT=${GOPATH}/src/github.com/kubeflow/katib
CODEGEN_PKG=${PROJECT_ROOT}/vendor/k8s.io/code-generator
VERSION_LIST=(v1alpha3 v1beta1)
SWAGGER_VERSION="0.1"

for VERSION in ${VERSION_LIST[@]}; do
    SWAGGER_CODEGEN_FILE=${PROJECT_ROOT}/pkg/apis/${VERSION}/swagger.json

    echo "Generating OpenAPI specification for ${VERSION} ..."
    go run ${CODEGEN_PKG}/cmd/openapi-gen/main.go \
      --go-header-file ${PROJECT_ROOT}/hack/boilerplate.go.txt \
      --input-dirs github.com/kubeflow/katib/pkg/apis/controller/common/${VERSION},github.com/kubeflow/katib/pkg/apis/controller/experiments/${VERSION},github.com/kubeflow/katib/pkg/apis/controller/suggestions/${VERSION},github.com/kubeflow/katib/pkg/apis/controller/trials/${VERSION} \
      --output-package github.com/kubeflow/katib/pkg/apis/${VERSION} \
      $@

    echo "Generating swagger file for ${VERSION} ..."
    go run ${PROJECT_ROOT}/hack/swagger/main.go ${VERSION}-${SWAGGER_VERSION} ${VERSION} > ${SWAGGER_CODEGEN_FILE}
done
back to top