forked from kubernetes/cloud-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (128 loc) · 4.01 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
SHELL := /bin/bash
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOPROXY ?= $(shell go env GOPROXY)
GIT_VERSION := $(shell git describe --dirty --tags --match='v*')
VERSION ?= $(GIT_VERSION)
IMAGE_REPOSITORY ?= amazon/cloud-controller-manager
IMAGE ?= $(IMAGE_REPOSITORY):$(VERSION)
OUTPUT ?= $(shell pwd)/_output
INSTALL_PATH ?= $(OUTPUT)/bin
LDFLAGS ?= -w -s -X k8s.io/component-base/version.gitVersion=$(VERSION)
.PHONY: aws-cloud-controller-manager
aws-cloud-controller-manager:
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=$(GOPROXY) go build \
-trimpath \
-ldflags="$(LDFLAGS)" \
-o=aws-cloud-controller-manager \
cmd/aws-cloud-controller-manager/main.go
.PHONY: ecr-credential-provider
ecr-credential-provider:
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=$(GOPROXY) go build \
-trimpath \
-ldflags="$(LDFLAGS)" \
-o=ecr-credential-provider \
cmd/ecr-credential-provider/*.go
.PHONY: ecr-credential-provider.exe
ecr-credential-provider.exe:
GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOPROXY=$(GOPROXY) go build \
-trimpath \
-ldflags="$(LDFLAGS)" \
-o=ecr-credential-provider.exe \
cmd/ecr-credential-provider/*.go
.PHONY: docker-build-amd64
docker-build-amd64:
docker buildx build --output=type=docker \
--build-arg VERSION=$(VERSION) \
--build-arg GOPROXY=$(GOPROXY) \
--platform linux/amd64 \
--tag $(IMAGE) .
.PHONY: docker-build-arm64
docker-build-arm64:
docker buildx build --output=type=docker \
--build-arg VERSION=$(VERSION) \
--build-arg GOPROXY=$(GOPROXY) \
--platform linux/arm64 \
--tag $(IMAGE) .
.PHONY: docker-build
docker-build:
docker buildx build --output=type=registry \
--build-arg LDFLAGS="$(LDFLAGS)" \
--build-arg GOPROXY=$(GOPROXY) \
--platform linux/amd64,linux/arm64 \
--tag $(IMAGE) .
.PHONY: ko
ko:
hack/install-ko.sh
.PHONY: ko-build
ko-build: ko
KO_DOCKER_REPO="$(IMAGE_REPOSITORY)" GOFLAGS="-ldflags=-X=k8s.io/component-base/version.gitVersion=$(VERSION)" ko build --tags ${VERSION} --platform=linux/amd64,linux/arm64 --bare ./cmd/aws-cloud-controller-manager/
.PHONY: e2e.test
e2e.test:
pushd tests/e2e > /dev/null && \
go test -c && popd
mv tests/e2e/e2e.test e2e.test
.PHONY: check
check: verify-fmt verify-lint vet
.PHONY: test
test:
go test -count=1 -race -v $(shell go list ./...)
.PHONY: verify-fmt
verify-fmt:
./hack/verify-gofmt.sh
.PHONY: verify-lint
verify-lint:
which golint 2>&1 >/dev/null || go install golang.org/x/lint/golint@latest
golint -set_exit_status $(shell go list ./...)
.PHONY: verify-codegen
verify-codegen:
./hack/verify-codegen.sh
.PHONY: vet
vet:
go vet ./...
.PHONY: update-fmt
update-fmt:
./hack/update-gofmt.sh
.PHONY: docs
docs:
./hack/build-gitbooks.sh
.PHONY: publish-docs
publish-docs:
./hack/publish-docs.sh
.PHONY: kops-example
kops-example:
./hack/kops-example.sh
.PHONY: test-e2e
test-e2e: e2e.test docker-build-amd64 install-e2e-tools
AWS_REGION=us-west-2 \
TEST_PATH=./tests/e2e/... \
BUILD_IMAGE=$(IMAGE) \
BUILD_VERSION=$(VERSION) \
INSTALL_PATH=$(INSTALL_PATH) \
GINKGO_FOCUS="\[cloud-provider-aws-e2e\]" \
./hack/e2e/run.sh
# Use `make install-e2e-tools KOPS_ROOT=<local-kops-installation>`
# to skip the kops download, test local changes to the kubetest2-kops
# deployer, etc.
.PHONY: install-e2e-tools
install-e2e-tools:
mkdir -p $(INSTALL_PATH)
INSTALL_PATH=$(INSTALL_PATH) \
./hack/install-e2e-tools.sh
.PHONY: print-image-tag
print-image-tag:
@echo $(IMAGE)