Skip to content

Commit

Permalink
chore: support kbcli milestone and release-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
1aal committed Nov 10, 2023
1 parent f9fc83d commit a1b1353
Showing 1 changed file with 5 additions and 80 deletions.
85 changes: 5 additions & 80 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ endif
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development
.PHONY: generate
generate: build-kbcli-embed-chart

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand All @@ -114,19 +111,19 @@ cue-fmt: cuetool ## Run cue fmt against code.
lint-fast: staticcheck vet golangci-lint # [INTERNAL] Run all lint job against code.

.PHONY: lint
lint: generate ## Run default lint job against code.
lint: ## Run default lint job against code.
$(MAKE) golangci-lint

.PHONY: golangci-lint
golangci-lint: golangci generate ## Run golangci-lint against code.
golangci-lint: golangci ## Run golangci-lint against code.
$(GOLANGCILINT) run ./...

.PHONY: staticcheck
staticcheck: staticchecktool generate ## Run staticcheck against code.
staticcheck: staticchecktool ## Run staticcheck against code.
$(STATICCHECK) -tags $(BUILD_TAGS) ./...

.PHONY: build-checks
build-checks: generate fmt vet goimports lint-fast ## Run build checks.
build-checks: fmt vet goimports lint-fast ## Run build checks.

.PHONY: mod-download
mod-download: ## Run go mod download against go modules.
Expand All @@ -141,7 +138,7 @@ TEST_PACKAGES ?= ./pkg/... ./cmd/...

OUTPUT_COVERAGE=-coverprofile cover.out
.PHONY: test
test: generate ## Run operator controller tests with current $KUBECONFIG context. if existing k8s cluster is k3d or minikube, specify EXISTING_CLUSTER_TYPE.
test: ## Run operator controller tests with current $KUBECONFIG context. if existing k8s cluster is k3d or minikube, specify EXISTING_CLUSTER_TYPE.
$(GO) test -tags $(BUILD_TAGS) -p 1 $(TEST_PACKAGES) $(OUTPUT_COVERAGE)

.PHONY: test-fast
Expand All @@ -162,78 +159,6 @@ goimports: goimportstool ## Run goimports against code.
$(GOIMPORTS) -local github.com/apecloud/kbcli -w $$(git ls-files|grep "\.go$$")


##@ CLI
K3S_VERSION ?= v1.23.8+k3s1
K3D_VERSION ?= 5.4.4
K3S_IMG_TAG ?= $(subst +,-,$(K3S_VERSION))

CLI_LD_FLAGS ="-s -w \
-X github.com/apecloud/kbcli/version.BuildDate=`date -u +'%Y-%m-%dT%H:%M:%SZ'` \
-X github.com/apecloud/kbcli/version.GitCommit=$(GIT_COMMIT) \
-X github.com/apecloud/kbcli/version.GitVersion=$(GIT_VERSION) \
-X github.com/apecloud/kbcli/version.Version=$(VERSION) \
-X github.com/apecloud/kbcli/version.K3sImageTag=$(K3S_IMG_TAG) \
-X github.com/apecloud/kbcli/version.K3dVersion=$(K3D_VERSION) \
-X github.com/apecloud/kbcli/version.DefaultKubeBlocksVersion=$(VERSION)"

bin/kbcli.%: ## Cross build bin/kbcli.$(OS).$(ARCH).
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build -tags $(BUILD_TAGS) -ldflags=${CLI_LD_FLAGS} -o $@ cmd/cli/main.go

.PHONY: fetch-addons
fetch-addons: ## fetch addons helm charts, if addons dir not exist, clone it, else pull it.
@if [ ! -d "addons" ]; then \
git clone https://github.com/apecloud/kubeblocks-addons.git -b main addons;\
else \
cd addons && git pull ;\
fi

.PHONY: kbcli-fast
kbcli-fast: OS=$(shell $(GO) env GOOS)
kbcli-fast: ARCH=$(shell $(GO) env GOARCH)
kbcli-fast: build-kbcli-embed-chart
$(MAKE) bin/kbcli.$(OS).$(ARCH)
@mv bin/kbcli.$(OS).$(ARCH) bin/kbcli

create-kbcli-embed-charts-dir:
mkdir -p pkg/cluster/charts/

build-single-kbcli-embed-chart.%: chart=$(word 2,$(subst ., ,$@))
build-single-kbcli-embed-chart.%:
$(HELM) dependency update addons/addons/$(chart) --skip-refresh
ifeq ($(VERSION), latest)
$(HELM) package addons/addons/$(chart)
else
$(HELM) package addons/addons/$(chart) --version $(VERSION)
endif
mv $(chart)-*.tgz pkg/cluster/charts/$(chart).tgz

.PHONY: build-kbcli-embed-chart
build-kbcli-embed-chart: helmtool fetch-addons create-kbcli-embed-charts-dir \
build-single-kbcli-embed-chart.apecloud-mysql-cluster \
build-single-kbcli-embed-chart.redis-cluster \
build-single-kbcli-embed-chart.postgresql-cluster \
build-single-kbcli-embed-chart.kafka-cluster \
build-single-kbcli-embed-chart.mongodb-cluster \
build-single-kbcli-embed-chart.llm-cluster \
build-single-kbcli-embed-chart.xinference-cluster \
# build-single-kbcli-embed-chart.neon-cluster
# build-single-kbcli-embed-chart.postgresql-cluster \
# build-single-kbcli-embed-chart.clickhouse-cluster \
# build-single-kbcli-embed-chart.milvus-cluster \
# build-single-kbcli-embed-chart.qdrant-cluster \
# build-single-kbcli-embed-chart.weaviate-cluster

.PHONY: kbcli
kbcli: build-checks kbcli-fast ## Build bin/kbcli.

.PHONY: clean-kbcli
clean-kbcli: ## Clean bin/kbcli*.
rm -f bin/kbcli*

.PHONY: kbcli-doc
kbcli-doc: ## generate CLI command reference manual.
$(GO) run -tags $(BUILD_TAGS) ./hack/docgen/cli/main.go ./docs/user_docs/cli

.PHONY: install-docker-buildx
install-docker-buildx: ## Create `docker buildx` builder.
@if ! docker buildx inspect $(BUILDX_BUILDER) > /dev/null; then \
Expand Down

0 comments on commit a1b1353

Please sign in to comment.