mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 14:41:10 +01:00
bump(vendor)
This commit is contained in:
104
vendor/github.com/openshift/custom-resource-status/conditions/v1/conditions.go
generated
vendored
Normal file
104
vendor/github.com/openshift/custom-resource-status/conditions/v1/conditions.go
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// SetStatusCondition sets the corresponding condition in conditions to newCondition.
|
||||
func SetStatusCondition(conditions *[]Condition, newCondition Condition) {
|
||||
if conditions == nil {
|
||||
conditions = &[]Condition{}
|
||||
}
|
||||
existingCondition := FindStatusCondition(*conditions, newCondition.Type)
|
||||
if existingCondition == nil {
|
||||
newCondition.LastTransitionTime = metav1.NewTime(time.Now())
|
||||
newCondition.LastHeartbeatTime = metav1.NewTime(time.Now())
|
||||
*conditions = append(*conditions, newCondition)
|
||||
return
|
||||
}
|
||||
|
||||
if existingCondition.Status != newCondition.Status {
|
||||
existingCondition.Status = newCondition.Status
|
||||
existingCondition.LastTransitionTime = metav1.NewTime(time.Now())
|
||||
}
|
||||
|
||||
existingCondition.Reason = newCondition.Reason
|
||||
existingCondition.Message = newCondition.Message
|
||||
existingCondition.LastHeartbeatTime = metav1.NewTime(time.Now())
|
||||
}
|
||||
|
||||
// SetStatusConditionNoHearbeat sets the corresponding condition in conditions to newCondition
|
||||
// without setting lastHeartbeatTime.
|
||||
func SetStatusConditionNoHeartbeat(conditions *[]Condition, newCondition Condition) {
|
||||
if conditions == nil {
|
||||
conditions = &[]Condition{}
|
||||
}
|
||||
existingCondition := FindStatusCondition(*conditions, newCondition.Type)
|
||||
if existingCondition == nil {
|
||||
newCondition.LastTransitionTime = metav1.NewTime(time.Now())
|
||||
*conditions = append(*conditions, newCondition)
|
||||
return
|
||||
}
|
||||
|
||||
if existingCondition.Status != newCondition.Status {
|
||||
existingCondition.Status = newCondition.Status
|
||||
existingCondition.LastTransitionTime = metav1.NewTime(time.Now())
|
||||
}
|
||||
|
||||
existingCondition.Reason = newCondition.Reason
|
||||
existingCondition.Message = newCondition.Message
|
||||
}
|
||||
|
||||
// RemoveStatusCondition removes the corresponding conditionType from conditions.
|
||||
func RemoveStatusCondition(conditions *[]Condition, conditionType ConditionType) {
|
||||
if conditions == nil {
|
||||
return
|
||||
}
|
||||
newConditions := []Condition{}
|
||||
for _, condition := range *conditions {
|
||||
if condition.Type != conditionType {
|
||||
newConditions = append(newConditions, condition)
|
||||
}
|
||||
}
|
||||
|
||||
*conditions = newConditions
|
||||
}
|
||||
|
||||
// FindStatusCondition finds the conditionType in conditions.
|
||||
func FindStatusCondition(conditions []Condition, conditionType ConditionType) *Condition {
|
||||
for i := range conditions {
|
||||
if conditions[i].Type == conditionType {
|
||||
return &conditions[i]
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsStatusConditionTrue returns true when the conditionType is present and set to `corev1.ConditionTrue`
|
||||
func IsStatusConditionTrue(conditions []Condition, conditionType ConditionType) bool {
|
||||
return IsStatusConditionPresentAndEqual(conditions, conditionType, corev1.ConditionTrue)
|
||||
}
|
||||
|
||||
// IsStatusConditionFalse returns true when the conditionType is present and set to `corev1.ConditionFalse`
|
||||
func IsStatusConditionFalse(conditions []Condition, conditionType ConditionType) bool {
|
||||
return IsStatusConditionPresentAndEqual(conditions, conditionType, corev1.ConditionFalse)
|
||||
}
|
||||
|
||||
// IsStatusConditionUnknown returns true when the conditionType is present and set to `corev1.ConditionUnknown`
|
||||
func IsStatusConditionUnknown(conditions []Condition, conditionType ConditionType) bool {
|
||||
return IsStatusConditionPresentAndEqual(conditions, conditionType, corev1.ConditionUnknown)
|
||||
}
|
||||
|
||||
// IsStatusConditionPresentAndEqual returns true when conditionType is present and equal to status.
|
||||
func IsStatusConditionPresentAndEqual(conditions []Condition, conditionType ConditionType, status corev1.ConditionStatus) bool {
|
||||
for _, condition := range conditions {
|
||||
if condition.Type == conditionType {
|
||||
return condition.Status == status
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
9
vendor/github.com/openshift/custom-resource-status/conditions/v1/doc.go
generated
vendored
Normal file
9
vendor/github.com/openshift/custom-resource-status/conditions/v1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +k8s:openapi-gen=true
|
||||
|
||||
// Package v1 provides version v1 of the types and functions necessary to
|
||||
// manage and inspect a slice of conditions. It is opinionated in the
|
||||
// condition types provided but leaves it to the user to define additional
|
||||
// types as necessary.
|
||||
package v1
|
||||
51
vendor/github.com/openshift/custom-resource-status/conditions/v1/types.go
generated
vendored
Normal file
51
vendor/github.com/openshift/custom-resource-status/conditions/v1/types.go
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// Condition represents the state of the operator's
|
||||
// reconciliation functionality.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type Condition struct {
|
||||
Type ConditionType `json:"type" description:"type of condition ie. Available|Progressing|Degraded."`
|
||||
|
||||
Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"`
|
||||
|
||||
// +optional
|
||||
Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"`
|
||||
|
||||
// +optional
|
||||
Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"`
|
||||
|
||||
// +optional
|
||||
LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime" description:"last time we got an update on a given condition"`
|
||||
|
||||
// +optional
|
||||
LastTransitionTime metav1.Time `json:"lastTransitionTime" description:"last time the condition transit from one status to another"`
|
||||
}
|
||||
|
||||
// ConditionType is the state of the operator's reconciliation functionality.
|
||||
type ConditionType string
|
||||
|
||||
const (
|
||||
// ConditionAvailable indicates that the resources maintained by the operator,
|
||||
// is functional and available in the cluster.
|
||||
ConditionAvailable ConditionType = "Available"
|
||||
|
||||
// ConditionProgressing indicates that the operator is actively making changes to the resources maintained by the
|
||||
// operator
|
||||
ConditionProgressing ConditionType = "Progressing"
|
||||
|
||||
// ConditionDegraded indicates that the resources maintained by the operator are not functioning completely.
|
||||
// An example of a degraded state would be if not all pods in a deployment were running.
|
||||
// It may still be available, but it is degraded
|
||||
ConditionDegraded ConditionType = "Degraded"
|
||||
|
||||
// ConditionUpgradeable indicates whether the resources maintained by the operator are in a state that is safe to upgrade.
|
||||
// When `False`, the resources maintained by the operator should not be upgraded and the
|
||||
// message field should contain a human readable description of what the administrator should do to
|
||||
// allow the operator to successfully update the resources maintained by the operator.
|
||||
ConditionUpgradeable ConditionType = "Upgradeable"
|
||||
)
|
||||
23
vendor/github.com/openshift/custom-resource-status/conditions/v1/zz_generated.deepcopy.go
generated
vendored
Normal file
23
vendor/github.com/openshift/custom-resource-status/conditions/v1/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Condition) DeepCopyInto(out *Condition) {
|
||||
*out = *in
|
||||
in.LastHeartbeatTime.DeepCopyInto(&out.LastHeartbeatTime)
|
||||
in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition.
|
||||
func (in *Condition) DeepCopy() *Condition {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Condition)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user