Send decline events back to UI (#680)

and remove unused code
This commit is contained in:
Anbraten 2022-01-09 03:47:31 +01:00 committed by GitHub
parent ce222dfe0e
commit 5e595978fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 16 deletions

View file

@ -269,7 +269,7 @@ func DeleteBuild(c *gin.Context) {
_ = c.AbortWithError(http.StatusInternalServerError, err)
return
}
if err := publishToTopic(c, killedBuild, repo, model.Canceled); err != nil {
if err := publishToTopic(c, killedBuild, repo); err != nil {
log.Error().Err(err).Msg("publishToTopic")
}
}
@ -366,6 +366,10 @@ func PostDecline(c *gin.Context) {
log.Error().Err(err).Msg("updateBuildStatus")
}
if err := publishToTopic(c, build, repo); err != nil {
log.Error().Err(err).Msg("publishToTopic")
}
c.JSON(200, build)
}
@ -609,7 +613,7 @@ func startBuild(ctx context.Context, store store.Store, build *model.Build, user
return nil, err
}
if err := publishToTopic(ctx, build, repo, model.Enqueued); err != nil {
if err := publishToTopic(ctx, build, repo); err != nil {
log.Error().Err(err).Msg("publishToTopic")
}

View file

@ -245,7 +245,7 @@ func PostHook(c *gin.Context) {
}
if build.Status == model.StatusBlocked {
if err := publishToTopic(c, build, repo, model.Enqueued); err != nil {
if err := publishToTopic(c, build, repo); err != nil {
log.Error().Err(err).Msg("publishToTopic")
}
@ -346,7 +346,7 @@ func findOrPersistPipelineConfig(store store.Store, build *model.Build, remoteYa
}
// publishes message to UI clients
func publishToTopic(c context.Context, build *model.Build, repo *model.Repo, event model.EventType) (err error) {
func publishToTopic(c context.Context, build *model.Build, repo *model.Repo) (err error) {
message := pubsub.Message{
Labels: map[string]string{
"repo": repo.FullName,
@ -359,7 +359,6 @@ func publishToTopic(c context.Context, build *model.Build, repo *model.Repo, eve
}
message.Data, _ = json.Marshal(model.Event{
Type: model.Enqueued,
Repo: *repo,
Build: buildCopy,
})

View file

@ -17,17 +17,8 @@ package model
// EventType defines the possible types of build events.
type EventType string
const (
Enqueued EventType = "enqueued"
Started EventType = "started"
Finished EventType = "finished"
Canceled EventType = "canceled"
)
// Event represents a build event.
type Event struct {
Type EventType `json:"type"`
Repo Repo `json:"repo"`
Build Build `json:"build"`
Proc Proc `json:"proc"`
Repo Repo `json:"repo"`
Build Build `json:"build"`
}