improvements for generate-test-certs target
@@ -19,22 +19,33 @@ TEST_RESOURCE_PREFIX ?= aso-$(BUILD_ID)
# Go compiler builds tags: some parts of the test suite use these to selectively compile tests.
BUILD_TAGS ?= all
-# Temp directory variable, set by environment on macOS and set to default for everything else
-TMPDIR ?= /tmp/
+ifdef TMPDIR
+TMPDIR := $(realpath ${TMPDIR})
+else
+TMPDIR := /tmp
+endif
all: manager
# Generate test certs for development
+generate-test-certs: CONFIGTXT := $(shell mktemp)
+generate-test-certs: WEBHOOK_DIR := $(TMPDIR)/k8s-webhook-server
+generate-test-certs: WEBHOOK_CERT_DIR := $(TMPDIR)/k8s-webhook-server/serving-certs
generate-test-certs:
- echo "[req]" > config.txt
- echo "distinguished_name = req_distinguished_name" >> config.txt
- echo "[req_distinguished_name]" >> config.txt
- echo "[SAN]" >> config.txt
- echo "subjectAltName=DNS:azureoperator-webhook-service.azureoperator-system.svc.cluster.local" >> config.txt
- openssl req -x509 -days 730 -out tls.crt -keyout tls.key -newkey rsa:4096 -subj "/CN=azureoperator-webhook-service.azureoperator-system" -config config.txt -nodes
- rm -rf $(TMPDIR)/k8s-webhook-server
- mkdir -p $(TMPDIR)/k8s-webhook-server/serving-certs
- mv tls.* $(TMPDIR)/k8s-webhook-server/serving-certs/
+ rm -rf $(WEBHOOK_DIR)
+ mkdir -p $(WEBHOOK_CERT_DIR)
+
+ @echo "[req]" > $(CONFIGTXT)
+ @echo "distinguished_name = req_distinguished_name" >> $(CONFIGTXT)
+ @echo "[req_distinguished_name]" >> $(CONFIGTXT)
+ @echo "[SAN]" >> $(CONFIGTXT)
+ @echo "subjectAltName=DNS:azureoperator-webhook-service.azureoperator-system.svc.cluster.local" >> $(CONFIGTXT)
+
+ @echo "OpenSSL Config:"
+ @cat $(CONFIGTXT)
+ @echo
+
+ openssl req -x509 -days 730 -out $(WEBHOOK_CERT_DIR)/tls.crt -keyout $(WEBHOOK_CERT_DIR)/tls.key -newkey rsa:4096 -subj "/CN=azureoperator-webhook-service.azureoperator-system" -config $(CONFIGTXT) -nodes
# Run Controller tests against the configured cluster
test-integration-controllers: generate fmt vet manifests
