ifneq (,$(wildcard ./.env))
    include .env
    export
endif
.PHONY: build run codegen build-image test test-unit test-coverage lint format check-format

build:
	go build -o main

build-image:
	docker build -t authentik-kubernetes-operator:latest .

run:
	make build
	./main --kubeconfig=/home/tbehrendt/.kube/config

codegen:
	./scripts/codegen.sh

test: test-unit test-coverage

test-unit:
	go test . -coverprofile=coverage.out

test-coverage:
	go tool gcov2lcov -infile coverage.out > lcov.info

lint:
	go vet ./...

format:
	gofmt -w .

check-format:
	@OUTPUT=$$(gofmt -l .); \
	if [ -n "$$OUTPUT" ]; then \
		echo "Formatter failed for:"; \
		echo "$$OUTPUT"; \
		exit 1; \
	fi
