Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit cb11828

Browse files
committed
Add install-tools and local-env rules to Makefiles
If required tool version is found on the host, then it will be linked into the ./bin folder. Otherwise, it will be downloaded. Signed-off-by: Francesco Ilario <[email protected]>
1 parent ca91ac5 commit cb11828

File tree

5 files changed

+292
-54
lines changed

5 files changed

+292
-54
lines changed

CONTRIBUTING.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,36 +174,76 @@ put us into an unreleasable state
174174
* End to end, i.e. acceptance tests
175175
* Unit tests:
176176
* Coverage should remain the same or increase
177-
177+
178+
## Configure your local environment
179+
180+
To compile and execute the Service Binding Operator, you must have on your machine the following dependencies:
181+
182+
* Git
183+
* Go
184+
* Python3
185+
* Make
186+
* Docker
187+
188+
Other dependencies are needed, but you can install them locally using the make rule `install-tools`.
189+
This rule will download into the local `./bin` folder all the missing tools needed to work with this repo.
190+
So, to install the dependencies locally and configure your shell to use them, use the following commands:
191+
192+
```
193+
make install-tools
194+
eval $(make local-env)
195+
```
196+
197+
If not present, the following dependencies will be downloaded:
198+
199+
* minikube
200+
* opm
201+
* mockgen
202+
* kubectl-slice
203+
* yq
204+
* kustomize
205+
* controller-gen
206+
* gen-mocks
207+
* operator-sdk
208+
* kubectl
209+
* helm
210+
178211
## Running Acceptance Tests
179212

180-
1. Set KUBECONFIG for both minikube and acceptance tests (it will be generated at minikube's start if it does not exist):
213+
1. Install dependencies
214+
215+
```
216+
make install-tools
217+
eval $(make local-env)
218+
```
219+
220+
2. Set KUBECONFIG for both minikube and acceptance tests (it will be generated at minikube's start if it does not exist):
181221

182222
```
183223
export KUBECONFIG=/tmp/minikubeconfig
184224
```
185225

186-
2. Start minikube:
226+
3. Start minikube:
187227

188228
```
189229
./hack/start-minikube.sh
190230
```
191231

192-
3. Enable olm on minikube:
232+
4. Enable olm on minikube:
193233

194234

195235
```
196236
minikube addons enable olm
197237
```
198238

199-
4. Deploy operator to the minikube cluster
239+
5. Deploy operator to the minikube cluster
200240

201241
```
202242
eval $(minikube docker-env)
203243
make deploy OPERATOR_REPO_REF=$(minikube ip):5000/sbo
204244
```
205245

206-
5. Execute all acceptance tests tagged with `@dev` using `kubectl` CLI:
246+
6. Execute all acceptance tests tagged with `@dev` using `kubectl` CLI:
207247

208248
```
209249
make test-acceptance TEST_ACCEPTANCE_TAGS="@dev" TEST_ACCEPTANCE_START_SBO=remote TEST_ACCEPTANCE_CLI=kubectl

make/acceptance.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ OLM_NAMESPACE ?=
2323

2424
# Testing setup
2525
.PHONY: deploy-test-3rd-party-crds
26-
deploy-test-3rd-party-crds:
27-
$(Q)kubectl --namespace $(TEST_NAMESPACE) apply -f ./test/third-party-crds/
26+
deploy-test-3rd-party-crds: kubectl
27+
$(Q)$(KUBECTL) --namespace $(TEST_NAMESPACE) apply -f ./test/third-party-crds/
2828

2929
.PHONY: create-test-namespace
30-
create-test-namespace:
31-
$(Q)kubectl get namespace $(TEST_NAMESPACE) || kubectl create namespace $(TEST_NAMESPACE)
30+
create-test-namespace: kubectl
31+
$(Q)$(KUBECTL) get namespace $(TEST_NAMESPACE) || $(KUBECTL) create namespace $(TEST_NAMESPACE)
3232

3333
.PHONY: test-setup
3434
test-setup: test-cleanup create-test-namespace deploy-test-3rd-party-crds
@@ -100,4 +100,4 @@ collect-kube-resources:
100100
-$(Q)OUTPUT_PATH=$(TEST_ACCEPTANCE_RESOURCES_DIR) \
101101
OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) \
102102
OLM_NAMESPACE=$(OLM_NAMESPACE) \
103-
$(HACK_DIR)/collect-kube-resources.sh
103+
$(HACK_DIR)/collect-kube-resources.sh

make/build.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ manifests: controller-gen
2323

2424
.PHONY: bundle
2525
# Generate bundle manifests and metadata, then validate generated files.
26-
bundle: manifests kustomize yq kubectl-slice push-image
27-
# operator-sdk generate kustomize manifests -q
26+
bundle: manifests kustomize yq kubectl-slice operator-sdk push-image
27+
# $(OPERATOR_SDK) generate kustomize manifests -q
2828
cd config/manager && $(KUSTOMIZE) edit set image controller=$(OPERATOR_REPO_REF)@$(OPERATOR_IMAGE_SHA_REF)
29-
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
29+
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
3030
$(YQ) e -i '.metadata.annotations.containerImage="$(OPERATOR_REPO_REF)@$(OPERATOR_IMAGE_SHA_REF)"' bundle/manifests/service-binding-operator.clusterserviceversion.yaml
31-
# this is needed because operator-sdk 1.16 filters out aggregated cluster role and the accompanied binding
31+
# this is needed because $(OPERATOR_SDK) 1.16 filters out aggregated cluster role and the accompanied binding
3232
$(KUSTOMIZE) build config/manifests | $(YQ) e 'select((.kind == "ClusterRole" and .metadata.name == "service-binding-controller-role") or (.kind == "ClusterRoleBinding" and .metadata.name == "service-binding-controller-rolebinding"))' - | $(KUBECTL_SLICE) -o bundle/manifests -t '{{.metadata.name}}_{{.apiVersion | replace "/" "_"}}_{{.kind | lower}}.yaml'
33-
operator-sdk bundle validate ./bundle --select-optional name=operatorhub
33+
$(OPERATOR_SDK) bundle validate ./bundle --select-optional name=operatorhub
3434

3535
.PHONY: registry-login
3636
registry-login:
@@ -52,9 +52,9 @@ bundle-image: bundle
5252
$(CONTAINER_RUNTIME) build -f bundle.Dockerfile -t $(OPERATOR_BUNDLE_IMAGE_REF) .
5353

5454
.PHONY: push-bundle-image
55-
push-bundle-image: bundle-image registry-login
55+
push-bundle-image: bundle-image registry-login operator-sdk
5656
$(Q)$(CONTAINER_RUNTIME) push $(OPERATOR_BUNDLE_IMAGE_REF)
57-
$(Q)operator-sdk bundle validate --select-optional name=operatorhub -b $(CONTAINER_RUNTIME) $(OPERATOR_BUNDLE_IMAGE_REF)
57+
$(Q)$(OPERATOR_SDK) bundle validate --select-optional name=operatorhub -b $(CONTAINER_RUNTIME) $(OPERATOR_BUNDLE_IMAGE_REF)
5858

5959
.PHONY: index-image
6060
index-image: opm push-bundle-image

0 commit comments

Comments
 (0)