Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDatabaseEntityId(internalId interface{}, orgId int64, entityType EntityType) string
- func UploadErrorToStatusCode(err error) int
- type CreateFolderCmd
- type DeleteFolderCmd
- type EntityEvent
- type EntityEventType
- type EntityEventsService
- type EntityType
- type EventHandler
- type GlobalStorageConfig
- type MockEntityEventsService
- func (_m *MockEntityEventsService) GetAllEventsAfter(ctx context.Context, id int64) ([]*EntityEvent, error)
- func (_m *MockEntityEventsService) GetLastEvent(ctx context.Context) (*EntityEvent, error)
- func (_m *MockEntityEventsService) IsDisabled() bool
- func (_m *MockEntityEventsService) OnEvent(handler EventHandler)
- func (_m *MockEntityEventsService) Run(ctx context.Context) error
- func (_m *MockEntityEventsService) SaveEvent(ctx context.Context, cmd SaveEventCmd) error
- type NewMockEntityEventsServiceT
- type RootStorageConfig
- type RootStorageMeta
- type SaveEventCmd
- type StorageGCSConfig
- type StorageGitConfig
- type StorageListFrame
- type StorageLocalDiskConfig
- type StorageS3Config
- type StorageSQLConfig
- type StorageService
- type UploadRequest
- type WriteValueRequest
- type WriteValueResponse
- type WriteValueWorkflow
Constants ¶
const ( ActionFilesRead = "files:read" ActionFilesWrite = "files:write" ActionFilesDelete = "files:delete" )
const MAX_UPLOAD_SIZE = 1 * 1024 * 1024 // 3MB
const RootContent = "content"
const RootDevenv = "devenv"
const RootPublicStatic = "public-static"
const RootResources = "resources"
const RootSystem = "system"
const SystemBrandingStorage = "system/" + brandingStorage
Variables ¶
var ( SystemBrandingReader = &user.SignedInUser{OrgID: ac.GlobalOrgID} SystemBrandingAdmin = &user.SignedInUser{OrgID: ac.GlobalOrgID} )
var ErrAccessDenied = errors.New("access denied")
var ErrFileAlreadyExists = errors.New("file exists")
var ErrOnlyDashboardSaveSupported = errors.New("only dashboard save is currently supported")
var ErrQuotaReached = errors.New("file quota reached")
var ErrStorageNotFound = errors.New("storage not found")
var ErrUnsupportedStorage = errors.New("storage does not support this operation")
var ErrUploadInternalError = errors.New("upload internal error")
var ErrValidationFailed = errors.New("request validation failed")
Functions ¶
func CreateDatabaseEntityId ¶
func CreateDatabaseEntityId(internalId interface{}, orgId int64, entityType EntityType) string
CreateDatabaseEntityId creates entityId for entities stored in the existing SQL tables
func UploadErrorToStatusCode ¶
Types ¶
type CreateFolderCmd ¶
type CreateFolderCmd struct {
Path string `json:"path"`
}
type DeleteFolderCmd ¶
type EntityEvent ¶
type EntityEvent struct { Id int64 EventType EntityEventType EntityId string Created int64 }
type EntityEventType ¶
type EntityEventType string
const ( EntityEventTypeDelete EntityEventType = "delete" EntityEventTypeCreate EntityEventType = "create" EntityEventTypeUpdate EntityEventType = "update" )
type EntityEventsService ¶
type EntityEventsService interface { registry.BackgroundService registry.CanBeDisabled GetLastEvent(ctx context.Context) (*EntityEvent, error) GetAllEventsAfter(ctx context.Context, id int64) ([]*EntityEvent, error) // contains filtered or unexported methods }
EntityEventsService is a temporary solution to support change notifications in an HA setup With this service each system can query for any events that have happened since a fixed time
func ProvideEntityEventsService ¶
func ProvideEntityEventsService(cfg *setting.Cfg, sqlStore *sqlstore.SQLStore, features featuremgmt.FeatureToggles) EntityEventsService
type EntityType ¶
type EntityType string
const ( EntityTypeDashboard EntityType = "dashboard" EntityTypeFolder EntityType = "folder" EntityTypeImage EntityType = "image" EntityTypeJSON EntityType = "json" )
type EventHandler ¶
type EventHandler func(ctx context.Context, e *EntityEvent) error
type GlobalStorageConfig ¶
type GlobalStorageConfig struct { // Defined in grafana.ini AllowUnsanitizedSvgUpload bool `json:"allowUnsanitizedSvgUpload"` // Add dev environment AddDevEnv bool `json:"addDevEnv"` // Paths under 'root' (NOTE: this is applied to all orgs) Roots []RootStorageConfig `json:"roots"` // contains filtered or unexported fields }
For now this file is stored in $GRAFANA_HOME/conf/storage.json and updated from the UI
func LoadStorageConfig ¶
func LoadStorageConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles) (*GlobalStorageConfig, error)
type MockEntityEventsService ¶
MockEntityEventsService is an autogenerated mock type for the EntityEventsService type
func NewMockEntityEventsService ¶
func NewMockEntityEventsService(t NewMockEntityEventsServiceT) *MockEntityEventsService
NewMockEntityEventsService creates a new instance of MockEntityEventsService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockEntityEventsService) GetAllEventsAfter ¶
func (_m *MockEntityEventsService) GetAllEventsAfter(ctx context.Context, id int64) ([]*EntityEvent, error)
GetAllEventsAfter provides a mock function with given fields: ctx, id
func (*MockEntityEventsService) GetLastEvent ¶
func (_m *MockEntityEventsService) GetLastEvent(ctx context.Context) (*EntityEvent, error)
GetLastEvent provides a mock function with given fields: ctx
func (*MockEntityEventsService) IsDisabled ¶
func (_m *MockEntityEventsService) IsDisabled() bool
IsDisabled provides a mock function with given fields:
func (*MockEntityEventsService) OnEvent ¶
func (_m *MockEntityEventsService) OnEvent(handler EventHandler)
OnEvent provides a mock function with given fields: handler
func (*MockEntityEventsService) Run ¶
func (_m *MockEntityEventsService) Run(ctx context.Context) error
Run provides a mock function with given fields: ctx
func (*MockEntityEventsService) SaveEvent ¶
func (_m *MockEntityEventsService) SaveEvent(ctx context.Context, cmd SaveEventCmd) error
SaveEvent provides a mock function with given fields: ctx, cmd
type RootStorageConfig ¶
type RootStorageConfig struct { Type string `json:"type"` Prefix string `json:"prefix"` UnderContentRoot bool `json:"underContentRoot"` Name string `json:"name"` Description string `json:"description"` Disabled bool `json:"disabled,omitempty"` // Depending on type, these will be configured Disk *StorageLocalDiskConfig `json:"disk,omitempty"` Git *StorageGitConfig `json:"git,omitempty"` SQL *StorageSQLConfig `json:"sql,omitempty"` S3 *StorageS3Config `json:"s3,omitempty"` GCS *StorageGCSConfig `json:"gcs,omitempty"` }
type RootStorageMeta ¶
type SaveEventCmd ¶
type SaveEventCmd struct { EntityId string EventType EntityEventType }
type StorageGCSConfig ¶
type StorageGitConfig ¶
type StorageGitConfig struct { Remote string `json:"remote"` Branch string `json:"branch"` Root string `json:"root"` // subfolder within the remote // Pull interval? // Requires pull request? RequirePullRequest bool `json:"requirePullRequest"` PullInterval string `json:"pullInterval"` // SECURE JSON :grimicing: AccessToken string `json:"accessToken,omitempty"` // Simplest auth method for github }
type StorageListFrame ¶
func (*StorageListFrame) GetFileNames ¶
func (s *StorageListFrame) GetFileNames() []string
type StorageLocalDiskConfig ¶
type StorageS3Config ¶
type StorageSQLConfig ¶
type StorageSQLConfig struct { }
type StorageService ¶
type StorageService interface { registry.BackgroundService // Register the HTTP RegisterHTTPRoutes(routing.RouteRegister) // List folder contents List(ctx context.Context, user *user.SignedInUser, path string) (*StorageListFrame, error) // Read raw file contents out of the store Read(ctx context.Context, user *user.SignedInUser, path string) (*filestorage.File, error) Upload(ctx context.Context, user *user.SignedInUser, req *UploadRequest) error Delete(ctx context.Context, user *user.SignedInUser, path string) error DeleteFolder(ctx context.Context, user *user.SignedInUser, cmd *DeleteFolderCmd) error CreateFolder(ctx context.Context, user *user.SignedInUser, cmd *CreateFolderCmd) error // contains filtered or unexported methods }
func ProvideService ¶
func ProvideService( sql db.DB, features featuremgmt.FeatureToggles, cfg *setting.Cfg, quotaService quota.Service, ) StorageService
type UploadRequest ¶
type WriteValueRequest ¶
type WriteValueRequest struct { User *user.SignedInUser Path string // added from URL EntityType EntityType `json:"kind,omitempty"` // for now only dashboard Body json.RawMessage `json:"body,omitempty"` Message string `json:"message,omitempty"` Title string `json:"title,omitempty"` // For PRs Workflow WriteValueWorkflow `json:"workflow,omitempty"` // save | pr | push }
type WriteValueResponse ¶
type WriteValueWorkflow ¶
type WriteValueWorkflow = string
var ( WriteValueWorkflow_Save WriteValueWorkflow = "save" // or empty WriteValueWorkflow_PR WriteValueWorkflow = "pr" WriteValueWorkflow_Push WriteValueWorkflow = "push" )