Support services in app xray

mine
Raphaël Pinson 2020-12-09 23:32:14 +01:00
parent f106692934
commit 7f18ce7031
No known key found for this signature in database
GPG Key ID: A1AAC49E10CB2A8D
1 changed files with 15 additions and 4 deletions

View File

@ -41,14 +41,15 @@ func (a *Application) Render(ctx context.Context, ns string, o interface{}) erro
var ar ApplicationResource
var dp Deployment
var svc Service
f, ok := ctx.Value(internal.KeyFactory).(dao.Factory)
if !ok {
return fmt.Errorf("Expecting a factory but got %T", ctx.Value(internal.KeyFactory))
}
for _, res := range app.Status.Resources {
gvr := gvkToGvr(res.GroupVersionKind())
switch gvr.String() {
case "apps/v1/deployments":
f, ok := ctx.Value(internal.KeyFactory).(dao.Factory)
if !ok {
return fmt.Errorf("Expecting a factory but got %T", ctx.Value(internal.KeyFactory))
}
d, err := f.Get("apps/v1/deployments", fmt.Sprintf("%s/%s", res.Namespace, res.Name), false, labels.Everything())
if err != nil {
return err
@ -58,6 +59,16 @@ func (a *Application) Render(ctx context.Context, ns string, o interface{}) erro
return err
}
case "v1/services":
d, err := f.Get("v1/services", fmt.Sprintf("%s/%s", res.Namespace, res.Name), false, labels.Everything())
if err != nil {
return err
}
if err := svc.Render(ctx, app.Namespace, d); err != nil {
return err
}
default:
if err := ar.Render(ctx, app.Namespace, res); err != nil {
return err