Skip to content

Commit

Permalink
feat: customizable certificate expiry warning period
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Oct 23, 2024
1 parent 63838eb commit 7f44e56
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/health/health_cert_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

var (
defaultCertExpiryWarningPeriod = time.Hour * 24 * 2
)

func SetDefaultCertificateExpiryWarningPeriod(p time.Duration) {
defaultCertExpiryWarningPeriod = p
}

func GetCertificateHealth(obj *unstructured.Unstructured) (*HealthStatus, error) {
if _renewalTime, ok := obj.Object["status"].(map[string]any)["renewalTime"]; ok {
if renewalTimeString := _renewalTime.(string); ok {
Expand All @@ -33,7 +41,7 @@ func GetCertificateHealth(obj *unstructured.Unstructured) (*HealthStatus, error)
return nil, fmt.Errorf("failed to parse notAfter time(%s): %v", notAfter, err)
}

if time.Until(notAfterTime) < time.Hour {
if time.Until(notAfterTime) < defaultCertExpiryWarningPeriod {
return &HealthStatus{
Health: HealthWarning,
Status: HealthStatusWarning,
Expand Down

0 comments on commit 7f44e56

Please sign in to comment.