.PHONY: generate license fix vet fmt test build tidy image SHELL := /bin/bash GOBIN := $(shell go env GOPATH)/bin # docker image options DOCKER_REGISTRY ?= quay.io DOCKER_IMAGE_NAME ?= templater DOCKER_IMAGE_PREFIX ?= airshipit DOCKER_IMAGE_TAG ?= latest DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) PUBLISH ?= false DOCKER_FORCE_CLEAN ?= true # proxy options PROXY ?= http://proxy.foo.com:8000 NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local USE_PROXY ?= false .PHONY: build build: (go build -v -o $(GOBIN)/config-function .) .PHONY: all all: generate license build fix vet fmt test lint tidy .PHONY: fix fix: (go fix .) .PHONY: fmt fmt: (go fmt .) .PHONY: generate generate: (which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo) (GOBIN=$(GOBIN) go generate .) .PHONY: tidy tidy: (go mod tidy) .PHONY: fix lint: (which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1) ($(GOBIN)/golangci-lint run .) .PHONY: test test: (go test -cover .) .PHONY: vet vet: (go vet .) .PHONY: image image: ifeq ($(USE_PROXY), true) docker build . --network=host \ --build-arg http_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \ --build-arg HTTP_PROXY=$(PROXY) \ --build-arg HTTPS_PROXY=$(PROXY) \ --build-arg no_proxy=$(NO_PROXY) \ --build-arg NO_PROXY=$(NO_PROXY) \ --tag $(DOCKER_IMAGE) \ --force-rm=$(DOCKER_FORCE_CLEAN) else docker build . --network=host \ --tag $(DOCKER_IMAGE) \ --force-rm=$(DOCKER_FORCE_CLEAN) endif ifeq ($(PUBLISH), true) @docker push $(DOCKER_IMAGE) endif