func (s *ConditionedStatus) SetConditions(c ...Condition) {
	for _, new := range c {
		exists := false
		for i, existing := range s.Conditions {
			if existing.Type != new.Type {
				continue
			}
			if existing.Equal(new) {
				exists = true
				continue
			}
			s.Conditions[i] = new
			exists = true
		}
		if !exists {
			s.Conditions = append(s.Conditions, new)
		}
	}
}
SetConditions sets the supplied conditions, replacing any existing conditions
of the same type. This is a no-op if all supplied conditions are identical,
ignoring the last transition time, to those already set.
package condition
import (
	"sort"
	"time"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ConditionType string
const (
	TypeReady ConditionType = "Ready"
	TypeSynced ConditionType = "Synced"
)
type ConditionReason string
const (
	ReasonAvailable   ConditionReason = "Available"
	ReasonUnavailable ConditionReason = "Unavailable"
	ReasonCreating    ConditionReason = "Creating"
	ReasonDeleting    ConditionReason = "Deleting"
)
const (
	ReasonReconcileSuccess ConditionReason = "ReconcileSuccess"
	ReasonReconcileError   ConditionReason = "ReconcileError"
)
type Condition struct {
	Type ConditionType `json:"type"`
	Status corev1.ConditionStatus `json:"status"`
	LastTransitionTime metav1.Time `json:"lastTransitionTime"`
	Reason ConditionReason `json:"reason"`
	Message string `json:"message,omitempty"`
}
func (c Condition) Equal(other Condition) bool {
	return c.Type == other.Type &&
		c.Status == other.Status &&
		c.Reason == other.Reason &&
		c.Message == other.Message
}
func (c Condition) WithMessage(msg string) Condition {
	c.Message = msg
	return c
}
type ConditionedStatus struct {
	Conditions []Condition `json:"conditions,omitempty"`
}
func NewConditionedStatus(c ...Condition) *ConditionedStatus {
	s := &ConditionedStatus{}
	s.SetConditions(c...)
	return s
}
func (s *ConditionedStatus) GetCondition(ct ConditionType) Condition {
	for _, c := range s.Conditions {
		if c.Type == ct {
			return c
		}
	}
	return Condition{Type: ct, Status: corev1.ConditionUnknown}
}