-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
80 lines (66 loc) · 3.35 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
SOURCEDIR=./pkg ./plugins
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
ROOT := $(shell pwd)
LOCAL_ENI_PLUGIN_BINARY=bin/plugins/ecs-eni
LOCAL_IPAM_PLUGIN_BINARY=bin/plugins/ecs-ipam
LOCAL_BRIDGE_PLUGIN_BINARY=bin/plugins/ecs-bridge
VERSION=$(shell cat $(ROOT)/VERSION)
GO_EXECUTABLE=$(shell command -v go 2> /dev/null)
# We want to embed some git details in the build. We support pulling
# these details from the environment in order support builds outside
# of a git working copy. If they're not given explicitly, we'll try to
# use git to directly inspect the repository state...
GIT_SHORT_HASH ?= $(shell git rev-parse --short=8 HEAD 2> /dev/null)
GIT_PORCELAIN ?= $(shell git status --porcelain 2> /dev/null | wc -l)
# ...and if we can't inspect the repo state, we'll fall back to some
# static strings
ifeq ($(strip $(GIT_SHORT_HASH)),)
GIT_SHORT_HASH=unknown
endif
ifeq ($(strip $(GIT_PORCELAIN)),)
# This indicates that the repo is dirty. Since we can't tell whether
# it is or not, this seems the safest fallback.
GIT_PORCELAIN=1
endif
.PHONY: get-deps
get-deps:
go install github.com/golang/mock/mockgen@v1.6.0
go install golang.org/x/tools/cmd/goimports@v0.24.0
.PHONY: plugins
plugins: $(LOCAL_ENI_PLUGIN_BINARY) $(LOCAL_IPAM_PLUGIN_BINARY) $(LOCAL_BRIDGE_PLUGIN_BINARY)
$(LOCAL_ENI_PLUGIN_BINARY): $(SOURCES)
GOOS=linux CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "\
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitShortHash=$(GIT_SHORT_HASH) \
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitPorcelain=$(GIT_PORCELAIN) \
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.Version=$(VERSION) -s" \
-o ${ROOT}/${LOCAL_ENI_PLUGIN_BINARY} github.com/aws/amazon-ecs-cni-plugins/plugins/eni
@echo "Built eni plugin"
$(LOCAL_IPAM_PLUGIN_BINARY): $(SOURCES)
GOOS=linux CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "\
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitShortHash=$(GIT_SHORT_HASH) \
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitPorcelain=$(GIT_PORCELAIN) \
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.Version=$(VERSION) -s" \
-o ${ROOT}/${LOCAL_IPAM_PLUGIN_BINARY} github.com/aws/amazon-ecs-cni-plugins/plugins/ipam
@echo "Built ipam plugin"
$(LOCAL_BRIDGE_PLUGIN_BINARY): $(SOURCES)
GOOS=linux CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "\
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitShortHash=$(GIT_SHORT_HASH) \
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitPorcelain=$(GIT_PORCELAIN) \
-X github.com/aws/amazon-ecs-cni-plugins/pkg/version.Version=$(VERSION) -s" \
-o ${ROOT}/${LOCAL_BRIDGE_PLUGIN_BINARY} github.com/aws/amazon-ecs-cni-plugins/plugins/ecs-bridge
@echo "Built bridge plugin"
.PHONY: generate
generate: $(SOURCES)
go generate -x ./pkg/... ./plugins/...
.PHONY: unit-test integration-test e2e-test
unit-test: $(SOURCES)
go test -v -cover -race -timeout 10s ./pkg/... ./plugins/...
integration-test: $(SOURCE)
go test -v -tags integration -race -timeout 10s ./pkg/... ./plugins/...
sudo-integration-test: $(SOURCE)
sudo -E ${GO_EXECUTABLE} test -v -tags "sudo integration" -race -timeout 10s ./plugins/...
e2e-test: $(SOURCE) plugins
sudo -E CNI_PATH=${ROOT}/bin/plugins ${GO_EXECUTABLE} test -v -tags e2e -race -timeout 120s ./plugins/...
.PHONY: clean
clean:
rm -rf ${ROOT}/bin ||: