diff --git a/libexec/watcher b/libexec/watcher index bc5c4b9..7ab32ce 100755 --- a/libexec/watcher +++ b/libexec/watcher @@ -7,12 +7,18 @@ set -euo pipefail process_routes() { local domainname selfLink local tmpl='.object.spec.host + ":" + .object.metadata.selfLink' + log "watching routes with selector $LETSENCRYPT_ROUTE_SELECTOR" + watch_routes | jq -er --unbuffered "$tmpl" \ | while IFS=: read -r domainname selfLink; do - log "Processing route $selfLink with domain $domainname." - get_certificate "$domainname" "$selfLink" - done + if [ -n domainname ] && [ -n selfLink ]; then + log "Processing route $selfLink with domain $domainname." + get_certificate "$domainname" "$selfLink" + else + log "$(watch_routes)" + fi + done } while true diff --git a/share/common.sh b/share/common.sh index 7d05465..81bbf8e 100644 --- a/share/common.sh +++ b/share/common.sh @@ -54,6 +54,7 @@ is_true() { ;; esac } + api_call() { local uri="${1##/}"; shift curl --fail -sSH "Authorization: Bearer $SA_TOKEN" \ @@ -71,9 +72,11 @@ api_call() { watch_routes() { local routes_uri routes_uri="$(route_uri)?watch" + if [ -n "$LETSENCRYPT_ROUTE_SELECTOR" ]; then routes_uri="$routes_uri&labelSelector=$LETSENCRYPT_ROUTE_SELECTOR" fi + api_call "$routes_uri" -N } diff --git a/template.yaml b/template.yaml index 64fe16c..d503eae 100644 --- a/template.yaml +++ b/template.yaml @@ -30,7 +30,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: ibotty/openshift-letsencrypt:latest + image: crossb0w/openshift-letsencrypt:latest imagePullPolicy: Always name: watcher volumeMounts: @@ -45,7 +45,7 @@ objects: env: - name: LETSENCRYPT_CONTACT_EMAIL value: ${LETSENCRYPT_CONTACT_EMAIL} - image: ibotty/openshift-letsencrypt:latest + image: crossb0w/openshift-letsencrypt:latest name: cron terminationMessagePath: /dev/termination-log volumeMounts: