@@ -54,12 +54,20 @@ func (a *aggregator) Reconciled(ctx context.Context, src declarative.Declarative
54
54
for _ , o := range objs .Items {
55
55
gk := o .Group + "/" + o .Kind
56
56
healthy := true
57
+ objKey := client.ObjectKey {
58
+ Name : o .Name ,
59
+ Namespace : o .Namespace ,
60
+ }
61
+ // If the namespace isn't set on the object, we would want to use the namespace of src
62
+ if objKey .Namespace == "" {
63
+ objKey .Namespace = src .GetNamespace ()
64
+ }
57
65
var err error
58
66
switch gk {
59
67
case "/Service" :
60
- healthy , err = a .service (ctx , src , o . Name )
68
+ healthy , err = a .service (ctx , objKey )
61
69
case "extensions/Deployment" , "apps/Deployment" :
62
- healthy , err = a .deployment (ctx , src , o . Name )
70
+ healthy , err = a .deployment (ctx , objKey )
63
71
default :
64
72
log .WithValues ("type" , gk ).V (2 ).Info ("type not implemented for status aggregation, skipping" )
65
73
}
@@ -129,8 +137,7 @@ func (a *aggregator) Reconciled(ctx context.Context, src declarative.Declarative
129
137
return nil
130
138
}
131
139
132
- func (a * aggregator ) deployment (ctx context.Context , src declarative.DeclarativeObject , name string ) (bool , error ) {
133
- key := client.ObjectKey {Name : name }
140
+ func (a * aggregator ) deployment (ctx context.Context , key client.ObjectKey ) (bool , error ) {
134
141
dep := & appsv1.Deployment {}
135
142
136
143
if err := a .client .Get (ctx , key , dep ); err != nil {
@@ -146,8 +153,7 @@ func (a *aggregator) deployment(ctx context.Context, src declarative.Declarative
146
153
return false , fmt .Errorf ("deployment (%s) does not meet condition: %s" , key , successfulDeployment )
147
154
}
148
155
149
- func (a * aggregator ) service (ctx context.Context , src declarative.DeclarativeObject , name string ) (bool , error ) {
150
- key := client.ObjectKey {Namespace : src .GetNamespace (), Name : name }
156
+ func (a * aggregator ) service (ctx context.Context , key client.ObjectKey ) (bool , error ) {
151
157
svc := & corev1.Service {}
152
158
err := a .client .Get (ctx , key , svc )
153
159
if err != nil {
0 commit comments