forked from kubermatic/operating-system-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
124 lines (98 loc) · 2.93 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
# Copyright 2021 The Operating System Manager contributors.
#
# 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 -eu -o pipefail
export GOPATH?=$(shell go env GOPATH)
export CGO_ENABLED=0
export GOPROXY?=https://proxy.golang.org
export GO111MODULE=on
export GOFLAGS?=-mod=readonly -trimpath
export GIT_TAG ?= $(shell git tag --points-at HEAD)
GO_VERSION = 1.18.1
CMD = $(notdir $(wildcard ./cmd/*))
BUILD_DEST ?= _build
REGISTRY ?= quay.io
REGISTRY_NAMESPACE ?= kubermatic
IMAGE_TAG = \
$(shell echo $$(git rev-parse HEAD && if [[ -n $$(git status --porcelain) ]]; then echo '-dirty'; fi)|tr -d ' ')
IMAGE_NAME ?= $(REGISTRY)/$(REGISTRY_NAMESPACE)/operating-system-manager:$(IMAGE_TAG)
BASE64_ENC = \
$(shell if base64 -w0 <(echo "") &> /dev/null; then echo "base64 -w0"; else echo "base64 -b0"; fi)
.PHONY: lint
lint:
@golangci-lint --version
golangci-lint run -v ./pkg/...
.PHONY: vendor
vendor: buildenv
go mod vendor
.PHONY: buildenv
buildenv:
@go version
.PHONY: verify-boilerplate
verify-boilerplate:
./hack/verify-boilerplate.sh
.PHONY: verify-licence
verify-licence: GOFLAGS = -mod=readonly
verify-licence: vendor
wwhrd check
.PHONY: verify-codegen
verify-codegen: GOFLAGS = -mod=readonly
verify-codegen: vendor
./hack/verify-codegen.sh
.PHONY: update-codegen
update-codegen: GOFLAGS = -mod=readonly
update-codegen: vendor
./hack/update-codegen.sh
.PHONY: verify-crds-openapi
verify-crds-openapi: GOFLAGS = -mod=readonly
verify-crds-openapi: vendor
./hack/verify-crds-openapi.sh
.PHONY: update-crds-openapi
update-crds-openapi: GOFLAGS = -mod=readonly
update-crds-openapi: vendor
./hack/update-crds-openapi.sh
.PHONY: all
all: build
.PHONY: build
build: $(CMD)
.PHONY: $(CMD)
$(CMD): %: $(BUILD_DEST)/%
$(BUILD_DEST)/%: cmd/%
go build -v -o $@ ./cmd/$*
.PHONY: run
run:
./hack/run-operating-system-manager.sh
.PHONY: test
test:
go test -v ./pkg...
.PHONY: clean
clean:
rm -rf $(BUILD_DEST)
@echo "Cleaned $(BUILD_DEST)"
.PHONY: download-gocache
download-gocache:
@./hack/ci/download-gocache.sh
.PHONY: docker-image
docker-image:
docker build --build-arg GO_VERSION=$(GO_VERSION) -t $(IMAGE_NAME) .
.PHONY: docker-image-publish
docker-image-publish: docker-image
docker push $(IMAGE_NAME)
if [[ -n "$(GIT_TAG)" ]]; then \
$(eval IMAGE_TAG = $(GIT_TAG)) \
docker build -t $(IMAGE_NAME) . && \
docker push $(IMAGE_NAME) && \
$(eval IMAGE_TAG = latest) \
docker build -t $(IMAGE_NAME) . ;\
docker push $(IMAGE_NAME) ;\
fi