.PHONY:  build test check build-bin generate generate4test go-clean clean

build: build-bin
	make -C ./svc build
	make -C ./portal build

test:
	make -C ./svc test
	make -C ./portal test
	make -C ./provider-cost test

lint:
	make -C ./svc lint
	make -C ./portal lint

generate:
	make -C ./svc generate
	make -C ./portal generate

generate4test:
	make -C ./svc generate4test
	make -C ./portal generate4test

clean: go-clean
	make -C ./svc clean
	make -C ./portal clean

coverage-after-test: gcov2lcov
	gcov2lcov -infile=coverage/coverage.out -outfile=coverage/coverage.out.lcov

#GCOV2LCOV = $(shell go env GOTOOLDIR)/gcov2lcov
gcov2lcov:
	go install github.com/jandelgado/gcov2lcov@v1.0.5

#### for develop ####
#
#fast-deploy: fast-deploy-svc fast-deploy-portal
#
#fast-deploy-svc:
#	cd svc/ && COMPONENTS=core-svc ../local/deploy_component.sh
#	cd ../
#
#fast-deploy-portal:
#	cd portal/ && COMPONENTS=core-portal ../local/deploy_component.sh
#	cd ../

local-run-svc:
	cd svc/ && CORE_SVC_ROLE=all go run ./cmd/server/main.go --config-path=../local/svc_conf.yaml serve

local-run-svc-server:
	cd svc/ && CORE_SVC_ROLE=API_SERVICE go run ./cmd/server/main.go --config-path=../local/svc_conf.yaml serve

local-run-svc-worker:
	cd svc/ && CORE_SVC_ROLE=WORKER go run ./cmd/server/main.go --config-path=../local/svc_conf.yaml serve

local-run-portal:
	cd portal/ && CENTRAL_ROLE=API_SERVICE REGION=us-west-2 AWS_REGION=us-west-2 go run ./cmd/server/main.go -config-path=../local/portal_conf.yaml

local-run-provider-cost:
	make -C ./provider-cost run

deploy-eventbus-proxy:
	kubectl --context="arn:aws:eks:us-west-2:385595570414:cluster/dev-base-us-west-2" apply -f ./local/eventbus-proxy-deployment.yaml

portforward-eventbus-proxy: deploy-eventbus-proxy
	kubectl --context=arn:aws:eks:us-west-2:385595570414:cluster/dev-base-us-west-2 -n nightly-ms port-forward  deployment/eventbus-proxy 9092:9092
