forked from Azure/aad-pod-identity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (92 loc) · 4.26 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
ORG_PATH=github.com/Azure
PROJECT_NAME := aad-pod-identity
REPO_PATH="$(ORG_PATH)/$(PROJECT_NAME)"
NMI_BINARY_NAME := nmi
MIC_BINARY_NAME := mic
DEMO_BINARY_NAME := demo
IDENTITY_VALIDATOR_BINARY_NAME := identityvalidator
NMI_VERSION ?= 1.3
MIC_VERSION ?= 1.2
DEMO_VERSION ?= 1.2
IDENTITY_VALIDATOR_VERSION ?= 1.0
VERSION_VAR := $(REPO_PATH)/version.Version
GIT_VAR := $(REPO_PATH)/version.GitCommit
BUILD_DATE_VAR := $(REPO_PATH)/version.BuildDate
BUILD_DATE := $$(date +%Y-%m-%d-%H:%M)
GIT_HASH := $$(git rev-parse --short HEAD)
ifeq ($(OS),Windows_NT)
GO_BUILD_MODE = default
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
GO_BUILD_MODE = pie
endif
ifeq ($(UNAME_S), Darwin)
GO_BUILD_MODE = default
endif
endif
GO_BUILD_OPTIONS := -buildmode=${GO_BUILD_MODE} --tags "netgo osusergo" -ldflags "-s -X $(VERSION_VAR)=$(NMI_VERSION) -X $(GIT_VAR)=$(GIT_HASH) -X $(BUILD_DATE_VAR)=$(BUILD_DATE) -extldflags '-static'"
E2E_TEST_OPTIONS := -count=1 -v
# useful for other docker repos
REGISTRY_NAME ?= upstreamk8sci
REGISTRY ?= upstreamk8sci.azurecr.io
REPO_PREFIX ?= k8s/aad-pod-identity
NMI_IMAGE ?= $(REPO_PREFIX)/$(NMI_BINARY_NAME):$(NMI_VERSION)
MIC_IMAGE ?= $(REPO_PREFIX)/$(MIC_BINARY_NAME):$(MIC_VERSION)
DEMO_IMAGE ?= $(REPO_PREFIX)/$(DEMO_BINARY_NAME):$(DEMO_VERSION)
IDENTITY_VALIDATOR_IMAGE ?= $(REPO_PREFIX)/$(IDENTITY_VALIDATOR_BINARY_NAME):$(IDENTITY_VALIDATOR_VERSION)
clean-nmi:
rm -rf bin/$(PROJECT_NAME)/$(NMI_BINARY_NAME)
clean-mic:
rm -rf bin/$(PROJECT_NAME)/$(MIC_BINARY_NAME)
clean-demo:
rm -rf bin/$(PROJECT_NAME)/$(DEMO_BINARY_NAME)
clean-identity-validator:
rm -rf bin/$(PROJECT_NAME)/$(IDENTITY_VALIDATOR_BINARY_NAME)
clean:
rm -rf bin/$(PROJECT_NAME)
build-nmi:clean-nmi
PKG_NAME=github.com/Azure/$(PROJECT_NAME)/cmd/$(NMI_BINARY_NAME) $(MAKE) bin/$(PROJECT_NAME)/$(NMI_BINARY_NAME)
build-mic:clean-mic
PKG_NAME=github.com/Azure/$(PROJECT_NAME)/cmd/$(MIC_BINARY_NAME) $(MAKE) bin/$(PROJECT_NAME)/$(MIC_BINARY_NAME)
build-demo: build_tags := netgo osusergo
build-demo:clean-demo
PKG_NAME=github.com/Azure/$(PROJECT_NAME)/cmd/$(DEMO_BINARY_NAME) ${MAKE} bin/$(PROJECT_NAME)/$(DEMO_BINARY_NAME)
bin/%:
GOOS=linux GOARCH=amd64 go build $(GO_BUILD_OPTIONS) -o "$(@)" "$(PKG_NAME)"
build-identity-validator:clean-identity-validator
PKG_NAME=github.com/Azure/$(PROJECT_NAME)/test/e2e/$(IDENTITY_VALIDATOR_BINARY_NAME) $(MAKE) bin/$(PROJECT_NAME)/$(IDENTITY_VALIDATOR_BINARY_NAME)
build:clean build-nmi build-mic build-demo build-identity-validator
deepcopy-gen:
deepcopy-gen -i ./pkg/apis/aadpodidentity/v1/ -o ../../../ -O aadpodidentity_deepcopy_generated -p aadpodidentity
image-nmi:
cp bin/$(PROJECT_NAME)/$(NMI_BINARY_NAME) images/nmi
docker build -t $(REGISTRY)/$(NMI_IMAGE) images/nmi
image-mic:
cp bin/$(PROJECT_NAME)/$(MIC_BINARY_NAME) images/mic
docker build -t $(REGISTRY)/$(MIC_IMAGE) images/mic
image-demo:
cp bin/$(PROJECT_NAME)/$(DEMO_BINARY_NAME) images/demo
docker build -t $(REGISTRY)/$(DEMO_IMAGE) images/demo
image-identity-validator:
cp bin/$(PROJECT_NAME)/$(IDENTITY_VALIDATOR_BINARY_NAME) images/identityvalidator
docker build -t $(REGISTRY)/$(IDENTITY_VALIDATOR_IMAGE) images/identityvalidator
image:image-nmi image-mic image-demo image-identity-validator
push-nmi:
az acr repository show --name $(REGISTRY_NAME) --image $(NMI_IMAGE) > /dev/null 2>&1; if [[ $$? -eq 0 ]]; then echo "$(NMI_IMAGE) already exists" && exit 1; fi
docker push $(REGISTRY)/$(NMI_IMAGE)
push-mic:
az acr repository show --name $(REGISTRY_NAME) --image $(MIC_IMAGE) > /dev/null 2>&1; if [[ $$? -eq 0 ]]; then echo "$(NMI_IMAGE) already exists" && exit 1; fi
docker push $(REGISTRY)/$(MIC_IMAGE)
push-demo:
az acr repository show --name $(REGISTRY_NAME) --image $(DEMO_IMAGE) > /dev/null 2>&1; if [[ $$? -eq 0 ]]; then echo "$(NMI_IMAGE) already exists" && exit 1; fi
docker push $(REGISTRY)/$(DEMO_IMAGE)
push-identity-validator:
az acr repository show --name $(REGISTRY_NAME) --image $(IDENTITY_VALIDATOR_IMAGE) > /dev/null 2>&1; if [[ $$? -eq 0 ]]; then echo "$(NMI_IMAGE) already exists" && exit 1; fi
docker push $(REGISTRY)/$(IDENTITY_VALIDATOR_IMAGE)
push:push-nmi push-mic push-demo push-identity-validator
e2e:
go test github.com/Azure/$(PROJECT_NAME)/test/e2e $(E2E_TEST_OPTIONS)
unit-test:
go test $(shell go list ./... | grep -v /test/e2e) -v
.PHONY: build