@@ -22,6 +22,15 @@ import (
22
22
"k8s.io/klog/v2"
23
23
)
24
24
25
+ type ObjectStatus struct {
26
+ GVK schema.GroupVersionKind
27
+ NameNamespace types.NamespacedName
28
+ IsHealthy bool
29
+ IsPruned bool
30
+ Message string
31
+ Error error
32
+ }
33
+
25
34
// ApplyResults contains the results of an Apply operation.
26
35
type ApplyResults struct {
27
36
total int
@@ -31,6 +40,7 @@ type ApplyResults struct {
31
40
pruneFailCount int
32
41
healthyCount int
33
42
unhealthyCount int
43
+ Objects []ObjectStatus
34
44
}
35
45
36
46
// AllApplied is true if the desired state has been successfully applied for all objects.
@@ -62,6 +72,14 @@ func (r *ApplyResults) checkInvariants() {
62
72
// applyError records that the apply of an object failed with an error.
63
73
func (r * ApplyResults ) applyError (gvk schema.GroupVersionKind , nn types.NamespacedName , err error ) {
64
74
r .applyFailCount ++
75
+ r .Objects = append (r .Objects , ObjectStatus {
76
+ GVK : gvk ,
77
+ NameNamespace : nn ,
78
+ IsHealthy : false ,
79
+ IsPruned : false ,
80
+ Message : "Apply Error" ,
81
+ Error : err ,
82
+ })
65
83
klog .Warningf ("error from apply on %s %s: %v" , gvk , nn , err )
66
84
}
67
85
@@ -72,17 +90,37 @@ func (r *ApplyResults) applySuccess(gvk schema.GroupVersionKind, nn types.Namesp
72
90
73
91
// pruneError records that the prune of an object failed with an error.
74
92
func (r * ApplyResults ) pruneError (gvk schema.GroupVersionKind , nn types.NamespacedName , err error ) {
93
+ r .Objects = append (r .Objects , ObjectStatus {
94
+ GVK : gvk ,
95
+ NameNamespace : nn ,
96
+ IsHealthy : true ,
97
+ IsPruned : true ,
98
+ Message : "Prune Error" ,
99
+ Error : err ,
100
+ })
75
101
r .pruneFailCount ++
76
102
klog .Warningf ("error from pruning on %s %s: %v" , gvk , nn , err )
77
103
}
78
104
79
105
// pruneSuccess records that an object was pruned and this succeeded.
80
106
func (r * ApplyResults ) pruneSuccess (gvk schema.GroupVersionKind , nn types.NamespacedName ) {
107
+ r .Objects = append (r .Objects , ObjectStatus {
108
+ GVK : gvk ,
109
+ NameNamespace : nn ,
110
+ IsPruned : true ,
111
+ })
81
112
r .pruneSuccessCount ++
82
113
}
83
114
84
115
// reportHealth records the health of an object.
85
- func (r * ApplyResults ) reportHealth (gvk schema.GroupVersionKind , nn types.NamespacedName , isHealthy bool ) {
116
+ func (r * ApplyResults ) reportHealth (gvk schema.GroupVersionKind , nn types.NamespacedName , isHealthy bool , message string ) {
117
+ r .Objects = append (r .Objects , ObjectStatus {
118
+ GVK : gvk ,
119
+ NameNamespace : nn ,
120
+ IsHealthy : isHealthy ,
121
+ IsPruned : false ,
122
+ Message : message ,
123
+ })
86
124
if isHealthy {
87
125
r .healthyCount ++
88
126
} else {
0 commit comments