mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-21 15:08:06 +00:00
Remove ready field from status
The usage of such a field is considered deprecated, conditions should be used instead. If there is a use-case that is not covered by conditions only we can always reconsider adding an extra field to the status. See the k8s guidelines for more details on the deprecation: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
This commit is contained in:
@@ -63,9 +63,6 @@ spec:
|
||||
- type
|
||||
type: object
|
||||
type: array
|
||||
ready:
|
||||
description: True when the Kubernetes secret is ready for use.
|
||||
type: boolean
|
||||
required:
|
||||
- conditions
|
||||
type: object
|
||||
|
@@ -36,9 +36,6 @@ type OnePasswordItemStatus struct {
|
||||
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
|
||||
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
|
||||
Conditions []OnePasswordItemCondition `json:"conditions"`
|
||||
|
||||
// True when the Kubernetes secret is ready for use.
|
||||
Ready *bool `json:"ready,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@@ -51,7 +48,7 @@ type OnePasswordItem struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Kubernetes secret type. More info: https://kubernetes.io/docs/concepts/configuration/secret/#secret-types
|
||||
Type string `json:"type,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
|
||||
Spec OnePasswordItemSpec `json:"spec,omitempty"`
|
||||
Status OnePasswordItemStatus `json:"status,omitempty"`
|
||||
|
@@ -113,11 +113,6 @@ func (in *OnePasswordItemStatus) DeepCopyInto(out *OnePasswordItemStatus) {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Ready != nil {
|
||||
in, out := &in.Ready, &out.Ready
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -172,22 +172,32 @@ func (r *ReconcileOnePasswordItem) HandleOnePasswordItem(resource *onepasswordv1
|
||||
}
|
||||
|
||||
func (r *ReconcileOnePasswordItem) updateStatus(resource *onepasswordv1.OnePasswordItem, err error) error {
|
||||
condition := onepasswordv1.OnePasswordItemCondition{
|
||||
Type: onepasswordv1.OnePasswordItemReady,
|
||||
Status: metav1.ConditionTrue,
|
||||
}
|
||||
existingCondition := findCondition(resource.Status.Conditions, onepasswordv1.OnePasswordItemReady)
|
||||
updatedCondition := existingCondition
|
||||
if err != nil {
|
||||
condition.Message = err.Error()
|
||||
condition.Status = metav1.ConditionFalse
|
||||
updatedCondition.Message = err.Error()
|
||||
updatedCondition.Status = metav1.ConditionFalse
|
||||
} else {
|
||||
updatedCondition.Message = ""
|
||||
updatedCondition.Status = metav1.ConditionTrue
|
||||
}
|
||||
|
||||
ready := err == nil
|
||||
if resource.Status.Ready == nil || ready != *resource.Status.Ready {
|
||||
condition.LastTransitionTime = metav1.Now()
|
||||
if existingCondition.Status != updatedCondition.Status {
|
||||
updatedCondition.LastTransitionTime = metav1.Now()
|
||||
}
|
||||
|
||||
resource.Status.Ready = &ready
|
||||
|
||||
resource.Status.Conditions = []onepasswordv1.OnePasswordItemCondition{condition}
|
||||
resource.Status.Conditions = []onepasswordv1.OnePasswordItemCondition{updatedCondition}
|
||||
return r.kubeClient.Status().Update(context.Background(), resource)
|
||||
}
|
||||
|
||||
func findCondition(conditions []onepasswordv1.OnePasswordItemCondition, t onepasswordv1.OnePasswordItemConditionType) onepasswordv1.OnePasswordItemCondition {
|
||||
for _, c := range conditions {
|
||||
if c.Type == t {
|
||||
return c
|
||||
}
|
||||
}
|
||||
return onepasswordv1.OnePasswordItemCondition{
|
||||
Type: t,
|
||||
Status: metav1.ConditionUnknown,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user