func extractPullSecretTimeAnnotation()

in internal/controller/acrpullbinding_controller.go [179:198]


func extractPullSecretTimeAnnotation(log logr.Logger, secret *corev1.Secret, annotation string) time.Time {
	if secret == nil {
		return time.Time{}
	}

	formattedTime, annotated := secret.Annotations[annotation]
	if !annotated {
		return time.Time{}
	}

	timestamp, err := time.Parse(time.RFC3339, formattedTime)
	if err != nil {
		// we should never get into this state unless some other actor corrupts our annotation,
		// so we can consider this token expired and re-generate it to get back to a good state
		log.WithValues("secret", client.ObjectKeyFromObject(secret).String()).WithValues("annotation", annotation).Error(err, "unexpected error parsing annotation on secret")
		return time.Time{}
	}

	return timestamp
}