mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix misspell issues (#23905)
* Fix misspell issues See, $ golangci-lint run --timeout 10m --disable-all -E misspell ./... Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com> * Fix codespell issues See, $ codespell -S './.git*' -L 'uint,thru,pres,unknwon,serie,referer,uptodate,durationm' Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com> * ci please? * non-empty commit - ci? * Trigger build Co-authored-by: bergquist <carl.bergquist@gmail.com> Co-authored-by: Kyle Brandt <kyle@grafana.com>
This commit is contained in:
parent
023c1a6e3f
commit
5116420e9a
@ -109,7 +109,7 @@ func (server *HTTPServer) ReloadLDAPCfg() Response {
|
|||||||
return Success("LDAP config reloaded")
|
return Success("LDAP config reloaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLDAPStatus attempts to connect to all the configured LDAP servers and returns information on whenever they're availabe or not.
|
// GetLDAPStatus attempts to connect to all the configured LDAP servers and returns information on whenever they're available or not.
|
||||||
func (server *HTTPServer) GetLDAPStatus(c *models.ReqContext) Response {
|
func (server *HTTPServer) GetLDAPStatus(c *models.ReqContext) Response {
|
||||||
if !ldap.IsEnabled() {
|
if !ldap.IsEnabled() {
|
||||||
return Error(http.StatusBadRequest, "LDAP is not enabled", nil)
|
return Error(http.StatusBadRequest, "LDAP is not enabled", nil)
|
||||||
@ -224,7 +224,7 @@ func (server *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) Response {
|
|||||||
err = bus.Dispatch(upsertCmd)
|
err = bus.Dispatch(upsertCmd)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Error(http.StatusInternalServerError, "Failed to udpate the user", err)
|
return Error(http.StatusInternalServerError, "Failed to update the user", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success("User synced successfully")
|
return Success("User synced successfully")
|
||||||
|
@ -377,7 +377,7 @@ func TestDSRouteRule(t *testing.T) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("When proxying a datasource that has oauth token pass-thru enabled", func() {
|
Convey("When proxying a datasource that has oauth token pass-through enabled", func() {
|
||||||
social.SocialMap["generic_oauth"] = &social.SocialGenericOAuth{
|
social.SocialMap["generic_oauth"] = &social.SocialGenericOAuth{
|
||||||
SocialBase: &social.SocialBase{
|
SocialBase: &social.SocialBase{
|
||||||
Config: &oauth2.Config{},
|
Config: &oauth2.Config{},
|
||||||
|
@ -49,7 +49,7 @@ func EncryptDatasourcePaswords(c utils.CommandLine, sqlStore *sqlstore.SqlStore)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if passwordsUpdated == 0 && basicAuthUpdated == 0 {
|
if passwordsUpdated == 0 && basicAuthUpdated == 0 {
|
||||||
logger.Infof("%s All datasources secrets are allready encrypted\n", color.GreenString("✔"))
|
logger.Infof("%s All datasources secrets are already encrypted\n", color.GreenString("✔"))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("\n")
|
logger.Info("\n")
|
||||||
|
@ -39,7 +39,7 @@ func (pd *profilingDiagnostics) overrideWithEnv() error {
|
|||||||
if portEnv != "" {
|
if portEnv != "" {
|
||||||
port, parseErr := strconv.ParseUint(portEnv, 0, 64)
|
port, parseErr := strconv.ParseUint(portEnv, 0, 64)
|
||||||
if parseErr != nil {
|
if parseErr != nil {
|
||||||
return fmt.Errorf("Failed to parse %s enviroment variable to unsigned integer", profilingPortEnvName)
|
return fmt.Errorf("Failed to parse %s environment variable to unsigned integer", profilingPortEnvName)
|
||||||
}
|
}
|
||||||
pd.port = uint(port)
|
pd.port = uint(port)
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ func init() {
|
|||||||
|
|
||||||
// CacheStorage allows the caller to set, get and delete items in the cache.
|
// CacheStorage allows the caller to set, get and delete items in the cache.
|
||||||
// Cached items are stored as byte arrays and marshalled using "encoding/gob"
|
// Cached items are stored as byte arrays and marshalled using "encoding/gob"
|
||||||
// so any struct added to the cache needs to be registred with `remotecache.Register`
|
// so any struct added to the cache needs to be registered with `remotecache.Register`
|
||||||
// ex `remotecache.Register(CacheableStruct{})``
|
// ex `remotecache.Register(CacheableStruct{})``
|
||||||
type CacheStorage interface {
|
type CacheStorage interface {
|
||||||
// Get reads object from Cache
|
// Get reads object from Cache
|
||||||
|
@ -289,7 +289,7 @@ func (s *SocialGenericOAuth) FetchPrivateEmail(client *http.Client) (string, err
|
|||||||
err = json.Unmarshal(response.Body, &data)
|
err = json.Unmarshal(response.Body, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Error("Error decoding email addresses response", "raw_json", string(response.Body), "error", err)
|
s.log.Error("Error decoding email addresses response", "raw_json", string(response.Body), "error", err)
|
||||||
return "", errutil.Wrap("Erro decoding email addresses response", err)
|
return "", errutil.Wrap("Error decoding email addresses response", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
records = data.Values
|
records = data.Values
|
||||||
|
@ -259,7 +259,7 @@ func (auth *AuthModuleConversion) FromDB(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just a stub, we don't wanna write to database
|
// Just a stub, we don't want to write to database
|
||||||
func (auth *AuthModuleConversion) ToDB() ([]byte, error) {
|
func (auth *AuthModuleConversion) ToDB() ([]byte, error) {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ func TestAlertingUsageStats(t *testing.T) {
|
|||||||
|
|
||||||
for k := range expected {
|
for k := range expected {
|
||||||
if expected[k] != result.DatasourceUsage[k] {
|
if expected[k] != result.DatasourceUsage[k] {
|
||||||
t.Errorf("result missmatch for %s. got %v expected %v", k, result.DatasourceUsage[k], expected[k])
|
t.Errorf("result mismatch for %s. got %v expected %v", k, result.DatasourceUsage[k], expected[k])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ func TestParsingAlertRuleSettings(t *testing.T) {
|
|||||||
tc.shouldErr(t, err)
|
tc.shouldErr(t, err)
|
||||||
diff := cmp.Diff(tc.expected, result)
|
diff := cmp.Diff(tc.expected, result)
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("result missmatch (-want +got) %s\n", diff)
|
t.Errorf("result mismatch (-want +got) %s\n", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ func inSlice(a string, list []string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// HumanThresholdType converts a treshold "type" string to a string that matches the UI
|
// HumanThresholdType converts a threshold "type" string to a string that matches the UI
|
||||||
// so errors are less confusing.
|
// so errors are less confusing.
|
||||||
func HumanThresholdType(typ string) string {
|
func HumanThresholdType(typ string) string {
|
||||||
switch typ {
|
switch typ {
|
||||||
|
@ -44,7 +44,7 @@ func (e *AlertEngine) IsDisabled() bool {
|
|||||||
return !setting.AlertingEnabled || !setting.ExecuteAlerts
|
return !setting.AlertingEnabled || !setting.ExecuteAlerts
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initalizes the AlertingService.
|
// Init initializes the AlertingService.
|
||||||
func (e *AlertEngine) Init() error {
|
func (e *AlertEngine) Init() error {
|
||||||
e.ticker = NewTicker(time.Now(), time.Second*0, clock.New())
|
e.ticker = NewTicker(time.Now(), time.Second*0, clock.New())
|
||||||
e.execQueue = make(chan *Job, 1000)
|
e.execQueue = make(chan *Job, 1000)
|
||||||
@ -209,8 +209,8 @@ func (e *AlertEngine) processJob(attemptID int, attemptChan chan int, cancelChan
|
|||||||
|
|
||||||
// override the context used for evaluation with a new context for notifications.
|
// override the context used for evaluation with a new context for notifications.
|
||||||
// This makes it possible for notifiers to execute when datasources
|
// This makes it possible for notifiers to execute when datasources
|
||||||
// dont respond within the timeout limit. We should rewrite this so notifications
|
// don't respond within the timeout limit. We should rewrite this so notifications
|
||||||
// dont reuse the evalContext and get its own context.
|
// don't reuse the evalContext and get its own context.
|
||||||
evalContext.Ctx = resultHandleCtx
|
evalContext.Ctx = resultHandleCtx
|
||||||
evalContext.Rule.State = evalContext.GetNewState()
|
evalContext.Rule.State = evalContext.GetNewState()
|
||||||
if err := e.resultHandler.handle(evalContext); err != nil {
|
if err := e.resultHandler.handle(evalContext); err != nil {
|
||||||
|
@ -141,7 +141,7 @@ func (n *NotifierBase) GetDisableResolveMessage() bool {
|
|||||||
return n.DisableResolveMessage
|
return n.DisableResolveMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFrequency returns the freqency for how often
|
// GetFrequency returns the frequency for how often
|
||||||
// alerts should be evaluated.
|
// alerts should be evaluated.
|
||||||
func (n *NotifierBase) GetFrequency() time.Duration {
|
func (n *NotifierBase) GetFrequency() time.Duration {
|
||||||
return n.Frequency
|
return n.Frequency
|
||||||
|
@ -78,7 +78,7 @@ type ThreemaNotifier struct {
|
|||||||
log log.Logger
|
log log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewThreemaNotifier is the constructor for the Threema notifer
|
// NewThreemaNotifier is the constructor for the Threema notifier
|
||||||
func NewThreemaNotifier(model *models.AlertNotification) (alerting.Notifier, error) {
|
func NewThreemaNotifier(model *models.AlertNotification) (alerting.Notifier, error) {
|
||||||
if model.Settings == nil {
|
if model.Settings == nil {
|
||||||
return nil, alerting.ValidationError{Reason: "No Settings Supplied"}
|
return nil, alerting.ValidationError{Reason: "No Settings Supplied"}
|
||||||
|
@ -157,7 +157,7 @@ func (server *Server) Close() {
|
|||||||
// 2. Single bind
|
// 2. Single bind
|
||||||
// // If all the users meant to be used with Grafana have the ability to search in LDAP server
|
// // If all the users meant to be used with Grafana have the ability to search in LDAP server
|
||||||
// then we bind with LDAP server with targeted login/password
|
// then we bind with LDAP server with targeted login/password
|
||||||
// and then search for the said user in order to retrive all the information about them
|
// and then search for the said user in order to retrieve all the information about them
|
||||||
// 3. Unauthenticated bind
|
// 3. Unauthenticated bind
|
||||||
// For some LDAP configurations it is allowed to search the
|
// For some LDAP configurations it is allowed to search the
|
||||||
// user without login/password binding with LDAP server, in such case
|
// user without login/password binding with LDAP server, in such case
|
||||||
|
@ -5,13 +5,13 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AttachedFile is struct representating email attached files
|
// AttachedFile struct represents email attached files.
|
||||||
type AttachedFile struct {
|
type AttachedFile struct {
|
||||||
Name string
|
Name string
|
||||||
Content []byte
|
Content []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message is representation of the email message
|
// Message is representation of the email message.
|
||||||
type Message struct {
|
type Message struct {
|
||||||
To []string
|
To []string
|
||||||
SingleEmail bool
|
SingleEmail bool
|
||||||
|
@ -14,7 +14,7 @@ notifiers:
|
|||||||
- name: another-not-default-notification
|
- name: another-not-default-notification
|
||||||
type: email
|
type: email
|
||||||
settings:
|
settings:
|
||||||
addresses: example@exmaple.com
|
addresses: example@example.com
|
||||||
org_id: 3
|
org_id: 3
|
||||||
uid: "notifier2"
|
uid: "notifier2"
|
||||||
is_default: false
|
is_default: false
|
||||||
@ -29,7 +29,7 @@ notifiers:
|
|||||||
org_id: 3
|
org_id: 3
|
||||||
uid: "notifier4"
|
uid: "notifier4"
|
||||||
settings:
|
settings:
|
||||||
addresses: example@exmaple.com
|
addresses: example@example.com
|
||||||
delete_notifiers:
|
delete_notifiers:
|
||||||
- name: default-slack-notification
|
- name: default-slack-notification
|
||||||
org_id: 2
|
org_id: 2
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package sqlstore
|
package sqlstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/grafana/grafana/pkg/models"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/models"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestApiKeyDataAccess(t *testing.T) {
|
func TestApiKeyDataAccess(t *testing.T) {
|
||||||
@ -54,7 +55,7 @@ func TestApiKeyDataAccess(t *testing.T) {
|
|||||||
assert.True(t, *query.Result.Expires >= timeNow().Unix())
|
assert.True(t, *query.Result.Expires >= timeNow().Unix())
|
||||||
|
|
||||||
// timeNow() has been called twice since creation; once by AddApiKey and once by GetApiKeyByName
|
// timeNow() has been called twice since creation; once by AddApiKey and once by GetApiKeyByName
|
||||||
// therefore two seconds should be subtracted by next value retuned by timeNow()
|
// therefore two seconds should be subtracted by next value returned by timeNow()
|
||||||
// that equals the number by which timeSeed has been advanced
|
// that equals the number by which timeSeed has been advanced
|
||||||
then := timeNow().Add(-2 * time.Second)
|
then := timeNow().Add(-2 * time.Second)
|
||||||
expected := then.Add(1 * time.Hour).UTC().Unix()
|
expected := then.Add(1 * time.Hour).UTC().Unix()
|
||||||
|
@ -308,7 +308,7 @@ type ITestDB interface {
|
|||||||
Fatalf(format string, args ...interface{})
|
Fatalf(format string, args ...interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitTestDB initiliaze test DB
|
// InitTestDB initialize test DB.
|
||||||
func InitTestDB(t ITestDB) *SqlStore {
|
func InitTestDB(t ITestDB) *SqlStore {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
sqlstore := &SqlStore{}
|
sqlstore := &SqlStore{}
|
||||||
|
@ -322,7 +322,7 @@ func TestUserDataAccess(t *testing.T) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("when retreiving signed in user for orgId=0 result should return active org id", func() {
|
Convey("when retrieving signed in user for orgId=0 result should return active org id", func() {
|
||||||
ss.CacheService.Flush()
|
ss.CacheService.Flush()
|
||||||
|
|
||||||
query := &models.GetSignedInUserQuery{OrgId: users[1].OrgId, UserId: users[1].Id}
|
query := &models.GetSignedInUserQuery{OrgId: users[1].OrgId, UserId: users[1].Id}
|
||||||
|
@ -47,7 +47,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// This constant corresponds to the default value for ldap_sync_ttl in .ini files
|
// This constant corresponds to the default value for ldap_sync_ttl in .ini files
|
||||||
// it is used for comparision and has to be kept in sync
|
// it is used for comparison and has to be kept in sync
|
||||||
const (
|
const (
|
||||||
AUTH_PROXY_SYNC_TTL = 60
|
AUTH_PROXY_SYNC_TTL = 60
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/tsdb"
|
"github.com/grafana/grafana/pkg/tsdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TimeGrain handles convertions between
|
// TimeGrain handles conversions between
|
||||||
// the ISO 8601 Duration format (PT1H), Kbn units (1h) and Time Grains (1 hour)
|
// the ISO 8601 Duration format (PT1H), Kbn units (1h) and Time Grains (1 hour)
|
||||||
// Also handles using the automatic Grafana interval to calculate a ISO 8601 Duration.
|
// Also handles using the automatic Grafana interval to calculate a ISO 8601 Duration.
|
||||||
type TimeGrain struct{}
|
type TimeGrain struct{}
|
||||||
|
@ -189,7 +189,7 @@ func TestCloudWatchResponseParser(t *testing.T) {
|
|||||||
So((*series)[1].Name, ShouldEqual, "lb4 Expanded")
|
So((*series)[1].Name, ShouldEqual, "lb4 Expanded")
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("can expand dimension value when no values are returned and a multi-valued template variabel is used", func() {
|
Convey("can expand dimension value when no values are returned and a multi-valued template variable is used", func() {
|
||||||
timestamp := time.Unix(0, 0)
|
timestamp := time.Unix(0, 0)
|
||||||
resp := map[string]*cloudwatch.MetricDataResult{
|
resp := map[string]*cloudwatch.MetricDataResult{
|
||||||
"lb3": {
|
"lb3": {
|
||||||
|
@ -619,7 +619,7 @@ func TestStackdriver(t *testing.T) {
|
|||||||
|
|
||||||
Convey("when interpolating filter wildcards", func() {
|
Convey("when interpolating filter wildcards", func() {
|
||||||
Convey("and wildcard is used in the beginning and the end of the word", func() {
|
Convey("and wildcard is used in the beginning and the end of the word", func() {
|
||||||
Convey("and theres no wildcard in the middle of the word", func() {
|
Convey("and there's no wildcard in the middle of the word", func() {
|
||||||
value := interpolateFilterWildcards("*-central1*")
|
value := interpolateFilterWildcards("*-central1*")
|
||||||
So(value, ShouldEqual, `has_substring("-central1")`)
|
So(value, ShouldEqual, `has_substring("-central1")`)
|
||||||
})
|
})
|
||||||
@ -680,7 +680,7 @@ func TestStackdriver(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("when building filter string", func() {
|
Convey("when building filter string", func() {
|
||||||
Convey("and theres no regex operator", func() {
|
Convey("and there's no regex operator", func() {
|
||||||
Convey("and there are wildcards in a filter value", func() {
|
Convey("and there are wildcards in a filter value", func() {
|
||||||
filterParts := []string{"zone", "=", "*-central1*"}
|
filterParts := []string{"zone", "=", "*-central1*"}
|
||||||
value := buildFilterString("somemetrictype", filterParts)
|
value := buildFilterString("somemetrictype", filterParts)
|
||||||
|
@ -31,7 +31,7 @@ func TestPrepareProxyRequest(t *testing.T) {
|
|||||||
require.Equal(t, "127.0.0.1", req.Header.Get("X-Forwarded-For"))
|
require.Equal(t, "127.0.0.1", req.Header.Get("X-Forwarded-For"))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Prepare proxy request should appent client ip at the end of X-Forwarded-For", func(t *testing.T) {
|
t.Run("Prepare proxy request should append client ip at the end of X-Forwarded-For", func(t *testing.T) {
|
||||||
req, err := http.NewRequest(http.MethodGet, "/", nil)
|
req, err := http.NewRequest(http.MethodGet, "/", nil)
|
||||||
req.RemoteAddr = "127.0.0.1:1234"
|
req.RemoteAddr = "127.0.0.1:1234"
|
||||||
req.Header.Add("X-Forwarded-For", "192.168.0.1")
|
req.Header.Add("X-Forwarded-For", "192.168.0.1")
|
||||||
|
Loading…
Reference in New Issue
Block a user