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

feat(events) Implement event for repeated crash #229

Merged
merged 2 commits into from
Oct 11, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* build(deps): bump github.com/golang-jwt/jwt/v4 from 4.0.0 to 4.1.0 [#225](https://github.com/Scalingo/go-scalingo/pull/225)
* chore: use jwt.RegistredClaims instead of jwt.StandardClaims [#227](https://github.com/Scalingo/go-scalingo/pull/227)
* feat(events): implement event for repeated crash [#229](https://github.com/Scalingo/go-scalingo/pull/229)

## 4.14.0

Expand Down
3 changes: 3 additions & 0 deletions events_boilerplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func (e *EventScaleType) TypeDataPtr() interface{} {
func (e *EventCrashType) TypeDataPtr() interface{} {
return &e.TypeData
}
func (e *EventRepeatedCrashType) TypeDataPtr() interface{} {
return &e.TypeData
}
func (e *EventDeploymentType) TypeDataPtr() interface{} {
return &e.TypeData
}
Expand Down
24 changes: 23 additions & 1 deletion events_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
EventScale EventTypeName = "scale"
EventStopApp EventTypeName = "stop_app"
EventCrash EventTypeName = "crash"
EventRepeatedCrash EventTypeName = "repeated_crash"
EventDeployment EventTypeName = "deployment"
EventLinkSCM EventTypeName = "link_scm"
EventUnlinkSCM EventTypeName = "unlink_scm"
Expand Down Expand Up @@ -298,6 +299,27 @@ type EventCrashTypeData struct {
LogsUrl string `json:"logs_url"`
}

type EventRepeatedCrashType struct {
Event
TypeData EventRepeatedCrashTypeData `json:"type_data"`
}

func (ev *EventRepeatedCrashType) String() string {
msg := fmt.Sprintf("container '%v' has crashed repeatedly", ev.TypeData.ContainerType)

if ev.TypeData.CrashLogs != "" {
msg += fmt.Sprintf(" (logs on %s)", ev.TypeData.LogsUrl)
}

return msg
}

type EventRepeatedCrashTypeData struct {
ContainerType string `json:"container_type"`
CrashLogs string `json:"crash_logs"`
LogsUrl string `json:"logs_url"`
}

type EventDeploymentType struct {
Event
TypeData EventDeploymentTypeData `json:"type_data"`
Expand All @@ -309,7 +331,7 @@ func (ev *EventDeploymentType) String() string {

type EventDeploymentTypeData struct {
DeploymentID string `json:"deployment_id"`
Pusher string `json:"pusher"`
Pusher string `json:"pusher"`
GitRef string `json:"git_ref"`
Status string `json:"status"`
Duration int `json:"duration"`
Expand Down