From 423ff13354d8eb0229331a317fa6e908af8f4460 Mon Sep 17 00:00:00 2001 From: jpflueger Date: Tue, 26 May 2020 16:12:48 -0600 Subject: [PATCH] improvements for generate-test-certs target --- Makefile | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index f92f6340700..5807017093c 100644 --- a/Makefile +++ b/Makefile @@ -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