feat(actions): introduce an explicit event for changes of an update's version
This commit is contained in:
parent
0277868c1b
commit
c0928c4128
4 changed files with 25 additions and 14 deletions
13
README.md
13
README.md
|
@ -239,12 +239,13 @@ 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` | An update's state changed |
|
| `update_updated_state` | An update's state changed |
|
||||||
| `update_deleted` | An update has been removed |
|
| `update_updated_version` | An update's version changed |
|
||||||
|
| `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
|
||||||
triggered, any occurrence of `<SECRET>SECRET_KEY</SECRET>` is properly replaced by the value of the `SECRET_KEY` defined
|
triggered, any occurrence of `<SECRET>SECRET_KEY</SECRET>` is properly replaced by the value of the `SECRET_KEY` defined
|
||||||
|
|
|
@ -2331,6 +2331,7 @@ components:
|
||||||
- update_created
|
- update_created
|
||||||
- update_updated
|
- update_updated
|
||||||
- update_updated_state
|
- update_updated_state
|
||||||
|
- update_updated_version
|
||||||
- update_deleted
|
- update_deleted
|
||||||
createdAt:
|
createdAt:
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -39,10 +39,11 @@ func (e WebhookType) Value() string {
|
||||||
type EventName string
|
type EventName string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
EventNameUpdateCreated EventName = "update_created"
|
EventNameUpdateCreated EventName = "update_created"
|
||||||
EventNameUpdateUpdated EventName = "update_updated"
|
EventNameUpdateUpdated EventName = "update_updated"
|
||||||
EventNameUpdateUpdatedState EventName = "update_updated_state"
|
EventNameUpdateUpdatedState EventName = "update_updated_state"
|
||||||
EventNameUpdateDeleted EventName = "update_deleted"
|
EventNameUpdateUpdatedVersion EventName = "update_updated_version"
|
||||||
|
EventNameUpdateDeleted EventName = "update_deleted"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *EventName) Scan(value interface{}) error {
|
func (e *EventName) Scan(value interface{}) error {
|
||||||
|
|
|
@ -40,14 +40,16 @@ func (s *eventService) createUpdateUpdated(old *Update, new *Update) *Event {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventName api.EventName
|
eventName := api.EventNameUpdateUpdated
|
||||||
|
|
||||||
if old.State == new.State {
|
if old.State != new.State {
|
||||||
eventName = api.EventNameUpdateUpdated
|
|
||||||
} else {
|
|
||||||
eventName = api.EventNameUpdateUpdatedState
|
eventName = api.EventNameUpdateUpdatedState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if old.Version != new.Version {
|
||||||
|
eventName = api.EventNameUpdateUpdatedVersion
|
||||||
|
}
|
||||||
|
|
||||||
s.createWithWarnOnly(eventName, &api.EventPayloadUpdateUpdatedDto{
|
s.createWithWarnOnly(eventName, &api.EventPayloadUpdateUpdatedDto{
|
||||||
ID: new.ID,
|
ID: new.ID,
|
||||||
Application: new.Application,
|
Application: new.Application,
|
||||||
|
@ -214,6 +216,12 @@ 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.EventNameUpdateUpdatedVersion.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.EventNameUpdateUpdated.Value():
|
case api.EventNameUpdateUpdated.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 {
|
||||||
|
|
Loading…
Reference in a new issue