-
Notifications
You must be signed in to change notification settings - Fork 71
/
Makefile
66 lines (47 loc) · 2.3 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# See: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
# For a list of valid GOOS and GOARCH values
# Note: these can be overriden on the command line e.g. `make PLATFORM=<platform> ARCH=<arch>`
PLATFORM=$(shell go env GOOS)
ARCH=$(shell go env GOARCH)
GOTESTSUM=go run gotest.tools/[email protected]
ifeq ("$(PLATFORM)", "windows")
agent=agent.exe
credential-helper=docker-credential-portainer.exe
else
agent=agent
credential-helper=docker-credential-portainer
endif
.DEFAULT_GOAL := help
.PHONY: agent credential-helper download-binaries clean help
##@ Building
all: agent credential-helper download-binaries ## Build everything
agent: ## Build the agent
@echo "Building Portainer agent..."
@CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) go build -trimpath --installsuffix cgo --ldflags "-s" -o dist/$(agent) ./cmd/agent/
credential-helper: ## Build the credential helper (used by edge private registries)
@echo "Building Portainer credential-helper..."
@cd cmd/docker-credential-portainer && \
CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) go build -trimpath --installsuffix cgo --ldflags "-s" -o ../../dist/$(credential-helper)
download-binaries: ## Download dependant binaries
@./setup.sh $(PLATFORM) $(ARCH)
image: ## Build the agent and the image
@./dev.sh build -c
##@ Dependencies
tidy: ## Tidy up the go.mod file
@go mod tidy
##@ Testing
.PHONY: test test-client test-server
test: ## Run server tests
$(GOTESTSUM) --format pkgname-and-test-fails --format-hide-empty-pkg --hide-summary skipped -- -cover -race -covermode=atomic -coverprofile=coverage.out ./...
##@ Miscellaneous
lint: ## Run linter
golangci-lint run -c .golangci.yaml
clean: ## Remove all build and download artifacts
@echo "Clearing the dist directory..."
@rm -f dist/*
mock: ## Regenerate the internals/mocks/* files | DL = go install go.uber.org/mock/mockgen@latest
mockgen -source=./agent.go -destination=./internals/mocks/mock_agent.go -package mocks
mockgen -source=./edge/client/interface.go -destination=./internals/mocks/mock_edge.go -package mocks
##@ Helpers
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)