Fix WRA cert info in the show-certs.sh output

When fgrep'ing for "ca.crt","ext-ca.crt" in the WRA secret "mon-elastic-
services-secrets" it is finding matches for "ca.crt:","ca.crt-helm:" and
"ext-ca.crt:","ext-ca.crt-helm:" respectively, this fails an if clause
where it checks whether it is managed by cert-manager and wrongly
displaying the renewal as "Manual" instead of "Automatic",this fix
addresses this issue by hardening the fgrep to look for "ca.crt:" and
"ext-ca.crt:" respectively.

Test Cases:
PASS: Run "show-certs.sh" script and verify that all information for WRA
      certs properly in the output
PASS: "show-certs.sh -k" script and verify that all information for WRA
      certs properly in the output

Closes-Bug: 2051880

Change-Id: I73af1ebd60a0c750569381b6ed67108f79dbb69e
Signed-off-by: amantri <ayyappa.mantri@windriver.com>
This commit is contained in:
amantri 2024-01-31 15:58:39 -05:00
parent 6d975b79a1
commit 8d7d74f97c

View File

@ -174,7 +174,8 @@ PrintCertInfo-fromGenericSecret () {
kubectl --kubeconfig /etc/kubernetes/admin.conf -n $NAMESPACE get secret $SECRET &> /dev/null
if [ $? -eq 0 ]; then
SECRET_VALUE=$(kubectl --kubeconfig /etc/kubernetes/admin.conf -n $NAMESPACE get secret $SECRET -o yaml | fgrep " $SECRETFILE" | awk '{print $2}')
SECRET_VALUE=$(kubectl --kubeconfig /etc/kubernetes/admin.conf -n $NAMESPACE get secret $SECRET -o yaml | fgrep " $SECRETFILE:" | awk '{print $2}')
if ! IsACertificate $SECRET_VALUE; then
return