Rainbond/Makefile

87 lines
2.2 KiB
Makefile
Raw Normal View History

2017-11-22 14:02:29 +08:00
GO_LDFLAGS=-ldflags " -w"
2020-03-22 12:54:17 +08:00
VERSION=$(shell git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3)
2017-11-07 11:40:44 +08:00
WORK_DIR=/go/src/github.com/goodrain/rainbond
BASE_NAME=rainbond
2017-11-22 14:02:29 +08:00
BASE_DOCKER=./hack/contrib/docker
2017-11-22 14:02:29 +08:00
default: help
2018-11-07 15:03:36 +08:00
all: image ## build linux binaries, build images for docker
2017-11-07 11:40:44 +08:00
2017-11-22 14:02:29 +08:00
clean:
@rm -rf ${BIN_PATH}/*
2017-11-07 11:40:44 +08:00
2018-07-24 23:20:27 +08:00
ifeq ($(origin WHAT), undefined)
WHAT = all
endif
2018-12-01 16:56:03 +08:00
ifeq ($(origin STATIC), undefined)
STATIC = false
else
STATIC = true
endif
2018-12-05 18:18:38 +08:00
ifeq ($(origin GOOS), undefined)
GOOS = $(shell go env GOOS)
endif
BIN_PATH=./_output/${GOOS}/${VERSION}
2018-11-21 17:35:07 +08:00
ifeq ($(origin PUSH), undefined)
PUSH = false
2019-02-15 18:46:11 +08:00
else
PUSH = push
2018-11-21 17:35:07 +08:00
endif
2018-07-24 23:20:27 +08:00
.PHONY: build
build:
@echo "🐳build ${WHAT} ${GOOS}"
@GOOS=$(GOOS) ./localbuild.sh $(WHAT)
2018-07-24 23:20:27 +08:00
image:
@echo "🐳build image ${WHAT}"
2018-11-21 17:35:07 +08:00
@bash ./release.sh ${WHAT} ${PUSH}
2018-12-01 18:11:32 +08:00
binary:
@echo "🐳build binary ${WHAT} os ${GOOS}"
@ GOOS=${GOOS} bash ./release.sh binary ${WHAT}
check:
./check.sh
mock:
@cd db && ./mock.sh && cd dao && ./mock.sh
2017-11-22 14:02:29 +08:00
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
2019-08-04 21:29:33 +08:00
precommit:
2021-04-14 20:17:40 +08:00
./precheck.sh
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
2021-04-15 15:58:50 +08:00
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./pkg/apis/..." output:crd:artifacts:config=config/crd
2021-04-14 20:17:40 +08:00
# Generate code
generate: controller-gen
2021-04-16 10:07:34 +08:00
chmod +x vendor/k8s.io/code-generator/generate-groups.sh
2021-04-15 15:58:50 +08:00
./hack/k8s/codegen/update-generated.sh
2021-04-15 13:45:07 +08:00
$(CONTROLLER_GEN) object:headerFile="hack/k8s/codegen/boilerplate.go.txt" paths="./pkg/apis/..."
cp -r github.com/goodrain/rainbond/pkg/ ./pkg/
rm -rf github.com/
2021-04-14 20:17:40 +08:00
# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
2021-05-06 09:34:15 +08:00
endif
.PHONY: test
test:
KUBE_CONFIG=~/.kube/config PROJECT_HOME=${shell pwd} ginkgo -v worker/controllers/helmapp