Support make help

This commit is contained in:
Lan Liang
2021-08-13 00:15:37 +08:00
parent 418a2a09c7
commit 989ab40952

View File

@@ -39,38 +39,46 @@ define ALL_HELP_INFO
# debugging tools like delve. # debugging tools like delve.
endef endef
.PHONY: all .PHONY: all
all: test ks-apiserver ks-controller-manager all: test ks-apiserver ks-controller-manager;$(info $(M)...Begin test and build all of binary) @ ## Test and build all of binary
help:
@grep -hE '^[ a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-17s\033[0m %s\n", $$1, $$2}'
.PHONY: binary
# Build all of binary
binary: | ks-apiserver ks-controller-manager; $(info $(M)...Build all of binary) @ ## Build all of binary
# Build ks-apiserver binary # Build ks-apiserver binary
ks-apiserver: ks-apiserver: ; $(info $(M)...Begin build ks-apiserver binary.) @ ## Build ks-apiserver
hack/gobuild.sh cmd/ks-apiserver hack/gobuild.sh cmd/ks-apiserver;
# Build ks-controller-manager binary # Build ks-controller-manager binary
ks-controller-manager: ks-controller-manager: ; $(info $(M)...Begin build ks-controller-manager binary.) @ ## Build ks-controller-manager
hack/gobuild.sh cmd/controller-manager hack/gobuild.sh cmd/controller-manager
# Run all verify scripts hack/verify-*.sh # Run all verify scripts hack/verify-*.sh
verify-all: verify-all: ; $(info $(M)...Begin run all verify scripts hack/verify-*.sh.) @ ## Run all verify scripts hack/verify-*.sh
hack/verify-all.sh hack/verify-all.sh
# Build e2e binary # Build e2e binary
e2e: e2e: ;$(info $(M)...Begin build e2e binary.) @ ## Build e2e binary
hack/build_e2e.sh test/e2e hack/build_e2e.sh test/e2e
# Run go fmt against code # Run go fmt against code
fmt: fmt: ;$(info $(M)...Begin run go fmt against code .) @ ## Run go fmt against code
gofmt -w ./pkg ./cmd ./tools ./api gofmt -w ./pkg ./cmd ./tools ./api
# Format all import, `goimports` is required. # Format all import, `goimports` is required.
goimports: goimports: ;$(info $(M)...Begin Format all import.) @ ## Format all import, `goimports` is required.
@hack/update-goimports.sh @hack/update-goimports.sh
# Run go vet against code # Run go vet against code
vet: vet: ;$(info $(M)...Begin run go vet against code.) @ ## Run go vet against code
go vet ./pkg/... ./cmd/... go vet ./pkg/... ./cmd/...
# Generate manifests e.g. CRD, RBAC etc. # Generate manifests e.g. CRD, RBAC etc.
manifests: manifests: ;$(info $(M)...Begin generate manifests e.g. CRD, RBAC etc..) @ ## Generate manifests e.g. CRD, RBAC etc.
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/application/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/application/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/cluster/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/cluster/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/devops/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/devops/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds
@@ -80,17 +88,17 @@ manifests:
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/storage/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/storage/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/tenant/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/tenant/... rbac:roleName=controller-perms ${CRD_OPTIONS} output:crd:artifacts:config=config/crds
deploy: manifests deploy: manifests ;$(info $(M)...Begin deploy.) @ ## deploy
kubectl apply -f config/crds kubectl apply -f config/crds
kustomize build config/default | kubectl apply -f - kustomize build config/default | kubectl apply -f -
mockgen: mockgen: ;$(info $(M)...Begin mockgen.) @ ## mockgen
mockgen -package=openpitrix -source=pkg/simple/client/openpitrix/openpitrix.go -destination=pkg/simple/client/openpitrix/mock.go mockgen -package=openpitrix -source=pkg/simple/client/openpitrix/openpitrix.go -destination=pkg/simple/client/openpitrix/mock.go
deepcopy: deepcopy: ;$(info $(M)...Begin deepcopy.) @ ## deepcopy
hack/generate_group.sh "deepcopy" kubesphere.io/api kubesphere.io/api ${GV} --output-base=staging/src/ -h "hack/boilerplate.go.txt" hack/generate_group.sh "deepcopy" kubesphere.io/api kubesphere.io/api ${GV} --output-base=staging/src/ -h "hack/boilerplate.go.txt"
openapi: openapi: ;$(info $(M)...Begin openapi.) @ ## openapi
go run ./vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go -O openapi_generated -i ./vendor/k8s.io/apimachinery/pkg/apis/meta/v1,./staging/src/kubesphere.io/api/tenant/v1alpha1 -p kubesphere.io/api/tenant/v1alpha1 -h ./hack/boilerplate.go.txt --report-filename ./api/api-rules/violation_exceptions.list go run ./vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go -O openapi_generated -i ./vendor/k8s.io/apimachinery/pkg/apis/meta/v1,./staging/src/kubesphere.io/api/tenant/v1alpha1 -p kubesphere.io/api/tenant/v1alpha1 -h ./hack/boilerplate.go.txt --report-filename ./api/api-rules/violation_exceptions.list
go run ./vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go -O openapi_generated -i ./vendor/k8s.io/apimachinery/pkg/apis/meta/v1,./staging/src/kubesphere.io/api/servicemesh/v1alpha2 -p kubesphere.io/api/servicemesh/v1alpha2 -h ./hack/boilerplate.go.txt --report-filename ./api/api-rules/violation_exceptions.list go run ./vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go -O openapi_generated -i ./vendor/k8s.io/apimachinery/pkg/apis/meta/v1,./staging/src/kubesphere.io/api/servicemesh/v1alpha2 -p kubesphere.io/api/servicemesh/v1alpha2 -h ./hack/boilerplate.go.txt --report-filename ./api/api-rules/violation_exceptions.list
go run ./vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go -O openapi_generated -i ./vendor/k8s.io/api/networking/v1,./vendor/k8s.io/apimachinery/pkg/apis/meta/v1,./vendor/k8s.io/apimachinery/pkg/util/intstr,./staging/src/kubesphere.io/api/network/v1alpha1 -p kubesphere.io/api/network/v1alpha1 -h ./hack/boilerplate.go.txt --report-filename ./api/api-rules/violation_exceptions.list go run ./vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go -O openapi_generated -i ./vendor/k8s.io/api/networking/v1,./vendor/k8s.io/apimachinery/pkg/apis/meta/v1,./vendor/k8s.io/apimachinery/pkg/util/intstr,./staging/src/kubesphere.io/api/network/v1alpha1 -p kubesphere.io/api/network/v1alpha1 -h ./hack/boilerplate.go.txt --report-filename ./api/api-rules/violation_exceptions.list
@@ -100,48 +108,44 @@ openapi:
go run ./tools/cmd/crd-doc-gen/main.go go run ./tools/cmd/crd-doc-gen/main.go
go run ./tools/cmd/doc-gen/main.go go run ./tools/cmd/doc-gen/main.go
# Build the docker image container: ;$(info $(M)...Begin build the docker image.) @ ## Build the docker image
container:
DRY_RUN=true hack/docker_build.sh DRY_RUN=true hack/docker_build.sh
# Build and push container-push: ;$(info $(M)...Begin build and push.) @ ## Build and push
container-push:
hack/docker_build.sh hack/docker_build.sh
# Build container images for multiple platforms. container-cross: ; $(info $(M)...Begin build container images for multiple platforms.) @ ## Build container images for multiple platforms. Currently, only linux/amd64,linux/arm64 are supported.
# Currently, only linux/amd64,linux/arm64 are supported.
container-cross:
DRY_RUN=true hack/docker_build_multiarch.sh DRY_RUN=true hack/docker_build_multiarch.sh
# Build and push # Build and push
container-cross-push: container-cross-push: ; $(info $(M)...Begin build and push.) @ ## Build and push
hack/docker_build_multiarch.sh hack/docker_build_multiarch.sh
helm-package: helm-package: ; $(info $(M)...Begin helm-package.) @ ## helm-package
ls config/crds/ | xargs -i cp -r config/crds/{} config/ks-core/crds/ ls config/crds/ | xargs -i cp -r config/crds/{} config/ks-core/crds/
helm package config/ks-core --app-version=v3.1.0 --version=0.1.0 -d ./bin helm package config/ks-core --app-version=v3.1.0 --version=0.1.0 -d ./bin
helm-deploy: helm-deploy: ; $(info $(M)...Begin helm-deploy.) @ ## helm-deploy
ls config/crds/ | xargs -i cp -r config/crds/{} config/ks-core/crds/ ls config/crds/ | xargs -i cp -r config/crds/{} config/ks-core/crds/
- kubectl create ns kubesphere-controls-system - kubectl create ns kubesphere-controls-system
helm upgrade --install ks-core ./config/ks-core -n kubesphere-system --create-namespace helm upgrade --install ks-core ./config/ks-core -n kubesphere-system --create-namespace
kubectl apply -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/roles/ks-core/prepare/files/ks-init/role-templates.yaml kubectl apply -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/roles/ks-core/prepare/files/ks-init/role-templates.yaml
helm-uninstall: helm-uninstall: ; $(info $(M)...Begin helm-uninstall.) @ ## helm-uninstall
- kubectl delete ns kubesphere-controls-system - kubectl delete ns kubesphere-controls-system
helm uninstall ks-core -n kubesphere-system helm uninstall ks-core -n kubesphere-system
kubectl delete -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/roles/ks-core/prepare/files/ks-init/role-templates.yaml kubectl delete -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/roles/ks-core/prepare/files/ks-init/role-templates.yaml
# Run tests # Run tests
test: vet test: vet ;$(info $(M)...Begin run tests.) @ ## Run tests
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT=2m; go test ./pkg/... ./cmd/... -covermode=atomic -coverprofile=coverage.txt export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT=2m; go test ./pkg/... ./cmd/... -covermode=atomic -coverprofile=coverage.txt
.PHONY: clean .PHONY: clean
clean: clean: ;$(info $(M)...Begin clean.) @ ## clean
-make -C ./pkg/version clean -make -C ./pkg/version clean
@echo "ok" @echo "ok"
# find or download controller-gen # find or download controller-gen
# download controller-gen if necessary # download controller-gen if necessary
clientset: clientset: ;$(info $(M)...Begin find or download controller-gen.) @ ## find or download controller-gen,download controller-gen if necessary
./hack/generate_client.sh ${GV} ./hack/generate_client.sh ${GV}