Commit 4dd7b7a8 by Arve Knudsen Committed by GitHub

Chore: Remove unused Go code (#28852)

* Chore: Remove more unused Go code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 8c765e80
...@@ -10,9 +10,6 @@ import ( ...@@ -10,9 +10,6 @@ import (
) )
var ( var (
NotFound = func() Response {
return Error(404, "Not found", nil)
}
ServerError = func(err error) Response { ServerError = func(err error) Response {
return Error(500, "Server error", err) return Error(500, "Server error", err)
} }
...@@ -59,16 +56,12 @@ func (r *NormalResponse) WriteTo(ctx *models.ReqContext) { ...@@ -59,16 +56,12 @@ func (r *NormalResponse) WriteTo(ctx *models.ReqContext) {
} }
} }
func (r *NormalResponse) Cache(ttl string) *NormalResponse {
return r.Header("Cache-Control", "public,max-age="+ttl)
}
func (r *NormalResponse) Header(key, value string) *NormalResponse { func (r *NormalResponse) Header(key, value string) *NormalResponse {
r.header.Set(key, value) r.header.Set(key, value)
return r return r
} }
// Empty create an empty response // Empty creates an empty response.
func Empty(status int) *NormalResponse { func Empty(status int) *NormalResponse {
return Respond(status, nil) return Respond(status, nil)
} }
......
...@@ -24,7 +24,9 @@ func (e URLValidationError) Error() string { ...@@ -24,7 +24,9 @@ func (e URLValidationError) Error() string {
return fmt.Sprintf("validation of data source URL %q failed: %s", e.URL, e.Err.Error()) return fmt.Sprintf("validation of data source URL %q failed: %s", e.URL, e.Err.Error())
} }
// nolint:unused
// Unwrap returns the wrapped error. // Unwrap returns the wrapped error.
// Used by errors package.
func (e URLValidationError) Unwrap() error { func (e URLValidationError) Unwrap() error {
return e.Err return e.Err
} }
......
...@@ -23,11 +23,6 @@ type IndexViewData struct { ...@@ -23,11 +23,6 @@ type IndexViewData struct {
Sentry *setting.Sentry Sentry *setting.Sentry
} }
type PluginCss struct {
Light string `json:"light"`
Dark string `json:"dark"`
}
const ( const (
// These weights may be used by an extension to reliably place // These weights may be used by an extension to reliably place
// itself in relation to a particular item in the menu. The weights // itself in relation to a particular item in the menu. The weights
......
...@@ -50,10 +50,6 @@ type MetricRequest struct { ...@@ -50,10 +50,6 @@ type MetricRequest struct {
Debug bool `json:"debug"` Debug bool `json:"debug"`
} }
type UserStars struct {
DashboardIds map[string]bool `json:"dashboardIds"`
}
func GetGravatarUrl(text string) string { func GetGravatarUrl(text string) string {
if setting.DisableGravatar { if setting.DisableGravatar {
return setting.AppSubUrl + "/public/img/user_profile.png" return setting.AppSubUrl + "/public/img/user_profile.png"
......
package dtos
import "encoding/json"
type StreamMessage struct {
Stream string `json:"stream"`
Series []StreamMessageSeries `json:"series"`
}
type StreamMessageSeries struct {
Name string `json:"name"`
Datapoints [][]json.Number `json:"datapoints"`
}
...@@ -21,12 +21,6 @@ type AdminCreateUserForm struct { ...@@ -21,12 +21,6 @@ type AdminCreateUserForm struct {
OrgId int64 `json:"orgId"` OrgId int64 `json:"orgId"`
} }
type AdminUpdateUserForm struct {
Email string `json:"email"`
Login string `json:"login"`
Name string `json:"name"`
}
type AdminUpdateUserPasswordForm struct { type AdminUpdateUserPasswordForm struct {
Password string `json:"password" binding:"Required"` Password string `json:"password" binding:"Required"`
} }
...@@ -35,13 +29,6 @@ type AdminUpdateUserPermissionsForm struct { ...@@ -35,13 +29,6 @@ type AdminUpdateUserPermissionsForm struct {
IsGrafanaAdmin bool `json:"isGrafanaAdmin"` IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
} }
type AdminUserListItem struct {
Email string `json:"email"`
Name string `json:"name"`
Login string `json:"login"`
IsGrafanaAdmin bool `json:"isGrafanaAdmin"`
}
type SendResetPasswordEmailForm struct { type SendResetPasswordEmailForm struct {
UserOrEmail string `json:"userOrEmail" binding:"Required"` UserOrEmail string `json:"userOrEmail" binding:"Required"`
} }
......
...@@ -61,7 +61,3 @@ func (c *ContextCommandLine) RepoDirectory() string { ...@@ -61,7 +61,3 @@ func (c *ContextCommandLine) RepoDirectory() string {
func (c *ContextCommandLine) PluginURL() string { func (c *ContextCommandLine) PluginURL() string {
return c.String("pluginUrl") return c.String("pluginUrl")
} }
func (c *ContextCommandLine) OptionsString() string {
return c.String("configOverrides")
}
...@@ -82,25 +82,6 @@ func (az *AzureBlobUploader) Upload(ctx context.Context, imageDiskPath string) ( ...@@ -82,25 +82,6 @@ func (az *AzureBlobUploader) Upload(ctx context.Context, imageDiskPath string) (
} }
// --- AZURE LIBRARY // --- AZURE LIBRARY
type Blobs struct {
XMLName xml.Name `xml:"EnumerationResults"`
Items []Blob `xml:"Blobs>Blob"`
}
type Blob struct {
Name string `xml:"Name"`
Property Property `xml:"Properties"`
}
type Property struct {
LastModified string `xml:"Last-Modified"`
Etag string `xml:"Etag"`
ContentLength int `xml:"Content-Length"`
ContentType string `xml:"Content-Type"`
BlobType string `xml:"BlobType"`
LeaseStatus string `xml:"LeaseStatus"`
}
type Error struct { type Error struct {
Code int Code int
Status string Status string
......
...@@ -134,20 +134,6 @@ func (f Float) FullString() string { ...@@ -134,20 +134,6 @@ func (f Float) FullString() string {
return fmt.Sprintf("%f", f.Float64) return fmt.Sprintf("%f", f.Float64)
} }
// SetValid changes this Float's value and also sets it to be non-null.
func (f *Float) SetValid(n float64) {
f.Float64 = n
f.Valid = true
}
// Ptr returns a pointer to this Float's value, or a nil pointer if this Float is null.
func (f Float) Ptr() *float64 {
if !f.Valid {
return nil
}
return &f.Float64
}
// IsZero returns true for invalid Floats, for future omitempty support (Go 1.4?) // IsZero returns true for invalid Floats, for future omitempty support (Go 1.4?)
// A non-null Float with a 0 value will not be considered zero. // A non-null Float with a 0 value will not be considered zero.
func (f Float) IsZero() bool { func (f Float) IsZero() bool {
......
// Package simplejson provides a wrapper for arbitrary JSON objects that adds methods to access properties. // Package simplejson provides a wrapper for arbitrary JSON objects that adds methods to access properties.
// Use of this package in place of types and the standard library's encoding/json package is strongly discouraged. // Use of this package in place of types and the standard library's encoding/json package is strongly discouraged.
//
// Don't lint for stale code, since it's a copied library and we might as well keep the whole thing.
// nolint:unused
package simplejson package simplejson
import ( import (
......
package events package events
import ( import (
"reflect"
"time" "time"
) )
// Events can be passed to external systems via for example AMQP // Events can be passed to external systems via for example AMQP
// Treat these events as basically DTOs so changes has to be backward compatible // Treat these events as basically DTOs so changes has to be backward compatible
type Priority string
const (
PRIO_DEBUG Priority = "DEBUG"
PRIO_INFO Priority = "INFO"
PRIO_ERROR Priority = "ERROR"
)
type Event struct {
Timestamp time.Time `json:"timestamp"`
}
type OnTheWireEvent struct {
EventType string `json:"event_type"`
Priority Priority `json:"priority"`
Timestamp time.Time `json:"timestamp"`
Payload interface{} `json:"payload"`
}
type EventBase interface {
ToOnWriteEvent() *OnTheWireEvent
}
func ToOnWriteEvent(event interface{}) (*OnTheWireEvent, error) {
eventType := reflect.TypeOf(event).Elem()
wireEvent := OnTheWireEvent{
Priority: PRIO_INFO,
EventType: eventType.Name(),
Payload: event,
}
baseField := reflect.Indirect(reflect.ValueOf(event)).FieldByName("Timestamp")
if baseField.IsValid() {
wireEvent.Timestamp = baseField.Interface().(time.Time)
} else {
wireEvent.Timestamp = time.Now()
}
return &wireEvent, nil
}
type OrgCreated struct { type OrgCreated struct {
Timestamp time.Time `json:"timestamp"` Timestamp time.Time `json:"timestamp"`
Id int64 `json:"id"` Id int64 `json:"id"`
......
package events
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type TestEvent struct {
Timestamp time.Time
}
func TestEventCreation(t *testing.T) {
e := TestEvent{
Timestamp: time.Unix(1231421123, 223),
}
wire, err := ToOnWriteEvent(&e)
require.NoError(t, err)
assert.Equal(t, e.Timestamp.Unix(), wire.Timestamp.Unix())
assert.Equal(t, "TestEvent", wire.EventType)
}
...@@ -14,7 +14,6 @@ var ( ...@@ -14,7 +14,6 @@ var (
ErrInvalidCredentials = errors.New("invalid username or password") ErrInvalidCredentials = errors.New("invalid username or password")
ErrNoEmail = errors.New("login provider didn't return an email address") ErrNoEmail = errors.New("login provider didn't return an email address")
ErrProviderDeniedRequest = errors.New("login provider denied login request") ErrProviderDeniedRequest = errors.New("login provider denied login request")
ErrSignUpNotAllowed = errors.New("signup is not allowed for this adapter")
ErrTooManyLoginAttempts = errors.New("too many consecutive incorrect login attempts for user - login for user temporarily blocked") ErrTooManyLoginAttempts = errors.New("too many consecutive incorrect login attempts for user - login for user temporarily blocked")
ErrPasswordEmpty = errors.New("no password provided") ErrPasswordEmpty = errors.New("no password provided")
ErrUserDisabled = errors.New("user is disabled") ErrUserDisabled = errors.New("user is disabled")
......
...@@ -574,7 +574,9 @@ func middlewareScenario(t *testing.T, desc string, fn scenarioFunc) { ...@@ -574,7 +574,9 @@ func middlewareScenario(t *testing.T, desc string, fn scenarioFunc) {
if sc.handlerFunc != nil { if sc.handlerFunc != nil {
sc.handlerFunc(sc.context) sc.handlerFunc(sc.context)
} else { } else {
c.JsonOK("OK") resp := make(map[string]interface{})
resp["message"] = "OK"
c.JSON(200, resp)
} }
} }
......
package middleware
import (
"net/http"
"github.com/grafana/grafana/pkg/models"
"gopkg.in/macaron.v1"
)
func MeasureRequestTime() macaron.Handler {
return func(res http.ResponseWriter, req *http.Request, c *models.ReqContext) {
}
}
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
) )
type AlertStateType string type AlertStateType string
type AlertSeverityType string
type NoDataOption string type NoDataOption string
type ExecutionErrorOption string type ExecutionErrorOption string
...@@ -93,10 +92,6 @@ func (a *Alert) ValidToSave() bool { ...@@ -93,10 +92,6 @@ func (a *Alert) ValidToSave() bool {
return a.DashboardId != 0 && a.OrgId != 0 && a.PanelId != 0 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 { func (a *Alert) ContainsUpdates(other *Alert) bool {
result := false result := false
result = result || a.Name != other.Name result = result || a.Name != other.Name
...@@ -132,24 +127,6 @@ func (a *Alert) GetTagsFromSettings() []*Tag { ...@@ -132,24 +127,6 @@ func (a *Alert) GetTagsFromSettings() []*Tag {
return tags 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 { type SaveAlertsCommand struct {
DashboardId int64 DashboardId int64
UserId int64 UserId int64
......
...@@ -11,9 +11,7 @@ import ( ...@@ -11,9 +11,7 @@ import (
var ( var (
ErrAlertNotificationNotFound = errors.New("alert notification not found") ErrAlertNotificationNotFound = errors.New("alert notification not found")
ErrNotificationFrequencyNotFound = errors.New("notification frequency not specified") ErrNotificationFrequencyNotFound = errors.New("notification frequency not specified")
ErrAlertNotificationStateNotFound = errors.New("alert notification state not found")
ErrAlertNotificationStateVersionConflict = errors.New("alert notification state update version conflict") 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") ErrAlertNotificationFailedGenerateUniqueUid = errors.New("failed to generate unique alert notification uid")
ErrAlertNotificationFailedTranslateUniqueID = errors.New("failed to translate Notification Id to Uid") ErrAlertNotificationFailedTranslateUniqueID = errors.New("failed to translate Notification Id to Uid")
ErrAlertNotificationWithSameNameExists = errors.New("alert notification with same name already exists") ErrAlertNotificationWithSameNameExists = errors.New("alert notification with same name already exists")
......
...@@ -32,14 +32,6 @@ type AddApiKeyCommand struct { ...@@ -32,14 +32,6 @@ type AddApiKeyCommand struct {
Result *ApiKey `json:"-"` Result *ApiKey `json:"-"`
} }
type UpdateApiKeyCommand struct {
Id int64 `json:"id"`
Name string `json:"name"`
Role RoleType `json:"role"`
OrgId int64 `json:"-"`
}
type DeleteApiKeyCommand struct { type DeleteApiKeyCommand struct {
Id int64 `json:"id"` Id int64 `json:"id"`
OrgId int64 `json:"-"` OrgId int64 `json:"-"`
......
...@@ -37,12 +37,6 @@ func (ctx *ReqContext) Handle(status int, title string, err error) { ...@@ -37,12 +37,6 @@ func (ctx *ReqContext) Handle(status int, title string, err error) {
ctx.HTML(status, setting.ErrTemplateName) 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 { func (ctx *ReqContext) IsApiRequest() bool {
return strings.HasPrefix(ctx.Req.URL.Path, "/api") return strings.HasPrefix(ctx.Req.URL.Path, "/api")
} }
......
...@@ -90,7 +90,6 @@ type GetDashboardSnapshotQuery struct { ...@@ -90,7 +90,6 @@ type GetDashboardSnapshotQuery struct {
Result *DashboardSnapshot Result *DashboardSnapshot
} }
type DashboardSnapshots []*DashboardSnapshot
type DashboardSnapshotsList []*DashboardSnapshotDTO type DashboardSnapshotsList []*DashboardSnapshotDTO
type GetDashboardSnapshotsQuery struct { type GetDashboardSnapshotsQuery struct {
......
...@@ -298,11 +298,6 @@ func (d *Dashboard) GetUrl() string { ...@@ -298,11 +298,6 @@ func (d *Dashboard) GetUrl() string {
return GetDashboardFolderUrl(d.IsFolder, d.Uid, d.Slug) 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 // 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 { func GetDashboardFolderUrl(isFolder bool, uid string, slug string) string {
if isFolder { if isFolder {
......
...@@ -9,8 +9,6 @@ const ( ...@@ -9,8 +9,6 @@ const (
func (f HelpFlags1) HasFlag(flag HelpFlags1) bool { return f&flag != 0 } func (f HelpFlags1) HasFlag(flag HelpFlags1) bool { return f&flag != 0 }
func (f *HelpFlags1) AddFlag(flag HelpFlags1) { *f |= flag } 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 { type SetUserHelpFlagCommand struct {
HelpFlags1 HelpFlags1 HelpFlags1 HelpFlags1
......
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 { ...@@ -26,17 +26,6 @@ type Measurement struct {
// MeasurementAction defines what should happen when you send a list of measurements. // MeasurementAction defines what should happen when you send a list of measurements.
type MeasurementAction string 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. // MeasurementBatch is a collection of measurements all sent at once.
type MeasurementBatch struct { type MeasurementBatch struct {
// Action is the action in question, the default is append. // Action is the action in question, the default is append.
......
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
// Typed errors // Typed errors
var ( var (
ErrInvalidRoleType = errors.New("invalid role type")
ErrLastOrgAdmin = errors.New("cannot remove last organization admin") ErrLastOrgAdmin = errors.New("cannot remove last organization admin")
ErrOrgUserNotFound = errors.New("cannot find the organization user") ErrOrgUserNotFound = errors.New("cannot find the organization user")
ErrOrgUserAlreadyAdded = errors.New("user is already added to organization") ErrOrgUserAlreadyAdded = errors.New("user is already added to organization")
......
...@@ -6,8 +6,7 @@ import ( ...@@ -6,8 +6,7 @@ import (
// Typed errors // Typed errors
var ( var (
ErrPlaylistNotFound = errors.New("playlist not found") ErrPlaylistNotFound = errors.New("Playlist not found")
ErrPlaylistWithSameNameExists = errors.New("a playlist with the same name already exists")
) )
// Playlist model // Playlist model
...@@ -35,12 +34,6 @@ type PlaylistItemDTO struct { ...@@ -35,12 +34,6 @@ type PlaylistItemDTO struct {
Order int `json:"order"` Order int `json:"order"`
} }
type PlaylistDashboard struct {
Id int64 `json:"id"`
Slug string `json:"slug"`
Title string `json:"title"`
}
type PlaylistItem struct { type PlaylistItem struct {
Id int64 Id int64
PlaylistId int64 PlaylistId int64
...@@ -50,12 +43,7 @@ type PlaylistItem struct { ...@@ -50,12 +43,7 @@ type PlaylistItem struct {
Title string Title string
} }
func (p PlaylistDashboard) TableName() string {
return "dashboard"
}
type Playlists []*Playlist type Playlists []*Playlist
type PlaylistDashboards []*PlaylistDashboard
// //
// COMMANDS // COMMANDS
......
...@@ -21,17 +21,3 @@ func (ps *PluginSetting) DecryptedValues() map[string]string { ...@@ -21,17 +21,3 @@ func (ps *PluginSetting) DecryptedValues() map[string]string {
return json 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 ( ...@@ -9,9 +9,17 @@ import (
"github.com/grafana/grafana/pkg/components/securejsondata" "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) { 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) { t.Run("When plugin settings hasn't been updated, encrypted JSON should be fetched from cache", func(t *testing.T) {
ClearPluginSettingDecryptionCache() clearPluginSettingDecryptionCache()
ps := PluginSetting{ ps := PluginSetting{
Id: 1, Id: 1,
...@@ -22,7 +30,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) { ...@@ -22,7 +30,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
} }
// Populate cache // Populate cache
password, ok := ps.DecryptedValue("password") password, ok := ps.DecryptedValues()["password"]
require.Equal(t, "password", password) require.Equal(t, "password", password)
require.True(t, ok) require.True(t, ok)
...@@ -35,7 +43,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) { ...@@ -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) { t.Run("When plugin settings is updated, encrypted JSON should not be fetched from cache", func(t *testing.T) {
ClearPluginSettingDecryptionCache() clearPluginSettingDecryptionCache()
ps := PluginSetting{ ps := PluginSetting{
Id: 1, Id: 1,
...@@ -46,7 +54,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) { ...@@ -46,7 +54,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
} }
// Populate cache // Populate cache
password, ok := ps.DecryptedValue("password") password, ok := ps.DecryptedValues()["password"]
require.Equal(t, "password", password) require.Equal(t, "password", password)
require.True(t, ok) require.True(t, ok)
...@@ -55,7 +63,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) { ...@@ -55,7 +63,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
}) })
ps.Updated = time.Now() ps.Updated = time.Now()
password, ok = ps.DecryptedValue("password") password, ok = ps.DecryptedValues()["password"]
require.Empty(t, password) require.Empty(t, password)
require.True(t, ok) require.True(t, ok)
}) })
......
package models package models
import ( import (
"errors"
"time" "time"
) )
// Typed errors
var (
ErrPreferencesNotFound = errors.New("Preferences not found")
)
type Preferences struct { type Preferences struct {
Id int64 Id int64
OrgId int64 OrgId int64
......
package models
type IsSAMLEnabledCommand struct {
Result bool
}
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"`
}
...@@ -13,11 +13,6 @@ import ( ...@@ -13,11 +13,6 @@ import (
"github.com/grafana/grafana/pkg/util/errutil" "github.com/grafana/grafana/pkg/util/errutil"
) )
type AppPluginCss struct {
Light string `json:"light"`
Dark string `json:"dark"`
}
type AppPlugin struct { type AppPlugin struct {
FrontendPluginBase FrontendPluginBase
Routes []*AppPluginRoute `json:"routes"` Routes []*AppPluginRoute `json:"routes"`
......
...@@ -11,17 +11,14 @@ import ( ...@@ -11,17 +11,14 @@ import (
) )
var ( var (
PluginTypeApp = "app" PluginTypeApp = "app"
PluginTypeDatasource = "datasource" PluginTypeDashboard = "dashboard"
PluginTypePanel = "panel"
PluginTypeDashboard = "dashboard"
) )
type PluginState string type PluginState string
var ( var (
PluginStateAlpha PluginState = "alpha" PluginStateAlpha PluginState = "alpha"
PluginStateBeta PluginState = "beta"
) )
type PluginSignature string type PluginSignature string
......
...@@ -58,7 +58,7 @@ func TestQueryCondition(t *testing.T) { ...@@ -58,7 +58,7 @@ func TestQueryCondition(t *testing.T) {
Convey("should fire when avg is above 100", func() { Convey("should fire when avg is above 100", func() {
points := newTimeSeriesPointsFromArgs(120, 0) points := newTimeSeriesPointsFromArgs(120, 0)
ctx.series = tsdb.TimeSeriesSlice{tsdb.NewTimeSeries("test1", points)} ctx.series = tsdb.TimeSeriesSlice{&tsdb.TimeSeries{Name: "test1", Points: points}}
cr, err := ctx.exec() cr, err := ctx.exec()
So(err, ShouldBeNil) So(err, ShouldBeNil)
...@@ -78,7 +78,7 @@ func TestQueryCondition(t *testing.T) { ...@@ -78,7 +78,7 @@ func TestQueryCondition(t *testing.T) {
Convey("Should not fire when avg is below 100", func() { Convey("Should not fire when avg is below 100", func() {
points := newTimeSeriesPointsFromArgs(90, 0) points := newTimeSeriesPointsFromArgs(90, 0)
ctx.series = tsdb.TimeSeriesSlice{tsdb.NewTimeSeries("test1", points)} ctx.series = tsdb.TimeSeriesSlice{&tsdb.TimeSeries{Name: "test1", Points: points}}
cr, err := ctx.exec() cr, err := ctx.exec()
So(err, ShouldBeNil) So(err, ShouldBeNil)
...@@ -98,8 +98,8 @@ func TestQueryCondition(t *testing.T) { ...@@ -98,8 +98,8 @@ func TestQueryCondition(t *testing.T) {
Convey("Should fire if only first series matches", func() { Convey("Should fire if only first series matches", func() {
ctx.series = tsdb.TimeSeriesSlice{ ctx.series = tsdb.TimeSeriesSlice{
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs(120, 0)), &tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs(120, 0)},
tsdb.NewTimeSeries("test2", newTimeSeriesPointsFromArgs(0, 0)), &tsdb.TimeSeries{Name: "test2", Points: newTimeSeriesPointsFromArgs(0, 0)},
} }
cr, err := ctx.exec() cr, err := ctx.exec()
...@@ -131,7 +131,7 @@ func TestQueryCondition(t *testing.T) { ...@@ -131,7 +131,7 @@ func TestQueryCondition(t *testing.T) {
Convey("Should set Firing if eval match", func() { Convey("Should set Firing if eval match", func() {
ctx.evaluator = `{"type": "no_value", "params": []}` ctx.evaluator = `{"type": "no_value", "params": []}`
ctx.series = tsdb.TimeSeriesSlice{ ctx.series = tsdb.TimeSeriesSlice{
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs()), &tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs()},
} }
cr, err := ctx.exec() cr, err := ctx.exec()
...@@ -141,8 +141,8 @@ func TestQueryCondition(t *testing.T) { ...@@ -141,8 +141,8 @@ func TestQueryCondition(t *testing.T) {
Convey("Should set NoDataFound both series are empty", func() { Convey("Should set NoDataFound both series are empty", func() {
ctx.series = tsdb.TimeSeriesSlice{ ctx.series = tsdb.TimeSeriesSlice{
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs()), &tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs()},
tsdb.NewTimeSeries("test2", newTimeSeriesPointsFromArgs()), &tsdb.TimeSeries{Name: "test2", Points: newTimeSeriesPointsFromArgs()},
} }
cr, err := ctx.exec() cr, err := ctx.exec()
...@@ -152,8 +152,8 @@ func TestQueryCondition(t *testing.T) { ...@@ -152,8 +152,8 @@ func TestQueryCondition(t *testing.T) {
Convey("Should set NoDataFound both series contains null", func() { Convey("Should set NoDataFound both series contains null", func() {
ctx.series = tsdb.TimeSeriesSlice{ ctx.series = tsdb.TimeSeriesSlice{
tsdb.NewTimeSeries("test1", tsdb.TimeSeriesPoints{tsdb.TimePoint{null.FloatFromPtr(nil), null.FloatFrom(0)}}), &tsdb.TimeSeries{Name: "test1", Points: tsdb.TimeSeriesPoints{tsdb.TimePoint{null.FloatFromPtr(nil), null.FloatFrom(0)}}},
tsdb.NewTimeSeries("test2", tsdb.TimeSeriesPoints{tsdb.TimePoint{null.FloatFromPtr(nil), null.FloatFrom(0)}}), &tsdb.TimeSeries{Name: "test2", Points: tsdb.TimeSeriesPoints{tsdb.TimePoint{null.FloatFromPtr(nil), null.FloatFrom(0)}}},
} }
cr, err := ctx.exec() cr, err := ctx.exec()
...@@ -163,8 +163,8 @@ func TestQueryCondition(t *testing.T) { ...@@ -163,8 +163,8 @@ func TestQueryCondition(t *testing.T) {
Convey("Should not set NoDataFound if one series is empty", func() { Convey("Should not set NoDataFound if one series is empty", func() {
ctx.series = tsdb.TimeSeriesSlice{ ctx.series = tsdb.TimeSeriesSlice{
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs()), &tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs()},
tsdb.NewTimeSeries("test2", newTimeSeriesPointsFromArgs(120, 0)), &tsdb.TimeSeries{Name: "test2", Points: newTimeSeriesPointsFromArgs(120, 0)},
} }
cr, err := ctx.exec() cr, err := ctx.exec()
......
...@@ -213,6 +213,7 @@ func (g *dashboardGuardianImpl) getTeams() ([]*models.TeamDTO, error) { ...@@ -213,6 +213,7 @@ func (g *dashboardGuardianImpl) getTeams() ([]*models.TeamDTO, error) {
return query.Result, err return query.Result, err
} }
// nolint:unused
type FakeDashboardGuardian struct { type FakeDashboardGuardian struct {
DashId int64 DashId int64
OrgId int64 OrgId int64
...@@ -255,6 +256,7 @@ func (g *FakeDashboardGuardian) GetAcl() ([]*models.DashboardAclInfoDTO, error) ...@@ -255,6 +256,7 @@ func (g *FakeDashboardGuardian) GetAcl() ([]*models.DashboardAclInfoDTO, error)
return g.GetAclValue, nil return g.GetAclValue, nil
} }
// nolint:unused
func MockDashboardGuardian(mock *FakeDashboardGuardian) { func MockDashboardGuardian(mock *FakeDashboardGuardian) {
New = func(dashId int64, orgId int64, user *models.SignedInUser) DashboardGuardian { New = func(dashId int64, orgId int64, user *models.SignedInUser) DashboardGuardian {
mock.OrgId = orgId mock.OrgId = orgId
......
...@@ -41,8 +41,3 @@ func ParseChannelAddress(id string) ChannelAddress { ...@@ -41,8 +41,3 @@ func ParseChannelAddress(id string) ChannelAddress {
func (ca *ChannelAddress) IsValid() bool { func (ca *ChannelAddress) IsValid() bool {
return ca.Scope != "" && ca.Namespace != "" && ca.Path != "" return ca.Scope != "" && ca.Namespace != "" && ca.Path != ""
} }
// ToChannelID converts this to a single string.
func (ca *ChannelAddress) ToChannelID() string {
return ca.Scope + "/" + ca.Namespace + "/" + ca.Path
}
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
) )
var ErrTimeout = errors.New("timeout error - you can set timeout in seconds with &timeout url parameter") var ErrTimeout = errors.New("timeout error - you can set timeout in seconds with &timeout url parameter")
var ErrNoRenderer = errors.New("no renderer plugin found nor is an external render server configured")
var ErrPhantomJSNotInstalled = errors.New("PhantomJS executable not found") var ErrPhantomJSNotInstalled = errors.New("PhantomJS executable not found")
type Opts struct { type Opts struct {
......
...@@ -76,8 +76,7 @@ var ( ...@@ -76,8 +76,7 @@ var (
DB_Integer = "INTEGER" DB_Integer = "INTEGER"
DB_BigInt = "BIGINT" DB_BigInt = "BIGINT"
DB_Enum = "ENUM" DB_Set = "SET"
DB_Set = "SET"
DB_Char = "CHAR" DB_Char = "CHAR"
DB_Varchar = "VARCHAR" DB_Varchar = "VARCHAR"
......
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"time" "time"
...@@ -75,14 +74,10 @@ var ( ...@@ -75,14 +74,10 @@ var (
PluginsPath string PluginsPath string
CustomInitPath = "conf/custom.ini" CustomInitPath = "conf/custom.ini"
// Log settings.
LogConfigs []util.DynMap
// HTTP server options // HTTP server options
Protocol Scheme Protocol Scheme
Domain string Domain string
HttpAddr, HttpPort string HttpAddr, HttpPort string
SshPort int
CertFile, KeyFile string CertFile, KeyFile string
SocketPath string SocketPath string
RouterLogging bool RouterLogging bool
...@@ -168,13 +163,8 @@ var ( ...@@ -168,13 +163,8 @@ var (
// Basic Auth // Basic Auth
BasicAuthEnabled bool BasicAuthEnabled bool
// Session settings.
SessionConnMaxLifetime int64
// Global setting objects. // Global setting objects.
Raw *ini.File Raw *ini.File
ConfRootPath string
IsWindows bool
// for logging purposes // for logging purposes
configFiles []string configFiles []string
...@@ -214,11 +204,6 @@ var ( ...@@ -214,11 +204,6 @@ var (
// Grafana.NET URL // Grafana.NET URL
GrafanaComUrl string GrafanaComUrl string
// S3 temp image store
S3TempImageStoreBucketUrl string
S3TempImageStoreAccessKey string
S3TempImageStoreSecretKey string
ImageUploadProvider string ImageUploadProvider string
) )
...@@ -342,10 +327,6 @@ func (cfg Cfg) IsNgAlertEnabled() bool { ...@@ -342,10 +327,6 @@ func (cfg Cfg) IsNgAlertEnabled() bool {
return cfg.FeatureToggles["ngalert"] return cfg.FeatureToggles["ngalert"]
} }
func (cfg Cfg) IsDatabaseMetricsEnabled() bool {
return cfg.FeatureToggles["database_metrics"]
}
func (cfg Cfg) IsHTTPRequestHistogramEnabled() bool { func (cfg Cfg) IsHTTPRequestHistogramEnabled() bool {
return cfg.FeatureToggles["http_request_histogram"] return cfg.FeatureToggles["http_request_histogram"]
} }
...@@ -356,10 +337,6 @@ type CommandLineArgs struct { ...@@ -356,10 +337,6 @@ type CommandLineArgs struct {
Args []string Args []string
} }
func init() {
IsWindows = runtime.GOOS == "windows"
}
func parseAppUrlAndSubUrl(section *ini.Section) (string, string, error) { func parseAppUrlAndSubUrl(section *ini.Section) (string, string, error) {
appUrl := valueAsString(section, "root_url", "http://localhost:3000/") appUrl := valueAsString(section, "root_url", "http://localhost:3000/")
......
...@@ -32,10 +32,6 @@ func (q *UserQuota) ToMap() map[string]int64 { ...@@ -32,10 +32,6 @@ func (q *UserQuota) ToMap() map[string]int64 {
return quotaToMap(*q) return quotaToMap(*q)
} }
func (q *GlobalQuota) ToMap() map[string]int64 {
return quotaToMap(*q)
}
func quotaToMap(q interface{}) map[string]int64 { func quotaToMap(q interface{}) map[string]int64 {
qMap := make(map[string]int64) qMap := make(map[string]int64)
typ := reflect.TypeOf(q) typ := reflect.TypeOf(q)
......
...@@ -54,18 +54,6 @@ type AzureMonitorResponse struct { ...@@ -54,18 +54,6 @@ type AzureMonitorResponse struct {
Resourceregion string `json:"resourceregion"` Resourceregion string `json:"resourceregion"`
} }
// ApplicationInsightsQueryResponse is the json response from the Application Insights API
type ApplicationInsightsQueryResponse struct {
Tables []struct {
Name string `json:"name"`
Columns []struct {
Name string `json:"name"`
Type string `json:"type"`
} `json:"columns"`
Rows [][]interface{} `json:"rows"`
} `json:"tables"`
}
// AzureLogAnalyticsResponse is the json response object from the Azure Log Analytics API. // AzureLogAnalyticsResponse is the json response object from the Azure Log Analytics API.
type AzureLogAnalyticsResponse struct { type AzureLogAnalyticsResponse struct {
Tables []AzureLogAnalyticsTable `json:"tables"` Tables []AzureLogAnalyticsTable `json:"tables"`
......
...@@ -69,7 +69,3 @@ func (q *cloudWatchQuery) isMultiValuedDimensionExpression() bool { ...@@ -69,7 +69,3 @@ func (q *cloudWatchQuery) isMultiValuedDimensionExpression() bool {
return false return false
} }
func (q *cloudWatchQuery) isMetricStat() bool {
return !q.isSearchExpression() && !q.isMathExpression()
}
...@@ -137,3 +137,7 @@ func TestCloudWatchQuery(t *testing.T) { ...@@ -137,3 +137,7 @@ func TestCloudWatchQuery(t *testing.T) {
assert.False(t, query.isMetricStat(), "Expected not metric stat") assert.False(t, query.isMetricStat(), "Expected not metric stat")
}) })
} }
func (q *cloudWatchQuery) isMetricStat() bool {
return !q.isSearchExpression() && !q.isMathExpression()
}
...@@ -97,11 +97,6 @@ type BoolQuery struct { ...@@ -97,11 +97,6 @@ type BoolQuery struct {
Filters []Filter Filters []Filter
} }
// NewBoolQuery create a new bool query
func NewBoolQuery() *BoolQuery {
return &BoolQuery{Filters: make([]Filter, 0)}
}
// MarshalJSON returns the JSON encoding of the boolean query. // MarshalJSON returns the JSON encoding of the boolean query.
func (q *BoolQuery) MarshalJSON() ([]byte, error) { func (q *BoolQuery) MarshalJSON() ([]byte, error) {
root := make(map[string]interface{}) root := make(map[string]interface{})
......
...@@ -25,10 +25,6 @@ type Tag struct { ...@@ -25,10 +25,6 @@ type Tag struct {
type Select []QueryPart type Select []QueryPart
type InfluxDbSelect struct {
Type string
}
type Response struct { type Response struct {
Results []Result Results []Result
Err error Err error
......
...@@ -128,10 +128,6 @@ func aliasRenderer(query *Query, queryContext *tsdb.TsdbQuery, part *QueryPart, ...@@ -128,10 +128,6 @@ func aliasRenderer(query *Query, queryContext *tsdb.TsdbQuery, part *QueryPart,
return fmt.Sprintf(`%s AS "%s"`, innerExpr, part.Params[0]) return fmt.Sprintf(`%s AS "%s"`, innerExpr, part.Params[0])
} }
func (r QueryDefinition) Render(query *Query, queryContext *tsdb.TsdbQuery, part *QueryPart, innerExpr string) string {
return r.Renderer(query, queryContext, part, innerExpr)
}
func NewQueryPart(typ string, params []string) (*QueryPart, error) { func NewQueryPart(typ string, params []string) (*QueryPart, error) {
def, exist := renders[typ] def, exist := renders[typ]
if !exist { if !exist {
......
...@@ -72,13 +72,6 @@ func NewTimePoint(value null.Float, timestamp float64) TimePoint { ...@@ -72,13 +72,6 @@ func NewTimePoint(value null.Float, timestamp float64) TimePoint {
return TimePoint{value, null.FloatFrom(timestamp)} return TimePoint{value, null.FloatFrom(timestamp)}
} }
func NewTimeSeries(name string, points TimeSeriesPoints) *TimeSeries {
return &TimeSeries{
Name: name,
Points: points,
}
}
// DataFrames is an interface for retrieving encoded and decoded data frames. // DataFrames is an interface for retrieving encoded and decoded data frames.
// //
// See NewDecodedDataFrames and NewEncodedDataFrames for more information. // See NewDecodedDataFrames and NewEncodedDataFrames for more information.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment