@@ -261,6 +261,21 @@ func (a *APIRouter) GetApplicationHistory(w http.ResponseWriter, r *http.Request
261
261
http .Error (w , fmt .Sprintf ("failed to get list of application, err: %v" , err ), http .StatusBadRequest )
262
262
return
263
263
}
264
+ // At this point, if there are no apps as generated by KAM, then check if there are any
265
+ // apps in general, where the app name is the environment name. Users aren't expected to use both
266
+ // KAM generated apps and custom apps in their GitOps repo.
267
+ if len (appList .Items ) == 0 {
268
+ listOptions = nil
269
+ listOptions = append (listOptions , ctrlclient .InNamespace ("" ), ctrlclient.MatchingFields {
270
+ "metadata.name" : fmt .Sprintf ("%s" , envName ),
271
+ })
272
+ err = a .k8sClient .List (r .Context (), appList , listOptions ... )
273
+ if err != nil {
274
+ log .Printf ("ERROR: failed to get application list: %v" , err )
275
+ http .Error (w , fmt .Sprintf ("failed to get list of application, err: %v" , err ), http .StatusBadRequest )
276
+ return
277
+ }
278
+ }
264
279
265
280
for _ , a := range appList .Items {
266
281
if a .Spec .Source .RepoURL == parsedRepoURL .String () {
@@ -285,8 +300,7 @@ func (a *APIRouter) GetApplicationHistory(w http.ResponseWriter, r *http.Request
285
300
}
286
301
commitInfo , err := a .getCommitInfo (app .Name , revision )
287
302
if err != nil {
288
- log .Printf ("ERROR: failed to retrieve revision metadata for app %s: %v" , appName , err )
289
- http .Error (w , fmt .Sprintf ("failed to retrieve revision metadata for app %s, err: %v" , appName , err ), http .StatusBadRequest )
303
+ log .Printf ("WARNING: failed to retrieve revision metadata for app %s: %v. The app might be unsynced." , appName , err )
290
304
}
291
305
hist := envHistory {
292
306
Author : commitInfo ["author" ],
@@ -337,6 +351,23 @@ func (a *APIRouter) GetApplicationDetails(w http.ResponseWriter, r *http.Request
337
351
return
338
352
}
339
353
354
+ // At this point, if there are no apps as generated by KAM, then check if there are any
355
+ // apps in general, where the app name is the environment name. Users aren't expected to use both
356
+ // KAM generated apps and custom apps in their GitOps repo.
357
+ // We should error out if we don't have the environments as applications
358
+ if len (appList .Items ) == 0 {
359
+ listOptions = nil
360
+ listOptions = append (listOptions , ctrlclient .InNamespace ("" ), ctrlclient.MatchingFields {
361
+ "metadata.name" : fmt .Sprintf ("%s" , envName ),
362
+ })
363
+ err = a .k8sClient .List (r .Context (), appList , listOptions ... )
364
+ if err != nil {
365
+ log .Printf ("ERROR: failed to get application list: %v" , err )
366
+ http .Error (w , fmt .Sprintf ("failed to get list of application, err: %v" , err ), http .StatusBadRequest )
367
+ return
368
+ }
369
+ }
370
+
340
371
for _ , a := range appList .Items {
341
372
if a .Spec .Source .RepoURL == parsedRepoURL .String () {
342
373
app = & a
@@ -359,9 +390,7 @@ func (a *APIRouter) GetApplicationDetails(w http.ResponseWriter, r *http.Request
359
390
360
391
commitInfo , err := a .getCommitInfo (app .Name , revision )
361
392
if err != nil {
362
- log .Printf ("ERROR: failed to retrieve revision metadata for app %s: %v" , appName , err )
363
- http .Error (w , fmt .Sprintf ("failed to retrieve revision metadata for app %s, err: %v" , appName , err ), http .StatusBadRequest )
364
- return
393
+ log .Printf ("Warning: failed to retrieve revision metadata for app %s: %v. The app might be unsynced" , appName , err )
365
394
}
366
395
367
396
revisionMeta := RevisionMeta {
@@ -393,9 +422,13 @@ func (a *APIRouter) GetApplicationDetails(w http.ResponseWriter, r *http.Request
393
422
Status : string (aResource .Status ),
394
423
})
395
424
case kindSecret , kindSealedSecret :
425
+ secretHealth := ""
426
+ if aResource .Health != nil {
427
+ secretHealth = string (aResource .Health .Status )
428
+ }
396
429
envResources [kindSecret ] = append (envResources [kindSecret ], envHealthResource {
397
430
Name : aResource .Name ,
398
- Health : string ( aResource . Health . Status ) ,
431
+ Health : secretHealth ,
399
432
Status : string (aResource .Status ),
400
433
})
401
434
case kindRoute :
0 commit comments