Live: support a dashboard gitops channel (#33291)

This commit is contained in:
Ryan McKinley
2021-04-23 21:55:31 +02:00
committed by GitHub
parent 788bc2a793
commit 1dd9e9b184
7 changed files with 269 additions and 65 deletions
+15 -2
View File
@@ -11,6 +11,9 @@ import (
// ChannelPublisher writes data into a channel. Note that permissions are not checked.
type ChannelPublisher func(channel string, data []byte) error
// ChannelClientCount will return the number of clients for a channel
type ChannelClientCount func(channel string) (int, error)
// SubscribeEvent contains subscription data.
type SubscribeEvent struct {
Channel string
@@ -63,6 +66,16 @@ type ChannelHandlerFactory interface {
// DashboardActivityChannel is a service to advertise dashboard activity
type DashboardActivityChannel interface {
DashboardSaved(uid string, userID int64) error
DashboardDeleted(uid string, userID int64) error
// Called when a dashboard is saved -- this includes the error so we can support a
// gitops workflow that knows if the value was saved to the local database or not
// in many cases all direct save requests will fail, but the request should be forwarded
// to any gitops observers
DashboardSaved(user *UserDisplayDTO, message string, dashboard *Dashboard, err error) error
// Called when a dashboard is deleted
DashboardDeleted(user *UserDisplayDTO, uid string) error
// Experimental! Indicate is GitOps is active. This really means
// someone is subscribed to the `grafana/dashboards/gitops` channel
HasGitOpsObserver() bool
}
+15
View File
@@ -195,6 +195,14 @@ func (u *SignedInUser) NameOrFallback() string {
return u.Email
}
func (u *SignedInUser) ToUserDisplayDTO() *UserDisplayDTO {
return &UserDisplayDTO{
Id: u.UserId,
Login: u.Login,
Name: u.Name,
}
}
type UpdateUserLastSeenAtCommand struct {
UserId int64
}
@@ -241,6 +249,13 @@ type UserSearchHitDTO struct {
AuthModule AuthModuleConversion `json:"-"`
}
type UserDisplayDTO struct {
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Login string `json:"login,omitempty"`
AvatarUrl string `json:"avatarUrl"`
}
type UserIdDTO struct {
Id int64 `json:"id"`
Message string `json:"message"`