
.PHONY: generate
generate:
	./genproto.sh
	go generate ./...

.PHONY: test
test:
	go test -json ./... | docker run -i ghcr.io/gotesttools/gotestfmt:latest

.PHONY: migrate-dev-db
migrate-dev-db:
	./migrate_dev.sh

# .PHONY: migrate-prod-db
# migrate-prod-db:
# 	./migrate_prod.sh

# ex: make create-migration ARG="create_users_table"
create-migration:
	echo "Creating migration with name $(ARG)"
	docker run -v ./migrations:/migrations --network host migrate/migrate create -ext sql -seq -dir /migrations $(ARG)

dev-database:
	kubectl run postgres-client \
		--rm -it --image=postgres:latest \
		--env="LLINK_POSTGRES_CONNECTION_URL=$$(kubectl get secret shared-secrets -o jsonpath='{.data.LLINK_POSTGRES_CONNECTION_URL}' --context dev | base64 --decode)" \
		--context dev \
		--command -- /bin/bash -c "psql \$$LLINK_POSTGRES_CONNECTION_URL"

# prod-database:
# 	kubectl run postgres-client \
# 		--rm -it --image=postgres:latest \
# 		--env="LLINK_POSTGRES_CONNECTION_URL=$$(kubectl get secret shared-secrets -o jsonpath='{.data.LLINK_POSTGRES_CONNECTION_URL}' --context prod | base64 --decode)" \
# 		--context prod \
# 		--command -- /bin/bash -c "psql \$$LLINK_POSTGRES_CONNECTION_URL"

.PHONY: deploy-dev
deploy-dev: generate test
	./deploy_dev.sh

# .PHONY: release
# deploy-prod: generate test
# 	# Check for any changes (both staged and unstaged)
# 	@if [ -n "$(git status --porcelain)" ]; then \
# 		echo "Error: You have uncommitted changes in your Git repository."; \
# 		exit 1; \
# 	fi
# 	./deploy_prod.sh
# 	
