controller config structure improvements

This commit is contained in:
Michael Quigley
2022-10-19 13:20:47 -04:00
parent c1f481e416
commit e2d3208165
14 changed files with 81 additions and 83 deletions

View File

@@ -26,29 +26,31 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
logrus.Errorf("error finding services for environment '%v': %v", env.ZId, err)
return metadata.NewOverviewInternalServerError()
}
es := &rest_model_zrok.EnvironmentServices{
Environment: &rest_model_zrok.Environment{
Active: env.Active,
Address: env.Address,
CreatedAt: env.CreatedAt.String(),
Description: env.Description,
Host: env.Host,
UpdatedAt: env.UpdatedAt.String(),
ZID: env.ZId,
},
if env.Active {
es := &rest_model_zrok.EnvironmentServices{
Environment: &rest_model_zrok.Environment{
Address: env.Address,
CreatedAt: env.CreatedAt.String(),
Description: env.Description,
Host: env.Host,
UpdatedAt: env.UpdatedAt.String(),
ZID: env.ZId,
},
}
for _, svc := range svcs {
if svc.Active {
es.Services = append(es.Services, &rest_model_zrok.Service{
CreatedAt: svc.CreatedAt.String(),
Frontend: svc.Frontend,
Backend: svc.Backend,
UpdatedAt: svc.UpdatedAt.String(),
ZID: svc.ZId,
Name: svc.Name,
})
}
}
out = append(out, es)
}
for _, svc := range svcs {
es.Services = append(es.Services, &rest_model_zrok.Service{
Active: svc.Active,
CreatedAt: svc.CreatedAt.String(),
Frontend: svc.Frontend,
Backend: svc.Backend,
UpdatedAt: svc.UpdatedAt.String(),
ZID: svc.ZId,
Name: svc.Name,
})
}
out = append(out, es)
}
return metadata.NewOverviewOK().WithPayload(out)
}