forked from IBM/ibm-iam-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
226 lines (193 loc) · 9.49 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
#
# Copyright 2020 IBM Corporation
#
# 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.
.DEFAULT_GOAL:=help
# Specify whether this repo is build locally or not, default values is '1';
# If set to 1, then you need to also set 'DOCKER_USERNAME' and 'DOCKER_PASSWORD'
# environment variables before build the repo.
BUILD_LOCALLY ?= 1
TARGET_GOOS=linux
TARGET_GOARCH=amd64
# The namespcethat operator will be deployed in
NAMESPACE=ibm-common-services
# Image URL to use all building/pushing image targets;
# Use your own docker registry and image name for dev/test by overridding the IMG and REGISTRY environment variable.
IMG ?= ibm-iam-operator
REGISTRY ?= "hyc-cloud-private-integration-docker-local.artifactory.swg-devops.com/ibmcom"
CSV_VERSION ?= 3.7.1
QUAY_USERNAME ?=
QUAY_PASSWORD ?=
MARKDOWN_LINT_WHITELIST=https://quay.io/cnr
TESTARGS_DEFAULT := "-v"
export TESTARGS ?= $(TESTARGS_DEFAULT)
VERSION ?= $(shell cat ./version/version.go | grep "Version =" | awk '{ print $$3}' | tr -d '"')
LOCAL_OS := $(shell uname)
LOCAL_ARCH := $(shell uname -m)
ifeq ($(LOCAL_OS),Linux)
TARGET_OS ?= linux
XARGS_FLAGS="-r"
STRIP_FLAGS=
else ifeq ($(LOCAL_OS),Darwin)
TARGET_OS ?= darwin
XARGS_FLAGS=
STRIP_FLAGS="-x"
else
$(error "This system's OS $(LOCAL_OS) isn't recognized/supported")
endif
include common/Makefile.common.mk
##@ Application
install: ## Install all resources (CR/CRD's, RBCA and Operator)
@echo ....... Set environment variables ......
- export DEPLOY_DIR=deploy/crds
- export WATCH_NAMESPACE=${NAMESPACE}
@echo ....... Creating namespace .......
- kubectl create namespace ${NAMESPACE}
@echo ....... Applying CRDS and Operator .......
- kubectl apply -f deploy/crds/operator.ibm.com_authentications_crd.yaml
- kubectl apply -f deploy/crds/operator.ibm.com_oidcclientwatchers_crd.yaml
- kubectl apply -f deploy/crds/operator.ibm.com_paps_crd.yaml
- kubectl apply -f deploy/crds/operator.ibm.com_policycontrollers_crd.yaml
- kubectl apply -f deploy/crds/operator.ibm.com_policydecisions_crd.yaml
- kubectl apply -f deploy/crds/operator.ibm.com_secretwatchers_crd.yaml
- kubectl apply -f deploy/crds/operator.ibm.com_securityonboardings_crd.yaml
@echo ....... Applying RBAC .......
- kubectl apply -f deploy/service_account.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/role.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/role_binding.yaml -n ${NAMESPACE}
@echo ....... Applying Operator .......
- kubectl apply -f deploy/operator.yaml -n ${NAMESPACE}
@echo ....... Creating the Instance .......
- kubectl apply -f deploy/crds/operator.ibm.com_v1alpha1_authentication_cr.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/crds/operator.ibm.com_v1alpha1_oidcclientwatcher_cr.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/crds/operator.ibm.com_v1alpha1_pap_cr.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/crds/operator.ibm.com_v1alpha1_policycontroller_cr.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/crds/operator.ibm.com_v1alpha1_policydecision_cr.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/crds/operator.ibm.com_v1alpha1_secretwatcher_cr.yaml -n ${NAMESPACE}
- kubectl apply -f deploy/crds/operator.ibm.com_v1alpha1_securityonboarding_cr.yaml -n ${NAMESPACE}
uninstall: ## Uninstall all that all performed in the $ make install
@echo ....... Uninstalling .......
@echo ....... Deleting CR .......
- kubectl delete -f deploy/crds/operator.ibm.com_v1alpha1_authentication_cr.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/crds/operator.ibm.com_v1alpha1_oidcclientwatcher_cr.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/crds/operator.ibm.com_v1alpha1_pap_cr.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/crds/operator.ibm.com_v1alpha1_policycontroller_cr.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/crds/operator.ibm.com_v1alpha1_policydecision_cr.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/crds/operator.ibm.com_v1alpha1_secretwatcher_cr.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/crds/operator.ibm.com_v1alpha1_securityonboarding_cr.yaml -n ${NAMESPACE}
@echo ....... Deleting Operator .......
- kubectl delete -f deploy/operator.yaml -n ${NAMESPACE}
@echo ....... Deleting CRDs.......
- kubectl delete -f deploy/crds/operator.ibm.com_authentications_crd.yaml
- kubectl delete -f deploy/crds/operator.ibm.com_oidcclientwatchers_crd.yaml
- kubectl delete -f deploy/crds/operator.ibm.com_paps_crd.yaml
- kubectl delete -f deploy/crds/operator.ibm.com_policycontrollers_crd.yaml
- kubectl delete -f deploy/crds/operator.ibm.com_policydecisions_crd.yaml
- kubectl delete -f deploy/crds/operator.ibm.com_secretwatchers_crd.yaml
- kubectl delete -f deploy/crds/operator.ibm.com_securityonboardings_crd.yaml
@echo ....... Deleting Rules and Service Account .......
- kubectl delete -f deploy/role_binding.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/service_account.yaml -n ${NAMESPACE}
- kubectl delete -f deploy/role.yaml -n ${NAMESPACE}
@echo ....... Deleting namespace ${NAMESPACE}.......
#- kubectl delete namespace ${NAMESPACE}
##@ Development
check: lint-all ## Check all files lint error
CSV_VERSION=$(CSV_VERSION) ./common/scripts/lint-csv.sh
code-dev: ## Run the default dev commands which are the go tidy, fmt, vet then execute the $ make code-gen
@echo Running the common required commands for developments purposes
- make code-tidy
- make code-fmt
- make code-vet
- make code-gen
@echo Running the common required commands for code delivery
- make check
- make test
- make build
run: ## Run against the configured Kubernetes cluster in ~/.kube/config
go run ./cmd/manager/main.go
ifeq ($(BUILD_LOCALLY),0)
export CONFIG_DOCKER_TARGET = config-docker
endif
##@ Build
build:
@echo "Building the ibm-iam-operator binary"
@CGO_ENABLED=0 go build -o build/_output/bin/$(IMG) ./cmd/manager
@strip $(STRIP_FLAGS) build/_output/bin/$(IMG)
build-image: build $(CONFIG_DOCKER_TARGET)
$(eval ARCH := $(shell uname -m|sed 's/x86_64/amd64/'))
docker build -t $(REGISTRY)/$(IMG)-$(ARCH):$(VERSION) -f build/Dockerfile .
@\rm -f build/_output/bin/ibm-iam-operator
@if [ $(BUILD_LOCALLY) -ne 1 ] && [ "$(ARCH)" = "amd64" ]; then docker push $(REGISTRY)/$(IMG)-$(ARCH):$(VERSION); fi
# runs on amd64 machine
build-image-ppc64le: $(CONFIG_DOCKER_TARGET)
ifeq ($(LOCAL_OS),Linux)
ifeq ($(LOCAL_ARCH),x86_64)
GOOS=linux GOARCH=ppc64le CGO_ENABLED=0 go build -o build/_output/bin/ibm-iam-operator-ppc64le ./cmd/manager
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker build -t $(REGISTRY)/$(IMG)-ppc64le:$(VERSION) -f build/Dockerfile.ppc64le .
@\rm -f build/_output/bin/ibm-iam-operator-ppc64le
@if [ $(BUILD_LOCALLY) -ne 1 ]; then docker push $(REGISTRY)/$(IMG)-ppc64le:$(VERSION); fi
endif
endif
# runs on amd64 machine
build-image-s390x: $(CONFIG_DOCKER_TARGET)
ifeq ($(LOCAL_OS),Linux)
ifeq ($(LOCAL_ARCH),x86_64)
GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -o build/_output/bin/ibm-iam-operator-s390x ./cmd/manager
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker build -t $(REGISTRY)/$(IMG)-s390x:$(VERSION) -f build/Dockerfile.s390x .
@\rm -f build/_output/bin/ibm-iam-operator-s390x
@if [ $(BUILD_LOCALLY) -ne 1 ]; then docker push $(REGISTRY)/$(IMG)-s390x:$(VERSION); fi
endif
endif
##@ Test
test: ## Run unit test
@go test ${TESTARGS} ./pkg/...
test-e2e: ## Run integration e2e tests with different options.
@echo ... Running the same e2e tests with different args ...
@echo ... Running locally ...
- operator-sdk test local ./test/e2e --verbose --up-local --namespace=${NAMESPACE}
# @echo ... Running with the param ...
# - operator-sdk test local ./test/e2e --namespace=${NAMESPACE}
coverage: ## Run code coverage test
@echo ... Code coverage test will be dealt with later
#@posriniv-getback
#@common/scripts/codecov.sh ${BUILD_LOCALLY}
scorecard: ## Run scorecard test
@echo ... Running the scorecard test
- operator-sdk scorecard --verbose
##@ Release
images: build-image build-image-ppc64le build-image-s390x
ifeq ($(LOCAL_OS),Linux)
ifeq ($(LOCAL_ARCH),x86_64)
@curl -L -o /tmp/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v1.0.0/manifest-tool-linux-amd64
@chmod +x /tmp/manifest-tool
/tmp/manifest-tool push from-args --platforms linux/amd64,linux/ppc64le,linux/s390x --template $(REGISTRY)/$(IMG)-ARCH:$(VERSION) --target $(REGISTRY)/$(IMG) --ignore-missing
/tmp/manifest-tool push from-args --platforms linux/amd64,linux/ppc64le,linux/s390x --template $(REGISTRY)/$(IMG)-ARCH:$(VERSION) --target $(REGISTRY)/$(IMG):$(VERSION) --ignore-missing
endif
endif
csv: ## Push CSV package to the catalog
@RELEASE=${CSV_VERSION} common/scripts/push-csv.sh
all: check test coverage build images
##@ Cleanup
clean: ## Clean build binary
rm -f build/_output/bin/$(IMG)
##@ Help
help: ## Display this help
@echo "Usage:\n make \033[36m<target>\033[0m"
@awk 'BEGIN {FS = ":.*##"}; \
/^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: all build run check install uninstall code-dev test test-e2e coverage images csv clean help