@@ -1476,6 +1476,84 @@ var _ = Describe("Fake client", func() {
1476
1476
objOriginal .Status .NodeInfo .MachineID = "machine-id-from-status-update"
1477
1477
Expect (cmp .Diff (objOriginal , actual )).To (BeEmpty ())
1478
1478
})
1479
+
1480
+ It ("should be able to update an object after updating an object's status" , func () {
1481
+ obj := & corev1.Node {
1482
+ ObjectMeta : metav1.ObjectMeta {
1483
+ Name : "node" ,
1484
+ },
1485
+ Spec : corev1.NodeSpec {
1486
+ PodCIDR : "old-cidr" ,
1487
+ },
1488
+ Status : corev1.NodeStatus {
1489
+ NodeInfo : corev1.NodeSystemInfo {
1490
+ MachineID : "machine-id" ,
1491
+ },
1492
+ },
1493
+ }
1494
+ cl := NewClientBuilder ().WithStatusSubresource (obj ).WithObjects (obj ).Build ()
1495
+ expectedObj := obj .DeepCopy ()
1496
+
1497
+ obj .Status .NodeInfo .MachineID = "machine-id-from-status-update"
1498
+ Expect (cl .Status ().Update (context .Background (), obj )).NotTo (HaveOccurred ())
1499
+
1500
+ obj .Annotations = map [string ]string {
1501
+ "some-annotation-key" : "some" ,
1502
+ }
1503
+ expectedObj .Annotations = map [string ]string {
1504
+ "some-annotation-key" : "some" ,
1505
+ }
1506
+ Expect (cl .Update (context .Background (), obj )).NotTo (HaveOccurred ())
1507
+
1508
+ actual := & corev1.Node {ObjectMeta : metav1.ObjectMeta {Name : obj .Name }}
1509
+ Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (actual ), actual )).NotTo (HaveOccurred ())
1510
+
1511
+ expectedObj .APIVersion = actual .APIVersion
1512
+ expectedObj .Kind = actual .Kind
1513
+ expectedObj .ResourceVersion = actual .ResourceVersion
1514
+ expectedObj .Status .NodeInfo .MachineID = "machine-id-from-status-update"
1515
+ Expect (cmp .Diff (expectedObj , actual )).To (BeEmpty ())
1516
+ })
1517
+
1518
+ It ("should be able to update an object's status after updating an object" , func () {
1519
+ obj := & corev1.Node {
1520
+ ObjectMeta : metav1.ObjectMeta {
1521
+ Name : "node" ,
1522
+ },
1523
+ Spec : corev1.NodeSpec {
1524
+ PodCIDR : "old-cidr" ,
1525
+ },
1526
+ Status : corev1.NodeStatus {
1527
+ NodeInfo : corev1.NodeSystemInfo {
1528
+ MachineID : "machine-id" ,
1529
+ },
1530
+ },
1531
+ }
1532
+ cl := NewClientBuilder ().WithStatusSubresource (obj ).WithObjects (obj ).Build ()
1533
+ expectedObj := obj .DeepCopy ()
1534
+
1535
+ obj .Annotations = map [string ]string {
1536
+ "some-annotation-key" : "some" ,
1537
+ }
1538
+ expectedObj .Annotations = map [string ]string {
1539
+ "some-annotation-key" : "some" ,
1540
+ }
1541
+ Expect (cl .Update (context .Background (), obj )).NotTo (HaveOccurred ())
1542
+
1543
+ obj .Spec .PodCIDR = "cidr-from-status-update"
1544
+ obj .Status .NodeInfo .MachineID = "machine-id-from-status-update"
1545
+ Expect (cl .Status ().Update (context .Background (), obj )).NotTo (HaveOccurred ())
1546
+
1547
+ actual := & corev1.Node {ObjectMeta : metav1.ObjectMeta {Name : obj .Name }}
1548
+ Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (actual ), actual )).NotTo (HaveOccurred ())
1549
+
1550
+ expectedObj .APIVersion = actual .APIVersion
1551
+ expectedObj .Kind = actual .Kind
1552
+ expectedObj .ResourceVersion = actual .ResourceVersion
1553
+ expectedObj .Status .NodeInfo .MachineID = "machine-id-from-status-update"
1554
+ Expect (cmp .Diff (expectedObj , actual )).To (BeEmpty ())
1555
+ })
1556
+
1479
1557
It ("Should only override status fields of typed objects that have a status subresource on status update" , func () {
1480
1558
obj := & corev1.Node {
1481
1559
ObjectMeta : metav1.ObjectMeta {
0 commit comments