use the new 'RefreshService(name)' instead of 'RefreshServices()' (#487)

This commit is contained in:
Michael Quigley 2023-12-12 10:51:03 -05:00
parent b376683b28
commit 049151a71b
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -8,14 +8,19 @@ import (
"strings"
)
func GetRefreshedService(name string, ctx ziti.Context) (*rest_model.ServiceDetail, bool) {
svc, found := ctx.GetService(name)
func GetRefreshedService(svcName string, ctx ziti.Context) (*rest_model.ServiceDetail, bool) {
svc, found := ctx.GetService(svcName)
if !found {
if err := ctx.RefreshServices(); err != nil {
logrus.Errorf("error refreshing services: %v", err)
svc, err := ctx.RefreshService(svcName)
if err != nil {
logrus.Errorf("error refreshing service '%v': %v", svcName, err)
return nil, false
}
return ctx.GetService(name)
if svc == nil {
logrus.Errorf("service '%v' not found", svcName)
return nil, false
}
return svc, true
}
return svc, found
}