-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
55 lines (45 loc) · 1.49 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
.PHONY: all build
VERSION ?= 0.8
GO_VERSION := 1.22.0
GOLANGCI_LINT_VERSION := v1.55.2
REPO ?= openpolicyagent/opa-docker-authz-v2
all: build
check:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION} golangci-lint run -v
fmt:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION} golangci-lint run -v --fix
test:
go test
build:
@docker container run --rm \
-e VERSION=$(VERSION) \
-v $(PWD):/go/src/github.com/open-policy-agent/opa-docker-authz \
-w /go/src/github.com/open-policy-agent/opa-docker-authz \
golang:$(GO_VERSION) \
./build.sh
image: build
@docker image build \
--tag $(REPO):$(VERSION) \
.
plugin: build
VERSION=$(VERSION) REPO=$(REPO) ./plugin.sh
plugin-push:
@for plugin in `docker plugin ls --format '{{.Name}}'`; do \
if [ "$$plugin" = "$(REPO)-v2:$(VERSION)" ]; then \
echo "\nPushing plugin $(REPO)-v2:$(VERSION) ..."; \
docker plugin push $(REPO)-v2:$(VERSION); \
exit; \
fi \
done; \
echo "\nNo local copy of $(REPO)-v2:$(VERSION) exists, create it before attempting push"
clean:
@if [ -f ./opa-docker-authz ]; then \
echo "\nRemoving opa-docker-authz binary ..."; \
rm -rvf ./opa-docker-authz; \
fi
@for plugin in `docker plugin ls --format '{{.Name}}'`; do \
if [ "$$plugin" = "$(REPO)-v2:$(VERSION)" ]; then \
echo "\nRemoving local copy of plugin $(REPO):$(VERSION) ..."; \
docker plugin rm -f $(REPO)-v2:$(VERSION); \
fi \
done