@@ -36,28 +36,22 @@ func (c *Config) SetConditionFalseWithMessage(condition k8upv1.ConditionType, re
3636}
3737
3838// patchConditions patches the Status object on the K8s controller with the given Conditions
39- func (c * Config ) patchConditions (conditionStatus metav1.ConditionStatus , reason k8upv1.ConditionReason , message string , conditions ... k8upv1.ConditionType ) {
40- runtimeObject := c .Obj
41- patch := client .MergeFrom (runtimeObject .DeepCopyObject ().(client.Object ))
42-
39+ func (c * Config ) patchConditions (conditionStatus metav1.ConditionStatus , reason k8upv1.ConditionReason , message string , condition k8upv1.ConditionType ) {
4340 status := c .Obj .GetStatus ()
44-
45- for _ , condition := range conditions {
46- meta .SetStatusCondition (& status .Conditions , metav1.Condition {
47- Type : condition .String (),
48- Status : conditionStatus ,
49- Message : message ,
50- Reason : reason .String (),
51- })
52- }
53-
41+ meta .SetStatusCondition (& status .Conditions , metav1.Condition {
42+ Type : condition .String (),
43+ Status : conditionStatus ,
44+ Message : message ,
45+ Reason : reason .String (),
46+ })
5447 c .Obj .SetStatus (status )
55- err := c .Client .Status ().Patch (c .CTX , c .Obj .(client.Object ), patch )
48+
49+ err := c .Client .Status ().Update (c .CTX , c .Obj )
5650 if err != nil {
5751 if errors .IsNotFound (err ) {
5852 return
5953 }
60- c .Log .Error (err , "could not patch status conditions " )
54+ c .Log .Error (err , "could not patch status condition " )
6155 }
6256}
6357
@@ -68,12 +62,13 @@ func (c *Config) SetStarted(message string, args ...interface{}) {
6862 status .SetStarted (fmt .Sprintf (message , args ... ))
6963 c .Obj .SetStatus (status )
7064
71- err := c .Client .Status ().Update (c .CTX , c .Obj )
65+ patch := client .MergeFrom (c .Obj .DeepCopyObject ().(client.Object ))
66+ err := c .Client .Status ().Patch (c .CTX , c .Obj , patch )
7267 if err != nil {
7368 if errors .IsNotFound (err ) {
7469 return
7570 }
76- c .Log .Error (err , "could not update status" )
71+ c .Log .Error (err , "could not patch status" )
7772 }
7873}
7974
@@ -83,12 +78,13 @@ func (c *Config) SetFinished(namespace, name string) {
8378 status .SetFinished (fmt .Sprintf ("the Job '%s/%s' ended" , namespace , name ))
8479 c .Obj .SetStatus (status )
8580
86- err := c .Client .Status ().Update (c .CTX , c .Obj )
81+ patch := client .MergeFrom (c .Obj .DeepCopyObject ().(client.Object ))
82+ err := c .Client .Status ().Patch (c .CTX , c .Obj , patch )
8783 if err != nil {
8884 if errors .IsNotFound (err ) {
8985 return
9086 }
91- c .Log .Error (err , "could not update status" )
87+ c .Log .Error (err , "could not patch status" )
9288 }
9389}
9490
0 commit comments