feat: notify on successful autoupdate (#13903)

This commit is contained in:
Marcin Tojek
2024-07-18 15:19:12 +02:00
committed by GitHub
parent 44924cd8d8
commit fbd1d7f9a7
8 changed files with 130 additions and 11 deletions

View File

@ -64,6 +64,8 @@ import (
"github.com/coder/coder/v2/coderd/externalauth"
"github.com/coder/coder/v2/coderd/gitsshkey"
"github.com/coder/coder/v2/coderd/httpmw"
"github.com/coder/coder/v2/coderd/notifications"
"github.com/coder/coder/v2/coderd/notifications/notiffake"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/coderd/schedule"
"github.com/coder/coder/v2/coderd/telemetry"
@ -154,6 +156,8 @@ type Options struct {
DatabaseRolluper *dbrollup.Rolluper
WorkspaceUsageTrackerFlush chan int
WorkspaceUsageTrackerTick chan time.Time
NotificationsEnqueuer notifications.Enqueuer
}
// New constructs a codersdk client connected to an in-memory API instance.
@ -238,6 +242,10 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
options.Database, options.Pubsub = dbtestutil.NewDB(t)
}
if options.NotificationsEnqueuer == nil {
options.NotificationsEnqueuer = new(notiffake.FakeNotificationEnqueuer)
}
accessControlStore := &atomic.Pointer[dbauthz.AccessControlStore]{}
var acs dbauthz.AccessControlStore = dbauthz.AGPLTemplateAccessControlStore{}
accessControlStore.Store(&acs)
@ -305,6 +313,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
accessControlStore,
*options.Logger,
options.AutobuildTicker,
options.NotificationsEnqueuer,
).WithStatsChannel(options.AutobuildStats)
lifecycleExecutor.Run()
@ -498,6 +507,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
NewTicker: options.NewTicker,
DatabaseRolluper: options.DatabaseRolluper,
WorkspaceUsageTracker: wuTracker,
NotificationsEnqueuer: options.NotificationsEnqueuer,
}
}