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://tmp/br-backup-basic?access-key=minioadmin&secret-access-key=minioadmin&endpoint=http%3a%2f%2fminio.pingcap.net%3a9000&force-path-style=true","timeout":"10m","crc32-checksum":0}' >> .env
	echo 'TI_PARAM_STR_mc_rm_opts: {"path":"qa-minio/tmp/br-backup-basic","timeout":"10m"}' >> .env

destroy-testbed:
	tcctl testbed delete

run:
	KUBECONFIG=$(KUBECONFIG) MYSQL_PROXY=socks5://172.16.4.180:30081 go run main.go

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

image:
	GOOS=linux GOARCH=amd64 make build
	docker build -t hub.pingcap.net/chengyou/br-database-test .

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

