diff --git a/go.mod b/go.mod index 721f30b..ec49cca 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.0 github.com/prometheus/client_golang v1.14.0 - github.com/redhat-cne/sdk-go v1.0.1-0.20240716153735-19a18fd38ee6 + github.com/redhat-cne/sdk-go v1.0.1-0.20240730145324-f9bea0ca99c7 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.8.0 golang.org/x/net v0.7.0 diff --git a/go.sum b/go.sum index 5b07b28..15c6141 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/redhat-cne/sdk-go v1.0.1-0.20240716153735-19a18fd38ee6 h1:TYW1M1qUC51tN5nIy3cRwNFDn/M7E81jbtIthzyTwQ8= -github.com/redhat-cne/sdk-go v1.0.1-0.20240716153735-19a18fd38ee6/go.mod h1:q9LxxPbK1tGpDbQm/KIPujqdP0bK1hhuHrIXV3vuUrM= +github.com/redhat-cne/sdk-go v1.0.1-0.20240730145324-f9bea0ca99c7 h1:Ef4rxp3TCCFcCmkmPKFhFMartnms9OnNrPF0a/DbbFo= +github.com/redhat-cne/sdk-go v1.0.1-0.20240730145324-f9bea0ca99c7/go.mod h1:q9LxxPbK1tGpDbQm/KIPujqdP0bK1hhuHrIXV3vuUrM= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= diff --git a/v2/routes.go b/v2/routes.go index 78ace03..f0627fc 100644 --- a/v2/routes.go +++ b/v2/routes.go @@ -427,6 +427,7 @@ func (s *Server) getCurrentState(w http.ResponseWriter, r *http.Request) { respondWithError(w, "resourceAddress can not be empty") return } + //identify publisher or subscriber is asking for status var sub *pubsub.PubSub if len(s.pubSubAPI.GetSubscriptions()) > 0 { @@ -449,6 +450,12 @@ func (s *Server) getCurrentState(w http.ResponseWriter, r *http.Request) { } if sub == nil { + respondWithStatusCode(w, http.StatusNotFound, fmt.Sprintf("subscriptions not found for %s", resourceAddress)) + return + } + + eventSubscribers := s.subscriberAPI.GetClientIDAddressByResource(resourceAddress) + if len(eventSubscribers) == 0 { respondWithStatusCode(w, http.StatusNotFound, fmt.Sprintf("subscription not found for %s", resourceAddress)) return } @@ -456,6 +463,7 @@ func (s *Server) getCurrentState(w http.ResponseWriter, r *http.Request) { if !strings.HasPrefix(resourceAddress, "/") { resourceAddress = fmt.Sprintf("/%s", resourceAddress) } + // this is placeholder not sending back to report out := channel.DataChan{ Address: resourceAddress, diff --git a/vendor/github.com/redhat-cne/sdk-go/v1/subscriber/subscriber.go b/vendor/github.com/redhat-cne/sdk-go/v1/subscriber/subscriber.go index 20f9c1d..64119f6 100644 --- a/vendor/github.com/redhat-cne/sdk-go/v1/subscriber/subscriber.go +++ b/vendor/github.com/redhat-cne/sdk-go/v1/subscriber/subscriber.go @@ -276,7 +276,7 @@ func (p *API) GetClientIDByResource(resource string) (clientIDs []uuid.UUID) { defer p.SubscriberStore.RUnlock() for _, subs := range p.SubscriberStore.Store { for _, sub := range subs.SubStore.Store { - if sub.GetResource() == resource { + if strings.Contains(sub.GetResource(), resource) { clientIDs = append(clientIDs, subs.ClientID) } } diff --git a/vendor/modules.txt b/vendor/modules.txt index c846c50..56a2ad1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -71,7 +71,7 @@ github.com/prometheus/common/model github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util -# github.com/redhat-cne/sdk-go v1.0.1-0.20240716153735-19a18fd38ee6 +# github.com/redhat-cne/sdk-go v1.0.1-0.20240730145324-f9bea0ca99c7 ## explicit; go 1.22 github.com/redhat-cne/sdk-go/pkg/channel github.com/redhat-cne/sdk-go/pkg/common