Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ lint: golangci-lint ## Run golangci-lint.

##@ Testing

# Note: Requires tinygo (0.31.2) and wasm-opt
.PHONY: test
test: manifests generate fmt vet build-wasm-testdata envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
Expand Down Expand Up @@ -132,36 +133,6 @@ docker-build: ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
docker push ${IMG}:${TAG}

##@ Deployment

ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/default && $(KUSTOMIZE) edit set image open-component-model/ocm-controller=$(IMG):$(TAG)
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: dev-deploy
dev-deploy: kustomize ## Deploy controller dev image in the configured Kubernetes cluster in ~/.kube/config
mkdir -p config/dev && cp -R config/default/* config/dev
cd config/dev && $(KUSTOMIZE) edit set image open-component-model/ocm-controller=$(IMG):$(TAG)
$(KUSTOMIZE) build config/dev | kubectl apply -f -
rm -rf config/dev

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

##@ Component

.PHONY: plain-push
Expand Down
12 changes: 7 additions & 5 deletions hack/prime_test_cluster.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash

# cleanup
rm -fr hack/rootCA.pem
if [[ -f hack/rootCA.pem ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the if?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm -fr will exit 0 even if the thing doesn't exist. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because -f (force-)pushes are not best practice in scripts. It is surely opinionated, but force-removals can be risky and are not necessary in most situations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the if?

To not use -f :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this situation we also want to make sure that a rootCA with a bad chmod or a different user is also removed. Or if it was created with a super user. But meh. :) I'm not gonna die on this hill. :D

rm hack/rootCA.pem
fi

CERT_MANAGER_VERSION=${CERT_MANAGER_VERSION:-v1.13.1}

Expand All @@ -12,23 +14,23 @@ fi

kind create cluster --name=e2e-test-cluster

echo -n 'installing cert-manager'
echo 'installing cert-manager'
kubectl apply -f hack/cert-manager.yaml
kubectl wait --for=condition=Available=True Deployment/cert-manager -n cert-manager --timeout=60s
kubectl wait --for=condition=Available=True Deployment/cert-manager-webhook -n cert-manager --timeout=60s
kubectl wait --for=condition=Available=True Deployment/cert-manager-cainjector -n cert-manager --timeout=60s
echo 'done'

echo -n 'applying root certificate issuer'
echo 'applying root certificate issuer'
kubectl apply -f hack/cluster_issuer.yaml
echo 'done'

echo -n 'waiting for root certificate to be generated...'
echo 'waiting for root certificate to be generated...'
kubectl wait --for=condition=Ready=true Certificate/mpas-bootstrap-certificate -n cert-manager --timeout=60s
echo 'done'

kubectl get secret ocm-registry-tls-certs -n cert-manager -o jsonpath="{.data['tls\.crt']}" | base64 -d > hack/rootCA.pem
echo -n 'installing root certificate into local trust store...'
echo 'installing root certificate into local trust store...'
CAROOT=hack ./bin/mkcert -install
rootCAPath="./hack/rootCA.pem"

Expand Down
Loading