forked from kubernetes-sigs/ibm-powervs-block-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
120 lines (99 loc) · 4.04 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
# Copyright 2019 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.
PKG=sigs.k8s.io/ibm-powervs-block-csi-driver
GIT_COMMIT?=$(shell git rev-parse --short HEAD)
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
REGISTRY?=gcr.io/k8s-staging-cloud-provider-ibm
IMG?=ibm-powervs-block-csi-driver
TAG?=$(GIT_COMMIT)
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${TAG} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE} -s -w"
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
PULL_BASE_REF ?= $(RELEASE_TAG) # PULL_BASE_REF will be provided by Prow
RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
GO111MODULE=on
GOPROXY=direct
GOPATH=$(shell go env GOPATH)
GOOS=$(shell go env GOOS)
GOBIN=$(shell pwd)/bin
.EXPORT_ALL_VARIABLES:
bin:
@mkdir -p $@
.PHONY: driver
driver: | bin
CGO_ENABLED=0 go build -ldflags ${LDFLAGS} -o bin/ibm-powervs-block-csi-driver ./cmd/
.PHONY: node-update-controller
node-update-controller: | bin
CGO_ENABLED=0 go build -ldflags ${LDFLAGS} -o bin/node-update-controller ./adhoc-controllers/
.PHONY: test
test:
./hack/test.sh
.PHONY: image
image:
docker build -t $(REGISTRY)/$(IMG):$(TAG) . --target centos-base
.PHONY: push
push:
docker push $(REGISTRY)/$(IMG):$(TAG)
build-image-and-push-linux-amd64: init-buildx
{ \
set -e ; \
docker buildx build \
--build-arg TARGETPLATFORM=linux/amd64 \
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 --push . --target centos-base; \
}
build-image-and-push-linux-ppc64le: init-buildx
{ \
set -e ; \
docker buildx build \
--build-arg TARGETPLATFORM=linux/ppc64le \
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le --push . --target centos-base; \
}
build-and-push-multi-arch: build-image-and-push-linux-amd64 build-image-and-push-linux-ppc64le
docker manifest create --amend $(REGISTRY)/$(IMG):$(TAG) $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le
docker manifest push -p $(REGISTRY)/$(IMG):$(TAG)
.PHONY: release-alias-tag
release-alias-tag: # Adds the tag to the last build tag.
gcloud container images add-tag -q $(REGISTRY)/$(IMG):$(TAG) $(REGISTRY)/$(IMG):$(RELEASE_ALIAS_TAG)
.PHONY: release-staging
release-staging: ## Builds and push container images to the staging image registry.
$(MAKE) build-and-push-multi-arch
$(MAKE) release-alias-tag
.PHONY: clean
clean:
rm -rf bin/*
bin/mockgen: | bin
go install github.com/golang/mock/[email protected]
bin/golangci-lint: | bin
echo "Installing golangci-lint..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.48.0
mockgen: bin/mockgen
./hack/update-gomock
.PHONY: verify
verify: bin/golangci-lint
echo "verifying and linting files ..."
./hack/verify-all
echo "Congratulations! All Go source files have been linted."
.PHONY: verify-vendor
test: verify-vendor
verify: verify-vendor
verify-vendor:
@ echo; echo "### $@:"
@ ./hack/verify-vendor.sh
init-buildx:
# Ensure we use a builder that can leverage it (the default on linux will not)
-docker buildx rm multiarch-multiplatform-builder
docker buildx create --use --name=multiarch-multiplatform-builder
docker run --rm --privileged multiarch/qemu-user-static --reset --credential yes --persistent yes
# Register gcloud as a Docker credential helper.
# Required for "docker buildx build --push".
gcloud auth configure-docker --quiet