Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update go and sdk-go #91

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: '1.19'
go-version: '1.21'
- name: tidy
run: go mod tidy
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.2.0
uses: golangci/golangci-lint-action@v4
with:
# Caching conflicts happen in GHA, so just disable for now
skip-pkg-cache: true
skip-build-cache: true
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.48.0
version: v1.54
args: --timeout 3m0s
unit-tests:
name: Unit Tests
Expand All @@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: '1.19'
go-version: '1.21'
- name: tidy
run: go mod tidy
- name: Run Test Scripts
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/redhat-cne/sdk-go

go 1.19
go 1.21

require (
github.com/Azure/go-amqp v0.17.5
github.com/cloudevents/sdk-go/protocol/amqp/v2 v2.13.0
github.com/cloudevents/sdk-go/v2 v2.13.0
github.com/cloudevents/sdk-go/protocol/amqp/v2 v2.15.2
github.com/cloudevents/sdk-go/v2 v2.15.2
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.3.0
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.0
github.com/json-iterator/go v1.1.12
github.com/pkg/errors v0.9.1
Expand Down
15 changes: 9 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cloudevents/sdk-go/protocol/amqp/v2 v2.13.0 h1:e0gIb0myoP+wqm0lAPuMGf69MclyjNum8ZTqdIqmEvs=
github.com/cloudevents/sdk-go/protocol/amqp/v2 v2.13.0/go.mod h1:GDZdtEDlsTA/xCEpLxWoQitCLWnFOuo0eu+ifeF4XJs=
github.com/cloudevents/sdk-go/v2 v2.13.0 h1:2zxDS8RyY1/wVPULGGbdgniGXSzLaRJVl136fLXGsYw=
github.com/cloudevents/sdk-go/v2 v2.13.0/go.mod h1:xDmKfzNjM8gBvjaF8ijFjM1VYOVUEeUfapHMUX1T5To=
github.com/cloudevents/sdk-go/protocol/amqp/v2 v2.15.2 h1:OhJ1zLIEPqyw4leCmqgEKUilwE8HA6JkryP1ptdoPLU=
github.com/cloudevents/sdk-go/protocol/amqp/v2 v2.15.2/go.mod h1:C0mhM7xabBtXpJx7qHE4uewN+KRaC2WHf8vCGP+7mWU=
github.com/cloudevents/sdk-go/v2 v2.15.2 h1:54+I5xQEnI73RBhWHxbI1XJcqOFOVJN85vb41+8mHUc=
github.com/cloudevents/sdk-go/v2 v2.15.2/go.mod h1:lL7kSWAE/V8VI4Wh0jbL2v/jvqsm6tjmaQBSvxcv4uE=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -24,8 +24,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down Expand Up @@ -66,6 +66,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
Expand All @@ -77,13 +78,15 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion pkg/event/redfish/event_marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

// WriteJSONEvent ...
func WriteJSONEvent(in *Event, writer io.Writer, stream *jsoniter.Stream) error {
func WriteJSONEvent(in *Event, _ io.Writer, stream *jsoniter.Stream) error {
stream.WriteObjectStart()

// Let's write the body
Expand Down
1 change: 0 additions & 1 deletion pkg/protocol/amqp/amqp.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ type Router struct {
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")

func init() {
rand.Seed(time.Now().UnixNano())
}

// RandStringRunes ... for status bus address
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func (h *Server) SendTo(wg *sync.WaitGroup, clientID uuid.UUID, clientAddress, r
}

// NewClient ...
func (h *Server) NewClient(host string, connOption []httpP.Option) (httpClient.Client, error) {
func (h *Server) NewClient(host string, _ []httpP.Option) (httpClient.Client, error) {
//--
c, err2 := cloudevents.NewClientHTTP(cloudevents.WithTarget(host))
if err2 != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,6 @@ func TestStatusWithOutSubscription(t *testing.T) {
close(closeCh)
}

func TestTeardown(t *testing.T) {
func TestTeardown(*testing.T) {
_ = os.Remove(fmt.Sprintf("./%s.json", clientClientID.String()))
}
10 changes: 5 additions & 5 deletions pkg/util/clock/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,30 +287,30 @@ func (i *IntervalClock) Since(ts time.Time) time.Duration {

// After is currently unimplemented, will panic.
// TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) After(d time.Duration) <-chan time.Time {
func (*IntervalClock) After(time.Duration) <-chan time.Time {
panic("IntervalClock doesn't implement After")
}

// AfterFunc is currently unimplemented, will panic.
// TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) AfterFunc(d time.Duration, cb func()) Timer {
func (*IntervalClock) AfterFunc(time.Duration, func()) Timer {
panic("IntervalClock doesn't implement AfterFunc")
}

// NewTimer is currently unimplemented, will panic.
// TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTimer(d time.Duration) Timer {
func (*IntervalClock) NewTimer(time.Duration) Timer {
panic("IntervalClock doesn't implement NewTimer")
}

// NewTicker is currently unimplemented, will panic.
// TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTicker(d time.Duration) Ticker {
func (*IntervalClock) NewTicker(time.Duration) Ticker {
panic("IntervalClock doesn't implement NewTicker")
}

// Sleep is currently unimplemented; will panic.
func (*IntervalClock) Sleep(d time.Duration) {
func (*IntervalClock) Sleep(time.Duration) {
panic("IntervalClock doesn't implement Sleep")
}

Expand Down
6 changes: 3 additions & 3 deletions v1/amqp/amqp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ var (
s = "amqp://localhost:5672"
in = make(chan *channel.DataChan)
out = make(chan *channel.DataChan)
close = make(chan struct{})
closeCh = make(chan struct{})
timeout = 1 * time.Second
globalInstance, _ = api.GetAMQPInstance(s, in, out, close, timeout)
globalInstance, _ = api.GetAMQPInstance(s, in, out, closeCh, timeout)
)

func TestAPI_GetAPIInstance(t *testing.T) {
localInstance, err := api.GetAMQPInstance(s, in, out, close, timeout)
localInstance, err := api.GetAMQPInstance(s, in, out, closeCh, timeout)
if err != nil {
t.Skipf("ampq.Dial(%#v): %v", localInstance, err)
}
Expand Down
17 changes: 3 additions & 14 deletions v1/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,11 @@ func (p *API) GetSubscriptionsFromFile() ([]byte, error) {

// deleteAllFromFile deletes publisher and subscription information from the file system
func deleteAllFromFile(filePath string) error {
//open file
if err := os.WriteFile(filePath, []byte{}, 0666); err != nil {
return err
}
return nil
return os.WriteFile(filePath, []byte{}, 0666)
}

// DeleteFromFile is used to delete subscription from the file system
func deleteFromFile(sub pubsub.PubSub, filePath string) error {
//open file
file, err := os.OpenFile(filePath, os.O_CREATE|os.O_RDWR, 0644)
if err != nil {
return err
Expand Down Expand Up @@ -336,10 +331,7 @@ func deleteFromFile(sub pubsub.PubSub, filePath string) error {
log.Errorf("error deleting sub %v", err)
return err
}
if err := os.WriteFile(filePath, newBytes, 0666); err != nil {
return err
}
return nil
return os.WriteFile(filePath, newBytes, 0666)
}

// loadFromFile is used to read subscription/publisher from the file system
Expand Down Expand Up @@ -386,8 +378,5 @@ func writeToFile(sub pubsub.PubSub, filePath string) error {
return err
}
log.Infof("persisting following contents %s to a file %s\n", string(newBytes), filePath)
if err := os.WriteFile(filePath, newBytes, 0666); err != nil {
return err
}
return nil
return os.WriteFile(filePath, newBytes, 0666)
}
2 changes: 1 addition & 1 deletion v1/pubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func clean() {
_ = globalInstance.DeleteAllSubscriptions()
_ = globalInstance.DeleteAllPublishers()
}
func TestTeardown(t *testing.T) {
func TestTeardown(*testing.T) {
_ = os.Remove("./pub.json")
_ = os.Remove("./sub.json")
}
15 changes: 3 additions & 12 deletions v1/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,7 @@ func (p *API) SubscriberMarkedForDelete(clientID uuid.UUID) bool {

// deleteAllFromFile deletes publisher and subscriptionOne information from the file system
func deleteAllFromFile(filePath string) error {
if err := os.Remove(filePath); err != nil {
return err
}
return nil
return os.Remove(filePath)
}

// DeleteFromFile is used to delete subscriptionOne from the file system
Expand Down Expand Up @@ -404,10 +401,7 @@ func deleteFromFile(sub pubsub.PubSub, filePath string) error {
log.Errorf("error deleting sub %v", err)
return err
}
if err := os.WriteFile(filePath, newBytes, 0666); err != nil {
return err
}
return nil
return os.WriteFile(filePath, newBytes, 0666)
}

// loadFromFile is used to read subscriptionOne/publisher from the file system
Expand Down Expand Up @@ -475,10 +469,7 @@ func writeToFile(subscriberClient subscriber.Subscriber, filePath string) error
return err
}
log.Infof("persisting following contents %s to a file %s\n", string(newBytes), filePath)
if err := os.WriteFile(filePath, newBytes, 0666); err != nil {
return err
}
return nil
return os.WriteFile(filePath, newBytes, 0666)
}

func hasDir(path string) {
Expand Down
2 changes: 1 addition & 1 deletion v1/subscriber/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,6 @@ func clean() {
_ = globalInstance.DeleteAllSubscriptions(clientID)
}

func TestTeardown(t *testing.T) {
func TestTeardown(*testing.T) {
_ = os.Remove(fmt.Sprintf("%s/%s.json", storePath, clientID))
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions vendor/github.com/cloudevents/sdk-go/v2/alias.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions vendor/github.com/cloudevents/sdk-go/v2/binding/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading