-
Notifications
You must be signed in to change notification settings - Fork 6
/
reprint
executable file
·42 lines (36 loc) · 1.22 KB
/
reprint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/bash
set -euo pipefail
help() {
cat <<EOF
We have seen cases where we needed to manually re-trigger the printing of the
labels. What it does to re-print is remove the Printed=True condition.
This command uses the namespace "default", and currently doesn't support
changing to a different namespace.
Usage:
$(basename "$0") <email | certname>
$(basename "$0") mael@vls.dev
$(basename "$0") 7db51dbcac48ed00883c89fab7e1f62613b5a547d278c957211b219f385dee25
EOF
}
if ! [ $# -eq 1 ]; then
printf "error: you need to give an email or a Certificate name as argument.\n" >&2
fi
emailOrName=$1
certName=
if [[ $emailOrName == *@* ]]; then
certName=$(
kubectl get secret -ojson \
| jq -r ".items[].metadata | select(.annotations.\"cert-manager.io/email-sans\" == \"$emailOrName\").name"
)
if [[ -z $certName ]]; then
echo "No certificate found with the subject alternative email '$certName'"
exit 1
fi
else
certName=$(kubectl get cert "$emailOrName" -oname | cut -d/ -f2)
if [[ -z $certName ]]; then
echo "Certificate $emailOrName not found"
exit 1
fi
fi
kubectl patch cert "$certName" --subresource status --type=json -p '[{"op":"replace","path":"/status/conditions","value":[{"type":"Printed","status":"False"}]}]'