forked from open-cluster-management-io/ocm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
140 lines (113 loc) · 5.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
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
SHELL :=/bin/bash
all: build
.PHONY: all
# Include the library makefile
include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
golang.mk \
targets/openshift/deps.mk \
targets/openshift/images.mk \
targets/openshift/yaml-patch.mk\
lib/tmp.mk\
)
# Include the integration/e2e setup makefile.
include ./test/integration-test.mk
include ./test/e2e-test.mk
include ./test/olm-test.mk
OPERATOR_SDK?=$(PERMANENT_TMP_GOPATH)/bin/operator-sdk
OPERATOR_SDK_VERSION?=v1.32.0
operatorsdk_gen_dir:=$(dir $(OPERATOR_SDK))
HELM?=$(PERMANENT_TMP_GOPATH)/bin/helm
HELM_VERSION?=v3.14.0
helm_gen_dir:=$(dir $(HELM))
# RELEASED_CSV_VERSION is used to generate a released CSV manifests
RELEASED_CSV_VERSION?=0.14.0
export RELEASED_CSV_VERSION
# CSV_VERSION is used to generate latest CSV manifests
CSV_VERSION?=9.9.9
export CSV_VERSION
OPERATOR_SDK_ARCHOS:=linux_amd64
HELM_ARCHOS:=linux-amd64
ifeq ($(GOHOSTOS),darwin)
ifeq ($(GOHOSTARCH),amd64)
OPERATOR_SDK_ARCHOS:=darwin_amd64
HELM_ARCHOS:=darwin-amd64
endif
ifeq ($(GOHOSTARCH),arm64)
OPERATOR_SDK_ARCHOS:=darwin_arm64
HELM_ARCHOS:=darwin-arm64
endif
endif
# Add packages to do unit test
GO_TEST_PACKAGES :=./pkg/...
GO_TEST_FLAGS := -race -coverprofile=coverage.out
IMAGE_REGISTRY?=quay.io/open-cluster-management
IMAGE_TAG?=latest
OPERATOR_IMAGE_NAME ?= $(IMAGE_REGISTRY)/registration-operator:$(IMAGE_TAG)
# WORK_IMAGE can be set in the env to override calculated value
WORK_IMAGE ?= $(IMAGE_REGISTRY)/work:$(IMAGE_TAG)
# REGISTRATION_IMAGE can be set in the env to override calculated value
REGISTRATION_IMAGE ?= $(IMAGE_REGISTRY)/registration:$(IMAGE_TAG)
# PLACEMENT_IMAGE can be set in the env to override calculated value
PLACEMENT_IMAGE ?= $(IMAGE_REGISTRY)/placement:$(IMAGE_TAG)
# ADDON_MANAGER_IMAGE can be set in the env to override calculated value
ADDON_MANAGER_IMAGE ?= $(IMAGE_REGISTRY)/addon-manager:$(IMAGE_TAG)
$(call build-image,registration,$(REGISTRATION_IMAGE),./build/Dockerfile.registration,.)
$(call build-image,work,$(WORK_IMAGE),./build/Dockerfile.work,.)
$(call build-image,placement,$(PLACEMENT_IMAGE),./build/Dockerfile.placement,.)
$(call build-image,registration-operator,$(OPERATOR_IMAGE_NAME),./build/Dockerfile.registration-operator,.)
$(call build-image,addon-manager,$(ADDON_MANAGER_IMAGE),./build/Dockerfile.addon,.)
copy-crd:
bash -x hack/copy-crds.sh $(YAML_PATCH)
update: copy-crd update-csv
test-unit: ensure-kubebuilder-tools
update-csv: ensure-operator-sdk ensure-helm
bash -x hack/update-csv.sh
# update the replaces to released version in csv
$(SED_CMD) -i 's/cluster-manager\.v[0-9]\+\.[0-9]\+\.[0-9]\+/cluster-manager\.v$(RELEASED_CSV_VERSION)/g' deploy/cluster-manager/config/manifests/bases/cluster-manager.clusterserviceversion.yaml
$(SED_CMD) -i 's/klusterlet\.v[0-9]\+\.[0-9]\+\.[0-9]\+/klusterlet\.v$(RELEASED_CSV_VERSION)/g' deploy/klusterlet/config/manifests/bases/klusterlet.clusterserviceversion.yaml
# generate current csv bundle files
cd deploy/cluster-manager && ../../$(OPERATOR_SDK) generate bundle --version $(CSV_VERSION) --package cluster-manager --channels stable --default-channel stable --input-dir config --output-dir olm-catalog/latest
cd deploy/klusterlet && ../../$(OPERATOR_SDK) generate bundle --version $(CSV_VERSION) --package klusterlet --channels stable --default-channel stable --input-dir config --output-dir olm-catalog/latest
# delete bundle.Dockerfile since we do not use it to build image.
rm ./deploy/cluster-manager/bundle.Dockerfile
rm ./deploy/klusterlet/bundle.Dockerfile
verify-crds:
bash -x hack/verify-crds.sh $(YAML_PATCH)
verify-gocilint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
golangci-lint run --timeout=5m --modules-download-mode vendor ./...
install-golang-gci:
go install github.com/daixiang0/[email protected]
fmt-imports: install-golang-gci
gci write --skip-generated -s standard -s default -s "prefix(open-cluster-management.io)" -s "prefix(open-cluster-management.io/ocm)" cmd pkg test dependencymagnet
verify-fmt-imports: install-golang-gci
@output=$$(gci diff --skip-generated -s standard -s default -s "prefix(open-cluster-management.io)" -s "prefix(open-cluster-management.io/ocm)" cmd pkg test dependencymagnet); \
if [ -n "$$output" ]; then \
echo "Diff output is not empty: $$output"; \
echo "Please run 'make fmt-imports' to format the golang files imports automatically."; \
exit 1; \
else \
echo "Diff output is empty"; \
fi
verify: verify-fmt-imports verify-crds verify-gocilint
ensure-operator-sdk:
ifeq "" "$(wildcard $(OPERATOR_SDK))"
$(info Installing operator-sdk into '$(OPERATOR_SDK)')
mkdir -p '$(operatorsdk_gen_dir)'
curl -s -f -L https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(OPERATOR_SDK_ARCHOS) -o '$(OPERATOR_SDK)'
chmod +x '$(OPERATOR_SDK)';
else
$(info Using existing operator-sdk from "$(OPERATOR_SDK)")
endif
ensure-helm:
ifeq "" "$(wildcard $(HELM))"
$(info Installing helm into '$(HELM)')
mkdir -p '$(helm_gen_dir)'
curl -s -f -L https://get.helm.sh/helm-$(HELM_VERSION)-$(HELM_ARCHOS).tar.gz -o '$(helm_gen_dir)$(HELM_VERSION)-$(HELM_ARCHOS).tar.gz'
tar -zvxf '$(helm_gen_dir)/$(HELM_VERSION)-$(HELM_ARCHOS).tar.gz' -C $(helm_gen_dir)
mv $(helm_gen_dir)/$(HELM_ARCHOS)/helm $(HELM)
rm -rf $(helm_gen_dir)/$(HELM_ARCHOS)
chmod +x '$(HELM)';
else
$(info Using existing helm from "$(HELM)")
endif