GO := CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go

.PHONY: run fmt

testbed: #install-tcctl
	tcctl testbed create -f testbed.yaml
	echo 'TI_PARAM_STR_br_opts: {"storage":"s3://nfs/tools_test_data/gotpc-100-tidb504-br504-backup?access-key=minioadmin&secret-access-key=minioadmin&endpoint=http%3a%2f%2fminio.pingcap.net%3a9000&force-path-style=true","timeout":"10m","crc32-checksum":1846875643,"database":"gotpc"}' >> .env
	echo 'TI_PARAM_STR_global_variable: []' >> .env
	echo 'TI_PARAM_STR_admin_check: []' >> .env

destroy-testbed:
	tcctl testbed delete

run:
	KUBECONFIG=$(KUBECONFIG) MYSQL_PROXY=socks5://rms-staging.pingcap.net:30081 go run main.go

build:
	$(GO) build -o ./dataCompatability main.go

image:
	GOOS=linux GOARCH=amd64 make build
	docker build -t hub-new.pingcap.net/fubinzhang/br-data-compatability .

fmt: groupimports
	go fmt ./...

groupimports: install-goimports
	goimports -w -l -local github.com/pingcap/test-infra .

install-goimports:
ifeq (, $(shell which goimports))
	@{ \
	set -e ;\
	TMP_DIR=$$(mktemp -d) ;\
	cd $$TMP_DIR ;\
	GO111MODULE=on go get golang.org/x/tools/cmd/goimports ;\
	rm -rf $$TMP_DIR ;\
	}
endif

install-testbed-cli:
	go install github.com/pingcap/test-infra/services/rms/cmd/testbed@latest

