From 7cfad7b027005ef45b936e954ce9bf9ca837668d Mon Sep 17 00:00:00 2001 From: OpenShift Cherrypick Robot Date: Fri, 20 Dec 2024 05:02:33 +0100 Subject: [PATCH] add checking of mandatory fields in pubsub (#393) Signed-off-by: Jack Ding Co-authored-by: Jack Ding --- go.mod | 4 ++-- go.sum | 8 ++++---- .../redhat-cne/sdk-go/pkg/pubsub/pubsub_unmarshal.go | 10 +++++++++- vendor/modules.txt | 4 ++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 60ea3557..d33536aa 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.23.0 github.com/prometheus/client_golang v1.14.0 - github.com/redhat-cne/rest-api v1.22.1 - github.com/redhat-cne/sdk-go v1.22.2 + github.com/redhat-cne/rest-api v1.22.2 + github.com/redhat-cne/sdk-go v1.22.3 github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.1 golang.org/x/net v0.23.0 diff --git a/go.sum b/go.sum index 44a275cf..99fd7571 100644 --- a/go.sum +++ b/go.sum @@ -419,10 +419,10 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 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/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/redhat-cne/rest-api v1.22.1 h1:XcYoTNW5zzNzski2IxOafJcpFqnWjiPxtmN4xtHZ3QI= -github.com/redhat-cne/rest-api v1.22.1/go.mod h1:2FnyhGOLshlEqZm2xZabBfXXp32v1Fc6VsWvK9Cqt6g= -github.com/redhat-cne/sdk-go v1.22.2 h1:4pyXsvnNGY+n7LITmppoEUgYM+4uDRV/jpdHtjgFn9c= -github.com/redhat-cne/sdk-go v1.22.2/go.mod h1:qeir05dwTscLvqGCIoQPCUM6HUoVmhR7521nXn28utA= +github.com/redhat-cne/rest-api v1.22.2 h1:L1gYpjdUg8NTb0tNBwrsA3EK++wnmpUhB+aunEzLqO0= +github.com/redhat-cne/rest-api v1.22.2/go.mod h1:2AmXrQWYJ//l+AfshOaP2YlWH4zgXgT0CN0i6NmZEVQ= +github.com/redhat-cne/sdk-go v1.22.3 h1:XiXnZf2c7CwWW3MAdnGYEj1sKTWdXGCUjECL6U69sqc= +github.com/redhat-cne/sdk-go v1.22.3/go.mod h1:qeir05dwTscLvqGCIoQPCUM6HUoVmhR7521nXn28utA= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= diff --git a/vendor/github.com/redhat-cne/sdk-go/pkg/pubsub/pubsub_unmarshal.go b/vendor/github.com/redhat-cne/sdk-go/pkg/pubsub/pubsub_unmarshal.go index dd95e7db..c3a96184 100644 --- a/vendor/github.com/redhat-cne/sdk-go/pkg/pubsub/pubsub_unmarshal.go +++ b/vendor/github.com/redhat-cne/sdk-go/pkg/pubsub/pubsub_unmarshal.go @@ -15,6 +15,7 @@ package pubsub import ( + "fmt" "io" "sync" @@ -91,7 +92,14 @@ func readJSONFromIterator(out *PubSub, iterator *jsoniter.Iterator) error { if iterator.Error != nil { return iterator.Error } - + // Skip checking EndPointURI here since it is not used in http transport. + // Check EndPointURI in O-RAN REST API handler + //if endpointUri == "" { + // return fmt.Errorf("mandatory field EndPointURI is not set") + //} + if resource == "" { + return fmt.Errorf("mandatory field ResourceAddress is not set") + } out.SetID(id) out.SetEndpointURI(endpointUri) //nolint:errcheck out.SetURILocation(uriLocation) //nolint:errcheck diff --git a/vendor/modules.txt b/vendor/modules.txt index f9658395..9813dc0f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -184,13 +184,13 @@ 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/rest-api v1.22.1 +# github.com/redhat-cne/rest-api v1.22.2 ## explicit; go 1.22 github.com/redhat-cne/rest-api github.com/redhat-cne/rest-api/pkg/localmetrics github.com/redhat-cne/rest-api/pkg/restclient github.com/redhat-cne/rest-api/v2 -# github.com/redhat-cne/sdk-go v1.22.2 +# github.com/redhat-cne/sdk-go v1.22.3 ## explicit; go 1.22 github.com/redhat-cne/sdk-go/pkg/channel github.com/redhat-cne/sdk-go/pkg/common