Skip to content

Commit

Permalink
Revert "event source was lost when converting cloud native events to …
Browse files Browse the repository at this point in the history
…events. (#39)"

This reverts commit ab7b206.
  • Loading branch information
aneeshkp authored Mar 24, 2022
1 parent ab7b206 commit 5d80083
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
5 changes: 1 addition & 4 deletions pkg/event/event_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (e *Event) NewCloudEvent(ps *pubsub.PubSub) (*cloudevent.Event, error) {
ce.SetTime(e.GetTime())
ce.SetType(e.Type)
ce.SetDataContentType(cloudevent.ApplicationJSON)
ce.SetSubject(e.Source) // subject is set to source of the event object
ce.SetSource(ps.Resource) // bus address
ce.SetSpecVersion(cloudevent.VersionV03)
ce.SetID(uuid.New().String())
Expand All @@ -51,9 +50,7 @@ func (e *Event) GetCloudNativeEvents(ce *cloudevent.Event) (err error) {
e.SetDataContentType(ApplicationJSON)
e.SetTime(ce.Time())
e.SetType(ce.Type())
e.SetSource(ce.Subject())
e.SetSource(ce.Source())
e.SetData(data)
e.SetID(ce.ID())

return
}
6 changes: 1 addition & 5 deletions pkg/event/event_ce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func TestEvent_NewCloudEvent(t *testing.T) {
e.SetType(_type)
e.SetSource(_source)
e.SetData(data)
e.SetID(id)
return &e
}(),
cnePubsub: &pubsub,
Expand All @@ -90,7 +89,6 @@ func TestEvent_NewCloudEvent(t *testing.T) {
_ = e.SetData(ce.ApplicationJSON, data)
e.SetTime(now.Time)
e.SetSource(pubsub.GetResource())
e.SetSubject(_source)
e.SetID(id)
return &e
}(),
Expand Down Expand Up @@ -126,7 +124,6 @@ func TestEvent_GetCloudNativeEvents(t *testing.T) {
_ = e.SetData(ce.ApplicationJSON, data)
e.SetTime(now.Time)
e.SetSource(pubsub.GetResource())
e.SetSubject(_source)
e.SetID(id)
return &e
}(),
Expand All @@ -135,9 +132,8 @@ func TestEvent_GetCloudNativeEvents(t *testing.T) {
e.SetDataContentType(cneevent.ApplicationJSON)
e.SetTime(now.Time)
e.SetType(_type)
e.SetSource(_source)
e.SetSource(pubsub.GetResource())
e.SetData(data)
e.SetID(id)
return &e
}(),
},
Expand Down
9 changes: 2 additions & 7 deletions pkg/event/redfish/event_ce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var (
uriLocation = "http://localhost:8089/api/cloudNotifications/v1/subscriptions/da42fb86-819e-47c5-84a3-5512d5a3c732"
endPointURI = "http://localhost:9089/event"
resource = "/cluster/node/nodename/redfish/event"
_source = "/cluster/node/nodename/redfish/event/fan"
_type = string(redfish.Alert)
version = "v1"
id = uuid.New().String()
Expand Down Expand Up @@ -99,9 +98,8 @@ func TestEvent_NewCloudEvent(t *testing.T) {
e.SetDataContentType(cneevent.ApplicationJSON)
e.SetTime(now.Time)
e.SetType(_type)
e.SetSource(_source)
e.SetSource(pubsub.GetResource())
e.SetData(data)
e.SetID(id)
return &e
}(),
cnePubsub: &pubsub,
Expand All @@ -112,7 +110,6 @@ func TestEvent_NewCloudEvent(t *testing.T) {
_ = e.SetData(ce.ApplicationJSON, data)
e.SetTime(now.Time)
e.SetSource(pubsub.GetResource())
e.SetSubject(_source)
e.SetID(id)
return &e
}(),
Expand Down Expand Up @@ -148,7 +145,6 @@ func TestEvent_GetCloudNativeEvents(t *testing.T) {
_ = e.SetData(ce.ApplicationJSON, data)
e.SetTime(now.Time)
e.SetSource(pubsub.GetResource())
e.SetSubject(_source)
e.SetID(id)
return &e
}(),
Expand All @@ -157,9 +153,8 @@ func TestEvent_GetCloudNativeEvents(t *testing.T) {
e.SetDataContentType(cneevent.ApplicationJSON)
e.SetTime(now.Time)
e.SetType(_type)
e.SetSource(_source)
e.SetSource(pubsub.GetResource())
e.SetData(data)
e.SetID(id)
return &e
}(),
},
Expand Down
1 change: 0 additions & 1 deletion v1/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func GetCloudNativeEvents(ce cloudevents.Event) (e event.Event, err error) {
e.SetTime(ce.Time())
e.SetType(ce.Type())
e.SetSource(ce.Source())
e.SetID(ce.ID())
e.SetData(data)
return
}

0 comments on commit 5d80083

Please sign in to comment.