Skip to content

Commit

Permalink
improvements for generate-test-certs target
Browse files Browse the repository at this point in the history
  • Loading branch information
jpflueger committed May 26, 2020
1 parent ab8c39d commit 423ff13
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 423ff13

Please sign in to comment.