-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
85 lines (69 loc) · 2.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
81
82
83
84
85
ROOT_DIR_RELATIVE := .
include $(ROOT_DIR_RELATIVE)/common.mk
# GIT_VERSION includes the latest git tag and is unique and not semver
GIT_VERSION := $(shell git describe --tags --always)
# GIT_VERSION_SHORT is only the latest git tag, not unique, semver
GIT_VERSION_SHORT := $(shell git describe --tags --abbrev=0 --always)
GIT_COMMIT_ID := $(shell git show -s --format=%H)
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
OUTPUT := _output/$(GOARCH)
BINARY := $(OUTPUT)/bin/eks-pod-identity-agent
# Directories
TOOLS_DIR := hack/tools
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
# Binaries
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
# Generic make
REGISTRY_ID?=$(shell aws sts get-caller-identity | jq -r '.Account')
IMAGE_NAME?=eks/eks-pod-identity-agent
REGION?=us-west-2
IMAGE?=$(REGISTRY_ID).dkr.ecr.$(REGION).amazonaws.com/$(IMAGE_NAME)
TAG?=0.1.0
.PHONY: docker
docker:
@echo 'Building image $(IMAGE)...'
docker buildx build --platform=linux/amd64 --progress plain --output=type=docker -t $(IMAGE):$(TAG) .
.PHONY: push
push: docker
eval $$(aws ecr get-login --registry-ids $(REGISTRY_ID) --no-include-email)
docker push $(IMAGE):$(TAG)
.PHONY: build
build:
@echo "Building eks-pod-identity-agent for $(shell go env GOOS)/$(GOARCH)"
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build \
-ldflags "-X 'k8s.io/component-base/version.gitVersion=$(GIT_VERSION_SHORT)' \
-X 'k8s.io/component-base/version.gitCommit=$(GIT_COMMIT_ID)' \
-X 'k8s.io/component-base/version/verflag.programName=eks-pod-identity-agent' " \
-o $(BINARY) .
# Run the agent locally
.PHONY: dev
dev: export BINARY := $(BINARY)
dev: build
./hack/run-bin.sh
.PHONY: clean
clean:
rm -rf "$(shell pwd)/$(OUTPUT)"
.PHONY: test
test: generate-mocks
go test -race -cover -covermode=atomic ./...
# test-verbose also prints output for tests that didn't fail
# and sets the verbosity to 5
.PHONY: test-verbose
test-verbose: generate-mocks
go test -v -race -cover -covermode=atomic ./... -test.v
.PHONY: generate-mocks
generate-mocks: $(MOCKGEN)
PATH="$(PATH):$(shell pwd)/hack/scripts" go generate ./...
.PHONY: format
format:
gofmt -w ./
.PHONY: vet
vet:
go vet -json ./...
.PHONY: lint
lint:
if ! command -v golangci-lint 2> /dev/null; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.52.1; \
fi
golangci-lint run ./...