feat(updates,events): Streamline update state changes into one event type only
All checks were successful
/ build (pull_request) Successful in 3m25s
All checks were successful
/ build (pull_request) Successful in 3m25s
This commit is contained in:
parent
1073148eee
commit
5d5db35ea6
4 changed files with 13 additions and 41 deletions
|
@ -240,12 +240,10 @@ action type, which can send notifications to a variety of services like Gotify,
|
||||||
Supported events are the following:
|
Supported events are the following:
|
||||||
|
|
||||||
| Event name | Description |
|
| Event name | Description |
|
||||||
|:--------------------------------|:--------------------------------------------------------------------|
|
|:-----------------------|:--------------------------------------------------------------------|
|
||||||
| `update_created` | An update has been created |
|
| `update_created` | An update has been created |
|
||||||
| `update_updated` | An update has been updated (not necessarily its version attribute!) |
|
| `update_updated` | An update has been updated (not necessarily its version attribute!) |
|
||||||
| `update_updated_state_pending` | An update's state changed to pending |
|
| `update_updated_state` | An update's state changed |
|
||||||
| `update_updated_state_approved` | An update's state changed to approved |
|
|
||||||
| `update_updated_state_ignored` | An update's state changed to ignored |
|
|
||||||
| `update_deleted` | An update has been removed |
|
| `update_deleted` | An update has been removed |
|
||||||
|
|
||||||
For privacy, an action's configuration supports upda's **secrets** vault, which means that before an action is
|
For privacy, an action's configuration supports upda's **secrets** vault, which means that before an action is
|
||||||
|
|
|
@ -2330,9 +2330,7 @@ components:
|
||||||
enum:
|
enum:
|
||||||
- update_created
|
- update_created
|
||||||
- update_updated
|
- update_updated
|
||||||
- update_updated_state_pending
|
- update_updated_state
|
||||||
- update_updated_state_approved
|
|
||||||
- update_updated_state_ignored
|
|
||||||
- update_deleted
|
- update_deleted
|
||||||
createdAt:
|
createdAt:
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -41,9 +41,7 @@ type EventName string
|
||||||
const (
|
const (
|
||||||
EventNameUpdateCreated EventName = "update_created"
|
EventNameUpdateCreated EventName = "update_created"
|
||||||
EventNameUpdateUpdated EventName = "update_updated"
|
EventNameUpdateUpdated EventName = "update_updated"
|
||||||
EventNameUpdateUpdatedPending EventName = "update_updated_state_pending"
|
EventNameUpdateUpdatedState EventName = "update_updated_state"
|
||||||
EventNameUpdateUpdatedApproved EventName = "update_updated_state_approved"
|
|
||||||
EventNameUpdateUpdatedIgnored EventName = "update_updated_state_ignored"
|
|
||||||
EventNameUpdateDeleted EventName = "update_deleted"
|
EventNameUpdateDeleted EventName = "update_deleted"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -45,17 +45,7 @@ func (s *eventService) createUpdateUpdated(old *Update, new *Update) *Event {
|
||||||
if old.State == new.State {
|
if old.State == new.State {
|
||||||
eventName = api.EventNameUpdateUpdated
|
eventName = api.EventNameUpdateUpdated
|
||||||
} else {
|
} else {
|
||||||
switch new.State {
|
eventName = api.EventNameUpdateUpdatedState
|
||||||
case api.UpdateStatePending.Value():
|
|
||||||
eventName = api.EventNameUpdateUpdatedPending
|
|
||||||
break
|
|
||||||
case api.UpdateStateApproved.Value():
|
|
||||||
eventName = api.EventNameUpdateUpdatedApproved
|
|
||||||
break
|
|
||||||
case api.UpdateStateIgnored.Value():
|
|
||||||
eventName = api.EventNameUpdateUpdatedIgnored
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.createWithWarnOnly(eventName, &api.EventPayloadUpdateUpdatedDto{
|
s.createWithWarnOnly(eventName, &api.EventPayloadUpdateUpdatedDto{
|
||||||
|
@ -218,19 +208,7 @@ func (s *eventService) extractPayloadInfo(event *Event) (*eventPayloadInformatio
|
||||||
return nil, newServiceError(General, err)
|
return nil, newServiceError(General, err)
|
||||||
}
|
}
|
||||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
||||||
case api.EventNameUpdateUpdatedApproved.Value():
|
case api.EventNameUpdateUpdatedState.Value():
|
||||||
var p api.EventPayloadUpdateUpdatedDto
|
|
||||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
|
||||||
return nil, newServiceError(General, err)
|
|
||||||
}
|
|
||||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
|
||||||
case api.EventNameUpdateUpdatedPending.Value():
|
|
||||||
var p api.EventPayloadUpdateUpdatedDto
|
|
||||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
|
||||||
return nil, newServiceError(General, err)
|
|
||||||
}
|
|
||||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
|
||||||
case api.EventNameUpdateUpdatedIgnored.Value():
|
|
||||||
var p api.EventPayloadUpdateUpdatedDto
|
var p api.EventPayloadUpdateUpdatedDto
|
||||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
||||||
return nil, newServiceError(General, err)
|
return nil, newServiceError(General, err)
|
||||||
|
|
Loading…
Reference in a new issue