github.com/giantswarm/apiextensions/v2@v2.6.2/pkg/apis/core/v1alpha1/drainer_funcs.go (about)

     1  package v1alpha1
     2  
     3  import (
     4  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  )
     6  
     7  func (s DrainerConfigStatus) HasDrainedCondition() bool {
     8  	return hasDrainerConfigCondition(s.Conditions, DrainerConfigStatusStatusTrue, DrainerConfigStatusTypeDrained)
     9  }
    10  
    11  func (s DrainerConfigStatus) HasTimeoutCondition() bool {
    12  	return hasDrainerConfigCondition(s.Conditions, DrainerConfigStatusStatusTrue, DrainerConfigStatusTypeTimeout)
    13  }
    14  
    15  func (s DrainerConfigStatus) NewDrainedCondition() DrainerConfigStatusCondition {
    16  	return DrainerConfigStatusCondition{
    17  		LastTransitionTime: metav1.Now(),
    18  		Status:             DrainerConfigStatusStatusTrue,
    19  		Type:               DrainerConfigStatusTypeDrained,
    20  	}
    21  }
    22  
    23  func (s DrainerConfigStatus) NewTimeoutCondition() DrainerConfigStatusCondition {
    24  	return DrainerConfigStatusCondition{
    25  		LastTransitionTime: metav1.Now(),
    26  		Status:             DrainerConfigStatusStatusTrue,
    27  		Type:               DrainerConfigStatusTypeTimeout,
    28  	}
    29  }
    30  
    31  func hasDrainerConfigCondition(conditions []DrainerConfigStatusCondition, s string, t string) bool {
    32  	for _, c := range conditions {
    33  		if c.Status == s && c.Type == t {
    34  			return true
    35  		}
    36  	}
    37  
    38  	return false
    39  }