mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
8c765e8068
commit
4dd7b7a82d
@ -10,9 +10,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
NotFound = func() Response {
|
||||
return Error(404, "Not found", nil)
|
||||
}
|
||||
ServerError = func(err error) Response {
|
||||
return Error(500, "Server error", err)
|
||||
}
|
||||
@ -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 {
|
||||
r.header.Set(key, value)
|
||||
return r
|
||||
}
|
||||
|
||||
// Empty create an empty response
|
||||
// Empty creates an empty response.
|
||||
func Empty(status int) *NormalResponse {
|
||||
return Respond(status, nil)
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
// nolint:unused
|
||||
// Unwrap returns the wrapped error.
|
||||
// Used by errors package.
|
||||
func (e URLValidationError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
@ -23,11 +23,6 @@ type IndexViewData struct {
|
||||
Sentry *setting.Sentry
|
||||
}
|
||||
|
||||
type PluginCss struct {
|
||||
Light string `json:"light"`
|
||||
Dark string `json:"dark"`
|
||||
}
|
||||
|
||||
const (
|
||||
// These weights may be used by an extension to reliably place
|
||||
// itself in relation to a particular item in the menu. The weights
|
||||
|
@ -50,10 +50,6 @@ type MetricRequest struct {
|
||||
Debug bool `json:"debug"`
|
||||
}
|
||||
|
||||
type UserStars struct {
|
||||
DashboardIds map[string]bool `json:"dashboardIds"`
|
||||
}
|
||||
|
||||
func GetGravatarUrl(text string) string {
|
||||
if setting.DisableGravatar {
|
||||
return setting.AppSubUrl + "/public/img/user_profile.png"
|
||||
|
@ -1,13 +0,0 @@
|
||||
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 {
|
||||
OrgId int64 `json:"orgId"`
|
||||
}
|
||||
|
||||
type AdminUpdateUserForm struct {
|
||||
Email string `json:"email"`
|
||||
Login string `json:"login"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type AdminUpdateUserPasswordForm struct {
|
||||
Password string `json:"password" binding:"Required"`
|
||||
}
|
||||
@ -35,13 +29,6 @@ type AdminUpdateUserPermissionsForm struct {
|
||||
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 {
|
||||
UserOrEmail string `json:"userOrEmail" binding:"Required"`
|
||||
}
|
||||
|
@ -61,7 +61,3 @@ func (c *ContextCommandLine) RepoDirectory() string {
|
||||
func (c *ContextCommandLine) PluginURL() string {
|
||||
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) (
|
||||
}
|
||||
|
||||
// --- 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 {
|
||||
Code int
|
||||
Status string
|
||||
|
@ -134,20 +134,6 @@ func (f Float) FullString() string {
|
||||
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?)
|
||||
// A non-null Float with a 0 value will not be considered zero.
|
||||
func (f Float) IsZero() bool {
|
||||
|
@ -1,5 +1,8 @@
|
||||
// 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.
|
||||
//
|
||||
// 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
|
||||
|
||||
import (
|
||||
|
@ -1,55 +1,12 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Events can be passed to external systems via for example AMQP
|
||||
// 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 {
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Id int64 `json:"id"`
|
||||
|
@ -1,24 +0,0 @@
|
||||
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 (
|
||||
ErrInvalidCredentials = errors.New("invalid username or password")
|
||||
ErrNoEmail = errors.New("login provider didn't return an email address")
|
||||
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")
|
||||
ErrPasswordEmpty = errors.New("no password provided")
|
||||
ErrUserDisabled = errors.New("user is disabled")
|
||||
|
@ -574,7 +574,9 @@ func middlewareScenario(t *testing.T, desc string, fn scenarioFunc) {
|
||||
if sc.handlerFunc != nil {
|
||||
sc.handlerFunc(sc.context)
|
||||
} else {
|
||||
c.JsonOK("OK")
|
||||
resp := make(map[string]interface{})
|
||||
resp["message"] = "OK"
|
||||
c.JSON(200, resp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
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 (
|
||||
)
|
||||
|
||||
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")
|
||||
|
@ -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"`
|
||||
}
|
@ -13,11 +13,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/util/errutil"
|
||||
)
|
||||
|
||||
type AppPluginCss struct {
|
||||
Light string `json:"light"`
|
||||
Dark string `json:"dark"`
|
||||
}
|
||||
|
||||
type AppPlugin struct {
|
||||
FrontendPluginBase
|
||||
Routes []*AppPluginRoute `json:"routes"`
|
||||
|
@ -11,17 +11,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
PluginTypeApp = "app"
|
||||
PluginTypeDatasource = "datasource"
|
||||
PluginTypePanel = "panel"
|
||||
PluginTypeDashboard = "dashboard"
|
||||
PluginTypeApp = "app"
|
||||
PluginTypeDashboard = "dashboard"
|
||||
)
|
||||
|
||||
type PluginState string
|
||||
|
||||
var (
|
||||
PluginStateAlpha PluginState = "alpha"
|
||||
PluginStateBeta PluginState = "beta"
|
||||
)
|
||||
|
||||
type PluginSignature string
|
||||
|
@ -58,7 +58,7 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("should fire when avg is above 100", func() {
|
||||
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()
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
@ -78,7 +78,7 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("Should not fire when avg is below 100", func() {
|
||||
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()
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
@ -98,8 +98,8 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("Should fire if only first series matches", func() {
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs(120, 0)),
|
||||
tsdb.NewTimeSeries("test2", newTimeSeriesPointsFromArgs(0, 0)),
|
||||
&tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs(120, 0)},
|
||||
&tsdb.TimeSeries{Name: "test2", Points: newTimeSeriesPointsFromArgs(0, 0)},
|
||||
}
|
||||
cr, err := ctx.exec()
|
||||
|
||||
@ -131,7 +131,7 @@ func TestQueryCondition(t *testing.T) {
|
||||
Convey("Should set Firing if eval match", func() {
|
||||
ctx.evaluator = `{"type": "no_value", "params": []}`
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs()),
|
||||
&tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs()},
|
||||
}
|
||||
cr, err := ctx.exec()
|
||||
|
||||
@ -141,8 +141,8 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("Should set NoDataFound both series are empty", func() {
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs()),
|
||||
tsdb.NewTimeSeries("test2", newTimeSeriesPointsFromArgs()),
|
||||
&tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs()},
|
||||
&tsdb.TimeSeries{Name: "test2", Points: newTimeSeriesPointsFromArgs()},
|
||||
}
|
||||
cr, err := ctx.exec()
|
||||
|
||||
@ -152,8 +152,8 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("Should set NoDataFound both series contains null", func() {
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", 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: "test1", Points: 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()
|
||||
|
||||
@ -163,8 +163,8 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("Should not set NoDataFound if one series is empty", func() {
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", newTimeSeriesPointsFromArgs()),
|
||||
tsdb.NewTimeSeries("test2", newTimeSeriesPointsFromArgs(120, 0)),
|
||||
&tsdb.TimeSeries{Name: "test1", Points: newTimeSeriesPointsFromArgs()},
|
||||
&tsdb.TimeSeries{Name: "test2", Points: newTimeSeriesPointsFromArgs(120, 0)},
|
||||
}
|
||||
cr, err := ctx.exec()
|
||||
|
||||
|
@ -213,6 +213,7 @@ func (g *dashboardGuardianImpl) getTeams() ([]*models.TeamDTO, error) {
|
||||
return query.Result, err
|
||||
}
|
||||
|
||||
// nolint:unused
|
||||
type FakeDashboardGuardian struct {
|
||||
DashId int64
|
||||
OrgId int64
|
||||
@ -255,6 +256,7 @@ func (g *FakeDashboardGuardian) GetAcl() ([]*models.DashboardAclInfoDTO, error)
|
||||
return g.GetAclValue, nil
|
||||
}
|
||||
|
||||
// nolint:unused
|
||||
func MockDashboardGuardian(mock *FakeDashboardGuardian) {
|
||||
New = func(dashId int64, orgId int64, user *models.SignedInUser) DashboardGuardian {
|
||||
mock.OrgId = orgId
|
||||
|
@ -41,8 +41,3 @@ func ParseChannelAddress(id string) ChannelAddress {
|
||||
func (ca *ChannelAddress) IsValid() bool {
|
||||
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 (
|
||||
)
|
||||
|
||||
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")
|
||||
|
||||
type Opts struct {
|
||||
|
@ -76,8 +76,7 @@ var (
|
||||
DB_Integer = "INTEGER"
|
||||
DB_BigInt = "BIGINT"
|
||||
|
||||
DB_Enum = "ENUM"
|
||||
DB_Set = "SET"
|
||||
DB_Set = "SET"
|
||||
|
||||
DB_Char = "CHAR"
|
||||
DB_Varchar = "VARCHAR"
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -75,14 +74,10 @@ var (
|
||||
PluginsPath string
|
||||
CustomInitPath = "conf/custom.ini"
|
||||
|
||||
// Log settings.
|
||||
LogConfigs []util.DynMap
|
||||
|
||||
// HTTP server options
|
||||
Protocol Scheme
|
||||
Domain string
|
||||
HttpAddr, HttpPort string
|
||||
SshPort int
|
||||
CertFile, KeyFile string
|
||||
SocketPath string
|
||||
RouterLogging bool
|
||||
@ -168,13 +163,8 @@ var (
|
||||
// Basic Auth
|
||||
BasicAuthEnabled bool
|
||||
|
||||
// Session settings.
|
||||
SessionConnMaxLifetime int64
|
||||
|
||||
// Global setting objects.
|
||||
Raw *ini.File
|
||||
ConfRootPath string
|
||||
IsWindows bool
|
||||
Raw *ini.File
|
||||
|
||||
// for logging purposes
|
||||
configFiles []string
|
||||
@ -214,11 +204,6 @@ var (
|
||||
// Grafana.NET URL
|
||||
GrafanaComUrl string
|
||||
|
||||
// S3 temp image store
|
||||
S3TempImageStoreBucketUrl string
|
||||
S3TempImageStoreAccessKey string
|
||||
S3TempImageStoreSecretKey string
|
||||
|
||||
ImageUploadProvider string
|
||||
)
|
||||
|
||||
@ -342,10 +327,6 @@ func (cfg Cfg) IsNgAlertEnabled() bool {
|
||||
return cfg.FeatureToggles["ngalert"]
|
||||
}
|
||||
|
||||
func (cfg Cfg) IsDatabaseMetricsEnabled() bool {
|
||||
return cfg.FeatureToggles["database_metrics"]
|
||||
}
|
||||
|
||||
func (cfg Cfg) IsHTTPRequestHistogramEnabled() bool {
|
||||
return cfg.FeatureToggles["http_request_histogram"]
|
||||
}
|
||||
@ -356,10 +337,6 @@ type CommandLineArgs struct {
|
||||
Args []string
|
||||
}
|
||||
|
||||
func init() {
|
||||
IsWindows = runtime.GOOS == "windows"
|
||||
}
|
||||
|
||||
func parseAppUrlAndSubUrl(section *ini.Section) (string, string, error) {
|
||||
appUrl := valueAsString(section, "root_url", "http://localhost:3000/")
|
||||
|
||||
|
@ -32,10 +32,6 @@ func (q *UserQuota) ToMap() map[string]int64 {
|
||||
return quotaToMap(*q)
|
||||
}
|
||||
|
||||
func (q *GlobalQuota) ToMap() map[string]int64 {
|
||||
return quotaToMap(*q)
|
||||
}
|
||||
|
||||
func quotaToMap(q interface{}) map[string]int64 {
|
||||
qMap := make(map[string]int64)
|
||||
typ := reflect.TypeOf(q)
|
||||
|
@ -54,18 +54,6 @@ type AzureMonitorResponse struct {
|
||||
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.
|
||||
type AzureLogAnalyticsResponse struct {
|
||||
Tables []AzureLogAnalyticsTable `json:"tables"`
|
||||
|
@ -69,7 +69,3 @@ func (q *cloudWatchQuery) isMultiValuedDimensionExpression() bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (q *cloudWatchQuery) isMetricStat() bool {
|
||||
return !q.isSearchExpression() && !q.isMathExpression()
|
||||
}
|
||||
|
@ -137,3 +137,7 @@ func TestCloudWatchQuery(t *testing.T) {
|
||||
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 {
|
||||
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.
|
||||
func (q *BoolQuery) MarshalJSON() ([]byte, error) {
|
||||
root := make(map[string]interface{})
|
||||
|
@ -25,10 +25,6 @@ type Tag struct {
|
||||
|
||||
type Select []QueryPart
|
||||
|
||||
type InfluxDbSelect struct {
|
||||
Type string
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Results []Result
|
||||
Err error
|
||||
|
@ -128,10 +128,6 @@ func aliasRenderer(query *Query, queryContext *tsdb.TsdbQuery, part *QueryPart,
|
||||
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) {
|
||||
def, exist := renders[typ]
|
||||
if !exist {
|
||||
|
@ -72,13 +72,6 @@ func NewTimePoint(value null.Float, timestamp float64) TimePoint {
|
||||
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.
|
||||
//
|
||||
// See NewDecodedDataFrames and NewEncodedDataFrames for more information.
|
||||
|
Loading…
Reference in New Issue
Block a user