@@ -393,15 +393,15 @@ func (s *Service) GetDetectorsForHosts(hosts []string) ([]string, error) {
393393 return detectorSlice , nil
394394}
395395
396- func (s * Service ) GetCRUCardsForHost (hostname string ) (string , error ) {
396+ func (s * Service ) GetCRUCardsForHost (hostname string ) ([] string , error ) {
397397 s .logMethod ()
398398
399399 if cSrc , ok := s .src .(* cfgbackend.ConsulSource ); ok {
400400 var cards map [string ]Card
401401 var serials []string
402402 cfgCards , err := cSrc .Get (filepath .Join ("o2/hardware" , "flps" , hostname , "cards" ))
403403 if err != nil {
404- return "" , err
404+ return nil , err
405405 }
406406 json .Unmarshal ([]byte (cfgCards ), & cards )
407407 unique := make (map [string ]bool )
@@ -411,17 +411,13 @@ func (s *Service) GetCRUCardsForHost(hostname string) (string, error) {
411411 serials = append (serials , card .Serial )
412412 }
413413 }
414- bytes , err := json .Marshal (serials )
415- if err != nil {
416- return "" , err
417- }
418- return string (bytes ), nil
414+ return serials , nil
419415 } else {
420- return "" , errors .New ("runtime KV not supported with file backend" )
416+ return nil , errors .New ("runtime KV not supported with file backend" )
421417 }
422418}
423419
424- func (s * Service ) GetEndpointsForCRUCard (hostname , cardSerial string ) (string , error ) {
420+ func (s * Service ) GetEndpointsForCRUCard (hostname , cardSerial string ) ([] string , error ) {
425421 s .logMethod ()
426422
427423 log .WithPrefix ("rpcserver" ).
@@ -433,23 +429,23 @@ func (s *Service) GetEndpointsForCRUCard(hostname, cardSerial string) (string, e
433429
434430 if cSrc , ok := s .src .(* cfgbackend.ConsulSource ); ok {
435431 var cards map [string ]Card
436- var endpoints string
432+ var endpoints [] string
437433 cfgCards , err := cSrc .Get (filepath .Join ("o2/hardware" , "flps" , hostname , "cards" ))
438434 if err != nil {
439- return "" , err
435+ return nil , err
440436 }
441437 err = json .Unmarshal ([]byte (cfgCards ), & cards )
442438 if err != nil {
443- return "" , err
439+ return nil , err
444440 }
445441 for _ , card := range cards {
446442 if card .Serial == cardSerial {
447- endpoints = endpoints + card .Endpoint + " "
443+ endpoints = append ( endpoints , card .Endpoint )
448444 }
449445 }
450446 return endpoints , nil
451447 } else {
452- return "" , errors .New ("runtime KV not supported with file backend" )
448+ return nil , errors .New ("runtime KV not supported with file backend" )
453449 }
454450}
455451
0 commit comments