Chore: Remove unused Go code (#28852)
* Chore: Remove more unused Go code Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
)
|
||||
|
||||
type AlertStateType string
|
||||
type AlertSeverityType string
|
||||
type NoDataOption string
|
||||
type ExecutionErrorOption string
|
||||
|
||||
@@ -93,10 +92,6 @@ func (a *Alert) ValidToSave() bool {
|
||||
return a.DashboardId != 0 && a.OrgId != 0 && a.PanelId != 0
|
||||
}
|
||||
|
||||
func (a *Alert) ShouldUpdateState(newState AlertStateType) bool {
|
||||
return a.State != newState
|
||||
}
|
||||
|
||||
func (a *Alert) ContainsUpdates(other *Alert) bool {
|
||||
result := false
|
||||
result = result || a.Name != other.Name
|
||||
@@ -132,24 +127,6 @@ func (a *Alert) GetTagsFromSettings() []*Tag {
|
||||
return tags
|
||||
}
|
||||
|
||||
type AlertingClusterInfo struct {
|
||||
ServerId string
|
||||
ClusterSize int
|
||||
UptimePosition int
|
||||
}
|
||||
|
||||
type HeartBeat struct {
|
||||
Id int64
|
||||
ServerId string
|
||||
Updated time.Time
|
||||
Created time.Time
|
||||
}
|
||||
|
||||
type HeartBeatCommand struct {
|
||||
ServerId string
|
||||
Result AlertingClusterInfo
|
||||
}
|
||||
|
||||
type SaveAlertsCommand struct {
|
||||
DashboardId int64
|
||||
UserId int64
|
||||
|
||||
@@ -11,9 +11,7 @@ import (
|
||||
var (
|
||||
ErrAlertNotificationNotFound = errors.New("alert notification not found")
|
||||
ErrNotificationFrequencyNotFound = errors.New("notification frequency not specified")
|
||||
ErrAlertNotificationStateNotFound = errors.New("alert notification state not found")
|
||||
ErrAlertNotificationStateVersionConflict = errors.New("alert notification state update version conflict")
|
||||
ErrAlertNotificationStateAlreadyExist = errors.New("alert notification state already exists")
|
||||
ErrAlertNotificationFailedGenerateUniqueUid = errors.New("failed to generate unique alert notification uid")
|
||||
ErrAlertNotificationFailedTranslateUniqueID = errors.New("failed to translate Notification Id to Uid")
|
||||
ErrAlertNotificationWithSameNameExists = errors.New("alert notification with same name already exists")
|
||||
|
||||
@@ -32,14 +32,6 @@ type AddApiKeyCommand struct {
|
||||
Result *ApiKey `json:"-"`
|
||||
}
|
||||
|
||||
type UpdateApiKeyCommand struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Role RoleType `json:"role"`
|
||||
|
||||
OrgId int64 `json:"-"`
|
||||
}
|
||||
|
||||
type DeleteApiKeyCommand struct {
|
||||
Id int64 `json:"id"`
|
||||
OrgId int64 `json:"-"`
|
||||
|
||||
@@ -37,12 +37,6 @@ func (ctx *ReqContext) Handle(status int, title string, err error) {
|
||||
ctx.HTML(status, setting.ErrTemplateName)
|
||||
}
|
||||
|
||||
func (ctx *ReqContext) JsonOK(message string) {
|
||||
resp := make(map[string]interface{})
|
||||
resp["message"] = message
|
||||
ctx.JSON(200, resp)
|
||||
}
|
||||
|
||||
func (ctx *ReqContext) IsApiRequest() bool {
|
||||
return strings.HasPrefix(ctx.Req.URL.Path, "/api")
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ type GetDashboardSnapshotQuery struct {
|
||||
Result *DashboardSnapshot
|
||||
}
|
||||
|
||||
type DashboardSnapshots []*DashboardSnapshot
|
||||
type DashboardSnapshotsList []*DashboardSnapshotDTO
|
||||
|
||||
type GetDashboardSnapshotsQuery struct {
|
||||
|
||||
@@ -298,11 +298,6 @@ func (d *Dashboard) GetUrl() string {
|
||||
return GetDashboardFolderUrl(d.IsFolder, d.Uid, d.Slug)
|
||||
}
|
||||
|
||||
// Return the html url for a dashboard
|
||||
func (d *Dashboard) GenerateUrl() string {
|
||||
return GetDashboardUrl(d.Uid, d.Slug)
|
||||
}
|
||||
|
||||
// GetDashboardFolderUrl return the html url for a folder if it's folder, otherwise for a dashboard
|
||||
func GetDashboardFolderUrl(isFolder bool, uid string, slug string) string {
|
||||
if isFolder {
|
||||
|
||||
@@ -9,8 +9,6 @@ const (
|
||||
|
||||
func (f HelpFlags1) HasFlag(flag HelpFlags1) bool { return f&flag != 0 }
|
||||
func (f *HelpFlags1) AddFlag(flag HelpFlags1) { *f |= flag }
|
||||
func (f *HelpFlags1) ClearFlag(flag HelpFlags1) { *f &= ^flag }
|
||||
func (f *HelpFlags1) ToggleFlag(flag HelpFlags1) { *f ^= flag }
|
||||
|
||||
type SetUserHelpFlagCommand struct {
|
||||
HelpFlags1 HelpFlags1
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type HomeDashboard struct {
|
||||
Id int64
|
||||
UserId int64
|
||||
AccountId int64
|
||||
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
|
||||
Data map[string]interface{}
|
||||
}
|
||||
@@ -26,17 +26,6 @@ type Measurement struct {
|
||||
// MeasurementAction defines what should happen when you send a list of measurements.
|
||||
type MeasurementAction string
|
||||
|
||||
const (
|
||||
// MeasurementActionAppend means new values should be added to a client buffer. This is the default action
|
||||
MeasurementActionAppend MeasurementAction = "append"
|
||||
|
||||
// MeasurementActionReplace means new values should replace any existing values.
|
||||
MeasurementActionReplace MeasurementAction = "replace"
|
||||
|
||||
// MeasurementActionClear means all existing values should be remoed before adding.
|
||||
MeasurementActionClear MeasurementAction = "clear"
|
||||
)
|
||||
|
||||
// MeasurementBatch is a collection of measurements all sent at once.
|
||||
type MeasurementBatch struct {
|
||||
// Action is the action in question, the default is append.
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
// Typed errors
|
||||
var (
|
||||
ErrInvalidRoleType = errors.New("invalid role type")
|
||||
ErrLastOrgAdmin = errors.New("cannot remove last organization admin")
|
||||
ErrOrgUserNotFound = errors.New("cannot find the organization user")
|
||||
ErrOrgUserAlreadyAdded = errors.New("user is already added to organization")
|
||||
|
||||
+1
-13
@@ -6,8 +6,7 @@ import (
|
||||
|
||||
// Typed errors
|
||||
var (
|
||||
ErrPlaylistNotFound = errors.New("playlist not found")
|
||||
ErrPlaylistWithSameNameExists = errors.New("a playlist with the same name already exists")
|
||||
ErrPlaylistNotFound = errors.New("Playlist not found")
|
||||
)
|
||||
|
||||
// Playlist model
|
||||
@@ -35,12 +34,6 @@ type PlaylistItemDTO struct {
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
type PlaylistDashboard struct {
|
||||
Id int64 `json:"id"`
|
||||
Slug string `json:"slug"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type PlaylistItem struct {
|
||||
Id int64
|
||||
PlaylistId int64
|
||||
@@ -50,12 +43,7 @@ type PlaylistItem struct {
|
||||
Title string
|
||||
}
|
||||
|
||||
func (p PlaylistDashboard) TableName() string {
|
||||
return "dashboard"
|
||||
}
|
||||
|
||||
type Playlists []*Playlist
|
||||
type PlaylistDashboards []*PlaylistDashboard
|
||||
|
||||
//
|
||||
// COMMANDS
|
||||
|
||||
@@ -21,17 +21,3 @@ func (ps *PluginSetting) DecryptedValues() map[string]string {
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
// DecryptedValue returns cached decrypted value from cached secureJsonData.
|
||||
func (ps *PluginSetting) DecryptedValue(key string) (string, bool) {
|
||||
value, exists := ps.DecryptedValues()[key]
|
||||
return value, exists
|
||||
}
|
||||
|
||||
// ClearPluginSettingDecryptionCache clears the datasource decryption cache.
|
||||
func ClearPluginSettingDecryptionCache() {
|
||||
pluginSettingDecryptionCache.Lock()
|
||||
defer pluginSettingDecryptionCache.Unlock()
|
||||
|
||||
pluginSettingDecryptionCache.cache = make(map[int64]cachedDecryptedJSON)
|
||||
}
|
||||
|
||||
@@ -9,9 +9,17 @@ import (
|
||||
"github.com/grafana/grafana/pkg/components/securejsondata"
|
||||
)
|
||||
|
||||
// clearPluginSettingDecryptionCache clears the datasource decryption cache.
|
||||
func clearPluginSettingDecryptionCache() {
|
||||
pluginSettingDecryptionCache.Lock()
|
||||
defer pluginSettingDecryptionCache.Unlock()
|
||||
|
||||
pluginSettingDecryptionCache.cache = make(map[int64]cachedDecryptedJSON)
|
||||
}
|
||||
|
||||
func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
t.Run("When plugin settings hasn't been updated, encrypted JSON should be fetched from cache", func(t *testing.T) {
|
||||
ClearPluginSettingDecryptionCache()
|
||||
clearPluginSettingDecryptionCache()
|
||||
|
||||
ps := PluginSetting{
|
||||
Id: 1,
|
||||
@@ -22,7 +30,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
}
|
||||
|
||||
// Populate cache
|
||||
password, ok := ps.DecryptedValue("password")
|
||||
password, ok := ps.DecryptedValues()["password"]
|
||||
require.Equal(t, "password", password)
|
||||
require.True(t, ok)
|
||||
|
||||
@@ -35,7 +43,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("When plugin settings is updated, encrypted JSON should not be fetched from cache", func(t *testing.T) {
|
||||
ClearPluginSettingDecryptionCache()
|
||||
clearPluginSettingDecryptionCache()
|
||||
|
||||
ps := PluginSetting{
|
||||
Id: 1,
|
||||
@@ -46,7 +54,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
}
|
||||
|
||||
// Populate cache
|
||||
password, ok := ps.DecryptedValue("password")
|
||||
password, ok := ps.DecryptedValues()["password"]
|
||||
require.Equal(t, "password", password)
|
||||
require.True(t, ok)
|
||||
|
||||
@@ -55,7 +63,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
|
||||
})
|
||||
ps.Updated = time.Now()
|
||||
|
||||
password, ok = ps.DecryptedValue("password")
|
||||
password, ok = ps.DecryptedValues()["password"]
|
||||
require.Empty(t, password)
|
||||
require.True(t, ok)
|
||||
})
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Typed errors
|
||||
var (
|
||||
ErrPreferencesNotFound = errors.New("Preferences not found")
|
||||
)
|
||||
|
||||
type Preferences struct {
|
||||
Id int64
|
||||
OrgId int64
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package models
|
||||
|
||||
type IsSAMLEnabledCommand struct {
|
||||
Result bool
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package models
|
||||
|
||||
type SearchHit struct {
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Uri string `json:"uri"`
|
||||
Type string `json:"type"`
|
||||
Tags []string `json:"tags"`
|
||||
IsStarred bool `json:"isStarred"`
|
||||
}
|
||||
Reference in New Issue
Block a user