mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 07:28: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
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
ready:
|
|
||||||
description: True when the Kubernetes secret is ready for use.
|
|
||||||
type: boolean
|
|
||||||
required:
|
required:
|
||||||
- conditions
|
- conditions
|
||||||
type: object
|
type: object
|
||||||
|
@@ -36,9 +36,6 @@ type OnePasswordItemStatus struct {
|
|||||||
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
|
// 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
|
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
|
||||||
Conditions []OnePasswordItemCondition `json:"conditions"`
|
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
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
@@ -113,11 +113,6 @@ func (in *OnePasswordItemStatus) DeepCopyInto(out *OnePasswordItemStatus) {
|
|||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if in.Ready != nil {
|
|
||||||
in, out := &in.Ready, &out.Ready
|
|
||||||
*out = new(bool)
|
|
||||||
**out = **in
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -172,22 +172,32 @@ func (r *ReconcileOnePasswordItem) HandleOnePasswordItem(resource *onepasswordv1
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *ReconcileOnePasswordItem) updateStatus(resource *onepasswordv1.OnePasswordItem, err error) error {
|
func (r *ReconcileOnePasswordItem) updateStatus(resource *onepasswordv1.OnePasswordItem, err error) error {
|
||||||
condition := onepasswordv1.OnePasswordItemCondition{
|
existingCondition := findCondition(resource.Status.Conditions, onepasswordv1.OnePasswordItemReady)
|
||||||
Type: onepasswordv1.OnePasswordItemReady,
|
updatedCondition := existingCondition
|
||||||
Status: metav1.ConditionTrue,
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
condition.Message = err.Error()
|
updatedCondition.Message = err.Error()
|
||||||
condition.Status = metav1.ConditionFalse
|
updatedCondition.Status = metav1.ConditionFalse
|
||||||
|
} else {
|
||||||
|
updatedCondition.Message = ""
|
||||||
|
updatedCondition.Status = metav1.ConditionTrue
|
||||||
}
|
}
|
||||||
|
|
||||||
ready := err == nil
|
if existingCondition.Status != updatedCondition.Status {
|
||||||
if resource.Status.Ready == nil || ready != *resource.Status.Ready {
|
updatedCondition.LastTransitionTime = metav1.Now()
|
||||||
condition.LastTransitionTime = metav1.Now()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource.Status.Ready = &ready
|
resource.Status.Conditions = []onepasswordv1.OnePasswordItemCondition{updatedCondition}
|
||||||
|
|
||||||
resource.Status.Conditions = []onepasswordv1.OnePasswordItemCondition{condition}
|
|
||||||
return r.kubeClient.Status().Update(context.Background(), resource)
|
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