@@ -47,23 +47,9 @@ type aggregator struct {
47
47
func (a * aggregator ) Reconciled (ctx context.Context , src declarative.DeclarativeObject , objs * manifest.Objects ) error {
48
48
log := log .Log
49
49
50
- unstruct , ok := src .(* unstructured.Unstructured )
51
- instance , commonOkay := src .(addonv1alpha1.CommonObject )
52
-
53
- unstructStatus := make (map [string ]interface {})
54
- var status addonv1alpha1.CommonStatus
55
-
56
50
statusHealthy := true
57
51
statusErrors := []string {}
58
52
59
- if ok {
60
- unstructStatus ["Healthy" ] = true
61
- } else if commonOkay {
62
- status = addonv1alpha1.CommonStatus {Healthy : true }
63
- } else {
64
- return fmt .Errorf ("object %T was not an addonv1alpha1.CommonObject" , src )
65
- }
66
-
67
53
for _ , o := range objs .Items {
68
54
gk := o .Group + "/" + o .Kind
69
55
healthy := true
@@ -84,7 +70,21 @@ func (a *aggregator) Reconciled(ctx context.Context, src declarative.Declarative
84
70
}
85
71
}
86
72
87
- log .WithValues ("object" , src ).WithValues ("status" , status ).V (2 ).Info ("built status" )
73
+ log .WithValues ("object" , src ).WithValues ("status" , statusHealthy ).V (2 ).Info ("built status" )
74
+
75
+ unstruct , ok := src .(* unstructured.Unstructured )
76
+ instance , commonOkay := src .(addonv1alpha1.CommonObject )
77
+
78
+ unstructStatus := make (map [string ]interface {})
79
+ var status addonv1alpha1.CommonStatus
80
+
81
+ if ok {
82
+ unstructStatus ["Healthy" ] = true
83
+ } else if commonOkay {
84
+ status = addonv1alpha1.CommonStatus {Healthy : true }
85
+ } else {
86
+ return fmt .Errorf ("object %T was not an addonv1alpha1.CommonObject" , src )
87
+ }
88
88
89
89
if commonOkay {
90
90
status .Errors = statusErrors
@@ -111,6 +111,11 @@ func (a *aggregator) Reconciled(ctx context.Context, src declarative.Declarative
111
111
}
112
112
if ! reflect .DeepEqual (status , s ) {
113
113
err = unstructured .SetNestedField (unstruct .Object , statusHealthy , "status" , "healthy" )
114
+ if err != nil {
115
+ log .Error (err , "updating status" )
116
+ return fmt .Errorf ("unable to set status in unstructured" , err )
117
+ }
118
+
114
119
err = unstructured .SetNestedStringSlice (unstruct .Object , statusErrors , "status" , "errors" )
115
120
if err != nil {
116
121
log .Error (err , "updating status" )
@@ -127,6 +132,8 @@ func (a *aggregator) Reconciled(ctx context.Context, src declarative.Declarative
127
132
}
128
133
}
129
134
135
+
136
+
130
137
return nil
131
138
}
132
139
0 commit comments