Skip to content

Commit

Permalink
add code-gen in makefile (fluid-cloudnative#1796)
Browse files Browse the repository at this point in the history
* add code-gen in makefile

Signed-off-by: zwwhdls <zww@hdls.me>

* add code-gen in makefile

Signed-off-by: zwwhdls <zww@hdls.me>

* GO111MODULE=auto in ci

Signed-off-by: zwwhdls <zww@hdls.me>

* delete useless parameter in sh

Signed-off-by: zwwhdls <zww@hdls.me>
  • Loading branch information
zwwhdls authored Apr 20, 2022
1 parent 17a7490 commit 8f58616
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
build:
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: off
GO111MODULE: auto
CI_TEST_FLAGS: -race -coverprofile=coverage.txt -covermode=atomic
defaults:
run:
Expand Down
23 changes: 13 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ build: ${BINARY_BUILD}
csi-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/fluid-csi -ldflags '${LDFLAGS}' cmd/csi/main.go

dataset-controller-build: generate fmt vet
dataset-controller-build: generate gen-openapi fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/dataset-controller -ldflags '${LDFLAGS}' cmd/dataset/main.go

alluxioruntime-controller-build: generate fmt vet
alluxioruntime-controller-build: generate gen-openapi fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/alluxioruntime-controller -ldflags '${LDFLAGS}' cmd/alluxio/main.go

jindoruntime-controller-build: generate fmt vet
jindoruntime-controller-build: generate gen-openapi fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/jindoruntime-controller -ldflags '${LDFLAGS}' cmd/jindo/main.go

goosefsruntime-controller-build: generate fmt vet
goosefsruntime-controller-build: generate gen-openapi fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/goosefsruntime-controller -ldflags '${LDFLAGS}' cmd/goosefs/main.go

juicefsruntime-controller-build: generate fmt vet
juicefsruntime-controller-build: generate gen-openapi fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/juicefsruntime-controller -ldflags '-s -w ${LDFLAGS}' cmd/juicefs/main.go

webhook-build: generate fmt vet
Expand Down Expand Up @@ -157,22 +157,22 @@ update-api-doc:
bash tools/api-doc-gen/generate_api_doc.sh && mv tools/api-doc-gen/api_doc.md docs/zh/dev/api_doc.md && cp docs/zh/dev/api_doc.md docs/en/dev/api_doc.md

# Build the docker image
docker-build-dataset-controller: generate fmt vet
docker-build-dataset-controller: generate gen-openapi fmt vet
docker build --no-cache . -f docker/Dockerfile.dataset -t ${DATASET_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-application-controller: generate fmt vet
docker build --no-cache . -f docker/Dockerfile.application -t ${APPLICATION_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-alluxioruntime-controller: generate fmt vet
docker-build-alluxioruntime-controller: generate gen-openapi fmt vet
docker build --no-cache . -f docker/Dockerfile.alluxioruntime -t ${ALLUXIORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-jindoruntime-controller: generate fmt vet
docker-build-jindoruntime-controller: generate gen-openapi fmt vet
docker build --no-cache . -f docker/Dockerfile.jindoruntime -t ${JINDORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-goosefsruntime-controller: generate fmt vet
docker-build-goosefsruntime-controller: generate gen-openapi fmt vet
docker build --no-cache . -f docker/Dockerfile.goosefsruntime -t ${GOOSEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-juicefsruntime-controller: generate fmt vet juicefsruntime-controller-build
docker-build-juicefsruntime-controller: generate gen-openapi fmt vet juicefsruntime-controller-build
docker build --no-cache . -f docker/Dockerfile.juicefsruntime -t ${JUICEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-csi: generate fmt vet
Expand Down Expand Up @@ -226,6 +226,9 @@ docker-push-all: ${DOCKER_PUSH}
gen-sdk:
./hack/sdk/gen-sdk.sh

gen-openapi:
./hack/gen-openapi.sh

# find or download controller-gen
# download controller-gen if necessary
controller-gen:
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions api/v1alpha1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1907,8 +1907,7 @@
"type": "string"
},
"mountTime": {
"description": "MountTime represents time last mount happened if Mounttime is early than master starting time, remount will be required",
"default": {},
"description": "MountTime represents time last mount happened if Mounttime is earlier than master starting time, remount will be required",
"$ref": "#/definitions/v1.Time"
},
"selector": {
Expand Down
32 changes: 32 additions & 0 deletions hack/gen-openapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env 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

# Grab kube-openapi version from go.mod
OPENAPI_VERSION=$(grep 'k8s.io/kube-openapi' go.mod | awk '{print $2}' | head -1)

echo "Installing openapi-gen"
go install k8s.io/kube-openapi/cmd/openapi-gen@${OPENAPI_VERSION}

echo "Generating OpenAPI specification ..."
${GOPATH}/bin/openapi-gen --input-dirs github.com/fluid-cloudnative/fluid/api/v1alpha1 --output-package github.com/fluid-cloudnative/fluid/api/v1alpha1 --go-header-file hack/boilerplate.go.txt
1 change: 0 additions & 1 deletion pkg/ddc/alluxio/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package alluxio
import (
"testing"


datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
ctrlhelper "github.com/fluid-cloudnative/fluid/pkg/ctrl"
"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
Expand Down

0 comments on commit 8f58616

Please sign in to comment.