package util import ( acmapi "gitbucket.jerxie.com/yangyangxie/AnthosCertManager/pkg/apis/anthoscertmanager/v1" ) // CertificateHasCondition will return true if the given Certificate has a // condition matching the provided CertificateCondition. // Only the Type and Status field will be used in the comparison, meaning that // this function will return 'true' even if the Reason, Message and // LastTransitionTime fields do not match. func CertificateHasCondition(crt *acmapi.Certificate, c acmapi.CertificateCondition) bool { if crt == nil { return false } existingConditions := crt.Status.Conditions for _, cond := range existingConditions { if c.Type == cond.Type && c.Status == cond.Status { return true } } return false } // RemoveCertificateCondition will remove any condition with this condition type func RemoveCertificateCondition(crt *acmapi.Certificate, conditionType acmapi.CertificateConditionType) { var updatedConditions []acmapi.CertificateCondition for _, cond := range crt.Status.Conditions { if cond.Type != conditionType { // Only add the unrelated conditions updatedConditions = append(updatedConditions, cond) } } // Add the other conditions back. crt.Status.Conditions = updatedConditions }